Skip to content

Commit 77fb233

Browse files
committed
guix: codesign script
1 parent b3864b4 commit 77fb233

File tree

2 files changed

+18
-81
lines changed

2 files changed

+18
-81
lines changed

contrib/guix/guix-codesign

Lines changed: 16 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fi
9191
################
9292

9393
# Default to building for all supported HOSTs (overridable by environment)
94-
export HOSTS="${HOSTS:-x86_64-w64-mingw32 x86_64-apple-darwin arm64-apple-darwin}"
94+
export HOSTS="${HOSTS:-x86_64-w64-mingw32 x86_64-w64-mingw32.installer}"
9595

9696
# Usage: distsrc_for_host HOST
9797
#
@@ -149,13 +149,13 @@ outdir_for_host() {
149149
}
150150

151151

152-
unsigned_tarball_for_host() {
152+
unsigned_file_for_host() {
153153
case "$1" in
154-
*mingw*)
155-
echo "$(outdir_for_host "$1")/${DISTNAME}-win64-unsigned.tar.gz"
154+
*mingw.installer)
155+
echo "$(outdir_for_host "$1")/FeatherWalletSetup-${DISTNAME}-unsigned.exe"
156156
;;
157-
*darwin*)
158-
echo "$(outdir_for_host "$1")/${DISTNAME}-${1}-unsigned.tar.gz"
157+
*mingw*)
158+
echo "$(outdir_for_host "$1")/${DISTNAME}-unsigned.exe"
159159
;;
160160
*)
161161
exit 1
@@ -164,22 +164,22 @@ unsigned_tarball_for_host() {
164164
}
165165

166166
# Accumulate a list of build directories that already exist...
167-
hosts_unsigned_tarball_missing=""
167+
hosts_file_tarball_missing=""
168168
for host in $HOSTS; do
169-
if [ ! -e "$(unsigned_tarball_for_host "$host")" ]; then
170-
hosts_unsigned_tarball_missing+=" ${host}"
169+
if [ ! -e "$(unsigned_file_for_host "$host")" ]; then
170+
hosts_file_tarball_missing+=" ${host}"
171171
fi
172172
done
173173

174-
if [ -n "$hosts_unsigned_tarball_missing" ]; then
174+
if [ -n "$hosts_file_tarball_missing" ]; then
175175
# ...so that we can print them out nicely in an error message
176176
cat << EOF
177-
ERR: Unsigned tarballs do not exist
177+
ERR: Unsigned files do not exist
178178
...
179179
180180
EOF
181-
for host in $hosts_unsigned_tarball_missing; do
182-
echo " ${host} '$(unsigned_tarball_for_host "$host")'"
181+
for host in $hosts_file_tarball_missing; do
182+
echo " ${host} '$(unsigned_file_for_host "$host")'"
183183
done
184184
exit 1
185185
fi
@@ -256,7 +256,6 @@ output directory.
256256
EOF
257257
}
258258

259-
# Deterministically build Bitcoin Core
260259
# shellcheck disable=SC2153
261260
for host in $HOSTS; do
262261

@@ -282,66 +281,6 @@ INFO: Codesigning ${VERSION:?not set} for platform triple ${HOST:?not set}:
282281
...bind-mounted in container to: '/detached-sigs'
283282
EOF
284283

