build: Better and friendlier tarball.

* build-aux/GNUmakefile.in (dist): Be friendly to Debian; avoid using
EPOCH.  Cater for file permission differences.
This commit is contained in:
Jan Nieuwenhuizen 2019-10-24 13:19:28 +02:00
parent 36ae666f05
commit 66296abdc8
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273

View file

@ -242,6 +242,10 @@ COMMIT=$(shell test -e ${srcdest}.git && (cd ${srcdir} && git describe --dirty 2
TARBALL_VERSION=$(COMMIT:v%=%) TARBALL_VERSION=$(COMMIT:v%=%)
TARBALL_DIR:=$(PACKAGE)-$(TARBALL_VERSION) TARBALL_DIR:=$(PACKAGE)-$(TARBALL_VERSION)
TARBALL:=$(TARBALL_DIR).tar.gz 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: .tarball-version:
echo $(COMMIT) > $@ echo $(COMMIT) > $@
@ -251,6 +255,7 @@ GIT_LS_FILES:=git ls-files
ifeq ($(wildcard .git),) ifeq ($(wildcard .git),)
GIT_ARCHIVE_HEAD:=tar -cf- GIT_ARCHIVE_HEAD:=tar -cf-
GIT_LS_FILES:=find GIT_LS_FILES:=find
MTIME:=0
endif endif
dist: $(TARBALL) dist: $(TARBALL)
@ -270,11 +275,12 @@ generate-ChangeLog:
mv generate-ChangeLog ChangeLog mv generate-ChangeLog ChangeLog
$(TARBALL): .tarball-version | generate-ChangeLog $(TARBALL): .tarball-version | generate-ChangeLog
($(GIT_LS_FILES)\ ($(GIT_LS_FILES) \
--exclude=$(TARBALL_DIR);\ --exclude=$(TARBALL_DIR); \
echo $^ | tr ' ' '\n')\ echo $^ | tr ' ' '\n') \
| GZIP=-n tar --sort=name --mtime=@0 --owner=0 --group=0 --numeric-owner\ | tar $(TAR_FLAGS) \
--transform=s,^,$(TARBALL_DIR)/,S -T- -czf $@ --transform=s,^,$(TARBALL_DIR)/,S -T- -cf- \
| gzip -c --no-name > $@
git checkout ChangeLog git checkout ChangeLog
ifdef GUIX ifdef GUIX