2024-02-02 13:35:39

by Masahiro Yamada

[permalink] [raw]
Subject: [PATCH 1/4] kbuild: rpm-pkg: do not include depmod-generated files

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 <[email protected]>
---

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



2024-02-02 13:35:49

by Masahiro Yamada

[permalink] [raw]
Subject: [PATCH 2/4] kbuild: rpm-pkg: mark installed files in /boot as %ghost

Mark the files installed to /boot as %ghost to make sure they will be
removed when the package is uninstalled.

Signed-off-by: Masahiro Yamada <[email protected]>
---

scripts/package/kernel.spec | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
index aaedb6d1b26f..ecedcfc11e73 100644
--- a/scripts/package/kernel.spec
+++ b/scripts/package/kernel.spec
@@ -77,6 +77,10 @@ ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEA
echo "%ghost /lib/modules/%{KERNELRELEASE}/modules.${x}"
done

+ for x in System.map config vmlinuz; do
+ echo "%ghost /boot/${x}-%{KERNELRELEASE}"
+ done
+
echo "%exclude /lib/modules/%{KERNELRELEASE}/build"
} > %{buildroot}/kernel.list

--
2.40.1


2024-02-02 13:36:07

by Masahiro Yamada

[permalink] [raw]
Subject: [PATCH 3/4] Revert "kbuild/mkspec: support 'update-bootloader'-based systems"

This reverts commit 27c3bffd230abd0a598586aed0fe0ba7b61e0e2e.

If this is still needed, we can bring it back.

However, I'd like to understand why 'update-bootloader --remove' is
needed for uninstallation, while 'update-bootloader --add' was not
called during the installation.

Signed-off-by: Masahiro Yamada <[email protected]>
---

scripts/package/kernel.spec | 5 -----
1 file changed, 5 deletions(-)

diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
index ecedcfc11e73..c1b745967f64 100644
--- a/scripts/package/kernel.spec
+++ b/scripts/package/kernel.spec
@@ -107,11 +107,6 @@ elif [ -x /usr/bin/kernel-install ]; then
kernel-install remove %{KERNELRELEASE}
fi

-%postun
-if [ -x /sbin/update-bootloader ]; then
-/sbin/update-bootloader --remove %{KERNELRELEASE}
-fi
-
%files -f %{buildroot}/kernel.list
%defattr (-, root, root)
%exclude /kernel.list
--
2.40.1


2024-02-02 13:36:47

by Masahiro Yamada

[permalink] [raw]
Subject: [PATCH 4/4] Revert "kbuild/mkspec: clean boot loader configuration on rpm removal"

This reverts commit 6ef41e22a320d95a246d45b673aa7247cc1bbf7b.

If this is still needed, we can bring it back.

However, I'd like to understand why 'new-kernel-pkg --remove' is
needed for uninstallation, while 'new-kernel-pkg --install' was not
called during the installation.

Signed-off-by: Masahiro Yamada <[email protected]>
---

scripts/package/kernel.spec | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
index c1b745967f64..c256b73cca3e 100644
--- a/scripts/package/kernel.spec
+++ b/scripts/package/kernel.spec
@@ -101,9 +101,7 @@ if [ ! -e "/lib/modules/%{KERNELRELEASE}/modules.dep" ]; then
fi

%preun
-if [ -x /sbin/new-kernel-pkg ]; then
-new-kernel-pkg --remove %{KERNELRELEASE} --rminitrd --initrdfile=/boot/initramfs-%{KERNELRELEASE}.img
-elif [ -x /usr/bin/kernel-install ]; then
+if [ -x /usr/bin/kernel-install ]; then
kernel-install remove %{KERNELRELEASE}
fi

--
2.40.1


2024-02-06 01:35:18

by Nathan Chancellor

[permalink] [raw]
Subject: Re: [PATCH 1/4] kbuild: rpm-pkg: do not include depmod-generated files

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 <[email protected]>

Tested-by: Nathan Chancellor <[email protected]>

> ---
>
> 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
>

2024-02-06 01:35:30

by Nathan Chancellor

[permalink] [raw]
Subject: Re: [PATCH 2/4] kbuild: rpm-pkg: mark installed files in /boot as %ghost

On Fri, Feb 02, 2024 at 10:35:18PM +0900, Masahiro Yamada wrote:
> Mark the files installed to /boot as %ghost to make sure they will be
> removed when the package is uninstalled.
>
> Signed-off-by: Masahiro Yamada <[email protected]>

Tested-by: Nathan Chancellor <[email protected]>

> ---
>
> scripts/package/kernel.spec | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
> index aaedb6d1b26f..ecedcfc11e73 100644
> --- a/scripts/package/kernel.spec
> +++ b/scripts/package/kernel.spec
> @@ -77,6 +77,10 @@ ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEA
> echo "%ghost /lib/modules/%{KERNELRELEASE}/modules.${x}"
> done
>
> + for x in System.map config vmlinuz; do
> + echo "%ghost /boot/${x}-%{KERNELRELEASE}"
> + done
> +
> echo "%exclude /lib/modules/%{KERNELRELEASE}/build"
> } > %{buildroot}/kernel.list
>
> --
> 2.40.1
>