summaryrefslogtreecommitdiffstats
path: root/create_tarball
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2020-03-20 15:30:00 +0100
committerSlávek Banko <slavek.banko@axis.cz>2020-03-23 17:45:20 +0100
commitb43f26a7ccd1dd92257163fa9fcfd5f00218e507 (patch)
tree7c37e9b15253fb32fd5bd2bc83b295f982f59214 /create_tarball
parentabf4cb3fbcb588e4d4ef68a92188013bd8eab741 (diff)
downloadscripts-b43f26a7ccd1dd92257163fa9fcfd5f00218e507.tar.gz
scripts-b43f26a7ccd1dd92257163fa9fcfd5f00218e507.zip
create_tarball: Modify the tarball creation so that it is reproducible.
Note: If gzip or pigz is used, it is necessary to use the "-n" option. Signed-off-by: Slávek Banko <slavek.banko@axis.cz> (cherry picked from commit 428c2d88b4ac80df001d25973a1511d6a3d424c6)
Diffstat (limited to 'create_tarball')
-rwxr-xr-xcreate_tarball19
1 files changed, 13 insertions, 6 deletions
diff --git a/create_tarball b/create_tarball
index 19a2209..1233b1d 100755
--- a/create_tarball
+++ b/create_tarball
@@ -15,9 +15,9 @@ TARBALL_DIR=${TARBALL_DIR:-".."}
# Set compression method
case ${COMPRESS:="xz"} in
- "gzip"|"pigz") TAR_SUFFIX="gz";;
- "bzip2"|"pbzip2") TAR_SUFFIX="bz2";;
- "xz"|"pxz") TAR_SUFFIX="xz";;
+ "gzip"*|"pigz"*) TAR_SUFFIX=".gz";;
+ "bzip2"|"pbzip2") TAR_SUFFIX=".bz2";;
+ "xz"|"pxz") TAR_SUFFIX=".xz";;
esac
# Check git-dir
@@ -149,18 +149,25 @@ fi
# Create tarball
echo "Package name: $package"
-if [ ! -e $TARBALL_DIR/$package.tar.$TAR_SUFFIX ]; then
+if [ ! -e $TARBALL_DIR/$package.tar$TAR_SUFFIX ]; then
echo "Creating tarball in $TARBALL_DIR."
echo "# TDE SCM module information" > .tdescminfo
echo "Name: $MODULE" >> .tdescminfo
echo "Revision: $branch-$(git rev-parse HEAD)" >> .tdescminfo
git log -1 --pretty=format:"DateTime: %cd%n" --date=format:"%m/%d/%Y %H:%M" >> .tdescminfo
trap "rm $TARBALL_DIR/tar-$$; rm .tdescminfo; exit 1" INT
- tar c --owner=root --group=users --exclude .git --exclude .gitmodules --transform "s|^\.\(/\|$\)|$package\1|" ./ | \
+ find ./ -print0 | LC_ALL=C sort -z | \
+ tar c --no-recursion --null -T - \
+ --mtime "@$(git log -1 --pretty=format:"%ct")" \
+ --owner=root --group=users --exclude .git --exclude .gitmodules \
+ --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime \
+ --transform "s|^\.\(/\|$\)|$package\1|" ./ | \
$COMPRESS -9 >$TARBALL_DIR/tar-$$ && \
- mv $TARBALL_DIR/tar-$$ $TARBALL_DIR/$package.tar.$TAR_SUFFIX || \
+ mv $TARBALL_DIR/tar-$$ $TARBALL_DIR/$package.tar$TAR_SUFFIX || \
rm $TARBALL_DIR/tar-$$
rm .tdescminfo
+ [ -f $TARBALL_DIR/$package.tar$TAR_SUFFIX ] && \
+ touch -d "@$(git log -1 --pretty=format:"%ct")" $TARBALL_DIR/$package.tar$TAR_SUFFIX
else
echo "Unchanged tarball in $TARBALL_DIR."
exit 2