This is another attempt to avoid having duplicated menu entries caused by
GRUB having support to parse BLS snippets and the 15_ostree script adding
menu entries as well.
The previous attempt was in commit 985a141002 ("grub2: Exit gracefully if
the configuration has BLS enabled") but that lead to users not having menu
entries at all, due having an old GRUB version that was not able to parse
the BLS snippets.
This happened because the GRUB bootloader is never updated in the ESP as
a part of the OSTree upgrade transaction.
The logic is similar to the previous commit, the 15_ostree script exits if
able to determine that the bootloader can parse the BLS snippets directly.
But this time it will not only check that a BLS configuration was enabled,
but also that a /boot/grub2/.grub2-blscfg-supported file exists. This file
has to be created by a component outside of OSTree that also takes care of
updating GRUB to a version that has proper BLS support.
62 lines
2.0 KiB
Bash
62 lines
2.0 KiB
Bash
#!/bin/sh
|
|
#
|
|
# Copyright (C) 2014 Colin Walters <walters@verbum.org>
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Lesser General Public License as published
|
|
# by the Free Software Foundation; either version 2 of the licence or (at
|
|
# your option) any later version.
|
|
#
|
|
# This library is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
# Lesser General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Lesser General
|
|
# Public License along with this library; if not, write to the
|
|
# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
|
# Boston, MA 02111-1307, USA.
|
|
|
|
# Gracefully exit if ostree is not installed, or there's
|
|
# no system repository initialized.
|
|
if ! which ostree >/dev/null 2>/dev/null; then
|
|
exit 0
|
|
fi
|
|
if ! test -d /ostree/repo; then
|
|
exit 0
|
|
fi
|
|
|
|
# Gracefully exit if the grub2 configuration has BLS enabled,
|
|
# and the installed version has support for the blscfg module.
|
|
# Since there is no need to create menu entries for that case.
|
|
# See: https://src.fedoraproject.org/rpms/grub2/c/7c2bab5e98d
|
|
. /etc/default/grub
|
|
if test -f /boot/grub2/.grub2-blscfg-supported && \
|
|
test "${GRUB_ENABLE_BLSCFG}" = "true"; then
|
|
exit 0
|
|
fi
|
|
|
|
# Make sure we're in the right environment
|
|
if ! test -n "${GRUB_DEVICE}"; then
|
|
echo "This script must be run as a child of grub2-mkconfig" 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
set -e
|
|
|
|
# Pick up stuff from grub's helper that we want to inject into our
|
|
# generated bootloader configuration. Yes, this is pretty awful, but
|
|
# it's a lot better than reimplementing the config-generating bits of
|
|
# OSTree in shell script.
|
|
|
|
. /usr/share/grub/grub-mkconfig_lib
|
|
|
|
DEVICE=${GRUB_DEVICE_BOOT:-${GRUB_DEVICE}}
|
|
|
|
GRUB2_BOOT_DEVICE_ID="$(grub_get_device_id ${DEVICE})"
|
|
export GRUB2_BOOT_DEVICE_ID
|
|
GRUB2_PREPARE_ROOT_CACHE="$(prepare_grub_to_access_device ${DEVICE})"
|
|
export GRUB2_PREPARE_ROOT_CACHE
|
|
|
|
exec ostree admin instutil grub2-generate
|