#! /bin/sh # $Id: dist-tar,v 1.6 2010/03/23 05:16:32 friedman Exp $ LC_COLLATE=C export LC_COLLATE if ${TAR-tar} --version 2>&1 | grep 'GNU tar' > /dev/null; then gnutar=t fi case ${DIST_TAR_ZIP-gzip} in gzip ) zip=gzip z=gz ;; bzip2 ) zip=bzip2 z=bz2 ;; lzma ) zip=lzma z=lzma ;; esac for dir in ${1+"$@"} ; do # Protect against accidental trailing slash, i.e. if someone does # dist-tar foo/, don't create foo/.tar.gz only to delete foo # afterward. case $dir in */ ) dir=`echo "$dir" | sed -e 's=/$==g'` ;; esac echo "dist-tar: packing $dir.tar.$z" { case $gnutar in t ) find "$dir" -print \ | sort \ | ${TAR-tar} --no-recursion -T - -cvf - \ | $zip --best > "$dir.tar.$z" ;; * ) ${TAR-tar} -cvf - "$dir" \ | $zip --best > "$dir.tar.$z" ;; esac } && touch -r "$dir" "$dir.tar.$z" \ && rm -rf "$dir" done # eof