From c904eddb9165e434a4f66cc9b15124ea7a99bd19 Mon Sep 17 00:00:00 2001 From: tobtoht Date: Tue, 12 Mar 2024 14:29:32 +0100 Subject: [PATCH] guix: use a fixed timestamp for depends packages --- contrib/guix/guix-build | 8 ++++---- contrib/guix/libexec/build.sh | 9 ++++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/contrib/guix/guix-build b/contrib/guix/guix-build index 93f624d..bff585f 100755 --- a/contrib/guix/guix-build +++ b/contrib/guix/guix-build @@ -199,7 +199,7 @@ host_to_commonname() { esac } -SOURCE_DATE_EPOCH="1701896000" +COMMIT_TIMESTAMP="$(git -c log.showSignature=false log --format=%at -1)" # Precious directories are those which should not be cleaned between successive # guix builds @@ -322,7 +322,7 @@ for host in $HOSTS; do # shellcheck disable=SC2030 cat << EOF INFO: Building ${VERSION:?not set} for platform triple ${HOST:?not set}: - ...using reference timestamp: ${SOURCE_DATE_EPOCH:?not set} + ...using commit timestamp: ${COMMIT_TIMESTAMP:?not set} ...running at most ${JOBS:?not set} jobs ...from worktree directory: '${PWD}' ...bind-mounted in container to: '/feather' @@ -434,7 +434,7 @@ EOF -- env HOST="$HOST" \ DISTNAME="$DISTNAME" \ JOBS="$JOBS" \ - SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:?unable to determine value}" \ + COMMIT_TIMESTAMP="${COMMIT_TIMESTAMP:?unable to determine value}" \ ${V:+V=1} \ ${SOURCES_PATH:+SOURCES_PATH="$SOURCES_PATH"} \ ${BASE_CACHE:+BASE_CACHE="$BASE_CACHE"} \ @@ -465,7 +465,7 @@ EOF ${SUBSTITUTE_URLS:+--substitute-urls="$SUBSTITUTE_URLS"} \ ${ADDITIONAL_GUIX_COMMON_FLAGS} ${ADDITIONAL_GUIX_ENVIRONMENT_FLAGS} \ -- env DISTNAME="$DISTNAME" \ - SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:?unable to determine value}" \ + SOURCE_DATE_EPOCH="${COMMIT_TIMESTAMP:?unable to determine value}" \ VERSION="$VERSION" \ bash -c "cd /feather && \ bash contrib/flatpak/make_flatpak.sh" diff --git a/contrib/guix/libexec/build.sh b/contrib/guix/libexec/build.sh index e53e9cc..e5c22e9 100755 --- a/contrib/guix/libexec/build.sh +++ b/contrib/guix/libexec/build.sh @@ -36,7 +36,7 @@ Required environment variables as seen inside the container: DIST_ARCHIVE_BASE: ${DIST_ARCHIVE_BASE:?not set} DISTNAME: ${DISTNAME:?not set} HOST: ${HOST:?not set} - SOURCE_DATE_EPOCH: ${SOURCE_DATE_EPOCH:?not set} + COMMIT_TIMESTAMP: ${COMMIT_TIMESTAMP:?not set} JOBS: ${JOBS:?not set} DISTSRC: ${DISTSRC:?not set} OUTDIR: ${OUTDIR:?not set} @@ -46,6 +46,9 @@ EOF ACTUAL_OUTDIR="${OUTDIR}" OUTDIR="${DISTSRC}/output" +# Use a fixed timestamp for depends builds so hashes match across commits that don't make changes to the build system +export SOURCE_DATE_EPOCH=1397818193 + ##################### # Environment Setup # ##################### @@ -230,6 +233,10 @@ make -C contrib/depends --jobs="$JOBS" HOST="$HOST" \ # Source Tarball Building # ########################### +# Use COMMIT_TIMESTAMP for the source and release binary archives +export SOURCE_DATE_EPOCH=${COMMIT_TIMESTAMP} +export TAR_OPTIONS="--owner=0 --group=0 --numeric-owner --mtime='@${SOURCE_DATE_EPOCH}' --sort=name" + GIT_ARCHIVE="${DIST_ARCHIVE_BASE}/${DISTNAME}.tar.gz" # Create the source tarball if not already there