285-
286-
# Run the build script 'contrib/guix/libexec/build.sh' in the build
287-
# container specified by 'contrib/guix/manifest.scm'.
288-
#
289-
# Explanation of `guix shell` flags:
290-
#
291-
# --container run command within an isolated container
292-
#
293-
# Running in an isolated container minimizes build-time differences
294-
# between machines and improves reproducibility
295-
#
296-
# --pure unset existing environment variables
297-
#
298-
# Same rationale as --container
299-
#
300-
# --no-cwd do not share current working directory with an
301-
# isolated container
302-
#
303-
# When --container is specified, the default behavior is to share
304-
# the current working directory with the isolated container at the
305-
# same exact path (e.g. mapping '/home/satoshi/bitcoin/' to
306-
# '/home/satoshi/bitcoin/'). This means that the $PWD inside the
307-
# container becomes a source of irreproducibility. --no-cwd disables
308-
# this behaviour.
309-
#
310-
# --share=SPEC for containers, share writable host file system
311-
# according to SPEC
312-
#
313-
# --share="$PWD"=/bitcoin
314-
#
315-
# maps our current working directory to /bitcoin
316-
# inside the isolated container, which we later cd
317-
# into.
318-
#
319-
# While we don't want to map our current working directory to the
320-
# same exact path (as this introduces irreproducibility), we do want
321-
# it to be at a _fixed_ path _somewhere_ inside the isolated
322-
# container so that we have something to build. '/bitcoin' was
323-
# chosen arbitrarily.
324-
#
325-
# ${SOURCES_PATH:+--share="$SOURCES_PATH"}
326-
#
327-
# make the downloaded depends sources path available
328-
# inside the isolated container
329-
#
330-
# The isolated container has no network access as it's in a
331-
# different network namespace from the main machine, so we have to
332-
# make the downloaded depends sources available to it. The sources
333-
# should have been downloaded prior to this invocation.
334-
#
335-
# ${SUBSTITUTE_URLS:+--substitute-urls="$SUBSTITUTE_URLS"}
336-
#
337-
# fetch substitute from SUBSTITUTE_URLS if they are
338-
# authorized
339-
#
340-
# Depending on the user's security model, it may be desirable to use
341-
# substitutes (pre-built packages) from servers that the user trusts.
342-
# Please read the README.md in the same directory as this file for
343-
# more information.
344-
#
345284
# shellcheck disable=SC2086,SC2031
346285
time-machine shell --manifest="${PWD}/contrib/guix/manifest.scm" \
347286
--container \
@@ -358,11 +297,13 @@ EOF
358297
--keep-failed \
359298
--fallback \
360299
--link-profile \
300+
--user="user" \
361301
--root="$(profiledir_for_host "${HOST}" codesigned)" \
362302
${SUBSTITUTE_URLS:+--substitute-urls="$SUBSTITUTE_URLS"} \
363303
${ADDITIONAL_GUIX_COMMON_FLAGS} ${ADDITIONAL_GUIX_ENVIRONMENT_FLAGS} \
364304
-- env HOST="$host" \
365305
DISTNAME="$DISTNAME" \
306+
VERSION="$VERSION" \
366307
JOBS="$JOBS" \
367308
SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:?unable to determine value}" \
368309
${V:+V=1} \
@@ -371,7 +312,7 @@ EOF
371312
OUTDIR="$(OUTDIR_BASE=/outdir-base && outdir_for_host "$HOST" codesigned)" \
372313
DIST_ARCHIVE_BASE=/outdir-base/dist-archive \
373314
GUIX_SIGS_REPO=/detached-sigs \
374-
UNSIGNED_TARBALL="$(OUTDIR_BASE=/outdir-base && unsigned_tarball_for_host "$HOST")" \
315+
UNSIGNED_TARBALL="$(OUTDIR_BASE=/outdir-base && unsigned_file_for_host "$HOST")" \
375316
bash -c "cd /bitcoin && bash contrib/guix/libexec/codesign.sh"
376317
)
377318

contrib/guix/libexec/codesign.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Required environment variables as seen inside the container:
3131
DETACHED_SIGS_REPO: ${DETACHED_SIGS_REPO:?not set}
3232
DIST_ARCHIVE_BASE: ${DIST_ARCHIVE_BASE:?not set}
3333
DISTNAME: ${DISTNAME:?not set}
34+
VERSION: ${VERSION:?not set}
3435
HOST: ${HOST:?not set}
3536
SOURCE_DATE_EPOCH: ${SOURCE_DATE_EPOCH:?not set}
3637
DISTSRC: ${DISTSRC:?not set}
@@ -55,11 +56,6 @@ mkdir -p "$DISTSRC"
5556
(
5657
cd "$DISTSRC"
5758

58-
tar -xf "$UNSIGNED_TARBALL"
59-
60-
mkdir -p codesignatures
61-
tar -C codesignatures -xf "$CODESIGNATURE_GIT_ARCHIVE"
62-
6359
case "$HOST" in
6460
*mingw*)
6561
find "$PWD" -name "*-unsigned.exe" | while read -r infile; do
@@ -70,7 +66,7 @@ mkdir -p "$DISTSRC"
7066
-in "$infile" \
7167
-out "${OUTDIR}/${infile_base/-unsigned}" \
7268
-CAfile "$GUIX_ENVIRONMENT/etc/ssl/certs/ca-certificates.crt" \
73-
-sigin codesignatures/win/"$infile_base".pem
69+
-sigin /detached-sigs/codesignatures/"${VERSION}"/"$infile_base".pem
7470
done
7571
;;
7672
*)

0 commit comments

Comments
 (0)