From 86138fdd23abb1b06e5a06acc2884a2ccb6f5ba6 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 9 May 2019 11:51:26 -0500 Subject: [PATCH] Fix make-tar.sh to work on MacOS too The BSD version of tar doesn't support -a, and requires -T instead of --files-from. --- .tools/make-tar.sh | 45 +++++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/.tools/make-tar.sh b/.tools/make-tar.sh index 4c9c33a7b..e6bf59315 100755 --- a/.tools/make-tar.sh +++ b/.tools/make-tar.sh @@ -16,23 +16,46 @@ PREFIX="$3" if ! [ "$TOPREV" ] then cat <&2 -usage: $0 [rev] [outfile.tar.gz] [prefix/] +usage: $0 [ []] may be any git revision spec. (tag, branch, or commit id). - Output file may be .tar.gz, .tar.bz2, or any extension supported by "tar -a". - If output file name is omitted, "base-.tar.gz" will be used. - If is omitted, the default prefix is "base-/". + If provided, must end with ".tar", ".tar.gz" or ".tar.bz2". + If is omitted, "base-.tar.gz" will be used. + If provided, must end with "/". If is omitted, + the default is "base-/". EOF exit 1 fi -[ "$FINALTAR" ] || FINALTAR="base-$TOPREV.tar.gz" -[ "$PREFIX" ] || PREFIX="base-$TOPREV/" +case "$FINALTAR" in +"") + TAROPT=-z + FINALTAR="base-$TOPREV.tar.gz" + ;; +*.tar) + TAROPT="" + ;; +*.tar.gz) + TAROPT=-z + ;; +*.tar.bz2) + TAROPT=-j + ;; +*) + die "outfile must end with '.tar.gz' or '.tar.bz2'" + ;; +esac case "$PREFIX" in -*/) ;; -*) die "Prefix must end with '/'";; +"") + PREFIX="base-$TOPREV/" + ;; +*/) + ;; +*) + die "Prefix must end with '/'" + ;; esac # Check for both and R @@ -97,13 +120,11 @@ then fi # Use the filtered list to build the final tar -# The -a option chooses compression automatically based on output file name. - -tar -C "$TDIR"/tar --files-from="$TDIR"/list.2 -caf "$FINALTAR" +tar -c $TAROPT -C "$TDIR"/tar -T "$TDIR"/list.2 -f "$FINALTAR" echo "Wrote $FINALTAR" -tar -taf "$FINALTAR" > "$TDIR"/list.3 +tar -t $TAROPT -f "$FINALTAR" > "$TDIR"/list.3 # make sure we haven't picked up anything extra if ! diff -u "$TDIR"/list.2 "$TDIR"/list.3