1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
#!/bin/bash
# put the files given on the command line into a tarball with the same name as the first file in that list. that first file gets overwritten.
files=$*
tmpdir=`mktemp -q -d /tmp/lw-tar.XXXXXX `
# -q is quiet and -d is --directory.
# short options are used here for portability purposes on systems that don't
# see the benefit of the explanatory power of long options.
file=`basename $1`
if [ "x$tmpdir" != "x" ]; then
cp $files $tmpdir
tarball=$file.tar
origdir=`pwd`
cd $tmpdir
tmpfiles=""
for f in $files; do
tmpfiles="$tmpfiles `basename $f`"
done
tar -cvf $tarball $tmpfiles --sort=name --clamp-mtime --mtime="@${SOURCE_DATE_EPOCH:-$(date +%s)}" --mode=go=rX,u+rw,a-s --owner=root --group=root --numeric-owner
cd $origdir
cp -f $tmpdir/$tarball $1
rm -f $tmpdir/*
rmdir $tmpdir
fi
|