]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Add support for Azure Linux 2833/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 4 Jul 2024 12:34:17 +0000 (14:34 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 22 Aug 2024 09:47:03 +0000 (11:47 +0200)
Azure Linux looks a lot like Fedora Linux so we opt to share configuration
between Azure and Fedora/CentOS and inherit the Azure definition from
Fedora.

19 files changed:
.github/workflows/ci.yml
mkosi.conf.d/20-azure.conf [new file with mode: 0644]
mkosi.conf.d/20-centos/mkosi.conf
mkosi.conf.d/20-fedora/mkosi.conf
mkosi.conf.d/20-fedora/mkosi.conf.d/20-x86_64.conf
mkosi.conf.d/30-azure-centos-fedora/mkosi.conf [moved from mkosi.conf.d/30-centos-fedora/mkosi.conf with 91% similarity]
mkosi.conf.d/30-azure-centos-fedora/mkosi.conf.d/20-arm64.conf [moved from mkosi.conf.d/30-centos-fedora/mkosi.conf.d/20-arm64.conf with 100% similarity]
mkosi.conf.d/30-azure-centos-fedora/mkosi.conf.d/20-uefi.conf [moved from mkosi.conf.d/30-centos-fedora/mkosi.conf.d/20-uefi.conf with 100% similarity]
mkosi.conf.d/30-azure-centos-fedora/mkosi.conf.d/20-x86-64.conf [moved from mkosi.conf.d/30-centos-fedora/mkosi.conf.d/20-x86-64.conf with 87% similarity]
mkosi/distributions/__init__.py
mkosi/distributions/azure.py [new file with mode: 0644]
mkosi/resources/mkosi-initrd/mkosi.conf.d/10-azure-centos-fedora.conf [moved from mkosi/resources/mkosi-initrd/mkosi.conf.d/10-centos-fedora.conf with 73% similarity]
mkosi/resources/mkosi-initrd/mkosi.conf.d/10-azure.conf [new file with mode: 0644]
mkosi/resources/mkosi-initrd/mkosi.conf.d/10-centos.conf
mkosi/resources/mkosi-initrd/mkosi.conf.d/10-fedora.conf
mkosi/resources/mkosi-tools/mkosi.conf.d/10-azure-centos-fedora/mkosi.conf [moved from mkosi/resources/mkosi-tools/mkosi.conf.d/10-centos-fedora/mkosi.conf with 96% similarity]
mkosi/resources/mkosi-tools/mkosi.conf.d/10-azure-centos-fedora/mkosi.conf.d/10-uefi.conf [moved from mkosi/resources/mkosi-tools/mkosi.conf.d/10-centos-fedora/mkosi.conf.d/10-uefi.conf with 100% similarity]
mkosi/resources/mkosi-tools/mkosi.conf.d/10-azure.conf [new file with mode: 0644]
mkosi/resources/mkosi.md

index 43f2e5c69ac1b6009ee10e27d5978e2bfedc75d2..673a6be6551e823488b12312f3c239eb25b98f50 100644 (file)
@@ -103,6 +103,7 @@ jobs:
           - fedora
           - opensuse
           - ubuntu
+          - azure
         tools:
           - arch
           - debian
diff --git a/mkosi.conf.d/20-azure.conf b/mkosi.conf.d/20-azure.conf
new file mode 100644 (file)
index 0000000..6dc333a
--- /dev/null
@@ -0,0 +1,17 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+[Match]
+Distribution=azure
+
+[Distribution]
+Release=3.0-preview
+
+[Content]
+# The unsigned-shim package tries to install to the same location as the signed shim package so we can't install and
+# test unsigned shim.
+ShimBootloader=none
+Packages=
+        kernel
+        kernel-tools
+        systemd-networkd
+        tpm2-tss
index 504b9396f568216ecdf4be871b9ce242a7c69225..117ef9ba608c33941f9d36a09cc0f67a23e26110 100644 (file)
@@ -12,4 +12,6 @@ Release=9
 # CentOS Stream 10 does not ship an unsigned shim
 ShimBootloader=none
 Packages=
+        kernel-core
         linux-firmware
+        perf
index f9fdf1f671e4172ff1090e35f9b2ae1728552d03..75101a1ee3a7c7a5e6236dea7e7ab777955a08db 100644 (file)
@@ -8,6 +8,8 @@ Release=rawhide
 
 [Content]
 Packages=
+        kernel-core
+        perf
         qemu-user-static
         rpmautospec
         systemd-networkd
index 1ffd9d4e21ab67359746418c9c0c6e2a60d4d1fd..dea16c8ab15449e192dacc59e0b091a667ce383c 100644 (file)
@@ -6,4 +6,5 @@ Architecture=x86-64
 [Content]
 Packages=
         amd-ucode-firmware
+        kernel-uki-virt
         shim-unsigned-x64
similarity index 91%
rename from mkosi.conf.d/30-centos-fedora/mkosi.conf
rename to mkosi.conf.d/30-azure-centos-fedora/mkosi.conf
index 17eb422f632ddd6ac52e9670a677da08c58dd1de..c7fe6e7f1e541c9f129dab92e277e2bd85b6d141 100644 (file)
@@ -5,16 +5,15 @@ Distribution=|centos
 Distribution=|alma
 Distribution=|rocky
 Distribution=|fedora
+Distribution=|azure
 
 [Content]
 Packages=
         bash
         iproute
         iputils
-        kernel-core
         openssh-clients
         openssh-server
-        perf
         polkit
         python3
         rpm-build
similarity index 87%
rename from mkosi.conf.d/30-centos-fedora/mkosi.conf.d/20-x86-64.conf
rename to mkosi.conf.d/30-azure-centos-fedora/mkosi.conf.d/20-x86-64.conf
index f558d660ba1abc1d5b2139a613d7fb69daeeef65..3551c7558b9e9ecbb7909abba02f1891384844ef 100644 (file)
@@ -7,5 +7,4 @@ Architecture=x86-64
 Packages=
         grub2-efi-x64-modules
         grub2-pc
-        kernel-uki-virt
         microcode_ctl
index 5d07b719c5141837d364f63880b1b01de4bf619b..eba9371e8722fa1b71c8e873149394508f38749a 100644 (file)
@@ -87,6 +87,7 @@ class Distribution(StrEnum):
     openmandriva = enum.auto()
     rocky        = enum.auto()
     alma         = enum.auto()
+    azure        = enum.auto()
     custom       = enum.auto()
 
     def is_centos_variant(self) -> bool:
@@ -103,6 +104,7 @@ class Distribution(StrEnum):
 
     def is_rpm_distribution(self) -> bool:
         return self in (
+            Distribution.azure,
             Distribution.fedora,
             Distribution.opensuse,
             Distribution.mageia,
diff --git a/mkosi/distributions/azure.py b/mkosi/distributions/azure.py
new file mode 100644 (file)
index 0000000..17f172c
--- /dev/null
@@ -0,0 +1,97 @@
+# SPDX-License-Identifier: LGPL-2.1+
+
+from collections.abc import Iterable
+
+from mkosi.config import Architecture
+from mkosi.context import Context
+from mkosi.distributions import (
+    fedora,
+    join_mirror,
+)
+from mkosi.installer.dnf import Dnf
+from mkosi.installer.rpm import RpmRepository, find_rpm_gpgkey, setup_rpm
+from mkosi.log import die
+from mkosi.util import listify
+
+
+class Installer(fedora.Installer):
+    @classmethod
+    def pretty_name(cls) -> str:
+        return "Azure Linux"
+
+    @classmethod
+    def default_release(cls) -> str:
+        return "3.0-prod"
+
+    @classmethod
+    def filesystem(cls) -> str:
+        return "ext4"
+
+    @classmethod
+    def setup(cls, context: Context) -> None:
+        Dnf.setup(context, cls.repositories(context), filelists=False)
+        setup_rpm(context, dbpath="/var/lib/rpm")
+
+    @classmethod
+    def install(cls, context: Context) -> None:
+        cls.install_packages(context, ["filesystem", "azurelinux-release"], apivfs=False)
+
+    @classmethod
+    @listify
+    def repositories(cls, context: Context) -> Iterable[RpmRepository]:
+        gpgurls = (
+            find_rpm_gpgkey(
+                context,
+                "MICROSOFT-RPM-GPG-KEY",
+                "https://raw.githubusercontent.com/rpm-software-management/distribution-gpg-keys/main/keys/azure-linux/MICROSOFT-RPM-GPG-KEY",
+            ),
+        )
+
+        if context.config.local_mirror:
+            yield RpmRepository("base", f"baseurl={context.config.local_mirror}", gpgurls)
+            return
+
+        mirror = context.config.mirror or "https://packages.microsoft.com/azurelinux"
+
+        if any(context.config.release.endswith(f"-{suffix}") for suffix in ("prod", "preview")):
+            rel = context.config.release
+        else:
+            rel = f"{context.config.release}-prod"
+
+        url = join_mirror(mirror, rel.replace("-", "/"))
+
+        nvidia = "nvidia" if rel.endswith("-prod") else "NVIDIA"
+        for repo in ("base", "extended", "ms-oss", "ms-non-oss", "cloud-native", nvidia):
+            yield RpmRepository(
+                repo,
+                f"baseurl={url}/{repo}/$basearch",
+                gpgurls,
+            )
+
+        for repo in ("base", "cloud-native", "extended"):
+            yield RpmRepository(
+                f"{repo}-debuginfo",
+                f"baseurl={url}/{repo}/debuginfo/$basearch",
+                gpgurls,
+                enabled=False,
+            )
+
+        for repo in ("base", "cloud-native", "extended", "ms-oss"):
+            yield RpmRepository(
+                f"{repo}-source",
+                f"baseurl={url}/{repo}/srpms",
+                gpgurls,
+                enabled=False,
+            )
+
+    @classmethod
+    def architecture(cls, arch: Architecture) -> str:
+        a = {
+            Architecture.arm64  : "aarch64",
+            Architecture.x86_64 : "x86_64",
+        }.get(arch)
+
+        if not a:
+            die(f"Architecture {a} is not supported by {cls.pretty_name()}")
+
+        return a
similarity index 73%
rename from mkosi/resources/mkosi-initrd/mkosi.conf.d/10-centos-fedora.conf
rename to mkosi/resources/mkosi-initrd/mkosi.conf.d/10-azure-centos-fedora.conf
index cd588162a0b5d50662f04f966bdc9b11e4960813..2cd18b74aa11a4a5a7088c2f735ed5ced435dbc6 100644 (file)
@@ -6,11 +6,11 @@ Distribution=|centos
 Distribution=|alma
 Distribution=|rocky
 Distribution=|rhel
+Distribution=|azure
 
 [Content]
 Packages=
         # Various libraries that are dlopen'ed by systemd
-        libfido2
         tpm2-tss
 
         # File system checkers for supported root file systems
@@ -18,7 +18,3 @@ Packages=
         xfsprogs
 
         # fsck.btrfs is a dummy, checking is done in the kernel.
-
-RemovePackages=
-        # Various packages pull in shadow-utils to create users, we can remove it afterwards
-        shadow-utils
diff --git a/mkosi/resources/mkosi-initrd/mkosi.conf.d/10-azure.conf b/mkosi/resources/mkosi-initrd/mkosi.conf.d/10-azure.conf
new file mode 100644 (file)
index 0000000..d591fbc
--- /dev/null
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+[Match]
+Distribution=azure
+
+[Content]
+Packages=
+        util-linux
index eda3177aca571c20a0f2e03c25167277e9ab7c0a..5b25c7e41a127f97c90166d31506b6dc9654d2da 100644 (file)
@@ -8,4 +8,9 @@ Distribution=|rhel
 
 [Content]
 Packages=
+        libfido2
         util-linux
+
+RemovePackages=
+        # Various packages pull in shadow-utils to create users, we can remove it afterwards
+        shadow-utils
index b1b77e210da6f7e3c2f60b699638f99e48153598..228a0ec87169a79f2ba9a217e848ff45891ab8b7 100644 (file)
@@ -5,4 +5,9 @@ Distribution=fedora
 
 [Content]
 Packages=
+        libfido2
         util-linux-core
+
+RemovePackages=
+        # Various packages pull in shadow-utils to create users, we can remove it afterwards
+        shadow-utils
similarity index 96%
rename from mkosi/resources/mkosi-tools/mkosi.conf.d/10-centos-fedora/mkosi.conf
rename to mkosi/resources/mkosi-tools/mkosi.conf.d/10-azure-centos-fedora/mkosi.conf
index dc1e4913c2452248f5d6febd5291010a6c052d3a..b860c9314c6ad1fd31f7ad6a3c6d2f4ce1ab0d8a 100644 (file)
@@ -6,6 +6,7 @@ Distribution=|alma
 Distribution=|rocky
 Distribution=|rhel
 Distribution=|fedora
+Distribution=|azure
 
 [Content]
 Packages=
diff --git a/mkosi/resources/mkosi-tools/mkosi.conf.d/10-azure.conf b/mkosi/resources/mkosi-tools/mkosi.conf.d/10-azure.conf
new file mode 100644 (file)
index 0000000..6d86676
--- /dev/null
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+[Match]
+Distribution=azure
+
+[Content]
+Packages=
+        btrfs-progs
+        distribution-gpg-keys
+        dnf5
+        dnf5-plugins
+        erofs-utils
+        qemu-system-aarch64-core
+        qemu-system-s390x-core
+        systemd-ukify
index b13b479216071195f8564515c2f92d57b471fd47..852b9081bee340daf7be8b4e1ff41ff78165d410 100644 (file)
@@ -394,8 +394,8 @@ boolean argument: either `1`, `yes`, or `true` to enable, or `0`, `no`,
 :   The distribution to install in the image. Takes one of the following
     arguments: `fedora`, `debian`, `kali`, `ubuntu`, `arch`, `opensuse`,
     `mageia`, `centos`, `rhel`, `rhel-ubi`, `openmandriva`, `rocky`, `alma`,
-    `custom`. If not specified, defaults to the distribution of the host
-    or `custom` if the distribution of the host is not a supported
+    `azure` or `custom`. If not specified, defaults to the distribution of
+    the host or `custom` if the distribution of the host is not a supported
     distribution.
 
 `Release=`, `--release=`, `-r`
@@ -441,6 +441,7 @@ boolean argument: either `1`, `yes`, or `true` to enable, or `0`, `no`,
     | `rhel-ubi`     | https://cdn-ubi.redhat.com        |                                |
     | `mageia`       | https://www.mageia.org            |                                |
     | `openmandriva` | http://mirrors.openmandriva.org   |                                |
+    | `azure`        | https://packages.microsoft.com/   |                                |
 
 `LocalMirror=`, `--local-mirror=`
 :   The mirror will be used as a local, plain and direct mirror instead
@@ -1918,6 +1919,8 @@ distributions:
 
 * *Alma Linux*
 
+* *Azure Linux*
+
 * *None* (**Requires the user to provide a pre-built rootfs**)
 
 In theory, any distribution may be used on the host for building images