summaryrefslogtreecommitdiffstats
path: root/create_tarball
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2013-02-13 22:45:58 +0100
committerSlávek Banko <slavek.banko@axis.cz>2013-02-13 22:53:36 +0100
commit6a19cd9bb6d3463f31299644cc687c0bc6d7c672 (patch)
tree9eca705006e58bf069cbf343ca905250d72ec58c /create_tarball
parentd5d288f9e8137e993b75cc0a946441921f43959f (diff)
downloadscripts-6a19cd9bb6d3463f31299644cc687c0bc6d7c672.tar.gz
scripts-6a19cd9bb6d3463f31299644cc687c0bc6d7c672.zip
create_tarball: Add option to select compression method
Diffstat (limited to 'create_tarball')
-rwxr-xr-xcreate_tarball13
1 files changed, 10 insertions, 3 deletions
diff --git a/create_tarball b/create_tarball
index d0f108d..03799b9 100755
--- a/create_tarball
+++ b/create_tarball
@@ -12,6 +12,13 @@ SUFFIX=${SUFFIX:-"true"}
# The default is the parent directory (..).
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
if [[ ! -e .git ]] ||
[[ -z "`git rev-parse --git-dir 2>/dev/null`" ]]; then
@@ -80,12 +87,12 @@ fi
# Create tarball
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."
trap "rm $TARBALL_DIR/tar-$$; exit 1" INT
tar c --owner=root --group=users --exclude .git --exclude .gitmodules --transform "s|^\.|$package|" ./ | \
- xz -9 >$TARBALL_DIR/tar-$$ && \
- mv $TARBALL_DIR/tar-$$ $TARBALL_DIR/$package.tar.xz || \
+ $COMPRESS -9 >$TARBALL_DIR/tar-$$ && \
+ mv $TARBALL_DIR/tar-$$ $TARBALL_DIR/$package.tar.$TAR_SUFFIX || \
rm $TARBALL_DIR/tar-$$
else
echo "Unchanged tarball in $TARBALL_DIR."