Rename installed kernel to match name used in boot entry

The mkbls() function would write 'linux /vmlinuz-${kernelver}' into the boot
loader entry. But the code that actually copies the file would use the original
file name with a version suffix ('cp -aT "$i" "/boot/${i##*/}-${KERNEL_VERSION}"').
In case of a local kernel build calling /sbin/installkernel this file name was
e.g. 'bzImage', so we would end up with '/bzImage-${KERNEL_VERSION}', which of
course doesn't match '/vmlinuz-*'. The script would later call 'grub2-mkrel'
on the name taken from the boot entry which would fail because the file does not
exist. Rename the argument to "vmlinuz", so that both parts match.

Tested by doing a local kernel build with 'sudo make install' at the end.

Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2023-09-27 17:05:21 +02:00 committed by Nicolas Frayer
parent aa936e7b0c
commit af4f1536b6
2 changed files with 11 additions and 2 deletions

View File

@ -54,8 +54,13 @@ EOF
case "$COMMAND" in
add)
if [[ "${KERNEL_DIR}" != "/boot" ]]; then
# rename to match the name used in the pseudo-BLS snippet above
rm -f "/boot/vmlinuz-${KERNEL_VERSION}"
cp -aT "${KERNEL_IMAGE}" "/boot/vmlinuz-${KERNEL_VERSION}"
command -v restorecon &>/dev/null && \
restorecon -R "/boot/vmlinuz-${KERNEL_VERSION}"
for i in \
"$KERNEL_IMAGE" \
"$KERNEL_DIR"/System.map \
"$KERNEL_DIR"/config \
"$KERNEL_DIR"/zImage.stub \

View File

@ -17,7 +17,7 @@
Name: grub2
Epoch: 1
Version: 2.06
Release: 102%{?dist}
Release: 103%{?dist}
Summary: Bootloader with support for Linux, Multiboot and more
License: GPLv3+
URL: http://www.gnu.org/software/grub/
@ -548,6 +548,10 @@ mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg
%endif
%changelog
* Fri Sep 29 2023 Zbigniew Jedrzejewski-Szmek <zbyszek@in.waw.pl> - 1:2.06-103
- Rename installed kernel to match name used in boot entry
- Resolves: #2239008
* Fri Sep 29 2023 Nicolas Frayer <nfrayer@redhat.com> - 2.06-102
- ofdisk: Fix missing #include in ofdisk.c