build: Better and friendlier tarball.
authorJan Nieuwenhuizen <janneke@gnu.org>
Thu, 24 Oct 2019 11:19:28 +0000 (13:19 +0200)
committerJan Nieuwenhuizen <janneke@gnu.org>
Thu, 24 Oct 2019 11:19:28 +0000 (13:19 +0200)
* build-aux/GNUmakefile.in (dist): Be friendly to Debian; avoid using
EPOCH.  Cater for file permission differences.

build-aux/GNUmakefile.in

index 7d9c91ca438fef731e7a9bf9685f4c532b1af2bc..6f3fda5e46bf20263d66659d8788c04c648268ba 100644 (file)
@@ -242,6 +242,10 @@ COMMIT=$(shell test -e ${srcdest}.git && (cd ${srcdir} && git describe --dirty 2
 TARBALL_VERSION=$(COMMIT:v%=%)
 TARBALL_DIR:=$(PACKAGE)-$(TARBALL_VERSION)
 TARBALL:=$(TARBALL_DIR).tar.gz
+# Be friendly to Debian; avoid using EPOCH
+MTIME=$(shell git show HEAD --format=%ct --no-patch 2>/dev/null)
+# Reproducible tarball
+TAR_FLAGS=--sort=name --mtime=@$(MTIME) --owner=0 --group=0 --numeric-owner --mode=go=rX,u+rw,a-s
 
 .tarball-version:
        echo $(COMMIT) > $@
@@ -251,6 +255,7 @@ GIT_LS_FILES:=git ls-files
 ifeq ($(wildcard .git),)
 GIT_ARCHIVE_HEAD:=tar -cf-
 GIT_LS_FILES:=find
+MTIME:=0
 endif
 
 dist: $(TARBALL)
@@ -270,11 +275,12 @@ generate-ChangeLog:
        mv generate-ChangeLog ChangeLog
 
 $(TARBALL): .tarball-version | generate-ChangeLog
-       ($(GIT_LS_FILES)\
-           --exclude=$(TARBALL_DIR);\
-           echo $^ | tr ' ' '\n')\
-           | GZIP=-n tar --sort=name --mtime=@0 --owner=0 --group=0 --numeric-owner\
-           --transform=s,^,$(TARBALL_DIR)/,S -T- -czf $@
+       ($(GIT_LS_FILES)                                \
+           --exclude=$(TARBALL_DIR);                   \
+           echo $^ | tr ' ' '\n')                      \
+           | tar $(TAR_FLAGS)                          \
+           --transform=s,^,$(TARBALL_DIR)/,S -T- -cf-  \
+           | gzip -c --no-name > $@
        git checkout ChangeLog
 
 ifdef GUIX