From 1b81ac3abbd6ca2ba71db70c84160bc0da40a17a Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Wed, 16 Nov 2022 18:14:40 +0100 Subject: [PATCH] add make-tarball.sh --- make-tarball.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 make-tarball.sh diff --git a/make-tarball.sh b/make-tarball.sh new file mode 100755 index 0000000..b0c0b8b --- /dev/null +++ b/make-tarball.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +# args +repo="${1%/}" +ref="${2-HEAD}" + +# check +if test ! -d "${repo}/.git"; then + echo "usage: $0 [ ]" + exit 1 +fi + +# get + print info +commit=$(cd $repo; git show --pretty='format:%h' $ref | head -1) +date=$(cd $repo; git show --pretty='format:%cs' $ref | head -1 | tr -d '-') +echo "# $repo $ref -> commit $commit - date $date" + +# create tarball +name="${repo##*/}" +file="${name}-${commit}.tar.xz" +(cd $repo; git archive --format=tar --prefix=${name}-${commit}/ ${commit}) \ + | xz -9ev > "$file" +echo "# $file written"