diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ae521f655b..ad27984761 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -40,26 +40,11 @@ builder-image: needs: - builder-image image: $CI_REGISTRY_IMAGE:builder-$CI_COMMIT_REF_SLUG - variables: - SDK_URL: https://bitcoincore.org/depends-sources/sdks - XCODE_VERSION: "15.0" - XCODE_BUILD_ID: 15A240d before_script: - - echo HOST=$HOST - | - if [ "$HOST" = "x86_64-apple-darwin" ]; then - mkdir -p depends/SDKs - mkdir -p depends/sdk-sources - OSX_SDK_BASENAME="Xcode-${XCODE_VERSION}-${XCODE_BUILD_ID}-extracted-SDK-with-libcxx-headers.tar.gz" - OSX_SDK_PATH="depends/sdk-sources/${OSX_SDK_BASENAME}" - if [ ! -f "$OSX_SDK_PATH" ]; then - echo "Downloading MacOS SDK" - curl --location --fail "${SDK_URL}/${OSX_SDK_BASENAME}" -o "$OSX_SDK_PATH" - fi - if [ -f "$OSX_SDK_PATH" ]; then - echo "Extracting MacOS SDK" - tar -C depends/SDKs -xf "$OSX_SDK_PATH" - fi + echo HOST=${HOST} + if [[ "${HOST}" == "x86_64-apple-darwin" ]]; then + ./contrib/containers/guix/scripts/setup-sdk fi script: - make -j$(nproc) -C depends HOST=$HOST $DEP_OPTS diff --git a/ci/dash/build_depends.sh b/ci/dash/build_depends.sh index 6ad5803ae5..3f1ff978eb 100755 --- a/ci/dash/build_depends.sh +++ b/ci/dash/build_depends.sh @@ -20,17 +20,8 @@ mkdir -p $CACHE_DIR/sdk-sources ln -s $CACHE_DIR/depends ${DEPENDS_DIR}/built ln -s $CACHE_DIR/sdk-sources ${DEPENDS_DIR}/sdk-sources -mkdir -p ${DEPENDS_DIR}/SDKs - -if [ -n "$XCODE_VERSION" ]; then - OSX_SDK_BASENAME="Xcode-${XCODE_VERSION}-${XCODE_BUILD_ID}-extracted-SDK-with-libcxx-headers.tar.gz" - OSX_SDK_PATH="${DEPENDS_DIR}/sdk-sources/${OSX_SDK_BASENAME}" - if [ ! -f "$OSX_SDK_PATH" ]; then - curl --location --fail "${SDK_URL}/${OSX_SDK_BASENAME}" -o "$OSX_SDK_PATH" - fi - if [ -f "$OSX_SDK_PATH" ]; then - tar -C ${DEPENDS_DIR}/SDKs -xf "$OSX_SDK_PATH" - fi +if [[ "${HOST}" == "x86_64-apple-darwin" ]]; then + ./contrib/containers/guix/scripts/setup-sdk fi make $MAKEJOBS -C depends HOST=$HOST $DEP_OPTS diff --git a/contrib/containers/guix/Dockerfile b/contrib/containers/guix/Dockerfile index 9039147011..861678502c 100644 --- a/contrib/containers/guix/Dockerfile +++ b/contrib/containers/guix/Dockerfile @@ -77,18 +77,19 @@ RUN usermod -aG sudo ${USERNAME} && \ echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers # Copy required files to container -COPY --from=docker_root ./motd.txt /etc/motd -COPY --from=docker_root ./scripts/entrypoint /usr/local/bin/entrypoint -COPY --from=docker_root ./scripts/guix-check /usr/local/bin/guix-check -COPY --from=docker_root ./scripts/guix-start /usr/local/bin/guix-start +COPY --from=docker_root ./motd.txt /etc/motd +COPY --from=docker_root ./scripts/entrypoint /usr/local/bin/entrypoint +COPY --from=docker_root ./scripts/guix-check /usr/local/bin/guix-check +COPY --from=docker_root ./scripts/guix-start /usr/local/bin/guix-start +COPY --from=docker_root ./scripts/setup-sdk /usr/local/bin/setup-sdk # Create directories for mounting to save/restore cache and grant necessary permissions RUN mkdir -p \ /home/${USERNAME}/.cache \ - /src/dash/depends/{built,sources,work} && \ + /src/dash/depends/{built,sources,work}; \ chown -R ${USER_ID}:${GROUP_ID} \ /home/${USERNAME}/.cache \ - /src + /src; WORKDIR "/src/dash" diff --git a/contrib/containers/guix/scripts/guix-start b/contrib/containers/guix/scripts/guix-start index 4d0c6f6dba..50264c42d0 100755 --- a/contrib/containers/guix/scripts/guix-start +++ b/contrib/containers/guix/scripts/guix-start @@ -9,19 +9,10 @@ if [[ ! -d "${WORKSPACE_PATH}" || ! "${WORKSPACE_PATH}" = /* || ! -f "${WORKSPAC exit 1 fi -XCODE_VERSION="15.0" -XCODE_RELEASE="15A240d" -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}" +export SDK_SRCS="${SDK_PATH:-${WORKSPACE_PATH}/depends/sdk-sources}" -# 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 "${XCODE_SOURCE}/${XCODE_ARCHIVE}.tar.gz" | tar -xz -C "${SDK_PATH}" -fi +./contrib/containers/guix/scripts/setup-sdk # Add safe.directory option only when WORKSPACE_PATH was specified via cmd-line arguments (happens in CI) if [[ -n "${1}" ]]; then diff --git a/contrib/containers/guix/scripts/setup-sdk b/contrib/containers/guix/scripts/setup-sdk new file mode 100755 index 0000000000..4550aeed64 --- /dev/null +++ b/contrib/containers/guix/scripts/setup-sdk @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# Copyright (c) 2024 The Dash Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +export LC_ALL=C.UTF-8 + +set -eo pipefail + +SDK_URL="${SDK_URL:-https://bitcoincore.org/depends-sources/sdks}" +SDK_PATH="${SDK_PATH:-depends/SDKs}" +SDK_SRCS="${SDK_SOURCES:-depends/sdk-sources}" +XCODE_VERSION="${XCODE_VERSION:-15.0}" +XCODE_RELEASE="${XCODE_RELEASE:-15A240d}" +XCODE_ARCHIVE="Xcode-${XCODE_VERSION}-${XCODE_RELEASE}-extracted-SDK-with-libcxx-headers" +XCODE_AR_PATH="${SDK_SRCS}/${XCODE_ARCHIVE}.tar.gz" + +if [ ! -d "${SDK_PATH}/${XCODE_ARCHIVE}" ]; then + if [ ! -f "${XCODE_AR_PATH}" ]; then + echo "Downloading macOS SDK..." + mkdir -p "${SDK_SRCS}" + curl --location --fail "${SDK_URL}/${XCODE_ARCHIVE}.tar.gz" -o "${XCODE_AR_PATH}" + fi + echo "Extracting macOS SDK..." + mkdir -p "${SDK_PATH}" + tar -C "${SDK_PATH}" -xf "${XCODE_AR_PATH}" +fi