From c12c954b2ee23df2fe586dc2f55067a1242f556a Mon Sep 17 00:00:00 2001 From: Pietro Abate Date: Wed, 7 Feb 2024 11:24:04 +0100 Subject: [PATCH] packages: add arm64 debian packages --- .../build-debian-packages-dependencies.sh | 37 +++++++++++++++---- .../jobs/packaging/build-debian-packages.sh | 13 ++++--- .../ci/jobs/packaging/debian_repository.yml | 14 ++++--- 3 files changed, 46 insertions(+), 18 deletions(-) diff --git a/.gitlab/ci/jobs/packaging/build-debian-packages-dependencies.sh b/.gitlab/ci/jobs/packaging/build-debian-packages-dependencies.sh index 203558907b0e..1945d80f7c2a 100755 --- a/.gitlab/ci/jobs/packaging/build-debian-packages-dependencies.sh +++ b/.gitlab/ci/jobs/packaging/build-debian-packages-dependencies.sh @@ -9,11 +9,11 @@ set -e # Determine platform based on runner's tags # This works with GCP. If switching to AWS these tags must be changed. case "$TAGS" in -gcp_arm64) +gcp_arm64 | gcp_dev_arm64) PLATFORM="linux/arm64" ARCHITECTURE="arm64" ;; -gcp) +gcp | gcp_dev) PLATFORM="linux/amd64" ARCHITECTURE="amd64" ;; @@ -23,6 +23,8 @@ gcp) ;; esac +LOCAL_IMAGE_NAME="$DEP_IMAGE:${ARCHITECTURE}-${CI_COMMIT_REF_SLUG}" + docker build \ --network host \ --platform $PLATFORM \ @@ -33,15 +35,34 @@ docker build \ --label "com.tezos.build-job-url"="${CI_JOB_URL}" \ --label "com.tezos.build-tezos-revision"="${CI_COMMIT_SHA}" \ --label "com.tezos.build-opam_repository_tag"="${opam_repository_tag}" \ - --cache-from="${DEP_IMAGE}:${ARCHITECTURE}" \ -f debian-deps-build.Dockerfile \ --build-arg=BUILDKIT_INLINE_CACHE=1 \ --build-arg IMAGE="$DISTRIBUTION:$RELEASE" \ - -t "$DEP_IMAGE:${ARCHITECTURE}" \ - -t "$DEP_IMAGE:latest" \ + --cache-from="${DEP_IMAGE}:${ARCHITECTURE}-${CI_COMMIT_REF_SLUG}" \ + --cache-from="${DEP_IMAGE}:master" \ + -t "$LOCAL_IMAGE_NAME" \ . -docker buildx imagetools create --append \ - -t "${DEP_IMAGE}:latest" "${DEP_IMAGE}:${ARCHITECTURE}" +LATEST_TAG="${CI_COMMIT_REF_SLUG}" + +echo "Checking for existance of image $DEP_IMAGE:$LATEST_TAG" +docker buildx imagetools inspect "$DEP_IMAGE:$LATEST_TAG" || export IMAGE_EXISTS="false" + +if [ "$IMAGE_EXISTS" = "false" ]; then + echo "Creating image manifesto for $DEP_IMAGE:$LATEST_TAG" + docker buildx imagetools create -t "$DEP_IMAGE:$LATEST_TAG" "$LOCAL_IMAGE_NAME" +else + echo "Appending to image manifesto for $DEP_IMAGE:$LATEST_TAG with new ${ARCHITECTURE} image" + + # we get the sha of the image of the "other" architecture + OTHER_SHA=$(docker manifest inspect "${DEP_IMAGE}:$LATEST_TAG" | jq -r ".manifests[] | select(.platform.architecture != \"$ARCHITECTURE\") | .digest" | head -n1) + + # we create a new manifest ( override the old one ) with both the + # local image and the image that was in the old manifest + docker buildx imagetools create \ + -t "${DEP_IMAGE}:$LATEST_TAG" \ + "$LOCAL_IMAGE_NAME" \ + "$DEP_IMAGE@$OTHER_SHA" +fi -docker buildx imagetools inspect "${DEP_IMAGE}:latest" +docker buildx imagetools inspect "${DEP_IMAGE}:${LATEST_TAG}" diff --git a/.gitlab/ci/jobs/packaging/build-debian-packages.sh b/.gitlab/ci/jobs/packaging/build-debian-packages.sh index 3b2ab3cc04c2..cff82f858179 100755 --- a/.gitlab/ci/jobs/packaging/build-debian-packages.sh +++ b/.gitlab/ci/jobs/packaging/build-debian-packages.sh @@ -11,10 +11,13 @@ if [ "$deps_opam_repository_tag" != "$opam_repository_tag" ]; then exit 1 fi +BUILDDIR=$(pwd) + # Prepare the building area: copying all files from -# the dependency image in the staging area and -# updating the source with the latest commits -cp -a /root/tezos/_opam /builds/tezos/tezos/ +# the dependency image a staging area. This is necessary +# to build on arm64 where the BUILDDIR is in ram. +cp -a ./* /root/tezos/ +cd /root/tezos/ # Build tezos as usual eval "$(opam env)" @@ -36,5 +39,5 @@ cd scripts/packaging/octez/ DEB_BUILD_OPTIONS=noautodbgsym dpkg-buildpackage -b --no-sign -sa # Move the debian package to be packed as artifacts -mkdir -p "/builds/tezos/tezos/packages/$DISTRIBUTION/$RELEASE" -mv ../*.deb "/builds/tezos/tezos/packages/$DISTRIBUTION/$RELEASE" +mkdir -p "$BUILDDIR/packages/$DISTRIBUTION/$RELEASE" +mv ../*.deb "$BUILDDIR/packages/$DISTRIBUTION/$RELEASE" diff --git a/.gitlab/ci/jobs/packaging/debian_repository.yml b/.gitlab/ci/jobs/packaging/debian_repository.yml index 6185c4f17015..be2853a81e77 100644 --- a/.gitlab/ci/jobs/packaging/debian_repository.yml +++ b/.gitlab/ci/jobs/packaging/debian_repository.yml @@ -32,7 +32,7 @@ oc.docker-build-debian-dependencies: parallel: matrix: - RELEASE: [unstable, bookworm] - TAGS: [gcp] + TAGS: [gcp, gcp_arm64] oc.docker-build-ubuntu-dependencies: extends: @@ -42,7 +42,7 @@ oc.docker-build-ubuntu-dependencies: parallel: matrix: - RELEASE: [focal, jammy] - TAGS: [gcp] + TAGS: [gcp, gcp_arm64] oc.build-debian-based-packages: stage: manual @@ -54,7 +54,7 @@ oc.build-debian-based-packages: .build-debian-packages: stage: manual needs: [oc.build-debian-based-packages] - image: $DEP_IMAGE:latest + image: $DEP_IMAGE:${CI_COMMIT_REF_SLUG} tags: - $TAGS artifacts: @@ -63,6 +63,10 @@ oc.build-debian-based-packages: script: - .gitlab/ci/jobs/packaging/build-debian-packages.sh +# Since we use parallel/matrix and we don't want to create +# false associations (i.e. debian:jammy). We have to create +# two different jobs for debian and ubuntu even if they +# share the same template. oc.build-debian: extends: - .build-debian-packages @@ -71,7 +75,7 @@ oc.build-debian: parallel: matrix: - RELEASE: [unstable, bookworm] - TAGS: [gcp] + TAGS: [gcp, gcp_arm64] oc.build-ubuntu: extends: @@ -81,4 +85,4 @@ oc.build-ubuntu: parallel: matrix: - RELEASE: [jammy, focal] - TAGS: [gcp] + TAGS: [gcp, gcp_arm64] -- GitLab