From 4dae3fde17d663bf39a17978c2ee365696a54fb0 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Tue, 12 Sep 2017 23:59:24 -0400 Subject: makepkg: respect $SOURCE_DATE_EPOCH to activate reproducible builds If SOURCE_DATE_EPOCH is set, `touch` all source files between the (optional) prepare() and build() functions to unify the modification times. This works around build systems and compilers that embed the file modification times into the file contents of release artifacts. Signed-off-by: Eli Schwartz Signed-off-by: Allan McRae --- scripts/makepkg.sh.in | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'scripts/makepkg.sh.in') diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 20e9dd7e..a466e4f1 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -79,6 +79,7 @@ PKGFUNC=0 PKGVERFUNC=0 PREPAREFUNC=0 REPKG=0 +REPRODUCIBLE=0 RMDEPS=0 SKIPCHECKSUMS=0 SKIPPGPCHECK=0 @@ -87,7 +88,12 @@ SPLITPKG=0 SOURCEONLY=0 VERIFYSOURCE=0 -export SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH:-$(date +%s)} +if [[ -n $SOURCE_DATE_EPOCH ]]; then + REPRODUCIBLE=1 +else + SOURCE_DATE_EPOCH=$(date +%s) +fi +export SOURCE_DATE_EPOCH PACMAN_OPTS=() @@ -1686,6 +1692,11 @@ if (( !REPKG )); then if (( PREPAREFUNC )); then run_prepare fi + if (( REPRODUCIBLE )); then + # We have activated reproducible builds, so unify source times before + # building + find "$srcdir" -exec touch -h -d @$SOURCE_DATE_EPOCH {} + + fi fi if (( PKGVERFUNC )); then -- cgit v1.2.3-54-g00ecf