guix, refactor: Remove `contains()` function
What changed, and why it matters
This commit is a small code cleanup in the Bitcoin Core Guix build script. It removes a custom helper function called contains() and replaces it with a simpler approach using two separate lists of directory names. There is no security issue here; it is purely a refactoring change to make the build script easier to read and maintain.
No security action needed. Treat as a normal refactoring review.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors contrib/guix/guix-build. It deletes the contains() shell function and the combined precious_dir_names loop logic. Instead, it splits directory names into depends_precious_dir_names and base_dir_names, then iterates only over base_dir_names when writing remaining precious directory definitions. The functional behavior is preserved: the same set of precious directories is ultimately handled, just without the membership check. No security-sensitive behavior is introduced or removed.
Changed components
contrib/guix/guix-buildInspect captured patch +5 / −16
diff --git a/contrib/guix/guix-build b/contrib/guix/guix-build
index 767ea920..ac788840 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"
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.