Files
exim-encrypt-dlfunc/ci_container/build.sh
2021-09-06 02:02:37 +02:00

81 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
# shellcheck disable=SC1004
set -e
images=('debian:buster|buster' 'debian:bullseye|bullseye' 'ubuntu:focal|focal')
BASENAME='exim-encrypt-dlfunc-build'
TAG='latest'
REGISTRY='localhost:5000'
USERNAME='nobody'
PASSWORD='password'
while getopts "r:u:p:b:t:" OPTION; do
case $OPTION in
r)
REGISTRY="${OPTARG}"
;;
u)
USERNAME="${OPTARG}"
;;
p)
PASSWORD="${OPTARG}"
;;
b)
BASENAME="${OPTARG}"
;;
t)
TAG="${OPTARG}"
;;
*)
echo "Invalid argument"
exit 127
esac
done
REGHOST="$(echo "${REGISTRY}" | cut -d/ -f1)"
if [ "${REGISTRY}" != "none" ]; then
echo "🔑 Logging into »${REGHOST}«"
if ! buildah login --get-login "${REGHOST}" > /dev/null 2> /dev/null; then
buildah login --password "${PASSWORD}" --username "${USERNAME}" "${REGHOST}"
fi
fi
for i in "${images[@]}"; do
basectr=$(echo "${i}" | cut -d'|' -f1)
name=$(echo "${i}" | cut -d'|' -f2)
IMAGENAME="${BASENAME}-${name}"
echo "🔨 Assembling »${IMAGENAME}«"
ctr="$(buildah from "$basectr")"
buildah run "$ctr" /bin/sh -c 'apt-get update; \
DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt-get install -y \
build-essential \
git \
exim4-dev \
libsodium-dev \
pkg-config \
python3-pip \
exim4-daemon-heavy \
openssl; \
DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt-get install -y \
debhelper \
dh-make \
devscripts \
git-buildpackage \
debsigs \
gpgv1; \
rm -rf /var/lib/apt/lists/*;'
buildah run "$ctr" /bin/sh -c \
'pip3 install meson ninja; \
rm -rf ~/.cache/pip/*;'
TARGET="${REGISTRY}/${BASENAME}-${name}:${TAG}"
IMAGEID=$(buildah commit --format docker "$ctr" "${IMAGENAME}")
if [ "${REGISTRY}" != "none" ]; then
echo "🚀 Pushing »${TARGET}«"
buildah push "${IMAGEID}" "${TARGET}"
echo "✅ Finished »${BASENAME}«"
fi
done