]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Compression improvements for apt distributions
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 13 Feb 2024 15:05:04 +0000 (16:05 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 13 Feb 2024 15:43:02 +0000 (16:43 +0100)
Focal's kernel does not support zstd compression so let's make sure
we use xz there, just like we do for CentOS 8 Stream.

In Debian testing and sid, kernel modules are compressed now so let's
stop compressing the kernel modules initrd on those releases.

mkosi/__init__.py
mkosi/config.py

index fd00c4547f2e042a748a1cae18edcf28ea78121d..bfca5eb83d21aec0f3fd9534dc581b786a86a36f 100644 (file)
@@ -1678,11 +1678,20 @@ def build_kernel_modules_initrd(context: Context, kver: str) -> Path:
         sandbox=context.sandbox,
     )
 
-    # Debian/Ubuntu do not compress their kernel modules, so we compress the initramfs instead. Note that
-    # this is not ideal since the compressed kernel modules will all be decompressed on boot which
-    # requires significant memory.
+
     if context.config.distribution.is_apt_distribution():
-        maybe_compress(context, Compression.zstd, kmods, kmods)
+        # Ubuntu Focal's kernel does not support zstd-compressed initrds so use xz instead.
+        if context.config.distribution == Distribution.ubuntu and context.config.release == "focal":
+            compression = Compression.xz
+        # Older Debian and Ubuntu releases do not compress their kernel modules, so we compress the initramfs instead.
+        # Note that this is not ideal since the compressed kernel modules will all be decompressed on boot which
+        # requires significant memory.
+        elif context.config.distribution == Distribution.debian and context.config.release in ("sid", "testing"):
+            compression = Compression.none
+        else:
+            compression = Compression.zstd
+
+        maybe_compress(context, compression, kmods, kmods)
 
     return kmods
 
index 495c4236629d3ce04047cabc8620bfcc53a79d35..e7eeb52052afc2cc952835e6f0692e63d3b1e7fe 100644 (file)
@@ -576,7 +576,10 @@ def config_parse_compress_level(value: Optional[str], old: Optional[int]) -> Opt
 
 def config_default_compression(namespace: argparse.Namespace) -> Compression:
     if namespace.output_format in (OutputFormat.tar, OutputFormat.cpio, OutputFormat.uki, OutputFormat.esp):
-        if namespace.distribution.is_centos_variant() and int(namespace.release) <= 8:
+        if (
+            (namespace.distribution.is_centos_variant() and int(namespace.release) <= 8) or
+            (namespace.distribution == Distribution.ubuntu and namespace.release == "focal")
+        ):
             return Compression.xz
         else:
             return Compression.zstd