On Thu, Jan 18, 2024 at 11:12 PM Jose Ignacio Tornos Martinez <jtornosm@xxxxxxxxxx> wrote: > > >> %post > >> ... > >> +if [ -e /boot/vmlinuz-%{KERNELRELEASE} ] && file -bL /boot/vmlinuz-%{KERNELRELEASE} | grep -q " #%{release} "; then > >> ... > >> > >> %preun > ... > >> +if [ -e /boot/vmlinuz-%{KERNELRELEASE} ] && file -bL /boot/vmlinuz-%{KERNELRELEASE} | grep -q " #%{release} "; then > > I do not understand why this is needed. > > Please explain. > Of course. > Fisrt of all, I have seen (i.e. openSUSE Tumbleweed) that in the same way > that vmlinuz, System.map and config was not copied when the rpm was > installed (because of the reason that you commented with the missing > script), they were not removed when the rpm was removed, so I have added > the lines to remove in a similar way as you suggested for install. Here, you are wrong. Those installed files should be removed by %ghost markers. I already have a local patch to do this. (see the attachment) I just asked you to fix up the code as I suggested in v4. > And I have seen as well (i.e. openSUSE Tumbleweed)) that if the a new rpm > is installed (same release but bigger build version to use default options > for the tool), vmlinuz, System.map and config are not copied from %post > because vmlinuz, System.map and config already exist and the situation is > not good, because /lib/modules/{KERNELRELEASE} is updated but the commented > files in /boot are not updated. That is the reason why I have tried to > identify when vmlinuz, System.map and config are not the good ones, to copy > too. For me (on Fedora 39 and openSUSE Tumbleweed), rpm fails due to file conflict. vagrant@opensuse-tumbleweed20231218:~> sudo rpm -i kernel-6.7.0_12924_g660a5f4a53e7-4.x86_64.rpm file /lib/modules/6.7.0-12924-g660a5f4a53e7/vmlinuz from install of kernel-6.7.0_12924_g660a5f4a53e7-4.x86_64 conflicts with file from package kernel-6.7.0_12924_g660a5f4a53e7-3.x86_64 So, this does not happen. > Besides, in the commented situation, the older rpm (same release but older > build version) is removed and with that, the new vmlinuz, System.map and > config are removed too. That is the reason that I have tried to identify > again the files, removing only the suitable vmlinuz, System.map and config > with the same release and build number requested. > > > And, is the output of 'file' standardized? > With no more information, file is going to print the strings in the file, > that is, the information containig release, version, ... and here we can > find what we are interested in. So in some way depends on vmlinuz binary. > > > You need to understand that ARCH is not always x86, > > and /boot/vmlinuz-%{KERNELRELEASE} > > is not always arch/x86/boot/bzImage. > > > > See arch/arm64/Makefile > KBUILD_IMAGE := $(boot)/Image.gz > > > > For arm64, /boot/vmlinuz-%{KERNELRELEASE} is Image.gz > > > > 'file' says it is gzip data, that's all. > > You cannot read the build version. > You are right, again good catch. > I will try to think something for aarch64. Maybe something more general, > and independent of the kernel binary name, is possible and valid for other > architectures, maybe with rpm command. > If nothing comes up, I will do only for x86. No. Please do not. > > > Unreadable. > > I suggested code with indentation and quotation, > > but you got rid of them. > I did not want to modify the style. > Ok, I will follow your suggestion, it's clearer to me too. > > Thanks > > Best regards > José Ignacio > -- Best Regards Masahiro Yamada
From ed1f0f3be8f4a679a078dad0b9acaf23b31447b2 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada <masahiroy@xxxxxxxxxx> 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 <masahiroy@xxxxxxxxxx> --- 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