From: Daan De Meyer Date: Sun, 14 Jul 2024 14:51:53 +0000 (+0200) Subject: Add DISTRIBUTION_ARCHITECTURE environment variable X-Git-Tag: v24~35^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2868%2Fhead;p=thirdparty%2Fmkosi.git Add DISTRIBUTION_ARCHITECTURE environment variable --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 23c9dad37..77791c9ed 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -436,6 +436,7 @@ def run_configure_scripts(config: Config) -> Config: RELEASE=config.release, ARCHITECTURE=str(config.architecture), QEMU_ARCHITECTURE=config.architecture.to_qemu(), + DISTRIBUTION_ARCHITECTURE=config.distribution.architecture(config.architecture), SRCDIR="/work/src", MKOSI_UID=str(INVOKING_USER.uid), MKOSI_GID=str(INVOKING_USER.gid), @@ -473,6 +474,7 @@ def run_sync_scripts(context: Context) -> None: DISTRIBUTION=str(context.config.distribution), RELEASE=context.config.release, ARCHITECTURE=str(context.config.architecture), + DISTRIBUTION_ARCHITECTURE=context.config.distribution.architecture(context.config.architecture), SRCDIR="/work/src", MKOSI_UID=str(INVOKING_USER.uid), MKOSI_GID=str(INVOKING_USER.gid), @@ -533,6 +535,7 @@ def run_prepare_scripts(context: Context, build: bool) -> None: DISTRIBUTION=str(context.config.distribution), RELEASE=context.config.release, ARCHITECTURE=str(context.config.architecture), + DISTRIBUTION_ARCHITECTURE=context.config.distribution.architecture(context.config.architecture), BUILDROOT="/buildroot", SRCDIR="/work/src", CHROOT_SRCDIR="/work/src", @@ -617,6 +620,7 @@ def run_build_scripts(context: Context) -> None: DISTRIBUTION=str(context.config.distribution), RELEASE=context.config.release, ARCHITECTURE=str(context.config.architecture), + DISTRIBUTION_ARCHITECTURE=context.config.distribution.architecture(context.config.architecture), BUILDROOT="/buildroot", DESTDIR="/work/dest", CHROOT_DESTDIR="/work/dest", @@ -705,6 +709,7 @@ def run_postinst_scripts(context: Context) -> None: DISTRIBUTION=str(context.config.distribution), RELEASE=context.config.release, ARCHITECTURE=str(context.config.architecture), + DISTRIBUTION_ARCHITECTURE=context.config.distribution.architecture(context.config.architecture), BUILDROOT="/buildroot", OUTPUTDIR="/work/out", CHROOT_OUTPUTDIR="/work/out", @@ -782,6 +787,7 @@ def run_finalize_scripts(context: Context) -> None: DISTRIBUTION=str(context.config.distribution), RELEASE=context.config.release, ARCHITECTURE=str(context.config.architecture), + DISTRIBUTION_ARCHITECTURE=context.config.distribution.architecture(context.config.architecture), BUILDROOT="/buildroot", OUTPUTDIR="/work/out", CHROOT_OUTPUTDIR="/work/out", @@ -857,6 +863,7 @@ def run_postoutput_scripts(context: Context) -> None: DISTRIBUTION=str(context.config.distribution), RELEASE=context.config.release, ARCHITECTURE=str(context.config.architecture), + DISTRIBUTION_ARCHITECTURE=context.config.distribution.architecture(context.config.architecture), SRCDIR="/work/src", OUTPUTDIR="/work/out", MKOSI_UID=str(INVOKING_USER.uid), @@ -4483,6 +4490,7 @@ def run_clean_scripts(config: Config) -> None: DISTRIBUTION=str(config.distribution), RELEASE=config.release, ARCHITECTURE=str(config.architecture), + DISTRIBUTION_ARCHITECTURE=config.distribution.architecture(config.architecture), SRCDIR="/work/src", OUTPUTDIR="/work/out", MKOSI_UID=str(INVOKING_USER.uid), diff --git a/mkosi/resources/mkosi.md b/mkosi/resources/mkosi.md index 8606f7ca1..274ca206d 100644 --- a/mkosi/resources/mkosi.md +++ b/mkosi/resources/mkosi.md @@ -2085,6 +2085,9 @@ Scripts executed by mkosi receive the following environment variables: * `$RELEASE` contains the release from the `Release=` setting. +* `$DISTRIBUTION_ARCHITECTURE` contains the architecture from + `$ARCHITECTURE` in the format used by the configured distribution. + * `$PROFILE` contains the profile from the `Profile=` setting. * `$CACHED=` is set to `1` if a cached image is available, `0` otherwise. @@ -2176,33 +2179,34 @@ Scripts executed by mkosi receive the following environment variables: Consult this table for which script receives which environment variables: -| Variable | `configure` | `sync` | `prepare` | `build` | `postinst` | `finalize` | `postoutput` | `clean` | -|---------------------|:-----------:|:------:|:---------:|:-------:|:----------:|:----------:|:------------:|:-------:| -| `ARCHITECTURE` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| `QEMU_ARCHITECTURE` | ✓ | | | | | | | | -| `DISTRIBUTION` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| `RELEASE` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| `PROFILE` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | ✓ | -| `CACHED` | | ✓ | | | | | | | -| `CHROOT_SCRIPT` | | | ✓ | ✓ | ✓ | ✓ | | | -| `SRCDIR` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| `CHROOT_SRCDIR` | | | ✓ | ✓ | ✓ | ✓ | | | -| `BUILDDIR` | | | ✓ | ✓ | ✓ | ✓ | | | -| `CHROOT_BUILDDIR` | | | | ✓ | | | | | -| `DESTDIR` | | | | ✓ | | | | | -| `CHROOT_DESTDIR` | | | | ✓ | | | | | -| `OUTPUTDIR` | | | | ✓ | ✓ | ✓ | ✓ | ✓ | -| `CHROOT_OUTPUTDIR` | | | | ✓ | ✓ | ✓ | | | -| `BUILDROOT` | | | ✓ | ✓ | ✓ | ✓ | | | -| `PACKAGEDIR` | | | ✓ | ✓ | ✓ | ✓ | | | -| `ARTIFACTDIR` | | | ✓ | ✓ | ✓ | ✓ | | | -| `WITH_DOCS` | | | ✓ | ✓ | | | | | -| `WITH_TESTS` | | | ✓ | ✓ | | | | | -| `WITH_NETWORK` | | | ✓ | ✓ | ✓ | ✓ | | | -| `SOURCE_DATE_EPOCH` | | | ✓ | ✓ | ✓ | ✓ | | ✓ | -| `MKOSI_UID` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| `MKOSI_GID` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| `MKOSI_CONFIG` | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | +| Variable | `configure` | `sync` | `prepare` | `build` | `postinst` | `finalize` | `postoutput` | `clean` | +|-----------------------------|:-----------:|:------:|:---------:|:-------:|:----------:|:----------:|:------------:|:-------:| +| `ARCHITECTURE` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | +| `QEMU_ARCHITECTURE` | ✓ | | | | | | | | +| `DISTRIBUTION` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | +| `DISTRIBUTION_ARCHITECTURE` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | +| `RELEASE` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | +| `PROFILE` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | ✓ | +| `CACHED` | | ✓ | | | | | | | +| `CHROOT_SCRIPT` | | | ✓ | ✓ | ✓ | ✓ | | | +| `SRCDIR` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | +| `CHROOT_SRCDIR` | | | ✓ | ✓ | ✓ | ✓ | | | +| `BUILDDIR` | | | ✓ | ✓ | ✓ | ✓ | | | +| `CHROOT_BUILDDIR` | | | | ✓ | | | | | +| `DESTDIR` | | | | ✓ | | | | | +| `CHROOT_DESTDIR` | | | | ✓ | | | | | +| `OUTPUTDIR` | | | | ✓ | ✓ | ✓ | ✓ | ✓ | +| `CHROOT_OUTPUTDIR` | | | | ✓ | ✓ | ✓ | | | +| `BUILDROOT` | | | ✓ | ✓ | ✓ | ✓ | | | +| `PACKAGEDIR` | | | ✓ | ✓ | ✓ | ✓ | | | +| `ARTIFACTDIR` | | | ✓ | ✓ | ✓ | ✓ | | | +| `WITH_DOCS` | | | ✓ | ✓ | | | | | +| `WITH_TESTS` | | | ✓ | ✓ | | | | | +| `WITH_NETWORK` | | | ✓ | ✓ | ✓ | ✓ | | | +| `SOURCE_DATE_EPOCH` | | | ✓ | ✓ | ✓ | ✓ | | ✓ | +| `MKOSI_UID` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | +| `MKOSI_GID` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | +| `MKOSI_CONFIG` | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | Additionally, when a script is executed, a few scripts are made available via `$PATH` to simplify common usecases.