From: Daan De Meyer Date: Thu, 5 Sep 2024 09:46:22 +0000 (+0200) Subject: mkosi-initrd: Add --debug-shell argument X-Git-Tag: v25~316^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=156880c39862162cc9428d90aaf0abaf2bf75c37;p=thirdparty%2Fmkosi.git mkosi-initrd: Add --debug-shell argument This is passed through directly to mkosi. To make this work we also pass through stdout/stdin directly to the invoked mkosi process. --- diff --git a/mkosi/initrd.py b/mkosi/initrd.py index 5874cfa24..c15fe72a2 100644 --- a/mkosi/initrd.py +++ b/mkosi/initrd.py @@ -4,6 +4,7 @@ import argparse import os import platform import shutil +import sys import tempfile from pathlib import Path @@ -55,6 +56,12 @@ def main() -> None: action="store_true", default=False, ) + parser.add_argument( + "--debug-shell", + help="Turn on debugging output", + action="store_true", + default=False, + ) parser.add_argument( "--version", action="version", @@ -82,6 +89,8 @@ def main() -> None: if args.debug: cmdline += ["--debug"] + if args.debug_shell: + cmdline += ["--debug-shell"] if os.getuid() == 0: cmdline += [ @@ -127,7 +136,12 @@ def main() -> None: # Prefer dnf as dnf5 has not yet officially replaced it and there's a much bigger chance that there will be a # populated dnf cache directory. - run(cmdline, env={"MKOSI_DNF": dnf.name} if (dnf := find_binary("dnf", "dnf5")) else {}) + run( + cmdline, + stdin=sys.stdin, + stdout=sys.stdout, + env={"MKOSI_DNF": dnf.name} if (dnf := find_binary("dnf", "dnf5")) else {} + ) if __name__ == "__main__": diff --git a/mkosi/resources/man/mkosi-initrd.md b/mkosi/resources/man/mkosi-initrd.md index 3c4ac4bae..fac7433ca 100644 --- a/mkosi/resources/man/mkosi-initrd.md +++ b/mkosi/resources/man/mkosi-initrd.md @@ -42,6 +42,9 @@ initrds and Unified Kernel Images for the current running system. `--debug=` : Enable additional debugging output. +`--debug-shell=` +: Spawn debug shell in sandbox if a sandboxed command fails. + `--version` : Show package version.