Skip to content

Commit f7852f5

Browse files
authored
Merge pull request #4511 from esl/bundle-openssl-for-older-systems
Bundle OpenSSL 3.x with packages for older systems
2 parents 4ef2739 + e402eb5 commit f7852f5

File tree

5 files changed

+93
-3
lines changed

5 files changed

+93
-3
lines changed

doc/getting-started/Installation.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,23 @@ The following sections describe the installation process for different operating
2525
=== "CentOS compatible: AlmaLinux / Rocky Linux"
2626

2727
An ODBC (RDBMS) driver must be installed on your machine to unpack and install from RPM packages. Enter the following command in a terminal window to install the latest unixODBC driver:
28-
28+
2929
```bash
3030
sudo yum install unixODBC
3131
```
32-
32+
3333
Once the RPM file is downloaded, open a terminal window and navigate to the directory containing the package. Use the following command to unpack and install MongooseIM:
34-
34+
3535
```bash
3636
sudo rpm -i mongooseim_[version here].rpm
3737
```
3838

39+
!!! info
40+
Packages for older systems (Ubuntu Focal, Debian Bullseye, Debian Buster, AlmaLinux 8, Rocky Linux 8)
41+
include a bundled OpenSSL 3.x, as this version is required for MongooseIM to function correctly,
42+
but is not available in the official repositories for these distributions.
43+
If your system already has OpenSSL 3.x installed, the package will detect and use the system version instead of the bundled one.
44+
3945
## Docker
4046

4147
In order to install MongooseIM using Docker, simply run the following command:

tools/pkg/scripts/deb/build_package.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,26 @@ apt-get update
1616

1717
rm -rf /usr/lib/erlang/man/man3/cerff.3.gz /usr/lib/erlang/man/man3/cerfl.3.gz /usr/lib/erlang/man/man3/cerfcl.3.gz /usr/lib/erlang/man/man3/cerfcf.3.gz /usr/lib/erlang/man/man3/cerfcf.3.gz /usr/lib/erlang/man/man1/x86_64-linux-gnu-gcov-tool.1.gz /usr/lib/erlang/man/man1/ocamlbuild.native.1.gz /usr/lib/erlang/man/man1/gcov-tool.1.gz /usr/lib/erlang/man/man1/ocamlbuild.byte.1.gz
1818

19+
OS_ID=$(grep ^ID= /etc/os-release | cut -d= -f2 | tr -d '"')
20+
OS_VERSION=$(grep ^VERSION_ID= /etc/os-release | cut -d= -f2 | tr -d '"' | cut -d. -f1)
21+
if { [ "$OS_ID" = "ubuntu" ] && [ "$OS_VERSION" -lt 22 ]; } || \
22+
{ [ "$OS_ID" = "debian" ] && [ "$OS_VERSION" -lt 12 ]; }; then
23+
export CFLAGS="-I/usr/local/ssl/include"
24+
25+
# Copy essential OpenSSL 3.x runtime files to bundle with the app
26+
mkdir -p mongooseim/opt/mongooseim/openssl/etc
27+
mkdir -p mongooseim/opt/mongooseim/openssl/include
28+
cp -a /usr/local/ssl/include/openssl mongooseim/opt/mongooseim/openssl/include/
29+
30+
if [ -d /usr/local/ssl/lib64 ]; then
31+
export LDFLAGS="-L/usr/local/ssl/lib64"
32+
cp -a /usr/local/ssl/lib64 mongooseim/opt/mongooseim/openssl/
33+
else
34+
export LDFLAGS="-L/usr/local/ssl/lib"
35+
cp -a /usr/local/ssl/lib mongooseim/opt/mongooseim/openssl/
36+
fi
37+
fi
38+
1939
make clean
2040
sed -i '1 s/^.*$/\#\!\/bin\/bash/' tools/install
2141
./tools/configure with-all user=mongooseim prefix="" system=yes

tools/pkg/scripts/deb/debian/postinst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,21 @@ setup()
3636
chown -R $NAME:$NAME $PKG_ROOT $MIM_CTL $ETC_DIR $VAR_LIB $VAR_LOCK $VAR_LOG
3737
fi
3838
#sed -i -e "s*\(RUNNER_SCRIPT_DIR=\).\**\1${PKG_ROOT}bin*" /usr/sbin/mongooseimctl
39+
40+
OS_ID=$(grep ^ID= /etc/os-release | cut -d= -f2 | tr -d '"')
41+
OS_VERSION=$(grep ^VERSION_ID= /etc/os-release | cut -d= -f2 | tr -d '"' | cut -d. -f1)
42+
if { [ "$OS_ID" = "ubuntu" ] && [ "$OS_VERSION" -lt 22 ]; } || \
43+
{ [ "$OS_ID" = "debian" ] && [ "$OS_VERSION" -lt 12 ]; }; then
44+
SYSTEM_OPENSSL=$(ldconfig -p | grep "libssl.so.3" | awk '{print $NF}' | head -n 1)
45+
if [ -z "$SYSTEM_OPENSSL" ]; then
46+
if [ -d /opt/mongooseim/openssl/lib64 ]; then
47+
echo "/opt/mongooseim/openssl/lib64" > /etc/ld.so.conf.d/mongooseim-openssl.conf
48+
else
49+
echo "/opt/mongooseim/openssl/lib" > /etc/ld.so.conf.d/mongooseim-openssl.conf
50+
fi
51+
ldconfig
52+
fi
53+
fi
3954
}
4055

