Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1#!/usr/bin/env bash2# Copyright (c) The Bitcoin Core developers3# Distributed under the MIT software license, see the accompanying4# file COPYING or https://opensource.org/license/mit.5export LC_ALL=C.UTF-86set -o errexit -o pipefail8# Environment variables for determinism9export TAR_OPTIONS="--owner=0 --group=0 --numeric-owner --mtime='@${SOURCE_DATE_EPOCH}' --sort=name"10export TZ=UTC12# Although Guix _does_ set umask when building its own packages (in our case,13# this is all packages in manifest.scm), it does not set it for `guix14# shell`. It does make sense for at least `guix shell --container`15# to set umask, so if that change gets merged upstream and we bump the16# time-machine to a commit which includes the aforementioned change, we can17# remove this line.18#19# This line should be placed before any commands which creates files.20umask 002222if [ -n "$V" ]; then23# Print both unexpanded (-v) and expanded (-x) forms of commands as they are24# read from this file.25set -vx26# Set VERBOSE for CMake-based builds27export VERBOSE="$V"28fi30# Check that required environment variables are set31cat << EOF32Required environment variables as seen inside the container:33CODESIGNING_TARBALL: ${CODESIGNING_TARBALL:?not set}34DETACHED_SIGS_REPO: ${DETACHED_SIGS_REPO:?not set}35DIST_ARCHIVE_BASE: ${DIST_ARCHIVE_BASE:?not set}36DISTNAME: ${DISTNAME:?not set}37HOST: ${HOST:?not set}38SOURCE_DATE_EPOCH: ${SOURCE_DATE_EPOCH:?not set}39DISTSRC: ${DISTSRC:?not set}40OUTDIR: ${OUTDIR:?not set}41EOF43ACTUAL_OUTDIR="${OUTDIR}"44OUTDIR="${DISTSRC}/output"46git_head_version() {47local recent_tag48if recent_tag="$(git -C "$1" describe --exact-match HEAD 2> /dev/null)"; then49echo "${recent_tag#v}"50else51git -C "$1" rev-parse --short=12 HEAD52fi53}55CODESIGNATURE_GIT_ARCHIVE="${DIST_ARCHIVE_BASE}/${DISTNAME}-codesignatures-$(git_head_version "$DETACHED_SIGS_REPO").tar.gz"57# Create the codesignature tarball if not already there58if [ ! -e "$CODESIGNATURE_GIT_ARCHIVE" ]; then59mkdir -p "$(dirname "$CODESIGNATURE_GIT_ARCHIVE")"60git -C "$DETACHED_SIGS_REPO" archive --output="$CODESIGNATURE_GIT_ARCHIVE" HEAD61fi63mkdir -p "$OUTDIR"65mkdir -p "$DISTSRC"66(67cd "$DISTSRC"69tar -xf "$CODESIGNING_TARBALL"71mkdir -p codesignatures72tar -C codesignatures -xf "$CODESIGNATURE_GIT_ARCHIVE"74case "$HOST" in75*mingw*)76# Apply detached codesignatures77WORKDIR=".tmp"78mkdir -p ${WORKDIR}79cp -r --target-directory="${WORKDIR}" "unsigned/${DISTNAME}"80find "${WORKDIR}/${DISTNAME}" -name "*.exe" -type f -exec rm {} \;81find unsigned/ -name "*.exe" -type f | while read -r bin82do83bin_base="$(realpath --relative-to=unsigned/ "${bin}")"84mkdir -p "${WORKDIR}/$(dirname "${bin_base}")"85osslsigncode attach-signature \86-in "${bin}" \87-out "${WORKDIR}/${bin_base/-unsigned}" \88-sigin codesignatures/win/"${bin_base}".pem89osslsigncode verify \90-CAfile "$GUIX_ENVIRONMENT/etc/ssl/certs/ca-certificates.crt" \91-TSA-CAfile "$GUIX_ENVIRONMENT/etc/ssl/certs/ca-certificates.crt" \92-ignore-crl \93-ignore-cdp \94-in "${WORKDIR}/${bin_base/-unsigned}"95done97# Move installer to outdir98cd "${WORKDIR}"99find . -name "*setup.exe" -print0 \100| xargs -0r mv --target-directory="${OUTDIR}"102# Make .zip from binaries103find "${DISTNAME}" -print0 \104| xargs -0r touch --no-dereference --date="@${SOURCE_DATE_EPOCH}"105find "${DISTNAME}" \106| sort \107| zip -X@ "${OUTDIR}/${DISTNAME}-${HOST//x86_64-w64-mingw32/win64}.zip" \108|| ( rm -f "${OUTDIR}/${DISTNAME}-${HOST//x86_64-w64-mingw32/win64}.zip" && exit 1 )109;;110*darwin*)111case "$HOST" in112arm64*) ARCH="arm64" ;;113x86_64*) ARCH="x86_64" ;;114esac116# Apply detached codesignatures (in-place)117signapple apply dist/Bitcoin-Qt.app codesignatures/osx/"${HOST}"/dist/Bitcoin-Qt.app118find "${DISTNAME}" \( -wholename "*/bin/*" -o -wholename "*/libexec/*" \) -type f | while read -r bin119do120signapple apply "${bin}" "codesignatures/osx/${HOST}/${bin}.${ARCH}sign"121done123# Make a .zip from dist/124cd dist/125find . -print0 \126| xargs -0r touch --no-dereference --date="@${SOURCE_DATE_EPOCH}"127find . | sort \128| zip -X@ "${OUTDIR}/${DISTNAME}-${HOST}.zip"129cd ..131# Make a .tar.gz from bins132find "${DISTNAME}" -print0 \133| sort --zero-terminated \134| tar --create --no-recursion --mode='u+rw,go+r-w,a+X' --null --files-from=- \135| gzip -9n > "${OUTDIR}/${DISTNAME}-${HOST}.tar.gz" \136|| ( rm -f "${OUTDIR}/${DISTNAME}-${HOST}.tar.gz" && exit 1 )137;;138*)139exit 1140;;141esac142) # $DISTSRC144rm -rf "$ACTUAL_OUTDIR"145mv --no-target-directory "$OUTDIR" "$ACTUAL_OUTDIR" \146|| ( rm -rf "$ACTUAL_OUTDIR" && exit 1 )148(149tmp="$(mktemp)"150cd /outdir-base151{152echo "$CODESIGNING_TARBALL"153echo "$CODESIGNATURE_GIT_ARCHIVE"154find "$ACTUAL_OUTDIR" -type f155} | xargs realpath --relative-base="$PWD" \156| xargs sha256sum \157| sort -k2 \158> "$tmp";159mv "$tmp" "$ACTUAL_OUTDIR"/SHA256SUMS.part160)
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.