diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2017-09-12 23:59:24 -0400 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2017-09-13 14:21:34 +1000 |
commit | 4dae3fde17d663bf39a17978c2ee365696a54fb0 (patch) | |
tree | 0c3a5f0a1a38fd35995961e550f8111cdf3ed61b /scripts | |
parent | 39319c1860d200a9b4a3cc2c6975e3cece502f2d (diff) | |
download | pacman-4dae3fde17d663bf39a17978c2ee365696a54fb0.tar.xz |
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 <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/makepkg.sh.in | 13 |
1 files changed, 12 insertions, 1 deletions
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 |