Skip to content

Commit

Permalink
Merge pull request #4273 from esl/fix-packages
Browse files Browse the repository at this point in the history
Fix and update package building scripts
  • Loading branch information
jacekwegr authored Apr 25, 2024
2 parents dbed20a + 05f03eb commit 56ff9c5
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 21 deletions.
23 changes: 15 additions & 8 deletions .circleci/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ jobs:
type: executor
platform:
type: enum
enum: [centos_7, rockylinux_9, rockylinux_8, almalinux_9, almalinux_8, debian_bullseye, debian_buster, ubuntu_xenial, ubuntu_focal, ubuntu_bionic]
enum: [centos_7, rockylinux_9, rockylinux_8, almalinux_9, almalinux_8, debian_bullseye, debian_buster, ubuntu_xenial, ubuntu_focal, ubuntu_bionic, ubuntu_jammy]
description: Platform type
otp_package:
type: string
Expand Down Expand Up @@ -711,49 +711,56 @@ workflows:
executor: otp_26
platform: centos_7
context: mongooseim-org
otp_package: "25.0.3-1"
otp_package: "26.2.2"
filters: *all_tags
- package:
name: rockylinux_8
executor: otp_26
platform: rockylinux_8
context: mongooseim-org
otp_package: "24.1.7-1"
otp_package: "26.2.4"
filters: *all_tags
- package:
name: almalinux_8
executor: otp_26
platform: almalinux_8
context: mongooseim-org
otp_package: "24.1.7-1"
otp_package: "26.2.4"
filters: *all_tags
- package:
name: debian_bullseye
executor: otp_26
platform: debian_bullseye
context: mongooseim-org
otp_package: "25.3-1"
otp_package: "26.2.1"
filters: *all_tags
- package:
name: debian_buster
executor: otp_26
platform: debian_buster
context: mongooseim-org
otp_package: "25.3-1"
otp_package: "26.2.3"
filters: *all_tags
- package:
name: ubuntu_jammy
executor: otp_26
platform: ubuntu_jammy
context: mongooseim-org
otp_package: "26.2.3"
filters: *all_tags
- package:
name: ubuntu_focal
executor: otp_26
platform: ubuntu_focal
context: mongooseim-org
otp_package: "25.3-1"
otp_package: "26.2.1"
filters: *all_tags
- package:
name: ubuntu_bionic
executor: otp_26
platform: ubuntu_bionic
context: mongooseim-org
otp_package: "25.3-1"
otp_package: "26.2.3"
filters: *all_tags
# ======== BASE DOCKER BUILDS ========
- build_in_docker:
Expand Down
10 changes: 4 additions & 6 deletions tools/pkg/Dockerfile_deb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@ FROM $dockerfile_platform 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
RUN apt-get install -y locales git make zlib1g-dev unixodbc-dev gcc g++ libssl-dev curl

RUN apt-get -y update && apt-get -y install curl gnupg && \
curl -O http://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb && \
dpkg -i erlang-solutions_2.0_all.deb && apt-get update
ARG erlang_version
RUN apt-get install -y esl-erlang=1:$erlang_version


# Fix locales
RUN locale-gen en_US.UTF-8
Expand All @@ -26,6 +21,9 @@ COPY . ./mongooseim

RUN cp -r ./mongooseim/tools/pkg/scripts/deb .

ARG dockerfile_platform
RUN ./deb/install_erlang.sh

ARG version
ARG revision

Expand Down
7 changes: 2 additions & 5 deletions tools/pkg/Dockerfile_rpm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ FROM $dockerfile_platform AS builder

# Install the build dependencies
RUN yum install -y epel-release
RUN yum install -y rpm-build rpmdevtools git make zlib-devel unixODBC-devel gcc gcc-c++ openssl openssl-devel
RUN yum install -y rpm-build rpmdevtools git make zlib-devel unixODBC-devel gcc gcc-c++ openssl openssl-devel chrpath

# Fix locale setup
# See https://github.com/CentOS/sig-cloud-instance-images/issues/71#issuecomment-266957519
Expand All @@ -26,17 +26,14 @@ RUN localedef -i en_US -f UTF-8 en_US.UTF-8

ARG erlang_version

RUN curl -O https://packages.erlang-solutions.com/erlang-solutions-2.0-1.noarch.rpm && \
rpm -Uvh erlang-solutions-2.0-1.noarch.rpm && \
yum install -y "esl-erlang-$erlang_version"