4156
case "$1" in

tools/pkg/scripts/rpm/build_package.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,27 @@ case "$arch" in
2020
;;
2121
esac
2222

23+
OS_ID=$(grep ^ID= /etc/os-release | cut -d= -f2 | tr -d '"')
24+
OS_VERSION=$(grep ^VERSION_ID= /etc/os-release | cut -d= -f2 | tr -d '"' | cut -d. -f1)
25+
if { [ "$OS_ID" = "rocky" ] && [ "$OS_VERSION" -lt 9 ]; } || \
26+
{ [ "$OS_ID" = "almalinux" ] && [ "$OS_VERSION" -lt 9 ]; }; then
27+
if [ -d /usr/local/ssl/lib64 ]; then
28+
export LDFLAGS="-L/usr/local/ssl/lib64"
29+
else
30+
export LDFLAGS="-L/usr/local/ssl/lib"
31+
fi
32+
export CFLAGS="-I/usr/local/ssl/include"
33+
34+
bundle_openssl=1
35+
else
36+
bundle_openssl=0
37+
fi
38+
2339
rpmbuild -bb \
2440
--define "version ${version}" \
2541
--define "release ${revision}" \
2642
--define "architecture ${arch}" \
43+
--define "with_bundled_openssl ${bundle_openssl}" \
2744
~/rpmbuild/SPECS/mongooseim.spec
2845

2946
source /etc/os-release

tools/pkg/scripts/rpm/mongooseim.spec

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ scale in need of more capacity (by just adding a box/VM).
3636
cp %{SOURCE0} .
3737

3838
%install
39+
%if %{with_bundled_openssl}
40+
# Copy essential OpenSSL 3.x runtime files to bundle with the app
41+
mkdir -p %{buildroot}/opt/mongooseim/openssl/etc
42+
mkdir -p %{buildroot}/opt/mongooseim/openssl/include
43+
cp -a /usr/local/ssl/include/openssl %{buildroot}/opt/mongooseim/openssl/include/
44+
if [ -d /usr/local/ssl/lib64 ]; then
45+
cp -a /usr/local/ssl/lib64 %{buildroot}/opt/mongooseim/openssl/
46+
else
47+
cp -a /usr/local/ssl/lib %{buildroot}/opt/mongooseim/openssl/
48+
fi
49+
%endif
50+
3951
make clean
4052
./tools/configure with-all user=root prefix=/ system=yes
4153
sed -i 's#PREFIX=\"/\"#PREFIX=\"%{buildroot}\"#' configure.out
@@ -58,12 +70,32 @@ getent passwd mongooseim >/dev/null || adduser -g mongooseim mongooseim
5870
exit 0
5971

6072
%post
73+
%if %{with_bundled_openssl}
74+
SYSTEM_OPENSSL=$(ldconfig -p | grep "libssl.so.3" | awk '{print $NF}' | head -n 1)
75+
if [ -z "$SYSTEM_OPENSSL" ]; then
76+
if [ -d /opt/mongooseim/openssl/lib64 ]; then
77+
echo "/opt/mongooseim/openssl/lib64" > /etc/ld.so.conf.d/mongooseim-openssl.conf
78+
else
79+
echo "/opt/mongooseim/openssl/lib" > /etc/ld.so.conf.d/mongooseim-openssl.conf
80+
fi
81+
ldconfig
82+
fi
83+
%endif
6184
echo "MongooseIM %{version} installed"
6285

6386
%clean
6487
rm -rf %{buildroot}
6588

6689
%files
90+
%if %{with_bundled_openssl}
91+
%ifarch x86_64
92+
/opt/mongooseim/openssl/lib64/
93+
%endif
94+
%ifarch aarch64
95+
/opt/mongooseim/openssl/lib/
96+
%endif
97+
/opt/mongooseim/openssl/include/openssl/
98+
%endif
6799

68100
%defattr(-, root, root, -)
69101

0 commit comments

Comments
 (0)