]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
mkosi: pass DEBUG enviroment variable to scripts 3634/head
authorAntonio Alvarez Feijoo <antonio.feijoo@suse.com>
Fri, 28 Mar 2025 14:53:10 +0000 (15:53 +0100)
committerAntonio Alvarez Feijoo <antonio.feijoo@suse.com>
Fri, 28 Mar 2025 14:53:10 +0000 (15:53 +0100)
So scripts can run debugging code if mkosi is running with `--debug`.

mkosi/__init__.py
mkosi/resources/man/mkosi.1.md

index dc01dbd0650f14ac2bf7ef488afbee71c0222a62..4493d7bd3e80c15f783be007482b80e502920c06 100644 (file)
@@ -599,6 +599,7 @@ def run_configure_scripts(config: Config) -> Config:
         SRCDIR="/work/src",
         MKOSI_UID=str(os.getuid()),
         MKOSI_GID=str(os.getgid()),
+        DEBUG=one_zero(ARG_DEBUG.get()),
     )
 
     if config.profiles:
@@ -641,6 +642,7 @@ def run_sync_scripts(config: Config) -> None:
         MKOSI_GID=str(os.getgid()),
         MKOSI_CONFIG="/work/config.json",
         CACHED=one_zero(have_cache(config)),
+        DEBUG=one_zero(ARG_DEBUG.get()),
     )
 
     if config.profiles:
@@ -761,6 +763,7 @@ def run_prepare_scripts(context: Context, build: bool) -> None:
         WITH_DOCS=one_zero(context.config.with_docs),
         WITH_NETWORK=one_zero(context.config.with_network),
         WITH_TESTS=one_zero(context.config.with_tests),
+        DEBUG=one_zero(ARG_DEBUG.get()),
     )
 
     if context.config.profiles:
@@ -830,6 +833,7 @@ def run_build_scripts(context: Context) -> None:
         WITH_DOCS=one_zero(context.config.with_docs),
         WITH_NETWORK=one_zero(context.config.with_network),
         WITH_TESTS=one_zero(context.config.with_tests),
+        DEBUG=one_zero(ARG_DEBUG.get()),
     )
 
     if context.config.profiles:
@@ -902,6 +906,7 @@ def run_postinst_scripts(context: Context) -> None:
         MKOSI_GID=str(os.getgid()),
         MKOSI_CONFIG="/work/config.json",
         WITH_NETWORK=one_zero(context.config.with_network),
+        DEBUG=one_zero(ARG_DEBUG.get()),
     )
 
     if context.config.profiles:
@@ -970,6 +975,7 @@ def run_finalize_scripts(context: Context) -> None:
         MKOSI_GID=str(os.getgid()),
         MKOSI_CONFIG="/work/config.json",
         WITH_NETWORK=one_zero(context.config.with_network),
+        DEBUG=one_zero(ARG_DEBUG.get()),
     )
 
     if context.config.profiles:
@@ -1030,6 +1036,7 @@ def run_postoutput_scripts(context: Context) -> None:
         MKOSI_UID=str(os.getuid()),
         MKOSI_GID=str(os.getgid()),
         MKOSI_CONFIG="/work/config.json",
+        DEBUG=one_zero(ARG_DEBUG.get()),
     )
 
     if context.config.profiles:
@@ -4587,6 +4594,7 @@ def run_clean_scripts(config: Config) -> None:
         MKOSI_UID=str(os.getuid()),
         MKOSI_GID=str(os.getgid()),
         MKOSI_CONFIG="/work/config.json",
+        DEBUG=one_zero(ARG_DEBUG.get()),
     )
 
     if config.profiles:
index 9c9425ba461bf68f876dd4e938976b1b4a6cdba6..30396a725324d3de14b8ec7335ac4862de9907aa 100644 (file)
@@ -2579,6 +2579,9 @@ Scripts executed by **mkosi** receive the following environment variables:
 
 * `$IMAGE_VERSION` contains the version from the `ImageVersion=` or `--image-version=` setting.
 
+* `$DEBUG` is either `0` or `1` depending on whether debugging output is
+  enabled.
+
 Consult this table for which script receives which environment variables:
 
 | Variable                    | `configure` | `sync` | `prepare` | `build` | `postinst` | `finalize` | `postoutput` | `clean` |
@@ -2593,6 +2596,7 @@ Consult this table for which script receives which environment variables:
 | `CHROOT_OUTPUTDIR`          |             |        |           |         | ✓          | ✓          |              |         |
 | `CHROOT_SCRIPT`             |             |        | ✓         | ✓       | ✓          | ✓          |              |         |
 | `CHROOT_SRCDIR`             |             |        | ✓         | ✓       | ✓          | ✓          |              |         |
+| `DEBUG`                     | ✓           | ✓      | ✓         | ✓       | ✓          | ✓          | ✓            | ✓       |
 | `DESTDIR`                   |             |        |           | ✓       |            |            |              |         |
 | `DISTRIBUTION`              | ✓           | ✓      | ✓         | ✓       | ✓          | ✓          | ✓            | ✓       |
 | `DISTRIBUTION_ARCHITECTURE` | ✓           | ✓      | ✓         | ✓       | ✓          | ✓          | ✓            | ✓       |