diff --git a/devel/container/base-devel/Dockerfile b/devel/container/base-devel/Dockerfile index b0aecead..453c734e 100644 --- a/devel/container/base-devel/Dockerfile +++ b/devel/container/base-devel/Dockerfile @@ -2,7 +2,8 @@ FROM archlinux:base as base MAINTAINER Martchus RUN mkdir -p /startdir /build && \ - useradd -m -d /build -u 1000 -U -s /bin/bash builduser && \ + groupadd -g 1000 builduser && \ + useradd -m -d /build -u 1000 -g 1000 -s /bin/bash builduser && \ chown -R builduser:builduser /startdir /build && \ echo 'builduser ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers && \ pacman-key --init && \ diff --git a/devel/container/makecontainerpkg b/devel/container/makecontainerpkg index 77bfc06d..a6a4f486 100755 --- a/devel/container/makecontainerpkg +++ b/devel/container/makecontainerpkg @@ -19,7 +19,19 @@ else uuid=$(cat /proc/sys/kernel/random/uuid) name=$tool-$pkgname-$uuid fi -cre_args=(--name "$name" --workdir "/startdir" -v "$PWD":/startdir -it --userns=keep-id:uid=1000,gid=1000) +cre_args=(--name "$name" --workdir "/startdir" -v "$PWD":/startdir -it) +cre_rm_args=(--force) + +# use "builduser" that has been created via the Dockerfile +uid=1000 gid=1000 +if [[ $CRE == 'podman' ]]; then + cre_args+=(--userns="keep-id:uid=$uid,gid=$gid") + cre_rm_args+=(--time 0) +else + cre_args+=(--user="$uid:$gid") + # caveat: In contrast to Podman this gives a wrong gid for newly created files by + # default. Maybe it would help to pass `--userns-remap=…` to `dockerd`. +fi # parse arguments script_args= read_script_args= @@ -77,7 +89,7 @@ fi # stop and remove container unless we want to keep it for debugging [[ $ec == 0 && $DEBUG == on-failure || -z $DEBUG ]] && \ - "$cre" container rm --force --time 0 "$name" + "$cre" container rm "${cre_rm_args[@]}" "$name" # log message about commands to use for investigation [[ $ec != 0 ]] && [[ $DEBUG ]] && echo \