20-grub-install: Replace, rather than overwrite, the existing kernel.
In rhbz#1638405, we worked around the issue of an existing initramfs being in the way by removing it if it's older than the kernel we're in the process of installing. But it was buggy and only worked with some filesystem layouts and paths, and also possibly had some issues with file creation times causing the shell -ot comparison to fail in some cases. This patch changes it to remove the existing kernel (as well as other related files) in the case that it's going to do the copy, and also fixes the path issues. Resolves: rhbz#1642402 Related: rhbz#1638405 Signed-off-by: Peter Jones <pjones@redhat.com> Tested-by: Prarit Bhargava <prarit@redhat.com>
This commit is contained in:
parent
f6d4ab8f83
commit
c9b8b10a61
@ -62,6 +62,7 @@ case "$COMMAND" in
|
|||||||
"$KERNEL_DIR"/dtb
|
"$KERNEL_DIR"/dtb
|
||||||
do
|
do
|
||||||
[[ -e "$i" ]] || continue
|
[[ -e "$i" ]] || continue
|
||||||
|
rm -f "/boot/${i##*/}-${KERNEL_VERSION}"
|
||||||
cp -aT "$i" "/boot/${i##*/}-${KERNEL_VERSION}"
|
cp -aT "$i" "/boot/${i##*/}-${KERNEL_VERSION}"
|
||||||
command -v restorecon &>/dev/null && \
|
command -v restorecon &>/dev/null && \
|
||||||
restorecon -R "/boot/${i##*/}-${KERNEL_VERSION}"
|
restorecon -R "/boot/${i##*/}-${KERNEL_VERSION}"
|
||||||
@ -69,6 +70,7 @@ case "$COMMAND" in
|
|||||||
# hmac is .vmlinuz-<version>.hmac so needs a special treatment
|
# hmac is .vmlinuz-<version>.hmac so needs a special treatment
|
||||||
i="$KERNEL_DIR/.${KERNEL_IMAGE##*/}.hmac"
|
i="$KERNEL_DIR/.${KERNEL_IMAGE##*/}.hmac"
|
||||||
if [[ -e "$i" ]]; then
|
if [[ -e "$i" ]]; then
|
||||||
|
rm -f "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac"
|
||||||
cp -a "$i" "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac"
|
cp -a "$i" "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac"
|
||||||
command -v restorecon &>/dev/null && \
|
command -v restorecon &>/dev/null && \
|
||||||
restorecon "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac"
|
restorecon "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac"
|
||||||
@ -92,6 +94,7 @@ case "$COMMAND" in
|
|||||||
INITRD="$(grep '^initrd[ \t]' "${BLS_TARGET}" | sed -e 's,^initrd[ \t]*,,')"
|
INITRD="$(grep '^initrd[ \t]' "${BLS_TARGET}" | sed -e 's,^initrd[ \t]*,,')"
|
||||||
LINUX_RELPATH="$(grub2-mkrelpath /boot${LINUX})"
|
LINUX_RELPATH="$(grub2-mkrelpath /boot${LINUX})"
|
||||||
BOOTPREFIX="$(dirname ${LINUX_RELPATH})"
|
BOOTPREFIX="$(dirname ${LINUX_RELPATH})"
|
||||||
|
ROOTPREFIX="$(dirname "/boot${LINUX}")"
|
||||||
|
|
||||||
if [[ $LINUX != $LINUX_RELPATH ]]; then
|
if [[ $LINUX != $LINUX_RELPATH ]]; then
|
||||||
sed -i -e "s,^linux.*,linux ${BOOTPREFIX}${LINUX},g" "${BLS_TARGET}"
|
sed -i -e "s,^linux.*,linux ${BOOTPREFIX}${LINUX},g" "${BLS_TARGET}"
|
||||||
@ -124,10 +127,10 @@ case "$COMMAND" in
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# this probably isn't the best place to do this, but it will do for now.
|
# this probably isn't the best place to do this, but it will do for now.
|
||||||
if [ -e "${BOOTPREFIX}${INITRD}" -a -e "${BOOTPREFIX}${LINUX}" -a \
|
if [ -e "${ROOTPREFIX}${INITRD}" -a -e "${ROOTPREFIX}${LINUX}" -a \
|
||||||
"${BOOTPREFIX}${INITRD}" -ot "${BOOTPREFIX}${LINUX}" -a \
|
"${ROOTPREFIX}${INITRD}" -ot "${ROOTPREFIX}${LINUX}" -a \
|
||||||
-x /usr/lib/kernel/install.d/50-dracut.install ]; then
|
-x /usr/lib/kernel/install.d/50-dracut.install ]; then
|
||||||
rm -f "${BOOTPREFIX}${INITRD}"
|
rm -f "${ROOTPREFIX}${INITRD}"
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user