# Copy source code and put building files in proper directories according to
# defaults of `rpmdev-setuptree` and `rpmbuild` commands
# The .dockerignore file in root dir ensures only needed files
# including not commited changes are used to build the package
RUN rpmdev-setuptree
WORKDIR /root/rpmbuild
COPY --from=source /SOURCE ./BUILD/mongooseim
RUN ./BUILD/mongooseim/tools/pkg/scripts/rpm/install_erlang.sh

RUN cp ./BUILD/mongooseim/tools/pkg/scripts/rpm/mongooseim.spec ./SPECS/.
RUN cp ./BUILD/mongooseim/tools/pkg/scripts/rpm/mongooseim.service \
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 @@ -44,5 +44,5 @@ source /etc/os-release
os=$ID
os_version=$VERSION_CODENAME
package_os_file_name=${os}~${os_version}
mv mongooseim_*.deb ~/mongooseim_${version}_${revision}_otp_${otp_version/-1/}~${package_os_file_name}_${arch}.deb
mv mongooseim_*.deb ~/mongooseim_${version}_${revision}_otp_${otp_version}~${package_os_file_name}_${arch}.deb

10 changes: 10 additions & 0 deletions tools/pkg/scripts/deb/install_erlang.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -euo pipefail

DISTRO=$(echo $dockerfile_platform | cut -f1 -d:)
ERLANG_PKG=esl-erlang_${erlang_version}-1~${dockerfile_platform/:/\~}_amd64.deb

curl -O https://binaries2.erlang-solutions.com/$DISTRO/pool/contrib/e/esl-erlang/$ERLANG_PKG
apt-get -y --no-install-recommends install ./$ERLANG_PKG

rm $ERLANG_PKG
2 changes: 1 addition & 1 deletion tools/pkg/scripts/rpm/build_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ os_version=$VERSION_ID
package_os_file_name=${os}~${os_version}

mv ~/rpmbuild/RPMS/${arch}/mongooseim-${version}-${revision}.${arch}.rpm \
~/mongooseim_${version}_${revision}_otp_${otp_version/-1/}~${package_os_file_name}_${package_name_arch}.rpm
~/mongooseim_${version}_${revision}_otp_${otp_version}~${package_os_file_name}_${package_name_arch}.rpm
21 changes: 21 additions & 0 deletions tools/pkg/scripts/rpm/install_erlang.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -euo pipefail

DISTRO=$(echo $dockerfile_platform | cut -f1 -d:)
OS_RELEASE=$(echo $dockerfile_platform | cut -f2 -d:)

# There is no Erlang package for Almalinux, so let's use the one for Rockylinux
if [ $DISTRO == almalinux ]; then DISTRO=rockylinux; fi

ERLANG_PKG=esl-erlang_${erlang_version}_1~${DISTRO}~${OS_RELEASE}_x86_64.rpm
if [ $DISTRO == centos ]; then
MAJOR_VSN=$(echo $erlang_version | cut -f1 -d.)
PREFIX=esl-erlang-${MAJOR_VSN}
elif [ $DISTRO == rockylinux ]; then
PREFIX=${OS_RELEASE}
fi

curl -O https://binaries2.erlang-solutions.com/$DISTRO/$PREFIX/$ERLANG_PKG
yum install -y ./$ERLANG_PKG

rm $ERLANG_PKG
2 changes: 2 additions & 0 deletions tools/pkg/scripts/rpm/mongooseim.spec
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ make install
sed -i 's#RUNNER_USER=\"root\"#RUNNER_USER=\"mongooseim\"#' %{buildroot}/usr/bin/mongooseimctl
sed -i 's#RUNNER_USER=\"root\"#RUNNER_USER=\"mongooseim\"#' %{buildroot}/usr/lib/mongooseim/bin/mongooseimctl
sed -i 's#RUNNER_USER=root#RUNNER_USER=\"mongooseim\"#' %{buildroot}/usr/lib/mongooseim/bin/mongooseim
chrpath -d %{buildroot}/usr/lib/mongooseim/lib/crypto-*/priv/lib/crypto.so
chrpath -d %{buildroot}/usr/lib/mongooseim/lib/crypto-*/priv/lib/otp_test_engine.so

install -p -D -m 0644 %{SOURCE0} %{buildroot}%{_unitdir}/mongooseim.service

Expand Down

0 comments on commit 56ff9c5

Please sign in to comment.