From: Ladislav Slezák Date: Mon, 15 Jan 2018 15:26:40 +0000 (+0100) Subject: Build reproducible tarballs by "make package" X-Git-Tag: v0.5.4~5^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F381%2Fhead;p=thirdparty%2Fsnapper.git Build reproducible tarballs by "make package" --- diff --git a/Makefile.am b/Makefile.am index f52dc28f..ec51da4b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -60,9 +60,32 @@ package-clean: # VERSION file. # # $< is the first depencency of the rule, i.e. snapper-$(VERSION).tar.gz in this case. -# + +# Build a reproducible tarball: +# - set the file time stamps according to the latest commit +# - sort the files (in a locale independent way, use the NULL separator to +# correctly process also the file names containing a new line) +# Note: tar >= 1.28 supports "--sort=name" option, unfortunately +# Leap 42.3 and SLES12-SP3 contain version 1.27.1 +# - use the GNU format (the default POSIX format contains some time stamps) +# - set the owner and group to "root" +# - set the fixed modification time + +# shared tar options +EXTRA_TAR_OPTIONS = --format=gnu --owner=root --group=root \ +--mtime='$(shell git show -s --format=%ci)' --null --files-from - + +# redefine the standard automake "tar" command +am__tar=find "$$tardir" -type f -print0 | LC_ALL=C sort -z | \ + tar -c -f - $(EXTRA_TAR_OPTIONS) + package: snapper-$(VERSION).tar.bz2 package-clean - tar cfzv package/debian.tar.gz --transform='s|dists/||' --show-transformed --exclude='*.in' dists/debian/* + find dists/debian -not -name '*.in' -not -name '.*' -type f -print0 | \ + LC_ALL=C sort -z | \ + tar -c -f package/debian.tar --transform='s|dists/||' --show-transformed \ + $(EXTRA_TAR_OPTIONS) + ## use -n option to exclude the original file time stamps to have a reproducible tarball + gzip -n package/debian.tar cp dists/debian/*.dsc.in package/ echo "$(shell md5sum $< | sed -e 's/\s.*//') $(shell wc -c $<)" >> package/snapper-Debian.dsc.in echo "$(shell md5sum $< | sed -e 's/\s.*//') $(shell wc -c $<)" >> package/snapper-xUbuntu.dsc.in