]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
env: export $EFI_ARCHITECTURE in hook scripts on EFI arches
authorLuca Boccassi <luca.boccassi@gmail.com>
Mon, 28 Jul 2025 11:12:29 +0000 (12:12 +0100)
committerJörg Behrmann <behrmann@physik.fu-berlin.de>
Mon, 28 Jul 2025 15:24:03 +0000 (17:24 +0200)
Saves from having to do the translations manually a bunch of times

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

index 1ebb627c7cb77416a67b3087885eed1fabc5296f..2abd46043b30f6fcafdefc66b5fe956324d31e4c 100644 (file)
@@ -609,6 +609,9 @@ def run_configure_scripts(config: Config) -> Config:
         MKOSI_DEBUG=one_zero(ARG_DEBUG.get()),
     )
 
+    if config.architecture.to_efi() is not None:
+        env["EFI_ARCHITECTURE"] = str(config.architecture.to_efi())
+
     if config.profiles:
         env["PROFILES"] = " ".join(config.profiles)
 
@@ -656,6 +659,9 @@ def run_sync_scripts(config: Config) -> None:
         MKOSI_DEBUG=one_zero(ARG_DEBUG.get()),
     )
 
+    if config.architecture.to_efi() is not None:
+        env["EFI_ARCHITECTURE"] = str(config.architecture.to_efi())
+
     if config.profiles:
         env["PROFILES"] = " ".join(config.profiles)
 
@@ -777,6 +783,9 @@ def run_prepare_scripts(context: Context, build: bool) -> None:
         MKOSI_DEBUG=one_zero(ARG_DEBUG.get()),
     )
 
+    if context.config.architecture.to_efi() is not None:
+        env["EFI_ARCHITECTURE"] = str(context.config.architecture.to_efi())
+
     if context.config.profiles:
         env["PROFILES"] = " ".join(context.config.profiles)
 
@@ -847,6 +856,9 @@ def run_build_scripts(context: Context) -> None:
         MKOSI_DEBUG=one_zero(ARG_DEBUG.get()),
     )
 
+    if context.config.architecture.to_efi() is not None:
+        env["EFI_ARCHITECTURE"] = str(context.config.architecture.to_efi())
+
     if context.config.profiles:
         env["PROFILES"] = " ".join(context.config.profiles)
 
@@ -920,6 +932,9 @@ def run_postinst_scripts(context: Context) -> None:
         MKOSI_DEBUG=one_zero(ARG_DEBUG.get()),
     )
 
+    if context.config.architecture.to_efi() is not None:
+        env["EFI_ARCHITECTURE"] = str(context.config.architecture.to_efi())
+
     if context.config.profiles:
         env["PROFILES"] = " ".join(context.config.profiles)
 
@@ -989,6 +1004,9 @@ def run_finalize_scripts(context: Context) -> None:
         MKOSI_DEBUG=one_zero(ARG_DEBUG.get()),
     )
 
+    if context.config.architecture.to_efi() is not None:
+        env["EFI_ARCHITECTURE"] = str(context.config.architecture.to_efi())
+
     if context.config.profiles:
         env["PROFILES"] = " ".join(context.config.profiles)
 
@@ -1050,6 +1068,9 @@ def run_postoutput_scripts(context: Context) -> None:
         MKOSI_DEBUG=one_zero(ARG_DEBUG.get()),
     )
 
+    if context.config.architecture.to_efi() is not None:
+        env["EFI_ARCHITECTURE"] = str(context.config.architecture.to_efi())
+
     if context.config.profiles:
         env["PROFILES"] = " ".join(context.config.profiles)
 
@@ -4592,6 +4613,9 @@ def run_clean_scripts(config: Config) -> None:
         MKOSI_DEBUG=one_zero(ARG_DEBUG.get()),
     )
 
+    if config.architecture.to_efi() is not None:
+        env["EFI_ARCHITECTURE"] = str(config.architecture.to_efi())
+
     if config.profiles:
         env["PROFILES"] = " ".join(config.profiles)
 
index 207db86243db6d87f58c0859bd0a1a0d05650c54..d08cdc452f4356a379695c4923f246e7f7748dc6 100644 (file)
@@ -2463,6 +2463,10 @@ Scripts executed by **mkosi** receive the following environment variables:
    the format used by **qemu**. Useful for finding the qemu binary (
     `qemu-system-$QEMU_ARCHITECTURE`).
 
+* `$EFI_ARCHITECTURE` contains the architecture from `$ARCHITECTURE` in
+   the format used by **UEFI**. It is unset on architectures that do not
+   support **UEFI**.
+
 * `$DISTRIBUTION` contains the distribution from the `Distribution=` setting.
 
 * `$RELEASE` contains the release from the `Release=` setting.
@@ -2582,6 +2586,7 @@ Consult this table for which script receives which environment variables:
 | `DESTDIR`                   |             |        |           | ✓       |            |            |              |         |
 | `DISTRIBUTION`              | ✓           | ✓      | ✓         | ✓       | ✓          | ✓          | ✓            | ✓       |
 | `DISTRIBUTION_ARCHITECTURE` | ✓           | ✓      | ✓         | ✓       | ✓          | ✓          | ✓            | ✓       |
+| `EFI_ARCHITECTURE`          | ✓           | ✓      | ✓         | ✓       | ✓          | ✓          | ✓            | ✓       |
 | `IMAGE_ID`                  | ✓           | ✓      | ✓         | ✓       | ✓          | ✓          | ✓            | ✓       |
 | `IMAGE_VERSION`             | ✓           | ✓      | ✓         | ✓       | ✓          | ✓          | ✓            | ✓       |
 | `MKOSI_CONFIG`              |             | ✓      | ✓         | ✓       | ✓          | ✓          | ✓            | ✓       |