Skip to content

Commit 50c9503

Browse files
committed
Fix for installation of msal library
This will create a python venv and point sasl-xoauth2-tool to use this venv. This way, when the user executes the command, it will "automagically" work instead of failing.
1 parent 3b2d8db commit 50c9503

File tree

3 files changed

+49
-31
lines changed

3 files changed

+49
-31
lines changed

Dockerfile

-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ ARG TARGETPLATFORM
3434
ARG SASL_XOAUTH2_REPO_URL=https://github.com/tarickb/sasl-xoauth2.git
3535
ARG SASL_XOAUTH2_GIT_REF=release-0.25
3636

37-
# --mount=type=cache,target=/var/cache/apk,sharing=locked,id=var-cache-apk-$TARGETPLATFORM \
38-
# --mount=type=cache,target=/etc/apk/cache,sharing=locked,id=etc-apk-cache-$TARGETPLATFORM \
3937
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=var-cache-apt-$TARGETPLATFORM \
4038
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=var-lib-apt-$TARGETPLATFORM \
4139
--mount=type=tmpfs,target=/etc/apk/cache \

build-scripts/sasl-build.sh

+42-29
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,53 @@
1-
#!/bin/sh
1+
#!/usr/bin/env bash
22
set -e
33

44
build_sasl2() {
5-
git clone --depth 1 --branch ${SASL_XOAUTH2_GIT_REF} ${SASL_XOAUTH2_REPO_URL} /sasl-xoauth2
6-
cd /sasl-xoauth2
7-
mkdir build
8-
cd build
9-
# Documentation build (now) requires pandoc, which is not available on multiple
10-
# architectures. Since we're are building an image that we want it to be as slim as possible,
11-
# we're removing the build of documentation instead of complicating things with pandoc.
12-
patch -p1 -d .. < /build-scripts/sasl-xoauth2-01.patch
13-
if [ -f /etc/alpine-release ]; then
14-
patch -p1 -d .. < /build-scripts/sasl-xoauth2-02.patch
15-
cmake -DCMAKE_INSTALL_PREFIX=/ ..
16-
else
17-
cmake -DCMAKE_INSTALL_PREFIX=/usr ..
18-
fi
19-
make
20-
make install
21-
install ../scripts/postfix-sasl-xoauth2-update-ca-certs /etc/ca-certificates/update.d
22-
update-ca-certificates
5+
git clone --depth 1 --branch ${SASL_XOAUTH2_GIT_REF} ${SASL_XOAUTH2_REPO_URL} /sasl-xoauth2
6+
cd /sasl-xoauth2
7+
mkdir build
8+
cd build
9+
# Documentation build (now) requires pandoc, which is not available on multiple
10+
# architectures. Since we're are building an image that we want it to be as slim as possible,
11+
# we're removing the build of documentation instead of complicating things with pandoc.
12+
patch -p1 -d .. < /build-scripts/sasl-xoauth2-01.patch
13+
14+
# Ensure that the sasl-xoauth2-tool uses python from the virtual environment into which we
15+
# installed the msal library.
16+
patch -p1 -d .. < /build-scripts/sasl-xoauth2-03.patch
17+
18+
if [ -f /etc/alpine-release ]; then
19+
patch -p1 -d .. < /build-scripts/sasl-xoauth2-02.patch
20+
cmake -DCMAKE_INSTALL_PREFIX=/ ..
21+
else
22+
cmake -DCMAKE_INSTALL_PREFIX=/usr ..
23+
fi
24+
make
25+
make install
26+
install ../scripts/postfix-sasl-xoauth2-update-ca-certs /etc/ca-certificates/update.d
27+
update-ca-certificates
28+
}
29+
30+
setup_python_venv() {
31+
python3 -m venv /sasl
32+
. /sasl/bin/activate
33+
pip3 install msal
2334
}
2435

2536
[ -f /etc/lsb-release ] && . /etc/lsb-release
2637
[ -f /etc/os-release ] && . /etc/os-release
2738
if [ -f /etc/alpine-release ]; then
28-
apk add --upgrade --virtual .build-deps git cmake clang make gcc g++ libc-dev pkgconfig curl-dev jsoncpp-dev cyrus-sasl-dev patch
29-
build_sasl2
30-
apk del .build-deps;
39+
apk add --upgrade --virtual .build-deps git cmake clang make gcc g++ libc-dev pkgconfig curl-dev jsoncpp-dev cyrus-sasl-dev patch
40+
setup_python_venv
41+
build_sasl2
42+
apk del .build-deps;
3143
else
32-
apt-get update -y -qq
33-
LIBS="git build-essential cmake pkg-config libcurl4-openssl-dev libssl-dev libjsoncpp-dev libsasl2-dev"
34-
apt-get install -y --no-install-recommends ${LIBS}
35-
build_sasl2
36-
apt-get remove --purge -y ${LIBS}
37-
apt-get autoremove --yes
38-
apt-get clean autoclean
44+
apt-get update -y -qq
45+
LIBS="git build-essential cmake pkg-config libcurl4-openssl-dev libssl-dev libjsoncpp-dev libsasl2-dev python3-venv"
46+
apt-get install -y --no-install-recommends ${LIBS}
47+
setup_python_venv
48+
build_sasl2
49+
apt-get remove --purge -y ${LIBS}
50+
apt-get autoremove --yes
51+
apt-get clean autoclean
3952
fi
4053

build-scripts/sasl-xoauth2-03.patch

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
--- sasl-xoauth2-orig/scripts/sasl-xoauth2-tool.in 2025-03-01 08:38:07
2+
+++ sasl-xoauth2/scripts/sasl-xoauth2-tool.in 2025-03-01 08:38:12
3+
@@ -1,4 +1,4 @@
4+
-#!/usr/bin/python3
5+
+#!/sasl/bin/python3
6+
# PYTHON_ARGCOMPLETE_OK
7+
# -*- coding: utf-8 -*-

0 commit comments

Comments
 (0)