Skip to content

Commit

Permalink
Set $PROFILE to the current profile
Browse files Browse the repository at this point in the history
  • Loading branch information
DaanDeMeyer committed Mar 14, 2024
1 parent bd645c7 commit 7ff9ad0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
15 changes: 15 additions & 0 deletions mkosi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions mkosi/resources/mkosi.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 |
Expand Down

0 comments on commit 7ff9ad0

Please sign in to comment.