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.
This commit is contained in:
Natanael Copa 2019-11-07 12:06:24 +00:00
parent 918cba2a77
commit 5b34b696d4
1 changed files with 13 additions and 5 deletions

View File

@ -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"