1
1
#! /usr/bin/env bash
2
2
set -e
3
3
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
4
42
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
5
60
6
61
# Build the sasl2 library with the sasl-xoauth2 plugin.
7
62
#
@@ -48,19 +103,25 @@ build_sasl2() {
48
103
# (because they don't exist in the PIP repositories) and "pip install" will fail without rust. Specifically, when
49
104
# compiling cryptographic libraries.
50
105
setup_rust () {
51
- if [[ " ${arch} " != " 386 " ]] && [[ " ${arch} " != " i386 " ]] && [[ " ${arch} " != " mips64el " ]]; then
106
+ if [[ -z " ${skip_msal} " ]]; then
52
107
curl --proto ' =https' --tlsv1.3 https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal
53
108
export PATH=" $HOME /.cargo/bin:$PATH "
54
109
. " $HOME /.cargo/env"
55
110
fi
56
111
}
57
112
113
+ teardown_rust () {
114
+ if command -v rustup 2>&1 > /dev/null; then
115
+ rustup self uninstall -y
116
+ fi
117
+ }
118
+
58
119
# Create a virtual environment and install the msal library for the
59
120
# sasl-xoauth2-tool.
60
121
setup_python_venv () {
61
122
python3 -m venv /sasl
62
123
. /sasl/bin/activate
63
- if [[ " ${arch} " != " 386 " ]] && [[ " ${arch} " != " i386 " ]] && [[ " ${arch} " != " mips64el " ]]; then
124
+ if [[ -z " ${skip_msal} " ]]; then
64
125
pip3 install msal
65
126
fi
66
127
}
@@ -74,10 +135,6 @@ base_install() {
74
135
setup_python_venv
75
136
}
76
137
77
-
78
- [ -f /etc/lsb-release ] && . /etc/lsb-release
79
- [ -f /etc/os-release ] && . /etc/os-release
80
-
81
138
# Determine the base installation method based on the OS.
82
139
# Alpine Linux has a different package management system than Debian-based systems.
83
140
if [ -f /etc/alpine-release ]; then
100
157
# Run compilation and installation
101
158
setup_rust
102
159
base_install
103
- if [[ " ${arch} " != " 386" ]] && [[ " ${arch} " != " i386" ]] && [[ " ${arch} " != " mips64el" ]]; then
104
- rustup self uninstall -y
105
- fi
160
+ teardown_rust
106
161
107
162
# Cleanup. This is important to ensure that we don't keep unnecessary files laying around and thus increasing the size of the image.
108
163
apt-get remove --purge -y ${LIBS} python3-venv
0 commit comments