Skip to content

Commit

Permalink
Merge pull request #4406 from esl/ci-build-packages-for-arm64
Browse files Browse the repository at this point in the history
Add building `arm64` packages to CI pipeline
  • Loading branch information
chrzaszcz authored Dec 6, 2024
2 parents ae7aad7 + 431357e commit cfc7187
Show file tree
Hide file tree
Showing 5 changed files with 149 additions and 9 deletions.
71 changes: 71 additions & 0 deletions .circleci/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,11 @@ jobs:
name: Build package
command: |
./tools/test.sh -p pkg -s false
- run:
name: Verify package architecture
command: |
./tools/circle-install-packages.sh rpm
./tools/pkg/verify_arch.sh
- when:
condition:
matches:
Expand Down Expand Up @@ -749,66 +754,132 @@ workflows:
platform: debian-bookworm
context: mongooseim-org
filters: *all_tags_and_master
- package:
name: debian-bookworm-arm64
executor: otp_27_arm64
platform: debian-bookworm
context: mongooseim-org
filters: *all_tags_and_master
- package:
name: debian-bullseye
executor: otp_27
platform: debian-bullseye
context: mongooseim-org
filters: *all_tags_and_master
- package:
name: debian-bullseye-arm64
executor: otp_27_arm64
platform: debian-bullseye
context: mongooseim-org
filters: *all_tags_and_master
- package:
name: debian-buster
executor: otp_27
platform: debian-buster
context: mongooseim-org
filters: *all_tags_and_master
- package:
name: debian-buster-arm64
executor: otp_27_arm64
platform: debian-buster
context: mongooseim-org
filters: *all_tags_and_master
- package:
name: ubuntu-oracular
executor: otp_27
platform: ubuntu-oracular
context: mongooseim-org
filters: *all_tags_and_master
- package:
name: ubuntu-oracular-arm64
executor: otp_27_arm64
platform: ubuntu-oracular
context: mongooseim-org
filters: *all_tags_and_master
- package:
name: ubuntu-noble
executor: otp_27
platform: ubuntu-noble
context: mongooseim-org
filters: *all_tags_and_master
- package:
name: ubuntu-noble-arm64
executor: otp_27_arm64
platform: ubuntu-noble
context: mongooseim-org
filters: *all_tags_and_master
- package:
name: ubuntu-jammy
executor: otp_27
platform: ubuntu-jammy
context: mongooseim-org
filters: *all_tags_and_master
- package:
name: ubuntu-jammy-arm64
executor: otp_27_arm64
platform: ubuntu-jammy
context: mongooseim-org
filters: *all_tags_and_master
- package:
name: ubuntu-focal
executor: otp_27
platform: ubuntu-focal
context: mongooseim-org
filters: *all_tags_and_master
- package:
name: ubuntu-focal-arm64
executor: otp_27_arm64
platform: ubuntu-focal
context: mongooseim-org
filters: *all_tags_and_master
- package:
name: rockylinux-9
executor: otp_27
platform: rockylinux-9
context: mongooseim-org
filters: *all_tags_and_master
- package:
name: rockylinux-9-arm64
executor: otp_27_arm64
platform: rockylinux-9
context: mongooseim-org
filters: *all_tags_and_master
- package:
name: rockylinux-8
executor: otp_27
platform: rockylinux-8
context: mongooseim-org
filters: *all_tags_and_master
- package:
name: rockylinux-8-arm64
executor: otp_27_arm64
platform: rockylinux-8
context: mongooseim-org
filters: *all_tags_and_master
- package:
name: almalinux-9
executor: otp_27
platform: almalinux-9
context: mongooseim-org
filters: *all_tags_and_master
- package:
name: almalinux-9-arm64
executor: otp_27_arm64
platform: almalinux-9
context: mongooseim-org
filters: *all_tags_and_master
- package:
name: almalinux-8
executor: otp_27
platform: almalinux-8
context: mongooseim-org
filters: *all_tags_and_master
- package:
name: almalinux-8-arm64
executor: otp_27_arm64
platform: almalinux-8
context: mongooseim-org
filters: *all_tags_and_master
# ======== BASE DOCKER BUILDS ========
- build_in_docker:
name: otp_27_docker
Expand Down
25 changes: 19 additions & 6 deletions tools/pkg/Dockerfile_deb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,28 @@ FROM $builder_image AS builder
# Install build deps
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get install -y locales git make zlib1g-dev unixodbc-dev gcc g++ libssl-dev curl gpg wget gnupg
RUN apt-get install -y locales git make zlib1g-dev unixodbc-dev gcc g++ libssl-dev curl gpg

