summaryrefslogtreecommitdiff
path: root/abuild.in
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2019-11-07 12:06:24 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2019-11-07 12:06:24 +0000
commit5b34b696d4cd6e83701e79a6b83f3b654183a241 (patch)
tree3fd701dcd206d8723a142e68784cc0aece0531fa /abuild.in
parent918cba2a77f6173fdddd96062514ad2acb20699e (diff)
downloadabuild-5b34b696d4cd6e83701e79a6b83f3b654183a241.tar.gz
abuild-5b34b696d4cd6e83701e79a6b83f3b654183a241.tar.bz2
abuild-5b34b696d4cd6e83701e79a6b83f3b654183a241.tar.xz
abuild-5b34b696d4cd6e83701e79a6b83f3b654183a241.zip
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.
Diffstat (limited to 'abuild.in')
-rw-r--r--abuild.in18
1 files changed, 13 insertions, 5 deletions
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"