From 8a5e6282b2bcd2d9d12a6418f9a5f004ca15a13a Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Tue, 26 Sep 2023 10:55:48 +0200 Subject: [PATCH] Pass command line arguments to build script again 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 | 2 +- mkosi/config.py | 4 ++-- mkosi/resources/mkosi.md | 10 ++++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/mkosi/__init__.py b/mkosi/__init__.py index fdd82b4a3..f640f637b 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -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), diff --git a/mkosi/config.py b/mkosi/config.py index 7c9f81872..f4679d3f8 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -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...] diff --git a/mkosi/resources/mkosi.md b/mkosi/resources/mkosi.md index 8b88c28a4..1c8f6089b 100644 --- a/mkosi/resources/mkosi.md +++ b/mkosi/resources/mkosi.md @@ -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` -- 2.47.2