From: Daan De Meyer Date: Fri, 7 Jun 2024 12:00:13 +0000 (+0200) Subject: Add dependencies verb X-Git-Tag: v23.1~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=81ce4b1876d02253047f78a14b1dbce9a1ab0dda;p=thirdparty%2Fmkosi.git Add dependencies verb Fixes #2529 --- diff --git a/NEWS.md b/NEWS.md index b3e2f3110..c544bab1c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -113,6 +113,8 @@ respectively. - `KernelModulesIncludeHost=` and `KernelModulesInitrdIncludeHost=` are now deprecated. +- Added `mkosi dependencies` to output the list of packages required by + mkosi to build and boot images. ## v22 diff --git a/mkosi/__init__.py b/mkosi/__init__.py index fbaab7405..f73ae342e 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -4593,6 +4593,14 @@ def run_verb(args: Args, images: Sequence[Config], *, resources: Path) -> None: if args.verb == Verb.bump: return bump_image_version() + if args.verb == Verb.dependencies: + _, [deps] = parse_config(["--directory", "", "--include=mkosi-tools", "build"], resources=resources) + + for p in deps.packages: + print(p) + + return + if all(config == Config.default() for config in images): die("No configuration found", hint="Make sure you're running mkosi from a directory with configuration files") diff --git a/mkosi/config.py b/mkosi/config.py index 565225592..534eb0f3e 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -74,6 +74,7 @@ class Verb(StrEnum): journalctl = enum.auto() coredumpctl = enum.auto() burn = enum.auto() + dependencies = enum.auto() def supports_cmdline(self) -> bool: return self in ( diff --git a/mkosi/resources/mkosi.md b/mkosi/resources/mkosi.md index e6418e4a0..1bab91802 100644 --- a/mkosi/resources/mkosi.md +++ b/mkosi/resources/mkosi.md @@ -36,6 +36,8 @@ mkosi — Build Bespoke OS Images `mkosi [options…] documentation` +`mkosi [options…] dependencies` + `mkosi [options…] help` # DESCRIPTION @@ -160,6 +162,18 @@ The following command line verbs are known: markdown file `mkosi/resources/mkosi.md` e.g via `pandoc -t man -s -o mkosi.1 mkosi.md`. +`dependencies` +: Output the list of packages required by mkosi to build and boot + images. + + This list can be piped directly to a package manager to install the + packages. For example, if the host system uses the dnf package + manager, the packages could be installed as follows: + + ```sh + mkosi dependencies | xargs -d '\n' dnf install + ``` + `help` : This verb is equivalent to the `--help` switch documented below: it shows a brief usage explanation.