From bd817c8e797269d7fc77eadb88b31213dcaa0a6f Mon Sep 17 00:00:00 2001 From: vanhofen Date: Thu, 12 May 2022 23:07:51 +0200 Subject: [PATCH] - support/scripts: add get-hg-archive.sh --- support/scripts/get-hg-archive.sh | 34 +++++++++++++++++++++++++++++++ support/scripts/get-hg-source.sh | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100755 support/scripts/get-hg-archive.sh diff --git a/support/scripts/get-hg-archive.sh b/support/scripts/get-hg-archive.sh new file mode 100755 index 00000000..10294108 --- /dev/null +++ b/support/scripts/get-hg-archive.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# +# get a specified hg version as tarball +# +# (C) 2022 vanhofen +# License: WTFPLv2 +# +# parameters: +# * hg URL +# * hg tag/tree-ish to archive +# * archive name (.tar.bz2 will be stripped off) +# * archive/download directory +# +# *** no matter the archive name, it will always be compressed with bzip2 *** +# +HG_URL="$1" +HG_TAG="$2" +TAR_NAME="$3" +ARCHIVE="$4" +test -z "$ARCHIVE" && ARCHIVE="$PWD" + +TAR_PATH=${TAR_NAME%.tar*} + +DIR=$(mktemp -d $PWD/hg_archive.XXXXXX) +# clean up at exit +trap "rm -rf $DIR" EXIT +# exit on error +set -e +hg clone $HG_URL $DIR +cd $DIR +hg archive -o $TAR_PATH.tar --prefix=$TAR_PATH/ $HG_TAG +bzip2 $TAR_PATH.tar +mv $TAR_PATH.tar.bz2 $ARCHIVE/ +# exit trap cleans up... diff --git a/support/scripts/get-hg-source.sh b/support/scripts/get-hg-source.sh index b7a83b1d..31c052cc 100755 --- a/support/scripts/get-hg-source.sh +++ b/support/scripts/get-hg-source.sh @@ -2,7 +2,7 @@ # # clone or pull an existing hg repository # -# (C) 2019 vanhofen +# (C) 2022 vanhofen # License: WTFPLv2 # # parameters: