From: Zbigniew Jędrzejewski-Szmek Date: Sun, 29 Oct 2023 13:26:45 +0000 (+0100) Subject: mkosi-chroot: just run shell if no arguments are specified X-Git-Tag: v19~33^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=106fc98b82a309d754e1f9c071ea4c32ef9870e1;p=thirdparty%2Fmkosi.git mkosi-chroot: just run shell if no arguments are specified chroot(1) is documented to run "$SHELL -i" as the default command. Let's do something similar and call "sh -i". When a user is using '--debug-shell' and one of the scripts fails, the mkosi-chroot can be used to chroot into the image. I think this is what users expect, based on the 'chroot' in the name. (I don't think using $SHELL makes sense. It could either be set to 'sh', or to something from the outside, which might not even be installed in the chroot. We call 'sh' ourselves, so we know it must be there, so let's just call that uncoditionally.) --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 7071a8a3d..f081d84c4 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -342,7 +342,11 @@ def finalize_scripts(scripts: Mapping[str, Sequence[PathString]] = {}) -> Iterat DIR="$(cd "$(dirname "$0")" && pwd)" PATH="$(echo "$PATH" | tr ':' '\\n' | grep -v "$DIR" | tr '\\n' ':')" export PATH - exec {shlex.join(str(s) for s in script)} "$@" + if [ $# -gt 0 ]; then + exec {shlex.join(str(s) for s in script)} "$@" + else + exec {shlex.join(str(s) for s in script)} sh -i + fi """ ) )