Fix util/grub.d/20_linux_xen.in: Add xen_boot command support for aarch64
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tue, 29 Aug 2017 20:40:52 +0000 (16:40 -0400)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 7 Sep 2017 21:25:29 +0000 (23:25 +0200)
commita8e0f1adf7019238fff263111794c86f4eea79ac
tree4cee78b109c93f5bb290222c37373ab8efccf5f0
parent78d2b81bd1af0a3a84d0c23c9ff4af3caa2df23b
Fix util/grub.d/20_linux_xen.in: Add xen_boot command support for aarch64

Commit d33045ce7ffcb7c1e4a60c14d5ca64b36e3c5abe introduced
the support for this, but it does not work under x86 (as it stops
20_linux_xen from running).

The 20_linux_xen is run under a shell and any exits from within it:

(For example on x86):
+ /usr/bin/grub2-file --is-arm64-efi /boot/xen-4.9.0.gz
[root@tst063 grub]# echo $?
1

will result in 20_linux_xen exiting without continuing
and also causing grub2-mkconfig to stop processing.

As in:

 [root@tst063 grub]# ./grub-mkconfig | tail
 Generating grub configuration file ...
 Found linux image: /boot/vmlinuz-4.13.0-0.rc5.git1.1.fc27.x86_64
 Found initrd image: /boot/initramfs-4.13.0-0.rc5.git1.1.fc27.x86_64.img
 Found linux image: /boot/vmlinuz-0-rescue-ec082ee24aea41b9b16aca52a6d10cc2
 Found initrd image: /boot/initramfs-0-rescue-ec082ee24aea41b9b16aca52a6d10cc2.img
  echo 'Loading Linux 0-rescue-ec082ee24aea41b9b16aca52a6d10cc2 ...'
  linux /vmlinuz-0-rescue-ec082ee24aea41b9b16aca52a6d10cc2 root=/dev/mapper/fedora_tst063-root ro single
  echo 'Loading initial ramdisk ...'
  initrd /initramfs-0-rescue-ec082ee24aea41b9b16aca52a6d10cc2.img
  }
 }

 ### END /usr/local/etc/grub.d/10_linux ###

 ### BEGIN /usr/local/etc/grub.d/20_linux_xen ###

 root@tst063 grub]#

And no more.

This patch wraps the invocation of grub-file to be a in subshell
and to process the return value in a conditional. That fixes
the issue.

RH-BZ 1486002: grub2-mkconfig does not work if xen.gz is installed.

CC: Fu Wei <fu.wei@linaro.org>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
util/grub.d/20_linux_xen.in