#29 Rename installed kernel to match name used in boot entry
Closed 7 months ago by nfrayer. Opened 8 months ago by zbyszek.
rpms/ zbyszek/grub2 rename-vmlinuz-file  into  rawhide

file modified
+10 -10
@@ -54,24 +54,26 @@ 

  case "$COMMAND" in

      add)

          if [[ "${KERNEL_DIR}" != "/boot" ]]; then

+             # rename to match the name used in the pseudo-BLS snippet above

+             cp --remove-destination --preserve=timestamps -T "${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 \

                      "$KERNEL_DIR"/dtb

              do

                  [[ -e "$i" ]] || continue

-                 rm -f "/boot/${i##*/}-${KERNEL_VERSION}"

-                 cp -aT "$i" "/boot/${i##*/}-${KERNEL_VERSION}"

+                 cp --remove-destination --preserve=timestamps -T "$i" "/boot/${i##*/}-${KERNEL_VERSION}"

                  command -v restorecon &>/dev/null && \

                      restorecon -R "/boot/${i##*/}-${KERNEL_VERSION}"

              done

              # hmac is .vmlinuz-<version>.hmac so needs a special treatment

              i="$KERNEL_DIR/.${KERNEL_IMAGE##*/}.hmac"

              if [[ -e "$i" ]]; then

-                 rm -f "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac"

-                 cp -a "$i" "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac"

+                 cp --remove-destination --preserve=timestamps "$i" "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac"

                  command -v restorecon &>/dev/null && \

                      restorecon "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac"

              fi
@@ -79,16 +81,14 @@ 

              # symvers is symvers-<version>.gz symlink, needs a special treatment

              i="$KERNEL_DIR/symvers.gz"

              if [[ -e "$i" ]]; then

-                 rm -f "/boot/symvers-${KERNEL_VERSION}.gz"

-                 ln -s "$i" "/boot/symvers-${KERNEL_VERSION}.gz"

+                 ln -fs "$i" "/boot/symvers-${KERNEL_VERSION}.gz"

                  command -v restorecon &>/dev/null && \

                      restorecon "/boot/symvers-${KERNEL_VERSION}.gz"

              fi

              # symvers is symvers-<version>.bz symlink, needs a special treatment

              i="$KERNEL_DIR/symvers.bz"

              if [[ -e "$i" ]]; then

-                 rm -f "/boot/symvers-${KERNEL_VERSION}.bz"

-                 ln -s "$i" "/boot/symvers-${KERNEL_VERSION}.bz"

+                 ln -fs "$i" "/boot/symvers-${KERNEL_VERSION}.bz"

                  command -v restorecon &>/dev/null && \

                      restorecon "/boot/symvers-${KERNEL_VERSION}.bz"

              fi
@@ -153,7 +153,7 @@ 

  

              if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then

                  BLS_DEBUG="$(echo ${BLS_TARGET} | sed -e "s/${KERNEL_VERSION}/${KERNEL_VERSION}~debug/")"

-                 cp -aT  "${BLS_TARGET}" "${BLS_DEBUG}"

+                 cp --preserve=timestamps -T  "${BLS_TARGET}" "${BLS_DEBUG}"

                  TITLE="$(grep '^title[ \t]' "${BLS_DEBUG}" | sed -e 's/^title[ \t]*//')"

                  OPTIONS="$(echo "${BOOT_OPTIONS[*]} ${GRUB_CMDLINE_LINUX_DEBUG}" | sed -e 's/\//\\\//g')"

                  sed -i -e "s/^title.*/title ${TITLE}${GRUB_LINUX_DEBUG_TITLE_POSTFIX}/" "${BLS_DEBUG}"

file modified
+5 -1
@@ -17,7 +17,7 @@ 

  Name:		grub2

  Epoch:		1

  Version:	2.06

- Release:	100%{?dist}

+ Release:	101%{?dist}

  Summary:	Bootloader with support for Linux, Multiboot and more

  License:	GPLv3+

  URL:		http://www.gnu.org/software/grub/
@@ -548,6 +548,10 @@ 

  %endif

  

  %changelog

+ * Wed Sep 27 2023 Zbigniew Jedrzejewski-Szmek <zbyszek@in.waw.pl> - 1:2.06-101

+ - Rename installed kernel to match name used in boot entry

+ - Resolves: #2239008

+ 

  * Wed Sep 13 2023 Nicolas Frayer <nfrayer@redhat.com> - 2.06-100

  - arm64: Use proper memory type for kernel allocation

  - Resolves: #2149020

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.

For F39 too of course.

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/c687ea70fa804f0cbf14789c3f101a2c

2 new commits added

  • Let ln and cp remove the destination files
  • Do not preserve ownership or xattrs on copied files
8 months ago

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/76230629d12f4971a0e9ebb440169c45

Pull-Request has been closed by nfrayer

7 months ago
Metadata