From ee5f62b0dbe1eddbab0af816b1a44f8cf1187375 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sun, 10 Nov 2024 20:51:29 +0000 Subject: [PATCH 1/9] guix: build only supported targets using Guix container --- contrib/containers/guix/scripts/guix-start | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contrib/containers/guix/scripts/guix-start b/contrib/containers/guix/scripts/guix-start index a32c4f71e1381..e8f24d29c56db 100755 --- a/contrib/containers/guix/scripts/guix-start +++ b/contrib/containers/guix/scripts/guix-start @@ -28,4 +28,8 @@ cd "${WORKSPACE_PATH}" git config --global --add safe.directory "${WORKSPACE_PATH}" git status >> /dev/null +export HOSTS="${HOSTS:-x86_64-linux-gnu aarch64-linux-gnu riscv64-linux-gnu + x86_64-w64-mingw32 + x86_64-apple-darwin arm64-apple-darwin}" + ./contrib/guix/guix-build From 87c978605eaa7038567a3bad093cbb2614da857f Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Mon, 11 Nov 2024 13:33:32 +0300 Subject: [PATCH 2/9] guix: `guix-start` should respect `SDK_PATH` --- contrib/containers/guix/scripts/guix-start | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/contrib/containers/guix/scripts/guix-start b/contrib/containers/guix/scripts/guix-start index e8f24d29c56db..dea0e6c96ddaf 100755 --- a/contrib/containers/guix/scripts/guix-start +++ b/contrib/containers/guix/scripts/guix-start @@ -17,11 +17,12 @@ XCODE_VERSION="12.2" XCODE_RELEASE="12B45b" XCODE_ARCHIVE="Xcode-${XCODE_VERSION}-${XCODE_RELEASE}-extracted-SDK-with-libcxx-headers" +export SDK_PATH="${SDK_PATH:-${WORKSPACE_PATH}/depends/SDKs}" + # Check if macOS SDK is present, if not, download it -if [ ! -d "${WORKSPACE_PATH}/depends/SDKs/${XCODE_ARCHIVE}" ] -then - mkdir -p "${WORKSPACE_PATH}/depends/SDKs" - curl -L https://bitcoincore.org/depends-sources/sdks/${XCODE_ARCHIVE}.tar.gz | tar -xz -C "${WORKSPACE_PATH}/depends/SDKs" +if [[ ! -d "${SDK_PATH}/${XCODE_ARCHIVE}" ]]; then + mkdir -p "${SDK_PATH}" + curl -L https://bitcoincore.org/depends-sources/sdks/${XCODE_ARCHIVE}.tar.gz | tar -xz -C "${SDK_PATH}" fi cd "${WORKSPACE_PATH}" From 187a4f1a0cfdb3b9dc0cdb10f5638aa89b0ce41f Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Tue, 12 Nov 2024 15:13:31 +0300 Subject: [PATCH 3/9] guix: Avoid adding duplicate `safe.directory` option --- contrib/containers/guix/scripts/guix-start | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/contrib/containers/guix/scripts/guix-start b/contrib/containers/guix/scripts/guix-start index dea0e6c96ddaf..df8f559deb58d 100755 --- a/contrib/containers/guix/scripts/guix-start +++ b/contrib/containers/guix/scripts/guix-start @@ -25,8 +25,10 @@ if [[ ! -d "${SDK_PATH}/${XCODE_ARCHIVE}" ]]; then curl -L https://bitcoincore.org/depends-sources/sdks/${XCODE_ARCHIVE}.tar.gz | tar -xz -C "${SDK_PATH}" fi +# Avoid adding duplicate safe.directory option +git config --global --fixed-value --get safe.directory "${WORKSPACE_PATH}" || git config --global --add safe.directory "${WORKSPACE_PATH}" + cd "${WORKSPACE_PATH}" -git config --global --add safe.directory "${WORKSPACE_PATH}" git status >> /dev/null export HOSTS="${HOSTS:-x86_64-linux-gnu aarch64-linux-gnu riscv64-linux-gnu From 3ac5739e383efd2ac642a9546487778c20d05e37 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Tue, 12 Nov 2024 15:13:51 +0300 Subject: [PATCH 4/9] guix: "Invert" `guix-start`/`guix-check` cmd-line argument behaviour, defaults to `pwd` --- .github/workflows/guix-build.yml | 2 +- contrib/containers/guix/scripts/guix-check | 6 +----- contrib/containers/guix/scripts/guix-start | 13 ++++++------- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/.github/workflows/guix-build.yml b/.github/workflows/guix-build.yml index 49d18bc292bc5..1ad6101e3a83c 100644 --- a/.github/workflows/guix-build.yml +++ b/.github/workflows/guix-build.yml @@ -114,7 +114,7 @@ jobs: -v ${{ github.workspace }}/.cache:/home/ubuntu/.cache \ -w /src/dash \ ghcr.io/${{ needs.build-image.outputs.repo-name }}/dashcore-guix-builder:${{ needs.build-image.outputs.image-tag }} && \ - docker exec guix-daemon bash -c 'HOSTS=${{ matrix.build_target }} /usr/local/bin/guix-start' + docker exec guix-daemon bash -c 'HOSTS=${{ matrix.build_target }} /usr/local/bin/guix-start /src/dash' - name: Ensure build passes run: | diff --git a/contrib/containers/guix/scripts/guix-check b/contrib/containers/guix/scripts/guix-check index 7111f63c5b02a..e294beb8f6e94 100755 --- a/contrib/containers/guix/scripts/guix-check +++ b/contrib/containers/guix/scripts/guix-check @@ -2,11 +2,7 @@ set -eo pipefail -if [[ -n "${1}" ]]; then - WORKSPACE_PATH="$1" -else - WORKSPACE_PATH="/src/dash" -fi +WORKSPACE_PATH="${1:-$(pwd)}" if [[ ! -d "$WORKSPACE_PATH" ]]; then echo "$0: $WORKSPACE_PATH is not a valid directory, exiting!" diff --git a/contrib/containers/guix/scripts/guix-start b/contrib/containers/guix/scripts/guix-start index df8f559deb58d..ac2b4cbe5756d 100755 --- a/contrib/containers/guix/scripts/guix-start +++ b/contrib/containers/guix/scripts/guix-start @@ -2,11 +2,7 @@ set -eo pipefail -if [[ -n "${1}" ]]; then - WORKSPACE_PATH="$1" -else - WORKSPACE_PATH="/src/dash" -fi +WORKSPACE_PATH="${1:-$(pwd)}" if [[ ! -d "$WORKSPACE_PATH" ]]; then echo "$0: $WORKSPACE_PATH is not a valid directory, exiting!" @@ -25,8 +21,11 @@ if [[ ! -d "${SDK_PATH}/${XCODE_ARCHIVE}" ]]; then curl -L https://bitcoincore.org/depends-sources/sdks/${XCODE_ARCHIVE}.tar.gz | tar -xz -C "${SDK_PATH}" fi -# Avoid adding duplicate safe.directory option -git config --global --fixed-value --get safe.directory "${WORKSPACE_PATH}" || git config --global --add safe.directory "${WORKSPACE_PATH}" +# Add safe.directory option only when WORKSPACE_PATH was specified via cmd-line arguments (happens in CI) +if [[ -n "${1}" ]]; then + # Avoid adding duplicates + git config --global --fixed-value --get safe.directory "${WORKSPACE_PATH}" || git config --global --add safe.directory "${WORKSPACE_PATH}" +fi cd "${WORKSPACE_PATH}" git status >> /dev/null From 74489dc82d30728a6b708cfc23c6efa25d276296 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Tue, 12 Nov 2024 15:28:55 +0300 Subject: [PATCH 5/9] chore: Log when preparing macOS SDK or adding `safe.directory` option --- contrib/containers/guix/scripts/guix-start | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/contrib/containers/guix/scripts/guix-start b/contrib/containers/guix/scripts/guix-start index ac2b4cbe5756d..f36674427d5ea 100755 --- a/contrib/containers/guix/scripts/guix-start +++ b/contrib/containers/guix/scripts/guix-start @@ -17,6 +17,7 @@ export SDK_PATH="${SDK_PATH:-${WORKSPACE_PATH}/depends/SDKs}" # Check if macOS SDK is present, if not, download it if [[ ! -d "${SDK_PATH}/${XCODE_ARCHIVE}" ]]; then + echo "Preparing macOS SDK..." mkdir -p "${SDK_PATH}" curl -L https://bitcoincore.org/depends-sources/sdks/${XCODE_ARCHIVE}.tar.gz | tar -xz -C "${SDK_PATH}" fi @@ -24,7 +25,8 @@ fi # Add safe.directory option only when WORKSPACE_PATH was specified via cmd-line arguments (happens in CI) if [[ -n "${1}" ]]; then # Avoid adding duplicates - git config --global --fixed-value --get safe.directory "${WORKSPACE_PATH}" || git config --global --add safe.directory "${WORKSPACE_PATH}" + git config --global --fixed-value --get safe.directory "${WORKSPACE_PATH}" || \ + (echo "Adding safe.directory" && git config --global --add safe.directory "${WORKSPACE_PATH}") fi cd "${WORKSPACE_PATH}" From 07f056a377d3ff319b420abd47f134941f9cafa8 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Tue, 12 Nov 2024 16:16:20 +0300 Subject: [PATCH 6/9] guix: Let `XCODE_SOURCE` be specified via env --- contrib/containers/guix/scripts/guix-start | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/containers/guix/scripts/guix-start b/contrib/containers/guix/scripts/guix-start index f36674427d5ea..1b5e75b5e77d9 100755 --- a/contrib/containers/guix/scripts/guix-start +++ b/contrib/containers/guix/scripts/guix-start @@ -12,6 +12,7 @@ fi XCODE_VERSION="12.2" XCODE_RELEASE="12B45b" XCODE_ARCHIVE="Xcode-${XCODE_VERSION}-${XCODE_RELEASE}-extracted-SDK-with-libcxx-headers" +XCODE_SOURCE="${XCODE_SOURCE:-https://bitcoincore.org/depends-sources/sdks}" export SDK_PATH="${SDK_PATH:-${WORKSPACE_PATH}/depends/SDKs}" @@ -19,7 +20,7 @@ export SDK_PATH="${SDK_PATH:-${WORKSPACE_PATH}/depends/SDKs}" if [[ ! -d "${SDK_PATH}/${XCODE_ARCHIVE}" ]]; then echo "Preparing macOS SDK..." mkdir -p "${SDK_PATH}" - curl -L https://bitcoincore.org/depends-sources/sdks/${XCODE_ARCHIVE}.tar.gz | tar -xz -C "${SDK_PATH}" + curl -L "${XCODE_SOURCE}/${XCODE_ARCHIVE}.tar.gz" | tar -xz -C "${SDK_PATH}" fi # Add safe.directory option only when WORKSPACE_PATH was specified via cmd-line arguments (happens in CI) From f4d879a0b3863c62f1c5a6773c9bea881839d17c Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Tue, 12 Nov 2024 16:33:04 +0300 Subject: [PATCH 7/9] guix: more sanity checks for `WORKSPACE_PATH` --- contrib/containers/guix/scripts/guix-check | 4 ++-- contrib/containers/guix/scripts/guix-start | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/containers/guix/scripts/guix-check b/contrib/containers/guix/scripts/guix-check index e294beb8f6e94..4958c1bb36477 100755 --- a/contrib/containers/guix/scripts/guix-check +++ b/contrib/containers/guix/scripts/guix-check @@ -4,8 +4,8 @@ set -eo pipefail WORKSPACE_PATH="${1:-$(pwd)}" -if [[ ! -d "$WORKSPACE_PATH" ]]; then - echo "$0: $WORKSPACE_PATH is not a valid directory, exiting!" +if [[ ! -d "${WORKSPACE_PATH}" || ! "${WORKSPACE_PATH}" = /* || ! -f "${WORKSPACE_PATH}/contrib/guix/libexec/prelude.bash" ]]; then + echo "${0}: ${WORKSPACE_PATH} is not a valid directory, exiting!" exit 1 fi diff --git a/contrib/containers/guix/scripts/guix-start b/contrib/containers/guix/scripts/guix-start index 1b5e75b5e77d9..42238e1d67282 100755 --- a/contrib/containers/guix/scripts/guix-start +++ b/contrib/containers/guix/scripts/guix-start @@ -4,8 +4,8 @@ set -eo pipefail WORKSPACE_PATH="${1:-$(pwd)}" -if [[ ! -d "$WORKSPACE_PATH" ]]; then - echo "$0: $WORKSPACE_PATH is not a valid directory, exiting!" +if [[ ! -d "${WORKSPACE_PATH}" || ! "${WORKSPACE_PATH}" = /* || ! -f "${WORKSPACE_PATH}/contrib/guix/guix-build" ]]; then + echo "${0}: ${WORKSPACE_PATH} is not a valid directory, exiting!" exit 1 fi From 8ce9bfea5999f3a12fdca2a69af07e9be98b7178 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Wed, 13 Nov 2024 21:09:03 +0300 Subject: [PATCH 8/9] chore: tweak error message --- contrib/containers/guix/scripts/guix-check | 2 +- contrib/containers/guix/scripts/guix-start | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/containers/guix/scripts/guix-check b/contrib/containers/guix/scripts/guix-check index 4958c1bb36477..12c9983753e21 100755 --- a/contrib/containers/guix/scripts/guix-check +++ b/contrib/containers/guix/scripts/guix-check @@ -5,7 +5,7 @@ set -eo pipefail WORKSPACE_PATH="${1:-$(pwd)}" if [[ ! -d "${WORKSPACE_PATH}" || ! "${WORKSPACE_PATH}" = /* || ! -f "${WORKSPACE_PATH}/contrib/guix/libexec/prelude.bash" ]]; then - echo "${0}: ${WORKSPACE_PATH} is not a valid directory, exiting!" + echo "${0##*/}: ${WORKSPACE_PATH} is not the top directory of the Dash Core repository, exiting!" exit 1 fi diff --git a/contrib/containers/guix/scripts/guix-start b/contrib/containers/guix/scripts/guix-start index 42238e1d67282..2d71193052dbb 100755 --- a/contrib/containers/guix/scripts/guix-start +++ b/contrib/containers/guix/scripts/guix-start @@ -5,7 +5,7 @@ set -eo pipefail WORKSPACE_PATH="${1:-$(pwd)}" if [[ ! -d "${WORKSPACE_PATH}" || ! "${WORKSPACE_PATH}" = /* || ! -f "${WORKSPACE_PATH}/contrib/guix/guix-build" ]]; then - echo "${0}: ${WORKSPACE_PATH} is not a valid directory, exiting!" + echo "${0##*/}: ${WORKSPACE_PATH} is not the top directory of the Dash Core repository, exiting!" exit 1 fi From c5d482e0d28d51eaa5fababdf85771dba113c380 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Wed, 13 Nov 2024 21:17:31 +0300 Subject: [PATCH 9/9] chore: suppress `git config` output --- contrib/containers/guix/scripts/guix-start | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/containers/guix/scripts/guix-start b/contrib/containers/guix/scripts/guix-start index 2d71193052dbb..415043f820d68 100755 --- a/contrib/containers/guix/scripts/guix-start +++ b/contrib/containers/guix/scripts/guix-start @@ -26,7 +26,7 @@ fi # Add safe.directory option only when WORKSPACE_PATH was specified via cmd-line arguments (happens in CI) if [[ -n "${1}" ]]; then # Avoid adding duplicates - git config --global --fixed-value --get safe.directory "${WORKSPACE_PATH}" || \ + git config --global --fixed-value --get safe.directory "${WORKSPACE_PATH}" >> /dev/null || \ (echo "Adding safe.directory" && git config --global --add safe.directory "${WORKSPACE_PATH}") fi