From 91bf61df652d13fac6d788a88d42ef50ca568972 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 5 Jan 2023 00:21:53 +0100 Subject: [PATCH] Split modules into separate sub-package Move modules to kernel-modules package, build modules.img in %post of kernel-qubes-vm package, using qubes-prepare-vm-kernel. Fixes QubesOS/qubes-issues#7969 (cherry picked from commit a41e019c4dd7229932d02f1fca877da9ed7c05be) --- kernel.spec.in | 68 ++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/kernel.spec.in b/kernel.spec.in index fbaed945..5d27c3e7 100644 --- a/kernel.spec.in +++ b/kernel.spec.in @@ -94,6 +94,7 @@ Provides: kernel-drm-nouveau = 16 Provides: kernel-modules-extra = %kernelrelease Provides: kernel-modeset = 1 +Requires: %name-modules = %kernelrelease Requires(pre): coreutils gawk Requires(post): dracut binutils Requires: qubes-core-dom0-linux-kernel-install @@ -139,6 +140,20 @@ Patch26: 0001-Re-enable-interrupts-before-loading-PNVM.patch %description Qubes Dom0 kernel. +%package modules +Summary: Kernel modules +License: GPL v2 only +Provides: multiversion(kernel) +Provides: %name-modules = %kernelrelease +%if "%{?name_suffix}" != "" +Provides: kernel-modules = %kernelrelease +%endif +Provides: kernel-modules-uname-r = %kernelrelease +AutoReqProv: on + +%description modules +This package provides kernel modules. + %prep SYMBOLS="xen-dom0 pvops" @@ -477,40 +492,12 @@ if [ -e /usr/lib/dracut/modules.d/90qubes-vm-simple/xen-scrub-pages-supported ]; fi echo "$def_kernelopts " > %buildroot/%vm_install_dir/default-kernelopts-common.txt -# Modules for Qubes VM -mkdir -p %buildroot%vm_install_dir/modules -cp -a %buildroot/lib/modules/%kernelrelease %buildroot%vm_install_dir/modules/ -mkdir -p %buildroot%vm_install_dir/modules/firmware -cp -a %buildroot/lib/firmware/%kernelrelease %buildroot%vm_install_dir/modules/firmware/ - -# Include kernel headers for Qubes VM in "/lib/modules" - so kernel-devel -# package will be unnecessary there, regardless of distribution -rm -f %buildroot%vm_install_dir/modules/%kernelrelease/build -cp -a %buildroot/%src_install_dir %buildroot%vm_install_dir/modules/%kernelrelease/build - -# include kernel+initramfs also inside modules.img, for direct kernel boot with -# stubdomain -cp %buildroot%vm_install_dir/vmlinuz %buildroot%vm_install_dir/modules/ -cp %buildroot%vm_install_dir/initramfs %buildroot%vm_install_dir/modules/ - -%if 0%{?fedora} >= 32 -flags=,no_copy_xattrs,hash_seed=dcee2318-92bd-47a5-a15d-e79d1412cdce -%else -flags= -%endif - -PATH=/usr/sbin:/sbin:$PATH mkfs.ext3 -F "-Enum_backup_sb=0,root_owner=0:0$flags" \ - -d %buildroot%vm_install_dir/modules %buildroot%vm_install_dir/modules.img 512M - -%if 0%{?fedora} >= 32 -SOURCE_DATE_EPOCH=$SOURCE_DATE_EPOCH %{_builddir}/genfs %buildroot%vm_install_dir/modules.img %{VERSION}-%{RELEASE}.%{_arch} immutable=yes -e2fsck -pDfE optimize_extents -- %buildroot%vm_install_dir/modules.img -resize2fs -M -- %buildroot%vm_install_dir/modules.img -e2fsck -pDfE optimize_extents -- %buildroot%vm_install_dir/modules.img -SOURCE_DATE_EPOCH=$SOURCE_DATE_EPOCH %{_builddir}/genfs %buildroot%vm_install_dir/modules.img -%endif +# Create a dummy modules.img with roughly the size the real one will have. +# That way, rpm will know that this package requires some additional +# space in /boot. +dd if=/dev/zero of=%buildroot/%vm_install_dir/modules.img \ + bs=1M count=500 -rm -rf %buildroot%vm_install_dir/modules # remove files that will be auto generated by depmod at rpm -i time for i in alias alias.bin ccwmap dep dep.bin ieee1394map inputmap isapnpmap ofmap pcimap seriomap symbols symbols.bin usbmap @@ -518,7 +505,7 @@ do rm -f %buildroot/lib/modules/%kernelrelease/modules.$i done -%post +%post modules /sbin/depmod -a %{kernelrelease} %posttrans @@ -549,6 +536,8 @@ fi /boot/symvers-%kernelrelease.gz %attr(0644, root, root) /boot/vmlinuz-%{kernelrelease} /lib/firmware/%{kernelrelease} + +%files modules /lib/modules/%{kernelrelease} %package devel @@ -602,8 +591,10 @@ Provides: kernel-xen-domU Provides: kernel-qubes-domU Requires(pre): coreutils gawk -Requires(post): dracut Requires(post): qubes-core-dom0 +Requires(post): qubes-prepare-vm-kernel >= 2 +Requires(post): kernel-devel = %kernelrelease +Requires(post): kernel-modules = %kernelrelease Conflicts: sysfsutils < 2.0 # root-lvm only works with newer udevs @@ -627,8 +618,9 @@ if [ "$current_default_package" = "%{name}-qubes-vm" ]; then type qubes-prefs &>/dev/null && qubes-prefs --set default-kernel %upstream_version-%plainrel fi -# make modules.img sparse (again) -fallocate --dig-holes %vm_install_dir/modules.img +SOURCE_DATE_EPOCH=$(stat -c %%Y %vm_install_dir/initramfs) +export SOURCE_DATE_EPOCH +qubes-prepare-vm-kernel --modules-only --include-devel %kernelrelease "%upstream_version-%{plainrel}" exit 0 @@ -648,7 +640,7 @@ exit 0 %files qubes-vm %defattr(-, root, root) %dir %vm_install_dir -%attr(0644, root, root) %vm_install_dir/modules.img +%ghost %attr(0644, root, root) %vm_install_dir/modules.img %attr(0644, root, root) %vm_install_dir/initramfs %attr(0644, root, root) %vm_install_dir/vmlinuz %attr(0644, root, root) %vm_install_dir/default-kernelopts-common.txt