Skip to content

Commit 358de8b

Browse files
jtornosmmasahir0y
authored andcommitted
kbuild: rpm-pkg: simplify installkernel %post
The new installkernel application that is now included in systemd-udev package allows installation although destination files are already present in the boot directory of the kernel package, but is failing with the implemented workaround for the old installkernel application from grubby package. For the new installkernel application, as Davide says: <<The %post currently does a shuffling dance before calling installkernel. This isn't actually necessary afaict, and the current implementation ends up triggering downstream issues such as systemd/systemd#29568 This commit simplifies the logic to remove the shuffling. For reference, the original logic was added in commit 3c9c7a1("rpm-pkg: add %post section to create initramfs and grub hooks").>> But we need to keep the old behavior as well, because the old installkernel application from grubby package, does not allow this simplification and we need to be backward compatible to avoid issues with the different packages. Mimic Fedora shipping process and store vmlinuz, config amd System.map in the module directory instead of the boot directory. In this way, we will avoid the commented problem for all the cases, because the new destination files are not going to exist in the boot directory of the kernel package. Replace installkernel tool with kernel-install tool, because the latter is more complete. Besides, after installkernel tool execution, check to complete if the correct package files vmlinuz, System.map and config files are present in /boot directory, and if necessary, copy manually for install operation. In this way, take into account if files were not previously copied from /usr/lib/kernel/install.d/* scripts and if the suitable files for the requested package are present (it could be others if the rpm files were replace with a new pacakge with the same release and a different build). Tested with Fedora 38, Fedora 39, RHEL 9, Oracle Linux 9.3, openSUSE Tumbleweed and openMandrive ROME, using dnf/zypper and rpm tools. cc: [email protected] Co-Developed-by: Davide Cavalca <[email protected]> Signed-off-by: Jose Ignacio Tornos Martinez <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 82175d1 commit 358de8b

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

scripts/package/kernel.spec

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ patch -p1 < %{SOURCE2}
5555
%{make} %{makeflags} KERNELRELEASE=%{KERNELRELEASE} KBUILD_BUILD_VERSION=%{release}
5656

5757
%install
58-
mkdir -p %{buildroot}/boot
59-
cp $(%{make} %{makeflags} -s image_name) %{buildroot}/boot/vmlinuz-%{KERNELRELEASE}
58+
mkdir -p %{buildroot}/lib/modules/%{KERNELRELEASE}
59+
cp $(%{make} %{makeflags} -s image_name) %{buildroot}/lib/modules/%{KERNELRELEASE}/vmlinuz
6060
%{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} modules_install
6161
%{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
62-
cp System.map %{buildroot}/boot/System.map-%{KERNELRELEASE}
63-
cp .config %{buildroot}/boot/config-%{KERNELRELEASE}
62+
cp System.map %{buildroot}/lib/modules/%{KERNELRELEASE}
63+
cp .config %{buildroot}/lib/modules/%{KERNELRELEASE}/config
6464
ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEASE}/build
6565
%if %{with_devel}
6666
%{make} %{makeflags} run-command KBUILD_RUN_COMMAND='${srctree}/scripts/package/install-extmod-build %{buildroot}/usr/src/kernels/%{KERNELRELEASE}'
@@ -70,13 +70,14 @@ ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEA
7070
rm -rf %{buildroot}
7171

7272
%post
73-
if [ -x /sbin/installkernel -a -r /boot/vmlinuz-%{KERNELRELEASE} -a -r /boot/System.map-%{KERNELRELEASE} ]; then
74-
cp /boot/vmlinuz-%{KERNELRELEASE} /boot/.vmlinuz-%{KERNELRELEASE}-rpm
75-
cp /boot/System.map-%{KERNELRELEASE} /boot/.System.map-%{KERNELRELEASE}-rpm
76-
rm -f /boot/vmlinuz-%{KERNELRELEASE} /boot/System.map-%{KERNELRELEASE}
77-
/sbin/installkernel %{KERNELRELEASE} /boot/.vmlinuz-%{KERNELRELEASE}-rpm /boot/.System.map-%{KERNELRELEASE}-rpm
78-
rm -f /boot/.vmlinuz-%{KERNELRELEASE}-rpm /boot/.System.map-%{KERNELRELEASE}-rpm
73+
if [ -x /usr/bin/kernel-install ]; then
74+
/usr/bin/kernel-install add %{KERNELRELEASE} /lib/modules/%{KERNELRELEASE}/vmlinuz
7975
fi
76+
for file in vmlinuz System.map config; do
77+
if ! cmp --silent "/lib/modules/%{KERNELRELEASE}/${file}" "/boot/${file}-%{KERNELRELEASE}"; then
78+
cp "/lib/modules/%{KERNELRELEASE}/${file}" "/boot/${file}-%{KERNELRELEASE}"
79+
fi
80+
done
8081

8182
%preun
8283
if [ -x /sbin/new-kernel-pkg ]; then
@@ -94,7 +95,6 @@ fi
9495
%defattr (-, root, root)
9596
/lib/modules/%{KERNELRELEASE}
9697
%exclude /lib/modules/%{KERNELRELEASE}/build
97-
/boot/*
9898

9999
%files headers
100100
%defattr (-, root, root)

0 commit comments

Comments
 (0)