From 5d46429e322aa4840e0e7a714caa87672aee5faa Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Wed, 29 Apr 2026 11:30:43 +0100 Subject: [PATCH] guix, refactor: Move `distsrc_for_host()` to `prelude.bash` The `distsrc_for_host()` function now accepts a second optional argument, `SUFFIX`, making it consistent with other similar functions. --- contrib/guix/guix-build | 8 -------- contrib/guix/guix-codesign | 18 +++++------------- contrib/guix/libexec/prelude.bash | 9 +++++++++ 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/contrib/guix/guix-build b/contrib/guix/guix-build index a02c3603e19..eed9d459526 100755 --- a/contrib/guix/guix-build +++ b/contrib/guix/guix-build @@ -85,14 +85,6 @@ export HOSTS="${HOSTS:-x86_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu ri x86_64-w64-mingw32 x86_64-apple-darwin arm64-apple-darwin}" -# Usage: distsrc_for_host HOST -# -# HOST: The current platform triple we're building for -# -distsrc_for_host() { - echo "${DISTSRC_BASE}/distsrc-${VERSION}-${1}" -} - # Accumulate a list of build directories that already exist... hosts_distsrc_exists="" for host in $HOSTS; do diff --git a/contrib/guix/guix-codesign b/contrib/guix/guix-codesign index f985fd4c2fd..1ceb65d6c4e 100755 --- a/contrib/guix/guix-codesign +++ b/contrib/guix/guix-codesign @@ -99,18 +99,10 @@ fi # Default to building for all supported HOSTs (overridable by environment) export HOSTS="${HOSTS:-x86_64-w64-mingw32 x86_64-apple-darwin arm64-apple-darwin}" -# Usage: distsrc_for_host HOST -# -# HOST: The current platform triple we're building for -# -distsrc_for_host() { - echo "${DISTSRC_BASE}/distsrc-${VERSION}-${1}-codesigned" -} - # Accumulate a list of build directories that already exist... hosts_distsrc_exists="" for host in $HOSTS; do - if [ -e "$(distsrc_for_host "$host")" ]; then + if [ -e "$(distsrc_for_host "$host" codesigned)" ]; then hosts_distsrc_exists+=" ${host}" fi done @@ -134,7 +126,7 @@ packages cache, the garbage collector roots for Guix environments, and the output directory. EOF for host in $hosts_distsrc_exists; do - echo " ${host} '$(distsrc_for_host "$host")'" + echo " ${host} '$(distsrc_for_host "$host" codesigned)'" done exit 1 else @@ -263,8 +255,8 @@ INFO: Codesigning ${VERSION:?not set} for platform triple ${HOST:?not set}: ...using reference timestamp: ${SOURCE_DATE_EPOCH:?not set} ...from worktree directory: '${PWD}' ...bind-mounted in container to: '/bitcoin' - ...in build directory: '$(distsrc_for_host "$HOST")' - ...bind-mounted in container to: '$(DISTSRC_BASE=/distsrc-base && distsrc_for_host "$HOST")' + ...in build directory: '$(distsrc_for_host "$HOST" codesigned)' + ...bind-mounted in container to: '$(DISTSRC_BASE=/distsrc-base && distsrc_for_host "$HOST" codesigned)' ...outputting in: '$(outdir_for_host "$HOST" codesigned)' ...bind-mounted in container to: '$(OUTDIR_BASE=/outdir-base && outdir_for_host "$HOST" codesigned)' ...using detached signatures in: '${DETACHED_SIGS_REPO:?not set}' @@ -347,7 +339,7 @@ EOF JOBS="$JOBS" \ SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:?unable to determine value}" \ ${V:+V=1} \ - DISTSRC="$(DISTSRC_BASE=/distsrc-base && distsrc_for_host "$HOST")" \ + DISTSRC="$(DISTSRC_BASE=/distsrc-base && distsrc_for_host "$HOST" codesigned)" \ OUTDIR="$(OUTDIR_BASE=/outdir-base && outdir_for_host "$HOST" codesigned)" \ DIST_ARCHIVE_BASE=/outdir-base/dist-archive \ DETACHED_SIGS_REPO=/detached-sigs \ diff --git a/contrib/guix/libexec/prelude.bash b/contrib/guix/libexec/prelude.bash index c13f24c538a..21e668cf1f9 100644 --- a/contrib/guix/libexec/prelude.bash +++ b/contrib/guix/libexec/prelude.bash @@ -80,6 +80,15 @@ time-machine() { -- "$@" } +# Usage: distsrc_for_host HOST [SUFFIX] +# +# HOST: The current platform triple we're building for +# SUFFIX: Optional. If provided, appended to the directory name as "-SUFFIX" +# +distsrc_for_host() { + echo "${DISTSRC_BASE}/distsrc-${VERSION}-${1}${2:+-${2}}" +} + # Usage: outdir_for_host HOST [SUFFIX] # # HOST: The current platform triple we're building for