]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Add dependencies verb
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 7 Jun 2024 12:00:13 +0000 (14:00 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 7 Jun 2024 12:35:12 +0000 (14:35 +0200)
Fixes #2529

NEWS.md
mkosi/__init__.py
mkosi/config.py
mkosi/resources/mkosi.md

diff --git a/NEWS.md b/NEWS.md
index b3e2f311011157ce67857e7bdf171be689950556..c544bab1cf07c67dc3f5ce1de758c4debb79b984 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
   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
 
index fbaab7405bda1db32658e27e618ed5ab2c76bbb6..f73ae342ea0a9eece07eb33104085fbb390da7c9 100644 (file)
@@ -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")
index 5652255920aa615a0efa21c6c0fc51f26d0d4099..534eb0f3e461d5f13364c608f4762302ba958035 100644 (file)
@@ -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 (
index e6418e4a00e1ddfabeadc1279c72604323c6cad4..1bab918024f5f9d7d3de95a2e7b638045a539578 100644 (file)
@@ -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.