create_tarball: Add option to select compression method

pull/1/head
Slávek Banko 11 years ago
parent d5d288f9e8
commit 6a19cd9bb6

@ -12,6 +12,13 @@ SUFFIX=${SUFFIX:-"true"}
# The default is the parent directory (..). # The default is the parent directory (..).
TARBALL_DIR=${TARBALL_DIR:-".."} TARBALL_DIR=${TARBALL_DIR:-".."}
# Set compression method
case ${COMPRESS:="xz"} in
"gzip") TAR_SUFFIX="gz";;
"bzip2") TAR_SUFFIX="bz2";;
"xz") TAR_SUFFIX="xz";;
esac
# Check git-dir # Check git-dir
if [[ ! -e .git ]] || if [[ ! -e .git ]] ||
[[ -z "`git rev-parse --git-dir 2>/dev/null`" ]]; then [[ -z "`git rev-parse --git-dir 2>/dev/null`" ]]; then
@ -80,12 +87,12 @@ fi
# Create tarball # Create tarball
echo "Package name: $package" echo "Package name: $package"
if [ ! -e $TARBALL_DIR/$package.tar.xz ]; then if [ ! -e $TARBALL_DIR/$package.tar.$TAR_SUFFIX ]; then
echo "Creating tarball in $TARBALL_DIR." echo "Creating tarball in $TARBALL_DIR."
trap "rm $TARBALL_DIR/tar-$$; exit 1" INT trap "rm $TARBALL_DIR/tar-$$; exit 1" INT
tar c --owner=root --group=users --exclude .git --exclude .gitmodules --transform "s|^\.|$package|" ./ | \ tar c --owner=root --group=users --exclude .git --exclude .gitmodules --transform "s|^\.|$package|" ./ | \
xz -9 >$TARBALL_DIR/tar-$$ && \ $COMPRESS -9 >$TARBALL_DIR/tar-$$ && \
mv $TARBALL_DIR/tar-$$ $TARBALL_DIR/$package.tar.xz || \ mv $TARBALL_DIR/tar-$$ $TARBALL_DIR/$package.tar.$TAR_SUFFIX || \
rm $TARBALL_DIR/tar-$$ rm $TARBALL_DIR/tar-$$
else else
echo "Unchanged tarball in $TARBALL_DIR." echo "Unchanged tarball in $TARBALL_DIR."

Loading…
Cancel
Save