add make-tarball.sh

This commit is contained in:
Gerd Hoffmann 2022-11-16 18:14:40 +01:00
parent c270beaf29
commit 1b81ac3abb
1 changed files with 23 additions and 0 deletions

23
make-tarball.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/sh
# args
repo="${1%/}"
ref="${2-HEAD}"
# check
if test ! -d "${repo}/.git"; then
echo "usage: $0 <repodir> [ <ref> ]"
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"