From ae025c7aba7e4cbbe794cb48de4464d0e136dfee Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Mon, 26 Feb 2024 16:25:59 +0100 Subject: debvm-create: allow running without unshare again In a CI-environment such as salsa-ci, we tend to run as root and want --mode=root rather than --mode=unshare. --- bin/debvm-create | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'bin/debvm-create') diff --git a/bin/debvm-create b/bin/debvm-create index b93fa23..a8d5727 100755 --- a/bin/debvm-create +++ b/bin/debvm-create @@ -303,12 +303,17 @@ fi # construct mmdebstrap options as $@: set -- \ --verbose \ - --mode=unshare \ --variant=apt \ "--format=$MMFORMAT" \ '--customize-hook=echo "LABEL=debvm / ext4 defaults 0 0" >"$1/etc/fstab"' \ "$@" +if test "$(id -u)" = 0; then + set -- --mode=root "$@" +else + set -- --mode=unshare "$@" +fi + if test -n "$ARCHITECTURE"; then set -- "--architecture=$ARCHITECTURE" "$@" fi @@ -394,9 +399,15 @@ if ! check_skip autologin; then set -- "--customize-hook=$SHARE_DIR/customize-autologin.sh" "$@" fi -run_inside_userns() { - unshare --user --map-auto --map-user=65536 --map-group=65536 --keep-caps -- "$@" -} +if test "$(id -u)" = 0; then + run_inside_userns() { + "$@" + } +else + run_inside_userns() { + unshare --user --map-auto --map-user=65536 --map-group=65536 --keep-caps -- "$@" + } +fi TEMPROOT= cleanup() { -- cgit v1.2.3