empserver/src/scripts/tarball
Markus Armbruster 240474195d src/scripts/tarball: Clean up to prepare for the next commit
We don't save $1 in a variable, only $1-$2.  Okay, because we don't
need $1 by itself.  However, the next commit will.  So save it.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-08-13 13:38:10 +02:00

33 lines
543 B
Bash
Executable file

#!/bin/sh -e
if [ $# = 0 ]; then
echo "Usage: $0 NAME (FILE | -C DIR)..."
exit 1
fi
name="$1"
version="$2"
shift; shift
nv=$name-$version
mkdir $nv
printf "%s" $version >$nv/.tarball-version
>$nv/.dirty-stamp
# arrange cleanup
trap 'rm -rf "$nv"' 0
dir=.
until [ $# = 0 ]; do
if [ "$1" = -C ]; then
dir="$2"
if shift 2; then continue; fi
echo "-C requires an argument" >&2
exit 1
fi
mkdir -p `dirname "$nv/$1"`
ln "$dir/$1" "$nv/$1"
shift
done
tar -czf $nv.tar.gz --owner=0 --group=0 --mode=ug+w,a+rX $nv