From 5b34b696d4cd6e83701e79a6b83f3b654183a241 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Thu, 7 Nov 2019 12:06:24 +0000 Subject: abuild: set SOURCE_DATE_EPOCH to last commit date by default set datestamps to be used in the built packages to date of commit. This makes it much easier to have reproducible builds. --- abuild.in | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'abuild.in') diff --git a/abuild.in b/abuild.in index 729a400..a7ece85 100644 --- a/abuild.in +++ b/abuild.in @@ -30,11 +30,6 @@ fi apk_opt_wait="--wait 30" -if [ -z "$SOURCE_DATE_EPOCH" ]; then - SOURCE_DATE_EPOCH=$(date -u "+%s") -fi -export SOURCE_DATE_EPOCH - umask 022 shell_escape() { @@ -872,6 +867,11 @@ git_last_commit() { $git log --format=oneline -n 1 "$startdir" | awk '{print $1}' } +# date of last commit +git_last_commit_epoch() { + $git log -1 --format=%cd --date=unix -- "$startdir" +} + get_maintainer() { if [ -z "$maintainer" ]; then maintainer=$(awk -F': ' '/# *Maintainer/ {print $2}' "$APKBUILD") @@ -2548,6 +2548,14 @@ BUILD_ROOT= export CC CXX +if [ -z "$SOURCE_DATE_EPOCH" ]; then + SOURCE_DATE_EPOCH=$(git_last_commit_epoch) +fi +if [ -z "$SOURCE_DATE_EPOCH" ]; then + SOURCE_DATE_EPOCH=$(date -u "+%s") +fi +export SOURCE_DATE_EPOCH + cd "$startdir" || die . "$APKBUILD" -- cgit v1.2.3-60-g2f50