From ba16a67781993e4017a1a5a5bc34703b3b975bc1 Mon Sep 17 00:00:00 2001 From: kpcyrd Date: Sat, 8 Jun 2019 21:42:21 +0200 Subject: abuild: add SOURCE_DATE_EPOCH support --- abuild-sign.in | 5 +++++ abuild.in | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/abuild-sign.in b/abuild-sign.in index 1ce3a88..05298b4 100644 --- a/abuild-sign.in +++ b/abuild-sign.in @@ -31,6 +31,11 @@ do_sign() { cd "$repo" sig=".SIGN.RSA.$keyname" $openssl dgst -sha1 -sign "$privkey" -out "$sig" "$i" + + if [ -n "$SOURCE_DATE_EPOCH" ]; then + touch -h -d "@$SOURCE_DATE_EPOCH" "$sig" + fi + tmptargz=$(mktemp) tar -f - -c "$sig" | abuild-tar --cut | gzip -9 > "$tmptargz" tmpsigned=$(mktemp) diff --git a/abuild.in b/abuild.in index af1b194..72ec016 100644 --- a/abuild.in +++ b/abuild.in @@ -29,6 +29,11 @@ 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 # run optional log command for remote logging @@ -936,7 +941,7 @@ prepare_metafiles() { [ ! -d "$dir" ] && die "Missing $dir" cd "$dir" mkdir -p "$controldir" - local builddate=$(date -u "+%s") + local builddate="$SOURCE_DATE_EPOCH" # Fix package size on several filesystems case "$(df -PT . | awk 'END {print $2}')" in @@ -957,7 +962,7 @@ prepare_metafiles() { if [ -n "$FAKEROOTKEY" ]; then echo "# using $($FAKEROOT -v)" >> "$pkginfo" fi - echo "# $(date -u)" >> "$pkginfo" + echo "# $(date -u -d @$SOURCE_DATE_EPOCH)" >> "$pkginfo" cat >> "$pkginfo" <<-EOF pkgname = $name pkgver = $pkgver-r$pkgrel @@ -1521,12 +1526,17 @@ create_apks() { touch .dummy set -- .dummy fi + + # normalize timestamps + find . -exec touch -h -d "@$SOURCE_DATE_EPOCH" {} + + tar --xattrs -f - -c "$@" | abuild-tar --hash | $gzip -9 >"$dir"/data.tar.gz msg "Create checksum..." # append the hash for data.tar.gz local sha256=$(sha256sum "$dir"/data.tar.gz | cut -f1 -d' ') echo "datahash = $sha256" >> "$dir"/.PKGINFO + touch -h -d "@$SOURCE_DATE_EPOCH" "$dir"/.PKGINFO # control.tar.gz cd "$dir" -- cgit v1.2.3-70-g09d2