nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/99-grub-mkconfig.install

5593c8
#!/bin/bash
5593c8
5593c8
if ! [[ $KERNEL_INSTALL_MACHINE_ID ]]; then
5593c8
    exit 0
5593c8
fi
5593c8
5593c8
# PV and PVH Xen DomU guests boot with pygrub that doesn't have BLS support,
5593c8
# also Xen Dom0 use the menuentries from 20_linux_xen and not the ones from
5593c8
# 10_linux. So BLS support needs to be disabled for both Xen Dom0 and DomU.
5593c8
if [[ -e /sys/hypervisor/type ]] && grep -q "^xen$" /sys/hypervisor/type; then
5593c8
    RUN_MKCONFIG=true
5593c8
    DISABLE_BLS=true
5593c8
fi
5593c8
5593c8
ARCH=$(uname -m)
5593c8
# Older ppc64le OPAL firmware (petitboot version < 1.8.0) don't have BLS support
5593c8
# so grub2-mkconfig has to be run to generate a config with menuentry commands.
5593c8
if [[ $ARCH = "ppc64le" ]] && [ -d /sys/firmware/opal ]; then
5593c8
5593c8
    petitboot_path="/sys/firmware/devicetree/base/ibm,firmware-versions/petitboot"
5593c8
5593c8
    if test -e ${petitboot_path}; then
5593c8
        read -r -d '' petitboot_version < ${petitboot_path}
5593c8
        petitboot_version="$(echo ${petitboot_version//v})"
5593c8
        major_version="$(echo ${petitboot_version} | cut -d . -f1)"
5593c8
        minor_version="$(echo ${petitboot_version} | cut -d . -f2)"
5593c8
5593c8
        if test -z ${petitboot_version} || test ${major_version} -lt 1 || \
5593c8
           test ${major_version} -eq 1 -a ${minor_version} -lt 8; then
5593c8
            RUN_MKCONFIG=true
5593c8
        fi
5593c8
    else
5593c8
        RUN_MKCONFIG=true
5593c8
    fi
5593c8
fi
5593c8
5593c8
if [[ $DISABLE_BLS = "true" ]]; then
5593c8
    if grep -q '^GRUB_ENABLE_BLSCFG="*true"*\s*$' /etc/default/grub; then
5593c8
	sed -i 's/^GRUB_ENABLE_BLSCFG=.*/GRUB_ENABLE_BLSCFG=false/' /etc/default/grub
5593c8
    fi
5593c8
fi
5593c8
5593c8
[ -f /etc/default/grub ] && . /etc/default/grub
5593c8
if [ x$GRUB_ENABLE_BLSCFG = xfalse ]; then
5593c8
   RUN_MKCONFIG=true
5593c8
fi
5593c8
5593c8
# A traditional grub configuration file needs to be generated only in the case when
5593c8
# the bootloaders are not capable of populating a menu entry from the BLS fragments.
5593c8
if [[ $RUN_MKCONFIG != "true" ]]; then
5593c8
    exit 0
5593c8
fi
5593c8
5593c8
COMMAND="$1"
5593c8
5593c8
case "$COMMAND" in
5593c8
    add|remove)
5593c8
        grub2-mkconfig --no-grubenv-update -o /boot/grub2/grub.cfg >& /dev/null
5593c8
        ;;
5593c8
    *)
5593c8
        ;;
5593c8
esac