PTU5KAS/container-entrypoint
Jan Kiszka a596e2ac33 kas-isar: Rework isar-specific entrypoint setup
Leave the isar-only commands commented-out in the container-entrypoint
and simply remove the comment when building kas-isar. This is simpler,
more readable and also more robust against changes of the entrypoint
file.

While at it, avoid a separate layer for modifying container-entrypoint.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2023-02-06 10:30:04 +01:00

63 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# kas-isar: update-binfmts --enable && [ -f /proc/sys/fs/binfmt_misc/status ]
if mount | grep -q "on / type aufs"; then
cat <<EOF >&2
WARNING: Generation of wic images will fail!
Your docker host setup uses broken aufs as storage driver. Adjust the docker
configuration to use a different driver (overlay, overlay2, devicemapper). You
may also need to update the host distribution (e.g. Debian Jessie -> Stretch).
EOF
fi
USER_ID=${USER_ID:-30000}
GROUP_ID=${GROUP_ID:-30000}
if [ "$USER_ID" == 0 ]; then
# We shall run everything as root
mkdir -p /builder
GOSU=""
elif [ "$USER_ID" == "$UID" ]; then
GOSU=""
else
if ! grep -q "^builder:" /etc/group; then
groupadd -o --gid "$GROUP_ID" builder
fi
if ! id builder >/dev/null 2>&1; then
# Create a non-root user that will perform the actual build
useradd -o --uid "$USER_ID" --gid "$GROUP_ID" --create-home \
--home-dir /builder builder
fi
GOSU="gosu builder"
# kas-isar: sbuild-adduser builder >/dev/null 2>&1
fi
if [ "$PWD" = / ]; then
cd /builder || exit 1
fi
if [ -n "$1" ]; then
case "$1" in
build|checkout|dump|for-all-repos|menu|shell|-*)
# SC2086: Double quote to prevent globbing and word splitting.
# shellcheck disable=2086
exec $GOSU kas "$@"
;;
*)
# SC2086: Double quote to prevent globbing and word splitting.
# shellcheck disable=2086
exec $GOSU "$@"
;;
esac
else
# SC2086: Double quote to prevent globbing and word splitting.
# shellcheck disable=2086
exec $GOSU bash
fi