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 pipefail8source contrib/shell/realpath.bash9source contrib/shell/git-utils.bash11################12# Required non-builtin commands should be invocable13################15check_tools() {16for cmd in "$@"; do17if ! command -v "$cmd" > /dev/null 2>&1; then18echo "ERR: This script requires that '$cmd' is installed and available in your \$PATH"19exit 120fi21done22}24################25# SOURCE_DATE_EPOCH should not unintentionally be set26################28check_source_date_epoch() {29if [ -n "$SOURCE_DATE_EPOCH" ] && [ -z "$FORCE_SOURCE_DATE_EPOCH" ]; then30cat << EOF31ERR: Environment variable SOURCE_DATE_EPOCH is set which may break reproducibility.33Aborting...35Hint: You may want to:361. Unset this variable: \`unset SOURCE_DATE_EPOCH\` before rebuilding372. Set the 'FORCE_SOURCE_DATE_EPOCH' environment variable if you insist on38using your own epoch39EOF40exit 141fi42}44check_tools cat env readlink dirname basename git46################47# We should be at the top directory of the repository48################50same_dir() {51local resolved1 resolved252resolved1="$(bash_realpath "${1}")"53resolved2="$(bash_realpath "${2}")"54[ "$resolved1" = "$resolved2" ]55}57if ! same_dir "${PWD}" "$(git_root)"; then58cat << EOF59ERR: This script must be invoked from the top level of the git repository61Hint: This may look something like:62env FOO=BAR ./contrib/guix/guix-<blah>64EOF65exit 166fi68################69# Execute "$@" in a pinned, possibly older version of Guix, for reproducibility70# across time.71time-machine() {72# shellcheck disable=SC208673guix time-machine --url=https://codeberg.org/guix/guix.git \74--commit=c5eee3336cc1d10a3cc1c97fde2809c3451624d3 \75--cores="$JOBS" \76--keep-failed \77--fallback \78${SUBSTITUTE_URLS:+--substitute-urls="$SUBSTITUTE_URLS"} \79${ADDITIONAL_GUIX_COMMON_FLAGS} ${ADDITIONAL_GUIX_TIMEMACHINE_FLAGS} \80-- "$@"81}83# Usage: distsrc_for_host HOST [SUFFIX] [BASE]84#85# HOST: The current platform triple we're building for86# SUFFIX: Optional. If provided, appended to the directory name as "-SUFFIX"87# BASE: Optional. If provided, replaces ${DISTSRC_BASE}88#89distsrc_for_host() {90echo "${3:-${DISTSRC_BASE}}/distsrc-${VERSION}-${1}${2:+-${2}}"91}93# Usage: outdir_for_host HOST [SUFFIX] [BASE]94#95# HOST: The current platform triple we're building for96# SUFFIX: Optional. If provided, appended to the directory name as "-SUFFIX"97# BASE: Optional. If provided, replaces ${OUTDIR_BASE}98#99outdir_for_host() {100echo "${3:-${OUTDIR_BASE}}/${1}${2:+-${2}}"101}103# Usage: profiledir_for_host HOST [SUFFIX]104#105# HOST: The current platform triple we're building for106# SUFFIX: Optional. If provided, appended to the directory name as "-SUFFIX"107#108profiledir_for_host() {109echo "${PROFILES_BASE}/${1}${2:+-${2}}"110}112################113# Set common variables114################116VERSION="${FORCE_VERSION:-$(git_head_version)}"117DISTNAME="${DISTNAME:-bitcoin-${VERSION}}"119version_base_prefix="${PWD}/guix-build-"120VERSION_BASE="${version_base_prefix}${VERSION}" # TOP122DISTSRC_BASE="${DISTSRC_BASE:-${VERSION_BASE}}"124OUTDIR_BASE="${OUTDIR_BASE:-${VERSION_BASE}/output}"126var_base_basename="var"127VAR_BASE="${VAR_BASE:-${VERSION_BASE}/${var_base_basename}}"129profiles_base_basename="profiles"130PROFILES_BASE="${PROFILES_BASE:-${VAR_BASE}/${profiles_base_basename}}"
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.