abuild: Fix abuild rootbld

Without this change abuild rootbld would fail with:

	touch: invalid date '@'

Because SOURCE_DATE_EPOCH wasn't set when abuild rootbld was used. This
is a bug introduced in 71d9d5233b9db3be91510addcb28721545d93185. Instead
of reverting the aforementioned commit move the SOURCE_DATE_EPOCH
initialization to a custom function and also call it from the abuild
rootbld function.

Fixes #9978
This commit is contained in:
Sören Tempel 2019-11-13 18:15:28 +01:00
parent 51d9e3bcb9
commit 918b7b1920

View File

@ -104,6 +104,18 @@ want_check() {
return 0 return 0
} }
set_source_date() {
# 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
}
default_cleanup_srcdir() { default_cleanup_srcdir() {
if options_has "chmod-clean" && test -d "$srcdir"; then if options_has "chmod-clean" && test -d "$srcdir"; then
chmod -R +w "$srcdir" chmod -R +w "$srcdir"
@ -1601,15 +1613,8 @@ build_abuildrepo() {
local _starttime=$(date --utc +%s) local _starttime=$(date --utc +%s)
msg "Building $repo/$pkgname $pkgver-r$pkgrel (using $program $program_version) started $(date -R)" msg "Building $repo/$pkgname $pkgver-r$pkgrel (using $program $program_version) started $(date -R)"
# set time stamp for reproducible builds # make sure SOURCE_DATE_EPOCH is set
export ABUILD_LAST_COMMIT="$(git_last_commit)$(git_dirty)" set_source_date
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 \ for part in sanitycheck builddeps clean fetch unpack prepare mkusers build \
$_check rootpkg; do $_check rootpkg; do
@ -2159,6 +2164,9 @@ rootbld() {
# check early if we have abuild key # check early if we have abuild key
abuild-sign --installed abuild-sign --installed
# make sure SOURCE_DATE_EPOCH is set
set_source_date
# networking business # networking business
sanitycheck sanitycheck
clean clean