Skip to content

Commit 294a6ba

Browse files
committed
Fix: Install latest version of rust for multi-platform build
1 parent cbc07b1 commit 294a6ba

File tree

1 file changed

+54
-7
lines changed

1 file changed

+54
-7
lines changed

build-scripts/sasl-build.sh

+54-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
#!/usr/bin/env bash
22
set -e
33

4+
# Build the sasl2 library with the sasl-xoauth2 plugin.
5+
#
6+
# The sasl-xoauth2 plugin is a SASL plugin that provides support for XOAUTH2 (OAuth 2.0) authentication.
7+
#
8+
# The build is done in /sasl-xoauth2/build.
9+
#
10+
# This script clones the sasl-xoauth2 repository, applies patches to:
11+
# - remove the build of the documentation
12+
# - fix the path to the python interpreter in the sasl-xoauth2-tool
13+
# - fix the path to the library when building on Alpine
14+
#
15+
# After building and installing the sasl2 library with the sasl-xoauth2 plugin, the
16+
# postfix-sasl-xoauth2-update-ca-certs script is installed into the /etc/ca-certificates/update.d directory.
17+
# This script is run by the update-ca-certificates command to update the list of trusted certificates.
418
build_sasl2() {
519
git clone --depth 1 --branch ${SASL_XOAUTH2_GIT_REF} ${SASL_XOAUTH2_REPO_URL} /sasl-xoauth2
620
cd /sasl-xoauth2
@@ -27,27 +41,60 @@ build_sasl2() {
2741
update-ca-certificates
2842
}
2943

44+
# Installs rust. Debian bookwork comes with an old version of rust, so we can't use the one from the repository.
45+
# Rust is needed, though for installation of msal library. On some architectures, we cannot use pre-compiled packages
46+
# (because they don't exist in the PIP repositories) and "pip install" will fail without rust. Specifically, when
47+
# compiling cryptographic libraries.
48+
setup_rust() {
49+
curl --proto '=https' --tlsv1.3 https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal
50+
export PATH="$HOME/.cargo/bin:$PATH"
51+
}
52+
53+
# Create a virtual environment and install the msal library for the
54+
# sasl-xoauth2-tool.
3055
setup_python_venv() {
3156
python3 -m venv /sasl
3257
. /sasl/bin/activate
3358
pip3 install msal
3459
}
3560

61+
# Installs the base components into the docker image:
62+
#
63+
# 1. sasl2 using the sasl-xoauth2 plugin
64+
# 2. a python virtual environment with the msal library
65+
base_install() {
66+
setup_rust
67+
build_sasl2
68+
setup_python_venv
69+
rustup self uninstall
70+
}
71+
72+
3673
[ -f /etc/lsb-release ] && . /etc/lsb-release
3774
[ -f /etc/os-release ] && . /etc/os-release
75+
76+
# Determine the base installation method based on the OS.
77+
# Alpine Linux has a different package management system than Debian-based systems.
3878
if [ -f /etc/alpine-release ]; then
39-
LIBS="git cmake clang make gcc g++ libc-dev pkgconfig curl-dev jsoncpp-dev cyrus-sasl-dev patch rust cargo libffi-dev python3-dev"
79+
# Install necessary libraries
80+
LIBS="git cmake clang make gcc g++ libc-dev pkgconfig curl-dev jsoncpp-dev cyrus-sasl-dev patch libffi-dev python3-dev"
4081
apk add --upgrade --virtual .build-deps ${LIBS}
41-
build_sasl2
42-
setup_python_venv
82+
83+
# Run compilation and installation
84+
base_install
85+
86+
# Cleanup. This is important to ensure that we don't keep unnecessary files laying around and thus increasing the size of the image.
4387
apk del .build-deps;
4488
else
89+
# Install necessary libraries
4590
apt-get update -y -qq
46-
LIBS="git build-essential cmake pkg-config libcurl4-openssl-dev libssl-dev libjsoncpp-dev libsasl2-dev rustc cargo rustfmt python3-dev"
91+
LIBS="git build-essential cmake pkg-config libcurl4-openssl-dev libssl-dev libjsoncpp-dev libsasl2-dev python3-dev"
4792
apt-get install -y --no-install-recommends ${LIBS}
48-
build_sasl2
49-
apt-get install -y --no-install-recommends python3-venv
50-
setup_python_venv
93+
94+
# Run compilation and installation
95+
base_install
96+
97+
# Cleanup. This is important to ensure that we don't keep unnecessary files laying around and thus increasing the size of the image.
5198
apt-get remove --purge -y ${LIBS} python3-venv
5299
apt-get autoremove --yes
53100
apt-get clean autoclean

0 commit comments

Comments
 (0)