diff --git a/rpm_spec/core-dom0-linux.spec b/rpm_spec/core-dom0-linux.spec index 378c29c..0da47d0 100644 --- a/rpm_spec/core-dom0-linux.spec +++ b/rpm_spec/core-dom0-linux.spec @@ -151,6 +151,7 @@ install -m 644 system-config/00-qubes-ignore-devices.rules $RPM_BUILD_ROOT/etc/u install -m 644 system-config/60-persistent-storage.rules $RPM_BUILD_ROOT/etc/udev/rules.d/ install -m 644 -D system-config/disable-lesspipe $RPM_BUILD_ROOT/etc/profile.d/zz-disable-lesspipe install -m 755 -D system-config/kernel-grub2.install $RPM_BUILD_ROOT/usr/lib/kernel/install.d/90-grub2.install +install -m 755 -D system-config/kernel-xen-efi.install $RPM_BUILD_ROOT/usr/lib/kernel/install.d/90-xen-efi.install install -m 755 -D system-config/kernel-remove-bls.install $RPM_BUILD_ROOT/usr/lib/kernel/install.d/99-remove-bls.install ### Icons @@ -276,6 +277,7 @@ chmod -x /etc/grub.d/10_linux %files kernel-install /usr/lib/kernel/install.d/90-grub2.install +/usr/lib/kernel/install.d/90-xen-efi.install /usr/lib/kernel/install.d/99-remove-bls.install %changelog diff --git a/system-config/kernel-xen-efi.install b/system-config/kernel-xen-efi.install new file mode 100755 index 0000000..9049509 --- /dev/null +++ b/system-config/kernel-xen-efi.install @@ -0,0 +1,84 @@ +#!/bin/sh + +set -e + +COMMAND="$1" +KVER="$2" + +ESP_MOUNTPOINT=/boot/efi +EFI_DIR="$ESP_MOUNTPOINT/qubes" + +if [ ! -d "$EFI_DIR" ]; then + # non-EFI system + exit 0; +fi + +case "$COMMAND" in + add) + # take the default section and use it as a template for the new entry + awk -F = --assign "kver=${KVER}" ' + /^\[/ { + # section header - previous section (if any) ended + + # if default section already processed, that is all + if (in_default) exit; + in_global=0; + in_default=0; + } + /\[global\]/ { + in_global=1; + } + /^\[/ { + if ("[" default_name "]" == $0) { + in_default=1; + print "[" kver "]"; + next; + } + } + /^default=/ { + if (in_global) + default_name=$2; + } + /^kernel=/ { + if (in_default) { + sub("=[^ ]*", "=vmlinuz-" kver); + } + } + /^ramdisk=/ { + if (in_default) { + sub("=[^ ]*", "=initramfs-" kver ".img"); + } + } + { + if (in_default) { + print; + } + }' $EFI_DIR/xen.cfg >> $EFI_DIR/xen.cfg + + # then change the default + sed -e "s/default=.*/default=$KVER/" -i $EFI_DIR/xen.cfg + + dracut -f "$EFI_DIR/initramfs-${KVER}.img" "$KVER" + ;; + 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 + + in_current=0; + } + /^\[/ { + if ($0 == "[" kver "]") + in_current=1; + } + { + if (!in_current) { + print; + } + }' $EFI_DIR/xen.cfg > $EFI_DIR/xen.cfg.new + mv $EFI_DIR/xen.cfg.new $EFI_DIR/xen.cfg + rm -f "$EFI_DIR/initramfs-${KVER}.img" + ;; +esac