]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Set $PROFILE to the current profile
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 14 Mar 2024 08:40:58 +0000 (09:40 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 14 Mar 2024 09:25:33 +0000 (10:25 +0100)
mkosi/__init__.py
mkosi/resources/mkosi.md

index 8041821426b80564305b33e42b80b911455be79e..3fb13b71a9abac92ba65268440ca0a2e62f00a75 100644 (file)
@@ -436,6 +436,9 @@ def run_sync_scripts(context: Context) -> None:
         CACHED=one_zero(have_cache(context.config)),
     )
 
+    if context.config.profile:
+        env["PROFILE"] = context.config.profile
+
     # We make sure to mount everything in to make ssh work since syncing might involve git which could invoke ssh.
     if agent := os.getenv("SSH_AUTH_SOCK"):
         env["SSH_AUTH_SOCK"] = agent
@@ -494,6 +497,9 @@ def run_prepare_scripts(context: Context, build: bool) -> None:
         WITH_TESTS=one_zero(context.config.with_tests),
     )
 
+    if context.config.profile:
+        env["PROFILE"] = context.config.profile
+
     with (
         mount_build_overlay(context) if build else contextlib.nullcontext(),
         finalize_chroot_scripts(context) as cd,
@@ -565,6 +571,9 @@ def run_build_scripts(context: Context) -> None:
         WITH_TESTS=one_zero(context.config.with_tests),
     )
 
+    if context.config.profile:
+        env["PROFILE"] = context.config.profile
+
     if context.config.build_dir is not None:
         env |= dict(
             BUILDDIR="/work/build",
@@ -643,6 +652,9 @@ def run_postinst_scripts(context: Context) -> None:
         MKOSI_CONFIG="/work/config.json",
     )
 
+    if context.config.profile:
+        env["PROFILE"] = context.config.profile
+
     with (
         finalize_chroot_scripts(context) as cd,
         finalize_source_mounts(context.config, ephemeral=context.config.build_sources_ephemeral) as sources,
@@ -702,6 +714,9 @@ def run_finalize_scripts(context: Context) -> None:
         MKOSI_CONFIG="/work/config.json",
     )
 
+    if context.config.profile:
+        env["PROFILE"] = context.config.profile
+
     with (
         finalize_chroot_scripts(context) as cd,
         finalize_source_mounts(context.config, ephemeral=context.config.build_sources_ephemeral) as sources,
index bf7294d244134e68db3edbbe7cde0a427cf8feff..a6916d736c0ce063993388cdad7a006f262a08ed 100644 (file)
@@ -1967,6 +1967,8 @@ Scripts executed by mkosi receive the following environment variables:
 
 * `$RELEASE` contains the release from the `Release=` setting.
 
+* `$PROFILE` contains the profile from the `Profile=` setting.
+
 * `$CACHED=` is set to `1` if a cached image is available, `0` otherwise.
 
 * `$CHROOT_SCRIPT` contains the path to the running script relative to
@@ -2041,6 +2043,7 @@ Consult this table for which script receives which environment variables:
 | `ARCHITECTURE`      | X            | X               | X             | X                | X                |
 | `DISTRIBUTION`      | X            | X               | X             | X                | X                |
 | `RELEASE`           | X            | X               | X             | X                | X                |
+| `PROFILE`           | X            | X               | X             | X                | X                |
 | `CACHED`            | X            |                 |               |                  |                  |
 | `CHROOT_SCRIPT`     |              | X               | X             | X                | X                |
 | `SRCDIR`            | X            | X               | X             | X                | X                |