From d4c69a72246ed6a290c5aca812d5b896904b4382 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Tue, 21 Apr 2026 14:57:42 +0100 Subject: [PATCH 1/7] guix, refactor: Remove unused `out_name()` function --- contrib/guix/guix-attest | 8 -------- 1 file changed, 8 deletions(-) diff --git a/contrib/guix/guix-attest b/contrib/guix/guix-attest index b0ef28dc3f9..3d70731cbdb 100755 --- a/contrib/guix/guix-attest +++ b/contrib/guix/guix-attest @@ -139,14 +139,6 @@ fi ## Attest ## ############## -# Usage: out_name $outdir -# -# HOST: The output directory being attested -# -out_name() { - basename "$(dirname "$1")" -} - shasum_already_exists() { cat < Date: Tue, 21 Apr 2026 14:58:41 +0100 Subject: [PATCH 2/7] guix, refactor: Remove `contains()` function --- contrib/guix/guix-build | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/contrib/guix/guix-build b/contrib/guix/guix-build index 767ea9208f6..ac7888409e4 100755 --- a/contrib/guix/guix-build +++ b/contrib/guix/guix-build @@ -244,18 +244,9 @@ SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-$(git -c log.showSignature=false log --f # Precious directories are those which should not be cleaned between successive # guix builds -depends_precious_dir_names='SOURCES_PATH BASE_CACHE SDK_PATH' -precious_dir_names="${depends_precious_dir_names} OUTDIR_BASE PROFILES_BASE" - -# Usage: contains IFS-SEPARATED-LIST ITEM -contains() { - for i in ${1}; do - if [ "$i" = "${2}" ]; then - return 0 # Found! - fi - done - return 1 -} +depends_precious_dir_names="SOURCES_PATH BASE_CACHE SDK_PATH" +base_dir_names="OUTDIR_BASE PROFILES_BASE" +precious_dir_names="${depends_precious_dir_names} ${base_dir_names}" # If the user explicitly specified a precious directory, create it so we # can map it into the container @@ -287,11 +278,9 @@ mkdir -p "$VAR_BASE" -- $(printf "print-%s\n" $depends_precious_dir_names) # Get remaining precious dir definitions from the environment - for precious_dir_name in $precious_dir_names; do + for precious_dir_name in $base_dir_names; do precious_dir_path="${!precious_dir_name}" - if ! contains "$depends_precious_dir_names" "$precious_dir_name"; then - echo "${precious_dir_name}=${precious_dir_path}" - fi + echo "${precious_dir_name}=${precious_dir_path}" done } > "${VAR_BASE}/precious_dirs" From faa9d4345ff584eb2a7c09f4087c487c381e6b42 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Wed, 29 Apr 2026 11:24:25 +0100 Subject: [PATCH 3/7] guix, refactor: Move duplicated `outdir_for_host()` to `prelude.bash` --- contrib/guix/guix-build | 8 -------- contrib/guix/guix-codesign | 9 --------- contrib/guix/libexec/prelude.bash | 8 ++++++++ 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/contrib/guix/guix-build b/contrib/guix/guix-build index ac7888409e4..9c78c2a2a0b 100755 --- a/contrib/guix/guix-build +++ b/contrib/guix/guix-build @@ -294,14 +294,6 @@ for host in $HOSTS; do make -C "${PWD}/depends" -j"$JOBS" download-"$(host_to_commonname "$host")" ${V:+V=1} ${SOURCES_PATH:+SOURCES_PATH="$SOURCES_PATH"} done -# Usage: outdir_for_host HOST SUFFIX -# -# HOST: The current platform triple we're building for -# -outdir_for_host() { - echo "${OUTDIR_BASE}/${1}${2:+-${2}}" -} - # Usage: profiledir_for_host HOST SUFFIX # # HOST: The current platform triple we're building for diff --git a/contrib/guix/guix-codesign b/contrib/guix/guix-codesign index 8c8682ddd0a..230499c0596 100755 --- a/contrib/guix/guix-codesign +++ b/contrib/guix/guix-codesign @@ -146,15 +146,6 @@ fi # Codesigning tarballs SHOULD exist ################ -# Usage: outdir_for_host HOST SUFFIX -# -# HOST: The current platform triple we're building for -# -outdir_for_host() { - echo "${OUTDIR_BASE}/${1}${2:+-${2}}" -} - - codesigning_tarball_for_host() { case "$1" in *mingw*) diff --git a/contrib/guix/libexec/prelude.bash b/contrib/guix/libexec/prelude.bash index 166675e8bf0..fbebd2a1aee 100644 --- a/contrib/guix/libexec/prelude.bash +++ b/contrib/guix/libexec/prelude.bash @@ -80,6 +80,14 @@ time-machine() { -- "$@" } +# Usage: outdir_for_host HOST [SUFFIX] +# +# HOST: The current platform triple we're building for +# SUFFIX: Optional. If provided, appended to the directory name as "-SUFFIX" +# +outdir_for_host() { + echo "${OUTDIR_BASE}/${1}${2:+-${2}}" +} ################ # Set common variables From cab65ea9c6963bfffe73524b1485378b6305c398 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Wed, 29 Apr 2026 11:27:42 +0100 Subject: [PATCH 4/7] guix, refactor: Move duplicated `profiledir_for_host()` to `prelude.bash` --- contrib/guix/guix-build | 8 -------- contrib/guix/guix-codesign | 8 -------- contrib/guix/libexec/prelude.bash | 9 +++++++++ 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/contrib/guix/guix-build b/contrib/guix/guix-build index 9c78c2a2a0b..a02c3603e19 100755 --- a/contrib/guix/guix-build +++ b/contrib/guix/guix-build @@ -294,14 +294,6 @@ for host in $HOSTS; do make -C "${PWD}/depends" -j"$JOBS" download-"$(host_to_commonname "$host")" ${V:+V=1} ${SOURCES_PATH:+SOURCES_PATH="$SOURCES_PATH"} done -# Usage: profiledir_for_host HOST SUFFIX -# -# HOST: The current platform triple we're building for -# -profiledir_for_host() { - echo "${PROFILES_BASE}/${1}${2:+-${2}}" -} - ######### # BUILD # diff --git a/contrib/guix/guix-codesign b/contrib/guix/guix-codesign index 230499c0596..f985fd4c2fd 100755 --- a/contrib/guix/guix-codesign +++ b/contrib/guix/guix-codesign @@ -223,14 +223,6 @@ SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-$(git -c log.showSignature=false log --f OUTDIR_BASE="${OUTDIR_BASE:-${VERSION_BASE}/output}" mkdir -p "$OUTDIR_BASE" -# Usage: profiledir_for_host HOST SUFFIX -# -# HOST: The current platform triple we're building for -# -profiledir_for_host() { - echo "${PROFILES_BASE}/${1}${2:+-${2}}" -} - ######### # BUILD # ######### diff --git a/contrib/guix/libexec/prelude.bash b/contrib/guix/libexec/prelude.bash index fbebd2a1aee..c13f24c538a 100644 --- a/contrib/guix/libexec/prelude.bash +++ b/contrib/guix/libexec/prelude.bash @@ -89,6 +89,15 @@ outdir_for_host() { echo "${OUTDIR_BASE}/${1}${2:+-${2}}" } +# Usage: profiledir_for_host HOST [SUFFIX] +# +# HOST: The current platform triple we're building for +# SUFFIX: Optional. If provided, appended to the directory name as "-SUFFIX" +# +profiledir_for_host() { + echo "${PROFILES_BASE}/${1}${2:+-${2}}" +} + ################ # Set common variables ################ 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 5/7] 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 From 62cf7bc53f238849cfa872972fc384dd25175fba Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Wed, 29 Apr 2026 11:45:43 +0100 Subject: [PATCH 6/7] guix, refactor: Add `BASE` argument to `*_for_host` functions --- contrib/guix/guix-build | 11 +++++------ contrib/guix/guix-codesign | 22 +++++++++++++--------- contrib/guix/libexec/prelude.bash | 10 ++++++---- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/contrib/guix/guix-build b/contrib/guix/guix-build index eed9d459526..1ab9cc7e455 100755 --- a/contrib/guix/guix-build +++ b/contrib/guix/guix-build @@ -321,7 +321,6 @@ for host in $HOSTS; do # for the particular $HOST we're building for export HOST="$host" - # shellcheck disable=SC2030 cat << EOF INFO: Building ${VERSION:?not set} for platform triple ${HOST:?not set}: ...using reference timestamp: ${SOURCE_DATE_EPOCH:?not set} @@ -329,9 +328,9 @@ INFO: Building ${VERSION:?not set} for platform triple ${HOST:?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")' + ...bind-mounted in container to: '$(distsrc_for_host "$HOST" "" /distsrc-base)' ...outputting in: '$(outdir_for_host "$HOST")' - ...bind-mounted in container to: '$(OUTDIR_BASE=/outdir-base && outdir_for_host "$HOST")' + ...bind-mounted in container to: '$(outdir_for_host "$HOST" "" /outdir-base)' ADDITIONAL FLAGS (if set) ADDITIONAL_GUIX_COMMON_FLAGS: ${ADDITIONAL_GUIX_COMMON_FLAGS} ADDITIONAL_GUIX_ENVIRONMENT_FLAGS: ${ADDITIONAL_GUIX_ENVIRONMENT_FLAGS} @@ -405,7 +404,7 @@ EOF # Please read the README.md in the same directory as this file for # more information. # - # shellcheck disable=SC2086,SC2031 + # shellcheck disable=SC2086 time-machine shell --manifest="${PWD}/contrib/guix/manifest_build.scm" \ --container \ --writable-root \ @@ -433,8 +432,8 @@ EOF ${SOURCES_PATH:+SOURCES_PATH="$SOURCES_PATH"} \ ${BASE_CACHE:+BASE_CACHE="$BASE_CACHE"} \ ${SDK_PATH:+SDK_PATH="$SDK_PATH"} \ - DISTSRC="$(DISTSRC_BASE=/distsrc-base && distsrc_for_host "$HOST")" \ - OUTDIR="$(OUTDIR_BASE=/outdir-base && outdir_for_host "$HOST")" \ + DISTSRC="$(distsrc_for_host "$HOST" "" /distsrc-base)" \ + OUTDIR="$(outdir_for_host "$HOST" "" /outdir-base)" \ DIST_ARCHIVE_BASE=/outdir-base/dist-archive \ bash -c "cd /bitcoin && bash contrib/guix/libexec/build.sh" ) diff --git a/contrib/guix/guix-codesign b/contrib/guix/guix-codesign index 1ceb65d6c4e..8cc6993b824 100755 --- a/contrib/guix/guix-codesign +++ b/contrib/guix/guix-codesign @@ -138,13 +138,18 @@ fi # Codesigning tarballs SHOULD exist ################ +# Usage: codesigning_tarball_for_host HOST [BASE] +# +# HOST: The current platform triple we're building for +# BASE: Optional. If provided, replaces ${OUTDIR_BASE} +# codesigning_tarball_for_host() { case "$1" in *mingw*) - echo "$(outdir_for_host "$1")/${DISTNAME}-win64-codesigning.tar.gz" + echo "$(outdir_for_host "$1" "" "$2")/${DISTNAME}-win64-codesigning.tar.gz" ;; *darwin*) - echo "$(outdir_for_host "$1")/${DISTNAME}-${1}-codesigning.tar.gz" + echo "$(outdir_for_host "$1" "" "$2")/${DISTNAME}-${1}-codesigning.tar.gz" ;; *) exit 1 @@ -249,16 +254,15 @@ for host in $HOSTS; do # for the particular $HOST we're building for export HOST="$host" - # shellcheck disable=SC2030 cat << EOF 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" codesigned)' - ...bind-mounted in container to: '$(DISTSRC_BASE=/distsrc-base && distsrc_for_host "$HOST" codesigned)' + ...bind-mounted in container to: '$(distsrc_for_host "$HOST" codesigned /distsrc-base)' ...outputting in: '$(outdir_for_host "$HOST" codesigned)' - ...bind-mounted in container to: '$(OUTDIR_BASE=/outdir-base && outdir_for_host "$HOST" codesigned)' + ...bind-mounted in container to: '$(outdir_for_host "$HOST" codesigned /outdir-base)' ...using detached signatures in: '${DETACHED_SIGS_REPO:?not set}' ...bind-mounted in container to: '/detached-sigs' EOF @@ -315,7 +319,7 @@ EOF # Please read the README.md in the same directory as this file for # more information. # - # shellcheck disable=SC2086,SC2031 + # shellcheck disable=SC2086 time-machine shell --manifest="${PWD}/contrib/guix/manifest_codesign.scm" \ --container \ --writable-root \ @@ -339,11 +343,11 @@ 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" codesigned)" \ - OUTDIR="$(OUTDIR_BASE=/outdir-base && outdir_for_host "$HOST" codesigned)" \ + DISTSRC="$(distsrc_for_host "$HOST" codesigned /distsrc-base)" \ + OUTDIR="$(outdir_for_host "$HOST" codesigned /outdir-base)" \ DIST_ARCHIVE_BASE=/outdir-base/dist-archive \ DETACHED_SIGS_REPO=/detached-sigs \ - CODESIGNING_TARBALL="$(OUTDIR_BASE=/outdir-base && codesigning_tarball_for_host "$HOST")" \ + CODESIGNING_TARBALL="$(codesigning_tarball_for_host "$HOST" /outdir-base)" \ bash -c "cd /bitcoin && bash contrib/guix/libexec/codesign.sh" ) diff --git a/contrib/guix/libexec/prelude.bash b/contrib/guix/libexec/prelude.bash index 21e668cf1f9..c89af17491f 100644 --- a/contrib/guix/libexec/prelude.bash +++ b/contrib/guix/libexec/prelude.bash @@ -80,22 +80,24 @@ time-machine() { -- "$@" } -# Usage: distsrc_for_host HOST [SUFFIX] +# Usage: distsrc_for_host HOST [SUFFIX] [BASE] # # HOST: The current platform triple we're building for # SUFFIX: Optional. If provided, appended to the directory name as "-SUFFIX" +# BASE: Optional. If provided, replaces ${DISTSRC_BASE} # distsrc_for_host() { - echo "${DISTSRC_BASE}/distsrc-${VERSION}-${1}${2:+-${2}}" + echo "${3:-${DISTSRC_BASE}}/distsrc-${VERSION}-${1}${2:+-${2}}" } -# Usage: outdir_for_host HOST [SUFFIX] +# Usage: outdir_for_host HOST [SUFFIX] [BASE] # # HOST: The current platform triple we're building for # SUFFIX: Optional. If provided, appended to the directory name as "-SUFFIX" +# BASE: Optional. If provided, replaces ${OUTDIR_BASE} # outdir_for_host() { - echo "${OUTDIR_BASE}/${1}${2:+-${2}}" + echo "${3:-${OUTDIR_BASE}}/${1}${2:+-${2}}" } # Usage: profiledir_for_host HOST [SUFFIX] From 53388773af78f8f1b8f3e705a5400cff6bee6de0 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Wed, 29 Apr 2026 11:46:42 +0100 Subject: [PATCH 7/7] guix: Remove redundant ShellCheck `source` directives --- contrib/guix/libexec/prelude.bash | 3 --- 1 file changed, 3 deletions(-) diff --git a/contrib/guix/libexec/prelude.bash b/contrib/guix/libexec/prelude.bash index c89af17491f..23852767897 100644 --- a/contrib/guix/libexec/prelude.bash +++ b/contrib/guix/libexec/prelude.bash @@ -2,10 +2,7 @@ export LC_ALL=C set -e -o pipefail -# shellcheck source=contrib/shell/realpath.bash source contrib/shell/realpath.bash - -# shellcheck source=contrib/shell/git-utils.bash source contrib/shell/git-utils.bash ################