Skip to content

Commit 9fcd02f

Browse files
committed
Fix: Refactor sasl compilation a bit, hopefuly to run without issues
1 parent d0590c7 commit 9fcd02f

File tree

1 file changed

+64
-9
lines changed

1 file changed

+64
-9
lines changed

build-scripts/sasl-build.sh

+64-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,62 @@
11
#!/usr/bin/env bash
22
set -e
33

4+
[ -f /etc/lsb-release ] && . /etc/lsb-release
5+
[ -f /etc/os-release ] && . /etc/os-release
6+
7+
# Alpine os-release
8+
# PRETTY_NAME="Alpine Linux v3.21"
9+
# NAME="Alpine Linux"
10+
# ID=alpine
11+
# VERSION_ID=3.21.2
12+
# HOME_URL="https://alpinelinux.org/"
13+
# BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues"
14+
#
15+
# Debian os-release
16+
# PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
17+
# NAME="Debian GNU/Linux"
18+
# ID=debian
19+
# VERSION_ID="12"
20+
# VERSION="12 (bookworm)"
21+
# VERSION_CODENAME=bookworm
22+
# HOME_URL="https://www.debian.org/"
23+
# SUPPORT_URL="https://www.debian.org/support"
24+
# BUG_REPORT_URL="https://bugs.debian.org/"
25+
#
26+
# Ubuntu os-release
27+
# PRETTY_NAME="Ubuntu 24.04.1 LTS"
28+
# NAME="Ubuntu"
29+
# ID=ubuntu
30+
# ID_LIKE=debian
31+
# VERSION_ID="24.04"
32+
# VERSION="24.04.1 LTS (Noble Numbat)"
33+
# VERSION_CODENAME=noble
34+
# HOME_URL="https://www.ubuntu.com/"
35+
# SUPPORT_URL="https://help.ubuntu.com/"
36+
# BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
37+
# PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
38+
# UBUNTU_CODENAME=noble
39+
# LOGO=ubuntu-logo
40+
41+
export DEBIAN_FRONTEND=noninteractive
442
export arch="$(uname -m)"
43+
export skip_msal=""
44+
45+
if [[ "${ID:-}" != "alpine" ]]; then
46+
if [[ "${arch}" != "386" ]] && [[ "${arch}" != "i386" ]] && [[ "${arch}" != "mips64el" ]]; then
47+
skip_msal="1"
48+
echo "Running on ${ID}/${arch}: ${skip_msal}"
49+
else
50+
echo "Running on ${ID}/${arch}: Installing msal"
51+
fi
52+
else
53+
if [[ "${arch}" != "mips64el" ]]; then
54+
skip_msal="1"
55+
echo "Running on ${ID}/${arch}: ${skip_msal}"
56+
else
57+
echo "Running on ${ID}/${arch}: ${skip_msal}"
58+
fi
59+
fi
560

661
# Build the sasl2 library with the sasl-xoauth2 plugin.
762
#
@@ -48,19 +103,25 @@ build_sasl2() {
48103
# (because they don't exist in the PIP repositories) and "pip install" will fail without rust. Specifically, when
49104
# compiling cryptographic libraries.
50105
setup_rust() {
51-
if [[ "${arch}" != "386" ]] && [[ "${arch}" != "i386" ]] && [[ "${arch}" != "mips64el" ]]; then
106+
if [[ -z "${skip_msal}" ]]; then
52107
curl --proto '=https' --tlsv1.3 https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal
53108
export PATH="$HOME/.cargo/bin:$PATH"
54109
. "$HOME/.cargo/env"
55110
fi
56111
}
57112

113+
teardown_rust() {
114+
if command -v rustup 2>&1 > /dev/null; then
115+
rustup self uninstall -y
116+
fi
117+
}
118+
58119
# Create a virtual environment and install the msal library for the
59120
# sasl-xoauth2-tool.
60121
setup_python_venv() {
61122
python3 -m venv /sasl
62123
. /sasl/bin/activate
63-
if [[ "${arch}" != "386" ]] && [[ "${arch}" != "i386" ]] && [[ "${arch}" != "mips64el" ]]; then
124+
if [[ -z "${skip_msal}" ]]; then
64125
pip3 install msal
65126
fi
66127
}
@@ -74,10 +135,6 @@ base_install() {
74135
setup_python_venv
75136
}
76137

77-
78-
[ -f /etc/lsb-release ] && . /etc/lsb-release
79-
[ -f /etc/os-release ] && . /etc/os-release
80-
81138
# Determine the base installation method based on the OS.
82139
# Alpine Linux has a different package management system than Debian-based systems.
83140
if [ -f /etc/alpine-release ]; then
@@ -100,9 +157,7 @@ else
100157
# Run compilation and installation
101158
setup_rust
102159
base_install
103-
if [[ "${arch}" != "386" ]] && [[ "${arch}" != "i386" ]] && [[ "${arch}" != "mips64el" ]]; then
104-
rustup self uninstall -y
105-
fi
160+
teardown_rust
106161

107162
# Cleanup. This is important to ensure that we don't keep unnecessary files laying around and thus increasing the size of the image.
108163
apt-get remove --purge -y ${LIBS} python3-venv

0 commit comments

Comments
 (0)