On Fri, Feb 02, 2024 at 10:35:17PM +0900, Masahiro Yamada wrote: > 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. > > 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. > > Signed-off-by: Masahiro Yamada <masahiroy@xxxxxxxxxx> Tested-by: Nathan Chancellor <nathan@xxxxxxxxxx> > --- > > scripts/package/kernel.spec | 22 +++++++++++++++++++--- > 1 file changed, 19 insertions(+), 3 deletions(-) > > diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec > index f58726671fb3..aaedb6d1b26f 100644 > --- a/scripts/package/kernel.spec > +++ b/scripts/package/kernel.spec > @@ -66,6 +66,20 @@ 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 > > +{ > + for x in System.map config kernel modules.builtin \ > + modules.builtin.modinfo modules.order vmlinuz; do > + echo "/lib/modules/%{KERNELRELEASE}/${x}" > + 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 > + > + echo "%exclude /lib/modules/%{KERNELRELEASE}/build" > +} > %{buildroot}/kernel.list > + > %clean > rm -rf %{buildroot} > > @@ -78,6 +92,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 +108,9 @@ if [ -x /sbin/update-bootloader ]; then > /sbin/update-bootloader --remove %{KERNELRELEASE} > fi > > -%files > +%files -f %{buildroot}/kernel.list > %defattr (-, root, root) > -/lib/modules/%{KERNELRELEASE} > -%exclude /lib/modules/%{KERNELRELEASE}/build > +%exclude /kernel.list > > %files headers > %defattr (-, root, root) > -- > 2.40.1 >