guix, refactor: Move `distsrc_for_host()` to `prelude.bash`
What changed, and why it matters
This commit is a simple code cleanup in Bitcoin Core's Guix build scripts. It moves a helper function that builds directory paths from two separate scripts into a shared library file, and adds an optional suffix parameter so both scripts can use the same function. There is no change to how Bitcoin works, no security fix, and no vulnerability.
No security action required. Treat as a normal build-system refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors distsrc_for_host() from contrib/guix/guix-build and contrib/guix/guix-codesign into contrib/guix/libexec/prelude.bash. The function now accepts an optional SUFFIX argument, replacing the previous hardcoded -codesigned variant in guix-codesign. All call sites are updated to pass the appropriate suffix. The resulting directory paths remain semantically identical: ${DISTSRC_BASE}/distsrc-${VERSION}-${1}${2:+-${2}} produces the same output as the previous implementations for both the plain and codesigned cases.
Changed components
contrib/guix/guix-buildcontrib/guix/guix-codesigncontrib/guix/libexec/prelude.bashInspect captured patch +14 / −21
diff --git a/contrib/guix/guix-build b/contrib/guix/guix-build
index a02c3603..eed9d459 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 f985fd4c..1ceb65d6 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 c13f24c5..21e668cf 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
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.