summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkpcyrd <git@rxv.cc>2019-06-08 21:42:21 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2019-07-17 13:11:20 +0000
commitba16a67781993e4017a1a5a5bc34703b3b975bc1 (patch)
treef5a255ae122db745d1208716cb06f2ce2d3178a2
parent2c2a518ac7c0babae0048de806e7c43fe398c166 (diff)
downloadabuild-ba16a67781993e4017a1a5a5bc34703b3b975bc1.tar.gz
abuild-ba16a67781993e4017a1a5a5bc34703b3b975bc1.tar.bz2
abuild-ba16a67781993e4017a1a5a5bc34703b3b975bc1.tar.xz
abuild-ba16a67781993e4017a1a5a5bc34703b3b975bc1.zip
abuild: add SOURCE_DATE_EPOCH support
-rw-r--r--abuild-sign.in5
-rw-r--r--abuild.in14
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"