abuild: get the git commit date only when needed

getting the commit date can be timeconsuming so only do it once we need
it. We also re-use the ABUILD_LAST_COMMIT to speed up the operation.
This commit is contained in:
Natanael Copa 2019-11-07 14:13:51 +00:00
parent 114c0cf287
commit 71d9d5233b

View File

@ -1608,6 +1608,17 @@ build_abuildrepo() {
logcmd "building $repo/$pkgname-$pkgver-r$pkgrel"
local _starttime=$(date --utc +%s)
msg "Building $repo/$pkgname $pkgver-r$pkgrel (using $program $program_version) started $(date -R)"
# set time stamp for reproducible builds
export ABUILD_LAST_COMMIT="$(git_last_commit)$(git_dirty)"
if [ -z "$SOURCE_DATE_EPOCH" ] && [ "${ABUILD_LAST_COMMIT%-dirty}" = "$ABUILD_LAST_COMMIT" ]; then
SOURCE_DATE_EPOCH=$(git_last_commit_epoch $ABUILD_LAST_COMMIT)
fi
if [ -z "$SOURCE_DATE_EPOCH" ]; then
SOURCE_DATE_EPOCH=$(date -u "+%s")
fi
export SOURCE_DATE_EPOCH
for part in sanitycheck builddeps clean fetch unpack prepare mkusers build \
$_check rootpkg; do
runpart $part
@ -1891,6 +1902,7 @@ rootpkg() {
cd "$startdir"
rm -rf "$pkgdir"
[ -n "$FAKEROOT" ] && msg "Entering fakeroot..."
do_fakeroot "$abuild_path" $forceroot $color_opt $keep_build \
package \
prepare_subpackages \
@ -2556,14 +2568,6 @@ 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"