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.
This commit is contained in:
Hennadii Stepanov
2026-04-29 11:30:43 +01:00
parent cab65ea9c6
commit 5d46429e32
3 changed files with 14 additions and 21 deletions

View File

@@ -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

View File

@@ -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 \

View File

@@ -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