From f7eaa7bec25814c76fc5d17c79852c6485e3eb3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sun, 15 May 2016 11:19:18 +0200 Subject: [PATCH] kernel-install: don't fail on kernel removal in non-EFI installs In non-EFI installation /boot/efi/EFI/qubes may not exists. In this case do not try to touch (non-existing) files there. Fixes QubesOS/qubes-issues#1829 --- system-config/kernel-xen-efi.install | 30 +++++++++++++++------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/system-config/kernel-xen-efi.install b/system-config/kernel-xen-efi.install index 8f5e9c6..da2afd9 100755 --- a/system-config/kernel-xen-efi.install +++ b/system-config/kernel-xen-efi.install @@ -64,22 +64,24 @@ case "$COMMAND" in remove) # don't care about changing default= line - yum should prevent removing # currently running kernel - awk -F = --assign "kver=${KVER}" ' - /^\[/ { - # section header - previous section (if any) ended + if [ -r $EFI_DIR/xen.cfg ]; then + awk -F = --assign "kver=${KVER}" ' + /^\[/ { + # section header - previous section (if any) ended - in_current=0; - } - /^\[/ { - if ($0 == "[" kver "]") - in_current=1; - } - { - if (!in_current) { - print; + in_current=0; + } + /^\[/ { + if ($0 == "[" kver "]") + in_current=1; } - }' $EFI_DIR/xen.cfg > $EFI_DIR/xen.cfg.new - mv $EFI_DIR/xen.cfg.new $EFI_DIR/xen.cfg + { + if (!in_current) { + print; + } + }' $EFI_DIR/xen.cfg > $EFI_DIR/xen.cfg.new + mv $EFI_DIR/xen.cfg.new $EFI_DIR/xen.cfg + fi rm -f "$EFI_DIR/initramfs-${KVER}.img" ;; esac