|
1 |
| -#!/bin/sh |
| 1 | +#!/usr/bin/env bash |
2 | 2 | set -e
|
3 | 3 |
|
4 | 4 | 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 |
23 | 34 | }
|
24 | 35 |
|
25 | 36 | [ -f /etc/lsb-release ] && . /etc/lsb-release
|
26 | 37 | [ -f /etc/os-release ] && . /etc/os-release
|
27 | 38 | 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; |
31 | 43 | 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 |
39 | 52 | fi
|
40 | 53 |
|
0 commit comments