diff --git a/contrib/guix/README.md b/contrib/guix/README.md index f0ba490366aa4..177f01f8ebac2 100644 --- a/contrib/guix/README.md +++ b/contrib/guix/README.md @@ -22,6 +22,11 @@ Conservatively, you will need: If you don't have Guix installed and set up, please follow the instructions in [INSTALL.md](./INSTALL.md) +Additionally the `guix-build` script will build a docker compatible image +which require to install QEMU user static binary. + +On Debian you can install `qemu-user-static` package. + # Usage If you haven't considered your security model yet, please read [the relevant @@ -224,7 +229,7 @@ details. _(defaults to "x86\_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu riscv64-linux-gnu powerpc64-linux-gnu powerpc64le-linux-gnu - x86\_64-w64-mingw32 x86\_64-apple-darwin arm64-apple-darwin")_ + x86\_64-w64-mingw32 x86\_64-apple-darwin arm64-apple-darwin docker-x86\_64-linux docker-aarch64-linux")_ * _**SOURCES_PATH**_ diff --git a/contrib/guix/docker/bitcoin-knots.scm b/contrib/guix/docker/bitcoin-knots.scm new file mode 100644 index 0000000000000..edf9719f01556 --- /dev/null +++ b/contrib/guix/docker/bitcoin-knots.scm @@ -0,0 +1,73 @@ +(define-module (bitcoin-knots) + #:use-module ((guix licenses) #:prefix license:) + #:use-module (guix packages) + #:use-module (guix git-download) + #:use-module (guix build-system cmake) + #:use-module (guix gexp) + #:use-module (guix utils) + #:use-module (gnu packages) + #:use-module (gnu packages bash) + #:use-module (gnu packages base) + #:use-module (gnu packages boost) + #:use-module (gnu packages libevent) + #:use-module (gnu packages networking) + #:use-module (gnu packages pkg-config) + #:use-module (gnu packages python) + #:use-module (gnu packages python-xyz) + #:use-module (gnu packages sqlite)) + +(define-public bitcoin-knots + (package + (name "bitcoin-knots") + (version (getenv "VERSION")) + ; the source section is overrided by the guix-build script + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/bitcoinknots/bitcoin") + (commit (string-append "v" version)))) + ; We use a fake hash because this scheme isn't supposed + ; to be builded outside the guix-build scipt + (sha256 #f))) + (build-system cmake-build-system) + (arguments + (list #:configure-flags + #~(list + "-DBUILD_GUI=OFF" + "-DBUILD_TESTS=ON" + "-DWITH_ZMQ=ON") + #:phases + #~(modify-phases %standard-phases + (add-before 'build 'set-no-git-flag + (lambda _ + ;; Make it clear we are not building from within a git repository + ;; (and thus no information regarding this build is available + ;; from git). + (setenv "BITCOIN_GENBUILD_NO_GIT" "1"))) + (add-before 'check 'set-home + (lambda _ + ;; Tests write to $HOME. + (setenv "HOME" (getenv "TMPDIR"))))))) + (native-inputs + (list bash ; provides the sh command for system_tests + coreutils ; provides the cat, echo and false commands for system_tests + pkg-config + python ; for the tests + python-pyzmq ; for the tests + )) + (inputs + (list boost + libevent + sqlite + zeromq)) + (home-page "https://bitcoinknots.org/") + (synopsis "Bitcoin peer-to-peer client") + (description + "Bitcoin is a digital currency that enables instant payments to anyone +anywhere in the world. It uses peer-to-peer technology to operate without +central authority: managing transactions and issuing money are carried out +collectively by the network. This package provides the Bitcoin Knots command +line client.") + (license license:expat))) + +bitcoin-knots diff --git a/contrib/guix/docker/channels.scm b/contrib/guix/docker/channels.scm new file mode 100644 index 0000000000000..9dd5eace55a75 --- /dev/null +++ b/contrib/guix/docker/channels.scm @@ -0,0 +1,14 @@ +(define-module (channels)) +(use-modules (guix channels)) + +(list (channel + (name 'guix) + (url "https://git.savannah.gnu.org/git/guix.git") + (branch "master") + (commit + "8eed773a70afa696b3b67ca49ee67257b8a44b03") + (introduction + (make-channel-introduction + "9edb3f66fd807b096b48283debdcddccfea34bad" + (openpgp-fingerprint + "BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A 54FA"))))) diff --git a/contrib/guix/guix-build b/contrib/guix/guix-build index f955124d014ec..c68ea7acf6bf4 100755 --- a/contrib/guix/guix-build +++ b/contrib/guix/guix-build @@ -82,7 +82,8 @@ check_source_date_epoch # Default to building for all supported HOSTs (overridable by environment) export HOSTS="${HOSTS:-x86_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu riscv64-linux-gnu powerpc64-linux-gnu powerpc64le-linux-gnu x86_64-w64-mingw32 - x86_64-apple-darwin arm64-apple-darwin}" + x86_64-apple-darwin arm64-apple-darwin + docker-x86_64-linux docker-aarch64-linux}" # Usage: distsrc_for_host HOST # @@ -301,6 +302,12 @@ mkdir -p "$OUTDIR_BASE" # Download the depends sources now as we won't have internet access in the build # container for host in $HOSTS; do + case "$host" in + docker*) + # No need to download depends sources for docker builds + continue + ;; + esac make -C "${PWD}/depends" -j"$JOBS" download-"$(host_to_commonname "$host")" ${V:+V=1} ${SOURCES_PATH:+SOURCES_PATH="$SOURCES_PATH"} done @@ -352,6 +359,33 @@ for host in $HOSTS; do # Display proper warning when the user interrupts the build trap 'int_trap ${host}' INT + if [[ "$host" == docker* ]]; then + mkdir -p "$OUTDIR_BASE/docker" + fi + + case "$host" in + docker*) + echo "Building docker image for ${host#docker-}" + dockerpath=$(VERSION="${VERSION}" \ + guix time-machine -C ${PWD}/contrib/guix/docker/channels.scm -- \ + pack -L "${PWD}"/contrib/guix/docker \ + -f docker \ + --system=${host#docker-} \ + --entry-point=bin/bitcoind \ + --with-git-url=bitcoin-knots=file://"${PWD}" \ + bitcoin-knots \ + | tee /dev/tty | tail -n1) + if [ ! -z "$dockerpath" ]; then + cp "$dockerpath" "$OUTDIR_BASE/docker/${DISTNAME}-${host}.tar.gz" + chmod 644 "$OUTDIR_BASE/docker/${DISTNAME}-${host}.tar.gz" + sha256sum "$OUTDIR_BASE/docker/${DISTNAME}-${host}.tar.gz" >> "$OUTDIR_BASE/docker/SHA256SUMS.part" + else + echo "Failed to build docker image for ${host#docker-}, exiting..." + exit 1 + fi + continue + ;; + *) ( # Required for 'contrib/guix/manifest.scm' to output the right manifest # for the particular $HOST we're building for @@ -471,5 +505,6 @@ EOF DIST_ARCHIVE_BASE=/outdir-base/dist-archive \ bash -c "cd /bitcoin && bash contrib/guix/libexec/build.sh" ) - + ;; + esac done