Untitled diff

Creado El diff nunca expira
6 eliminaciones
295 líneas
104 adiciones
390 líneas
#! /bin/sh
#! /bin/sh
set -e
set -e


# grub-mkconfig helper script.
# grub-mkconfig helper script.
# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
#
#
# GRUB is free software: you can redistribute it and/or modify
# GRUB is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# (at your option) any later version.
#
#
# GRUB is distributed in the hope that it will be useful,
# GRUB is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.


prefix="/usr"
prefix="/usr"
exec_prefix="/usr"
exec_prefix="/usr"
datarootdir="/usr/share"
datarootdir="/usr/share"


ME=$(basename $0)

. "${datarootdir}/grub2/grub-mkconfig_lib"
. "${datarootdir}/grub2/grub-mkconfig_lib"


export TEXTDOMAIN=grub2
export TEXTDOMAIN=grub2
export TEXTDOMAINDIR="${datarootdir}/locale"
export TEXTDOMAINDIR="${datarootdir}/locale"


if [ ! -e /proc/xen/xsd_port -a -e /proc/xen ]; then
if [ ! -e /proc/xen/xsd_port -a -e /proc/xen ]; then
# we're running on xen domU guest
# we're running on xen domU guest
# prevent setting up nested virt on HVM or PV domU guest
# prevent setting up nested virt on HVM or PV domU guest
exit 0
exit 0
fi
fi


CLASS="--class gnu-linux --class gnu --class os --class xen"
CLASS="--class gnu-linux --class gnu --class os --class xen"


if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
OS=GNU/Linux
OS=GNU/Linux
os=linux
else
else
OS="${GRUB_DISTRIBUTOR} GNU/Linux"
OS="${GRUB_DISTRIBUTOR}"
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}"
os="$(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1)"
CLASS="--class ${os} ${CLASS}"
fi
fi


# loop-AES arranges things so that /dev/loop/X can be our root device, but
# loop-AES arranges things so that /dev/loop/X can be our root device, but
# the initrds that Linux uses don't like that.
# the initrds that Linux uses don't like that.
case ${GRUB_DEVICE} in
case ${GRUB_DEVICE} in
/dev/loop/*|/dev/loop[0-9])
/dev/loop/*|/dev/loop[0-9])
GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
;;
;;
esac
esac


if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
|| ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
|| ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
|| uses_abstraction "${GRUB_DEVICE}" lvm; then
|| uses_abstraction "${GRUB_DEVICE}" lvm; then
LINUX_ROOT_DEVICE=${GRUB_DEVICE}
LINUX_ROOT_DEVICE=${GRUB_DEVICE}
else
else
LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
fi
fi


# Allow overriding GRUB_CMDLINE_LINUX and GRUB_CMDLINE_LINUX_DEFAULT.
# Allow overriding GRUB_CMDLINE_LINUX and GRUB_CMDLINE_LINUX_DEFAULT.
if [ "${GRUB_CMDLINE_LINUX_XEN_REPLACE}" ]; then
if [ "${GRUB_CMDLINE_LINUX_XEN_REPLACE}" ]; then
GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX_XEN_REPLACE}"
GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX_XEN_REPLACE}"
fi
fi
if [ "${GRUB_CMDLINE_LINUX_XEN_REPLACE_DEFAULT}" ]; then
if [ "${GRUB_CMDLINE_LINUX_XEN_REPLACE_DEFAULT}" ]; then
GRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_XEN_REPLACE_DEFAULT}"
GRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_XEN_REPLACE_DEFAULT}"
fi
fi


case x"$GRUB_FS" in
case x"$GRUB_FS" in
xbtrfs)
xbtrfs)
if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ]; then
if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ]; then
GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX} \${extra_cmdline}"
GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX} \${extra_cmdline}"
else
else
rootsubvol="`make_system_path_relative_to_its_root /`"
rootsubvol="`make_system_path_relative_to_its_root /`"
rootsubvol="${rootsubvol#/}"
rootsubvol="${rootsubvol#/}"
if [ "x${rootsubvol}" != x ]; then
if [ "x${rootsubvol}" != x ]; then
GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
fi
fi
fi;;
fi;;
xzfs)
xzfs)
rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true`
rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true`
bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`"
bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`"
LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs}"
LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs}"
;;
;;
esac
esac


title_correction_code=
title_correction_code=


if [ -d /sys/firmware/efi ]; then
is_efi=true
err_msg=""
efi_dir="/boot/efi/efi/${os}"
grub_dir=/boot/grub2
xen_dir=/usr/lib64/efi
for d in $grub_dir $efi_dir $xen_dir; do
[ ! -d "$d" ] || continue
err_msg="${err_msg}$ME: Essential directory '$d' not found!\n"
done
if ! [ -d "$efi_dir" -a -d "$grub_dir" -a -d "$xen_dir" ]; then
err_msg="${err_msg}$ME: XEN configuration skipped!\n"
else
rm -f $grub_dir/xen*.cfg
if [ -s $efi_dir/grub.xen-files ]; then
for f in $(sort $efi_dir/grub.xen-files| uniq); do
rm -f $efi_dir/$f
done
: > $efi_dir/grub.xen-files
fi
fi
else
is_efi=false
fi

linux_entry ()
linux_entry ()
{
{
os="$1"
os="$1"
version="$2"
version="$2"
xen_version="$3"
xen_version="$3"
type="$4"
type="$4"
args="$5"
args="$5"
xen_args="$6"
xen_args="$6"
if [ -n "${linux_root_device_thisversion}" ]; then
root_device="root=${linux_root_device_thisversion}"
else
root_device=""
fi
if [ -z "$boot_device_id" ]; then
if [ -z "$boot_device_id" ]; then
boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"