From: Daan De Meyer Date: Thu, 14 Mar 2024 08:40:58 +0000 (+0100) Subject: Set $PROFILE to the current profile X-Git-Tag: v22~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ff9ad04d7a0fc16e1389eaed4ee77bd254d3070;p=thirdparty%2Fmkosi.git Set $PROFILE to the current profile --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 804182142..3fb13b71a 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -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, diff --git a/mkosi/resources/mkosi.md b/mkosi/resources/mkosi.md index bf7294d24..a6916d736 100644 --- a/mkosi/resources/mkosi.md +++ b/mkosi/resources/mkosi.md @@ -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 |