From ed1f0f3be8f4a679a078dad0b9acaf23b31447b2 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Mon, 25 Dec 2023 22:58:17 +0900 Subject: [PATCH] kbuild: rpm-pkg: specify more files as %ghost Installing the kernel package is fine, but when uninstalling it, the following warnings are shown: warning: file modules.symbols.bin: remove failed: No such file or directory warning: file modules.symbols: remove failed: No such file or directory warning: file modules.softdep: remove failed: No such file or directory warning: file modules.devname: remove failed: No such file or directory warning: file modules.dep.bin: remove failed: No such file or directory warning: file modules.dep: remove failed: No such file or directory warning: file modules.builtin.bin: remove failed: No such file or directory warning: file modules.builtin.alias.bin: remove failed: No such file or directory warning: file modules.alias.bin: remove failed: No such file or directory warning: file modules.alias: remove failed: No such file or directory The %preun scriptlet runs 'kernel-install remove', which in turn invokes /usr/lib/kernel/install.d/50-depmod.install to remove those files before the actual package removal. Modern RPM-based distributions do not ship files generated by depmod. Mark them as %ghost in order to exclude them from the package, but still claim the ownership on them. Do likewise for the files copied to /boot. Signed-off-by: Masahiro Yamada --- scripts/package/kernel.spec | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec index 6a7625da7ea5..c72466a93843 100644 --- a/scripts/package/kernel.spec +++ b/scripts/package/kernel.spec @@ -66,6 +66,27 @@ ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEA %{make} %{makeflags} run-command KBUILD_RUN_COMMAND='${srctree}/scripts/package/install-extmod-build %{buildroot}/usr/src/kernels/%{KERNELRELEASE}' %endif +{ + echo "%defattr (-, root, root)" + + for f in System.map config kernel modules.builtin modules.builtin.modinfo \ + modules.order vmlinuz; do + echo "/lib/modules/%{KERNELRELEASE}/${f}" + done + + for x in alias alias.bin builtin.alias.bin builtin.bin dep dep.bin devname \ + softdep symbols symbols.bin; do + echo "%ghost /lib/modules/%{KERNELRELEASE}/modules.${x}" + done + + for f in System.map config initramfs vmlinuz; do + echo "%ghost /boot/${f}-%{KERNELRELEASE}" + done + + echo "%exclude /lib/modules/%{KERNELRELEASE}/build" + echo "%exclude /kernel-files.list" +} > %{buildroot}/kernel-files.list + %clean rm -rf %{buildroot} @@ -78,6 +99,9 @@ for file in vmlinuz System.map config; do cp "/lib/modules/%{KERNELRELEASE}/${file}" "/boot/${file}-%{KERNELRELEASE}" fi done +if [ ! -e "/lib/modules/%{KERNELRELEASE}/modules.dep" ]; then + /usr/sbin/depmod %{KERNELRELEASE} +fi %preun if [ -x /sbin/new-kernel-pkg ]; then @@ -91,10 +115,7 @@ if [ -x /sbin/update-bootloader ]; then /sbin/update-bootloader --remove %{KERNELRELEASE} fi -%files -%defattr (-, root, root) -/lib/modules/%{KERNELRELEASE} -%exclude /lib/modules/%{KERNELRELEASE}/build +%files -f %{buildroot}/kernel-files.list %files headers %defattr (-, root, root) -- 2.40.1