]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
mkosi-initrd: Add --debug-shell argument
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 5 Sep 2024 09:46:22 +0000 (11:46 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 5 Sep 2024 09:46:22 +0000 (11:46 +0200)
This is passed through directly to mkosi. To make this work we also
pass through stdout/stdin directly to the invoked mkosi process.

mkosi/initrd.py
mkosi/resources/man/mkosi-initrd.md

index 5874cfa24613364963424f74235de4cb4c5aa19f..c15fe72a2666859de24697d6c1db89d551baeffd 100644 (file)
@@ -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__":
index 3c4ac4baee813446bdeaf9b6cbe40290c3116882..fac7433ca75a4352b84f15f8fa0aaa669587fae1 100644 (file)
@@ -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.