From: Daan De Meyer Date: Tue, 13 Feb 2024 15:05:04 +0000 (+0100) Subject: Compression improvements for apt distributions X-Git-Tag: v21~56^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=71f44ea23889311e16a176ec0299e91aeb9be75f;p=thirdparty%2Fmkosi.git Compression improvements for apt distributions 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. --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index fd00c4547..bfca5eb83 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -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 diff --git a/mkosi/config.py b/mkosi/config.py index 495c42366..e7eeb5205 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -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