diff --git a/.circleci/template.yml b/.circleci/template.yml index e528942dd8f..008089dccda 100644 --- a/.circleci/template.yml +++ b/.circleci/template.yml @@ -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: @@ -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 diff --git a/tools/pkg/Dockerfile_deb b/tools/pkg/Dockerfile_deb index 92faf998a4e..2b5ca060b52 100644 --- a/tools/pkg/Dockerfile_deb +++ b/tools/pkg/Dockerfile_deb @@ -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 diff --git a/tools/pkg/scripts/deb/build_package.sh b/tools/pkg/scripts/deb/build_package.sh index eb08393763a..9e7d4af1936 100755 --- a/tools/pkg/scripts/deb/build_package.sh +++ b/tools/pkg/scripts/deb/build_package.sh @@ -5,7 +5,7 @@ version=$1 revision=$2 otp_version=$3 -arch="amd64" +arch=$(dpkg --print-architecture) cd ~/mongooseim diff --git a/tools/pkg/scripts/rpm/build_package.sh b/tools/pkg/scripts/rpm/build_package.sh index 719bb1d713a..6cc831c82bc 100755 --- a/tools/pkg/scripts/rpm/build_package.sh +++ b/tools/pkg/scripts/rpm/build_package.sh @@ -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}" \ diff --git a/tools/pkg/verify_arch.sh b/tools/pkg/verify_arch.sh new file mode 100755 index 00000000000..479cfe6911d --- /dev/null +++ b/tools/pkg/verify_arch.sh @@ -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"