From 47f56d8f944849301af4ae7848dc9da49fbb2484 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ladislav=20Slez=C3=A1k?= Date: Mon, 15 Jan 2018 16:26:40 +0100 Subject: [PATCH] Build reproducible tarballs by "make package" --- Makefile.am | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) 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 -- 2.47.3