# The signing script requires debsigs version 0.2 or higher, which is unavailable in
# package repositories of Ubuntu versions earlier than 24.10 and Debian versions earlier than 13.
# TODO: Switch to installing debsigs via apt once support for these older versions is dropped.
RUN wget http://ftp.de.debian.org/debian/pool/main/d/debsigs/debsigs_0.2.2-1_all.deb && \
dpkg -i debsigs_0.2.2-1_all.deb && \
rm debsigs_0.2.2-1_all.deb && \
which debsigs
# TODO: Remove custom repo setup once older distro support ends.
RUN arch=$(dpkg --print-architecture) && \
distro=$(grep ^ID= /etc/os-release | cut -d= -f2 | tr -d '"') && \
if [ "$distro" = "ubuntu" ]; then \
if [ "$arch" = "arm64" ]; then \
echo "deb http://ports.ubuntu.com/ubuntu-ports oracular main restricted universe multiverse" >> /etc/apt/sources.list; \
else \
echo "deb http://archive.ubuntu.com/ubuntu oracular main restricted universe multiverse" >> /etc/apt/sources.list; \
fi && \
printf "Package: debsigs\nPin: release n=oracular\nPin-Priority: 990\n" > /etc/apt/preferences.d/debsigs; \
elif [ "$distro" = "debian" ]; then \
echo "deb http://deb.debian.org/debian trixie main" >> /etc/apt/sources.list && \
printf "Package: debsigs\nPin: release n=trixie\nPin-Priority: 990\n" > /etc/apt/preferences.d/debsigs; \
fi && \
apt-get update && \
apt-get install -y --no-install-recommends debsigs && \
sed -i '/oracular/d' /etc/apt/sources.list && \
sed -i '/trixie/d' /etc/apt/sources.list

ARG erlang_version

Expand Down
2 changes: 1 addition & 1 deletion tools/pkg/scripts/deb/build_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version=$1
revision=$2
otp_version=$3

arch="amd64"
arch=$(dpkg --print-architecture)

cd ~/mongooseim

Expand Down
15 changes: 13 additions & 2 deletions tools/pkg/scripts/rpm/build_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,20 @@ version=$1
revision=$2
otp_version=$3

arch="x86_64"
package_name_arch="amd64"
arch=$(uname -m)

case "$arch" in
x86_64)
package_name_arch="amd64"
;;
aarch64)
package_name_arch="arm64"
;;
*)
echo "Unsupported architecture: $arch"
exit 1
;;
esac

rpmbuild -bb \
--define "version ${version}" \
Expand Down
45 changes: 45 additions & 0 deletions tools/pkg/verify_arch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
executor_arch=$(uname -m)
case "$executor_arch" in
x86_64)
expected_arch="amd64"
;;
aarch64)
expected_arch="arm64"
;;
*)
echo "Unsupported executor architecture: $executor_arch"
exit 1
;;
esac

echo "Executor architecture detected: $expected_arch"

package_file=$(find tools/pkg/packages -name "*.deb" -o -name "*.rpm")
if [ -z "$package_file" ]; then
echo "No package found in the output directory."
exit 1
fi

if [[ $package_file == *.deb ]]; then
actual_arch=$(dpkg --info "$package_file" | grep Architecture | awk '{print $2}')
elif [[ $package_file == *.rpm ]]; then
actual_arch=$(rpm -qi "$package_file" | grep Architecture | awk '{print $2}')
if [ "$actual_arch" == "x86_64" ]; then
actual_arch="amd64"
elif [ "$actual_arch" == "aarch64" ]; then
actual_arch="arm64"
else
echo "Unable to determine architecture from file output."
exit 1
fi
else
echo "Unknown package type: $package_file"
exit 1
fi

if [ "$expected_arch" != "$actual_arch" ]; then
echo "Architecture mismatch: expected $expected_arch but got $actual_arch"
exit 1
fi

echo "Package architecture verified: $actual_arch"

0 comments on commit cfc7187

Please sign in to comment.