From dc5da1811840c4c79c2a2df6c1ea53d25818d0e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20N=C3=BCtzi?= Date: Sun, 14 Jul 2024 11:31:31 +0200 Subject: [PATCH] fix: add missing build type behavior MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add argument to container file. Signed-off-by: Gabriel Nützi --- Containerfile | 12 +++++++++--- root/setup.sh | 45 +++++++++++++++++++++++++++------------------ 2 files changed, 36 insertions(+), 21 deletions(-) diff --git a/Containerfile b/Containerfile index 2c344af..4aec1ba 100644 --- a/Containerfile +++ b/Containerfile @@ -20,6 +20,10 @@ ADD /root/ /root/ ADD /etc/ /etc/ ADD /home/ /home/ +# The build type: either `dev` or `prod` +# In `dev` mode: the package manager will not be deleted. +ARG BUILD_TYPE=prod + # Allow image-builders to choose another version besides "latest" should # an incompatible change be introduced. ARG RUNNER_VERSION=latest @@ -35,9 +39,11 @@ ARG TARGETARCH=amd64 ARG PRUNE_INTERVAL=daily # see systemd.timer for allowable values # All-in-one packaging/image-setup script to keep things simple. -RUN PRUNE_INTERVAL=${PRUNE_INTERVAL} \ - RUNNER_VERSION=${RUNNER_VERSION} \ - bash /root/setup.sh +RUN \ + PRUNE_INTERVAL=${PRUNE_INTERVAL} \ + RUNNER_VERSION=${RUNNER_VERSION} \ + BUILD_TYPE=${BUILD_TYPE} \ + bash /root/setup.sh VOLUME /cache /home/podman/.local/share/containers ENTRYPOINT /lib/systemd/systemd diff --git a/root/setup.sh b/root/setup.sh index e50fed9..3973277 100644 --- a/root/setup.sh +++ b/root/setup.sh @@ -33,6 +33,10 @@ function check_vars() { die "Env. variable '$varname' must be non-empty." fi done + + if [[ ! "$BUILD_TYPE" =~ dev|prod ]]; then + die "Build type must be 'dev' or 'prod': '$BUILD_TYPE'." + fi } function main() { @@ -51,6 +55,10 @@ function main() { finalize_ownership } +function is_release() { + [ "$BUILD_TYPE" = "prod" ] || return 1 +} + function install_packages() { readarray xpackages < <(grep -vE '^(# )+'