From 28aa3f2d047067c63b328f35e4bbade017bbf6ec Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kittywhiskers@users.noreply.github.com> Date: Wed, 21 Jun 2023 06:45:46 +0000 Subject: [PATCH] contrib: create container for interactive guix builds --- contrib/guix/Dockerfile.local | 15 +++++++++++++++ contrib/guix/docker-compose.yml | 19 +++++++++++++++++++ contrib/guix/extras/entrypoint | 15 +++++++++++++++ contrib/guix/extras/guix-check | 17 +++++++++++++++++ contrib/guix/extras/guix-start | 15 +++++++++++++++ contrib/guix/extras/motd.txt | 4 ++++ 6 files changed, 85 insertions(+) create mode 100644 contrib/guix/Dockerfile.local create mode 100644 contrib/guix/docker-compose.yml create mode 100755 contrib/guix/extras/entrypoint create mode 100755 contrib/guix/extras/guix-check create mode 100755 contrib/guix/extras/guix-start create mode 100644 contrib/guix/extras/motd.txt diff --git a/contrib/guix/Dockerfile.local b/contrib/guix/Dockerfile.local new file mode 100644 index 0000000000000..a33e0f0fe7901 --- /dev/null +++ b/contrib/guix/Dockerfile.local @@ -0,0 +1,15 @@ +# syntax = edrevo/dockerfile-plus + +FROM alpine:3.17 + +INCLUDE+ Dockerfile.base + +ENV PATH /root/.local/bin:$PATH +RUN mkdir -p /root/.local/bin + +COPY ./extras/motd.txt /etc/motd +COPY ./extras/entrypoint /root/.local/bin/entrypoint +COPY ./extras/guix-check /root/.local/bin/guix-check +COPY ./extras/guix-start /root/.local/bin/guix-start + +ENTRYPOINT ["/root/.local/bin/entrypoint"] diff --git a/contrib/guix/docker-compose.yml b/contrib/guix/docker-compose.yml new file mode 100644 index 0000000000000..a44500edab8dd --- /dev/null +++ b/contrib/guix/docker-compose.yml @@ -0,0 +1,19 @@ +# Note: Using 'docker compose up' will leave you hanging, you need +# to use 'docker compose run guix-alpine' to drop into an +# interactive shell + +version: "3.9" +services: + guix-alpine: + network_mode: host + build: + context: '.' + dockerfile: './Dockerfile.local' + tty: true # Equivalent to -t + stdin_open: true # Equivalent to -i + privileged: true # Needed for Guix to run properly + volumes: + - "../..:/dash:rw" + - "guix-alpine-cache:/root/.cache/guix:rw" +volumes: + guix-alpine-cache: diff --git a/contrib/guix/extras/entrypoint b/contrib/guix/extras/entrypoint new file mode 100755 index 0000000000000..d0aac96710bad --- /dev/null +++ b/contrib/guix/extras/entrypoint @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +export LC_ALL=C +set -e -o pipefail + +# Read instructions +cat /etc/motd + +# Start the Guix daemon +/root/.config/guix/current/bin/guix-daemon \ + --build-users-group='guixbuild' \ + --substitute-urls='https://bordeaux.guix.gnu.org https://ci.guix.gnu.org' < /dev/null 2>&1 | + tee /var/log/guix.log > /dev/null & + +# Hand over control +exec bash diff --git a/contrib/guix/extras/guix-check b/contrib/guix/extras/guix-check new file mode 100755 index 0000000000000..643473bfdf35b --- /dev/null +++ b/contrib/guix/extras/guix-check @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +export LC_ALL=C +set -e -o pipefail + +cd /dash +COMMIT_ID=guix-build-$(git rev-parse --short=12 HEAD) + +printf "Binaries:\n" +( \ +SRC_PATH_PREFIX=guix-build-${COMMIT_ID}/distsrc- && \ +sha256sum ${SRC_PATH_PREFIX}*/src/dash{d,-cli,-tx,-wallet}{,.exe} && \ +sha256sum ${SRC_PATH_PREFIX}*/src/qt/dash-qt{,.exe} && \ +sha256sum ${SRC_PATH_PREFIX}*/src/test/test_dash{,.exe} \ +) | sort -k 2 + +printf "Archives:\n" +find guix-build-"${COMMIT_ID}"/output -type f | grep -v SHA256 | xargs sha256sum | sort -k 2 diff --git a/contrib/guix/extras/guix-start b/contrib/guix/extras/guix-start new file mode 100755 index 0000000000000..e58c896eace40 --- /dev/null +++ b/contrib/guix/extras/guix-start @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +export LC_ALL=C +set -e -o pipefail + +# Check if macOS SDK is present, if not, download it +if [ ! -d "/dash/depends/SDKs/Xcode-12.1-12A7403-extracted-SDK-with-libcxx-headers" ] +then + curl -L https://bitcoincore.org/depends-sources/sdks/Xcode-12.1-12A7403-extracted-SDK-with-libcxx-headers.tar.gz | tar -xz -C /dash/depends/SDKs +fi + +cd /dash +git status >> /dev/null +git config --global --add safe.directory /dash + +./contrib/guix/guix-build diff --git a/contrib/guix/extras/motd.txt b/contrib/guix/extras/motd.txt new file mode 100644 index 0000000000000..448da605920a1 --- /dev/null +++ b/contrib/guix/extras/motd.txt @@ -0,0 +1,4 @@ +##################################################### +To get started, run 'guix-start' and then calculate +hashes using 'guix-check' +#####################################################