build: Add dist target.

* makefile (dist): Create reproducible tarball.
This commit is contained in:
Jan Nieuwenhuizen 2019-11-17 11:21:58 +01:00
parent b87ddb0051
commit 30a09a592b
1 changed files with 23 additions and 0 deletions

View File

@ -16,6 +16,7 @@
# Prevent rebuilding
VPATH = bin:test:test/results
PACKAGE = m2-planet
all: M2-Planet
@ -604,3 +605,25 @@ bindir:=$(DESTDIR)$(PREFIX)/bin
install: M2-Planet
mkdir -p $(bindir)
cp $^ $(bindir)
### dist
.PHONY: dist
COMMIT=$(shell git describe --dirty)
TARBALL_VERSION=$(COMMIT:Release_%=%)
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)
# Reproducible tarball
TAR_FLAGS=--sort=name --mtime=@$(MTIME) --owner=0 --group=0 --numeric-owner --mode=go=rX,u+rw,a-s
$(TARBALL):
(git ls-files \
--exclude=$(TARBALL_DIR); \
echo $^ | tr ' ' '\n') \
| tar $(TAR_FLAGS) \
--transform=s,^,$(TARBALL_DIR)/,S -T- -cf- \
| gzip -c --no-name > $@
dist: $(TARBALL)