]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Pass command line arguments to build script again 1926/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 26 Sep 2023 08:55:48 +0000 (10:55 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 26 Sep 2023 09:26:22 +0000 (11:26 +0200)
It turns out this can be useful after all, for example to specify
whether to build in debug mode or release mode, or which config to
use when building kernels, so let's pass arguments to the build
script again.

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

index fdd82b4a39fdf28ee6f7db45a5dae28cfdaef6bf..f640f637b2c009a4a83da4c2bddaa74caa0a1977 100644 (file)
@@ -360,7 +360,7 @@ def run_build_script(state: MkosiState) -> None:
          mount_build_overlay(state),\
          mount_passwd(state.name, state.uid, state.gid, state.root):
         bwrap(
-            [state.config.build_script],
+            [state.config.build_script, *(state.args.cmdline if state.args.verb == Verb.build else [])],
             network=state.config.with_network,
             readonly=True,
             options=finalize_mounts(state.config),
index 7c9f81872b05e00c70dd3a69cd740d4d0e7688d9..f4679d3f86f464cb922bcdd3362a2738bd9706c0 100644 (file)
@@ -60,7 +60,7 @@ class Verb(StrEnum):
     documentation = enum.auto()
 
     def supports_cmdline(self) -> bool:
-        return self in (Verb.shell, Verb.boot, Verb.qemu, Verb.ssh)
+        return self in (Verb.build, Verb.shell, Verb.boot, Verb.qemu, Verb.ssh)
 
     def needs_build(self) -> bool:
         return self in (Verb.build, Verb.shell, Verb.boot, Verb.qemu, Verb.serve)
@@ -1752,7 +1752,7 @@ def create_argument_parser() -> argparse.ArgumentParser:
         # the synopsis below is supposed to be indented by two spaces
         usage="\n  " + textwrap.dedent("""\
               mkosi [options...] {b}summary{e}
-                mkosi [options...] {b}build{e}
+                mkosi [options...] {b}build{e} [command line...]
                 mkosi [options...] {b}shell{e} [command line...]
                 mkosi [options...] {b}boot{e}  [nspawn settings...]
                 mkosi [options...] {b}qemu{e}  [qemu parameters...]
index 8b88c28a487847703003c4c5b39ede4b615928e2..1c8f6089b50fbb663d29ca7c76b33007464e917c 100644 (file)
@@ -10,7 +10,7 @@ mkosi — Build Bespoke OS Images
 
 `mkosi [options…] summary`
 
-`mkosi [options…] build`
+`mkosi [options…] build [command line…]`
 
 `mkosi [options…] shell [command line…]`
 
@@ -51,9 +51,11 @@ The following command line verbs are known:
 
 `build`
 
-: This builds the image based on the settings passed in on the command line or
-  read from configuration files. This command is the default if no verb is
-  explicitly specified.
+: This builds the image based on the settings passed in on the command
+  line or read from configuration files. This command is the default if
+  no verb is explicitly specified. If any command line arguments are
+  specified, these are passed directly to the build script if one is
+  defined.
 
 `shell`