Skip to content

Commit 8b08663

Browse files
committed
mkosi-initrd: add --show-summary/-S
This is quite useful to figure out what configuration is used. (I considered adding an option to allow arbitrary mkosi verbs. But most verbs either don't make sense or don't work. E.g. 'shell' could be potentially useful but it doesn't support cpio atm. So limiting this to 'summary' for now seems OK. Having an easy way to show the config will be useful even if we add a more generic hookup into mkosi later.)
1 parent cf83236 commit 8b08663

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

mkosi/addon.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,13 @@ def main() -> None:
7474
if Path("/etc/kernel/cmdline").exists():
7575
cmdline += ["--kernel-command-line", Path("/etc/kernel/cmdline").read_text()]
7676

77+
if args.show_summary:
78+
cmdline += ["summary"]
79+
7780
run(cmdline, stdin=sys.stdin, stdout=sys.stdout)
7881

79-
initrd_finalize(Path(staging_dir), args.output, args.output_dir)
82+
if not args.show_summary:
83+
initrd_finalize(Path(staging_dir), args.output, args.output_dir)
8084

8185

8286
if __name__ == "__main__":

mkosi/initrd.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,13 @@ def initrd_common_args(parser: argparse.ArgumentParser) -> None:
293293
action="store_true",
294294
default=False,
295295
)
296+
parser.add_argument(
297+
"-S",
298+
"--show-summary",
299+
help="Show the summary of configuration",
300+
action="store_true",
301+
default=False,
302+
)
296303
parser.add_argument(
297304
"--version",
298305
action="version",
@@ -428,6 +435,9 @@ def main() -> None:
428435

429436
cmdline += vconsole_config()
430437

438+
if args.show_summary:
439+
cmdline += ["summary"]
440+
431441
# Resolve dnf binary to determine which version the host uses by default
432442
# (to avoid preferring dnf5 if the host uses dnf4)
433443
# as there's a much bigger chance that it has a populated dnf cache directory.
@@ -438,7 +448,8 @@ def main() -> None:
438448
env=os.environ | ({"MKOSI_DNF": dnf.resolve().name} if (dnf := find_binary("dnf")) else {}),
439449
)
440450

441-
initrd_finalize(Path(staging_dir), args.output, args.output_dir)
451+
if not args.show_summary:
452+
initrd_finalize(Path(staging_dir), args.output, args.output_dir)
442453

443454

444455
if __name__ == "__main__":

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ initrds and Unified Kernel Images for the current running system.
6565
`--show-documentation`, `-D`
6666
: Show the man page for mkosi-initrd.
6767

68+
`--show-summary`, `-S`
69+
: Show the summary of configuration.
70+
6871
`--version`
6972
: Show package version.
7073

0 commit comments

Comments
 (0)