guix, refactor: Move duplicated `profiledir_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 removes two identical copies of a helper function and places a single shared copy in a common file. The function itself only builds a directory path string and does not change behavior. There is no security issue here.
No security action needed. Treat as routine maintenance/refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors profiledir_for_host() out of contrib/guix/guix-build and contrib/guix/guix-codesign into contrib/guix/libexec/prelude.bash. The function signature and implementation remain effectively identical: it echoes ${PROFILES_BASE}/${1}${2:+-${2}}. This is a pure DRY (don’t-repeat-yourself) refactor with no functional or security impact.
Changed components
contrib/guix/guix-buildcontrib/guix/guix-codesigncontrib/guix/libexec/prelude.bashInspect captured patch +9 / −16
diff --git a/contrib/guix/guix-build b/contrib/guix/guix-build
index 9c78c2a2..a02c3603 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 230499c0..f985fd4c 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 fbebd2a1..c13f24c5 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
################
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.