Initial commit.
This commit is contained in:
368
grub.d/00_header
Executable file
368
grub.d/00_header
Executable file
@@ -0,0 +1,368 @@
|
||||
#! /bin/sh
|
||||
set -e
|
||||
|
||||
# grub-mkconfig helper script.
|
||||
# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||
#
|
||||
# GRUB is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# GRUB 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
prefix="/usr"
|
||||
exec_prefix="/usr"
|
||||
datarootdir="/usr/share"
|
||||
grub_lang=`echo $LANG | cut -d . -f 1`
|
||||
|
||||
export TEXTDOMAIN=grub
|
||||
export TEXTDOMAINDIR="${datarootdir}/locale"
|
||||
|
||||
. "$pkgdatadir/grub-mkconfig_lib"
|
||||
|
||||
if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ] &&
|
||||
[ "x${GRUB_FS}" = "xbtrfs" ] ; then
|
||||
cat <<EOF
|
||||
set btrfs_relative_path="y"
|
||||
export btrfs_relative_path
|
||||
EOF
|
||||
fi
|
||||
|
||||
# Do this as early as possible, since other commands might depend on it.
|
||||
# (e.g. the `loadfont' command might need lvm or raid modules)
|
||||
for i in ${GRUB_PRELOAD_MODULES} ; do
|
||||
echo "insmod $i"
|
||||
done
|
||||
|
||||
if [ "x${GRUB_DEFAULT}" = "x" ] ; then GRUB_DEFAULT=0 ; fi
|
||||
if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then GRUB_DEFAULT='${saved_entry}' ; fi
|
||||
if [ "x${GRUB_TIMEOUT}" = "x" ] ; then GRUB_TIMEOUT=5 ; fi
|
||||
if [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=auto ; fi
|
||||
|
||||
if [ "x${GRUB_DEFAULT_BUTTON}" = "x" ] ; then GRUB_DEFAULT_BUTTON="$GRUB_DEFAULT" ; fi
|
||||
if [ "x${GRUB_DEFAULT_BUTTON}" = "xsaved" ] ; then GRUB_DEFAULT_BUTTON='${saved_entry}' ; fi
|
||||
if [ "x${GRUB_TIMEOUT_BUTTON}" = "x" ] ; then GRUB_TIMEOUT_BUTTON="$GRUB_TIMEOUT" ; fi
|
||||
|
||||
cat << EOF
|
||||
set pager=1
|
||||
|
||||
if [ -f \${config_directory}/grubenv ]; then
|
||||
load_env -f \${config_directory}/grubenv
|
||||
elif [ -s \$prefix/grubenv ]; then
|
||||
load_env
|
||||
fi
|
||||
EOF
|
||||
if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
|
||||
cat <<EOF
|
||||
if cmostest $GRUB_BUTTON_CMOS_ADDRESS ; then
|
||||
set default="${GRUB_DEFAULT_BUTTON}"
|
||||
elif [ "\${next_entry}" ] ; then
|
||||
set default="\${next_entry}"
|
||||
set next_entry=
|
||||
save_env next_entry
|
||||
set boot_once=true
|
||||
else
|
||||
set default="${GRUB_DEFAULT}"
|
||||
fi
|
||||
EOF
|
||||
else
|
||||
cat <<EOF
|
||||
if [ "\${next_entry}" ] ; then
|
||||
set default="\${next_entry}"
|
||||
set next_entry=
|
||||
save_env next_entry
|
||||
set boot_once=true
|
||||
else
|
||||
set default="${GRUB_DEFAULT}"
|
||||
fi
|
||||
EOF
|
||||
fi
|
||||
cat <<EOF
|
||||
|
||||
if [ x"\${feature_menuentry_id}" = xy ]; then
|
||||
menuentry_id_option="--id"
|
||||
else
|
||||
menuentry_id_option=""
|
||||
fi
|
||||
|
||||
export menuentry_id_option
|
||||
|
||||
if [ "\${prev_saved_entry}" ]; then
|
||||
set saved_entry="\${prev_saved_entry}"
|
||||
save_env saved_entry
|
||||
set prev_saved_entry=
|
||||
save_env prev_saved_entry
|
||||
set boot_once=true
|
||||
fi
|
||||
|
||||
function savedefault {
|
||||
if [ -z "\${boot_once}" ]; then
|
||||
saved_entry="\${chosen}"
|
||||
save_env saved_entry
|
||||
fi
|
||||
}
|
||||
|
||||
function load_video {
|
||||
EOF
|
||||
if [ -n "${GRUB_VIDEO_BACKEND}" ]; then
|
||||
cat <<EOF
|
||||
insmod ${GRUB_VIDEO_BACKEND}
|
||||
EOF
|
||||
else
|
||||
# If all_video.mod isn't available load all modules available
|
||||
# with versions prior to introduction of all_video.mod
|
||||
cat <<EOF
|
||||
if [ x\$feature_all_video_module = xy ]; then
|
||||
insmod all_video
|
||||
else
|
||||
insmod efi_gop
|
||||
insmod efi_uga
|
||||
insmod ieee1275_fb
|
||||
insmod vbe
|
||||
insmod vga
|
||||
insmod video_bochs
|
||||
insmod video_cirrus
|
||||
fi
|
||||
EOF
|
||||
fi
|
||||
cat <<EOF
|
||||
}
|
||||
|
||||
EOF
|
||||
|
||||
serial=0;
|
||||
gfxterm=0;
|
||||
for x in ${GRUB_TERMINAL_INPUT} ${GRUB_TERMINAL_OUTPUT}; do
|
||||
if [ xserial = "x$x" ]; then
|
||||
serial=1;
|
||||
fi
|
||||
if [ xgfxterm = "x$x" ]; then
|
||||
gfxterm=1;
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "x$serial" = x1 ]; then
|
||||
if [ "x${GRUB_SERIAL_COMMAND}" = "x" ] ; then
|
||||
grub_warn "$(gettext "Requested serial terminal but GRUB_SERIAL_COMMAND is unspecified. Default parameters will be used.")"
|
||||
GRUB_SERIAL_COMMAND=serial
|
||||
fi
|
||||
echo "${GRUB_SERIAL_COMMAND}"
|
||||
fi
|
||||
|
||||
if [ "x$gfxterm" = x1 ]; then
|
||||
if [ -n "$GRUB_FONT" ] ; then
|
||||
# Make the font accessible
|
||||
prepare_grub_to_access_device `${grub_probe} --target=device "${GRUB_FONT}"`
|
||||
cat << EOF
|
||||
if loadfont `make_system_path_relative_to_its_root "${GRUB_FONT}"` ; then
|
||||
EOF
|
||||
else
|
||||
for dir in "${pkgdatadir}" "`echo '/boot/grub2' | sed "s,//*,/,g"`" /usr/share/grub ; do
|
||||
for basename in unicode unifont ascii; do
|
||||
path="${dir}/${basename}.pf2"
|
||||
if is_path_readable_by_grub "${path}" > /dev/null ; then
|
||||
font_path="${path}"
|
||||
else
|
||||
continue
|
||||
fi
|
||||
break 2
|
||||
done
|
||||
done
|
||||
if [ -n "${font_path}" ] ; then
|
||||
cat << EOF
|
||||
if [ x\$feature_default_font_path = xy ] ; then
|
||||
font=unicode
|
||||
else
|
||||
EOF
|
||||
# Make the font accessible
|
||||
prepare_grub_to_access_device `${grub_probe} --target=device "${font_path}"`
|
||||
cat << EOF
|
||||
font="`make_system_path_relative_to_its_root "${font_path}"`"
|
||||
fi
|
||||
|
||||
if loadfont \$font ; then
|
||||
EOF
|
||||
else
|
||||
cat << EOF
|
||||
if loadfont unicode ; then
|
||||
EOF
|
||||
fi
|
||||
fi
|
||||
|
||||
cat << EOF
|
||||
set gfxmode=${GRUB_GFXMODE}
|
||||
load_video
|
||||
insmod gfxterm
|
||||
EOF
|
||||
|
||||
# Gettext variables and module
|
||||
if [ "x${LANG}" != "xC" ] && [ "x${LANG}" != "x" ]; then
|
||||
cat << EOF
|
||||
set locale_dir=\$prefix/locale
|
||||
set lang=${grub_lang}
|
||||
insmod gettext
|
||||
EOF
|
||||
fi
|
||||
|
||||
cat <<EOF
|
||||
fi
|
||||
EOF
|
||||
fi
|
||||
|
||||
case x${GRUB_TERMINAL_INPUT} in
|
||||
x)
|
||||
# Just use the native terminal
|
||||
;;
|
||||
x*)
|
||||
cat << EOF
|
||||
terminal_input ${GRUB_TERMINAL_INPUT}
|
||||
EOF
|
||||
;;
|
||||
esac
|
||||
|
||||
case x${GRUB_TERMINAL_OUTPUT} in
|
||||
x)
|
||||
# Just use the native terminal
|
||||
;;
|
||||
x*)
|
||||
cat << EOF
|
||||
terminal_output ${GRUB_TERMINAL_OUTPUT}
|
||||
EOF
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "x$gfxterm" = x1 ]; then
|
||||
if [ "x$GRUB_THEME" != x ] && [ -f "$GRUB_THEME" ] \
|
||||
&& is_path_readable_by_grub "$GRUB_THEME"; then
|
||||
gettext_printf "Found theme: %s\n" "$GRUB_THEME" >&2
|
||||
|
||||
prepare_grub_to_access_device `${grub_probe} --target=device "$GRUB_THEME"`
|
||||
cat << EOF
|
||||
insmod gfxmenu
|
||||
EOF
|
||||
themedir="`dirname "$GRUB_THEME"`"
|
||||
for x in "$themedir"/*.pf2 "$themedir"/f/*.pf2; do
|
||||
if [ -f "$x" ]; then
|
||||
cat << EOF
|
||||
loadfont (\$root)`make_system_path_relative_to_its_root $x`
|
||||
EOF
|
||||
fi
|
||||
done
|
||||
if [ x"`echo "$themedir"/*.jpg`" != x"$themedir/*.jpg" ] || [ x"`echo "$themedir"/*.jpeg`" != x"$themedir/*.jpeg" ]; then
|
||||
cat << EOF
|
||||
insmod jpeg
|
||||
EOF
|
||||
fi
|
||||
if [ x"`echo "$themedir"/*.png`" != x"$themedir/*.png" ]; then
|
||||
cat << EOF
|
||||
insmod png
|
||||
EOF
|
||||
fi
|
||||
if [ x"`echo "$themedir"/*.tga`" != x"$themedir/*.tga" ]; then
|
||||
cat << EOF
|
||||
insmod tga
|
||||
EOF
|
||||
fi
|
||||
|
||||
cat << EOF
|
||||
set theme=(\$root)`make_system_path_relative_to_its_root $GRUB_THEME`
|
||||
export theme
|
||||
EOF
|
||||
elif [ "x$GRUB_BACKGROUND" != x ] && [ -f "$GRUB_BACKGROUND" ] \
|
||||
&& is_path_readable_by_grub "$GRUB_BACKGROUND"; then
|
||||
gettext_printf "Found background: %s\n" "$GRUB_BACKGROUND" >&2
|
||||
case "$GRUB_BACKGROUND" in
|
||||
*.png) reader=png ;;
|
||||
*.tga) reader=tga ;;
|
||||
*.jpg|*.jpeg) reader=jpeg ;;
|
||||
*) gettext "Unsupported image format" >&2; echo >&2; exit 1 ;;
|
||||
esac
|
||||
prepare_grub_to_access_device `${grub_probe} --target=device "$GRUB_BACKGROUND"`
|
||||
cat << EOF
|
||||
insmod $reader
|
||||
background_image -m stretch `make_system_path_relative_to_its_root "$GRUB_BACKGROUND"`
|
||||
EOF
|
||||
fi
|
||||
fi
|
||||
|
||||
make_timeout ()
|
||||
{
|
||||
if [ "x${3}" != "x" ] ; then
|
||||
timeout="${2}"
|
||||
style="${3}"
|
||||
elif [ "x${1}" != "x" ] && [ "x${1}" != "x0" ] ; then
|
||||
# Handle the deprecated GRUB_HIDDEN_TIMEOUT scheme.
|
||||
timeout="${1}"
|
||||
if [ "x${2}" != "x0" ] ; then
|
||||
grub_warn "$(gettext "Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.")"
|
||||
fi
|
||||
if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
|
||||
style="hidden"
|
||||
verbose=
|
||||
else
|
||||
style="countdown"
|
||||
verbose=" --verbose"
|
||||
fi
|
||||
else
|
||||
# No hidden timeout, so treat as GRUB_TIMEOUT_STYLE=menu
|
||||
timeout="${2}"
|
||||
style="menu"
|
||||
fi
|
||||
cat << EOF
|
||||
if [ x\$feature_timeout_style = xy ] ; then
|
||||
set timeout_style=${style}
|
||||
set timeout=${timeout}
|
||||
EOF
|
||||
if [ "x${style}" = "xmenu" ] ; then
|
||||
cat << EOF
|
||||
# Fallback normal timeout code in case the timeout_style feature is
|
||||
# unavailable.
|
||||
else
|
||||
set timeout=${timeout}
|
||||
EOF
|
||||
else
|
||||
cat << EOF
|
||||
# Fallback hidden-timeout code in case the timeout_style feature is
|
||||
# unavailable.
|
||||
elif sleep${verbose} --interruptible ${timeout} ; then
|
||||
set timeout=0
|
||||
EOF
|
||||
fi
|
||||
cat << EOF
|
||||
fi
|
||||
EOF
|
||||
}
|
||||
|
||||
if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
|
||||
cat <<EOF
|
||||
if cmostest $GRUB_BUTTON_CMOS_ADDRESS ; then
|
||||
EOF
|
||||
make_timeout "${GRUB_HIDDEN_TIMEOUT_BUTTON}" "${GRUB_TIMEOUT_BUTTON}" "${GRUB_TIMEOUT_STYLE_BUTTON}"
|
||||
echo else
|
||||
make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}" "${GRUB_TIMEOUT_STYLE}"
|
||||
echo fi
|
||||
else
|
||||
make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}" "${GRUB_TIMEOUT_STYLE}"
|
||||
fi
|
||||
|
||||
if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ] && [ "x$GRUB_BUTTON_CMOS_CLEAN" = "xyes" ]; then
|
||||
cat <<EOF
|
||||
cmosclean $GRUB_BUTTON_CMOS_ADDRESS
|
||||
EOF
|
||||
fi
|
||||
|
||||
# Play an initial tune
|
||||
if [ "x${GRUB_INIT_TUNE}" != "x" ] ; then
|
||||
echo "play ${GRUB_INIT_TUNE}"
|
||||
fi
|
||||
|
||||
if [ "x${GRUB_BADRAM}" != "x" ] ; then
|
||||
echo "badram ${GRUB_BADRAM}"
|
||||
fi
|
||||
29
grub.d/00_tuned
Executable file
29
grub.d/00_tuned
Executable file
@@ -0,0 +1,29 @@
|
||||
#! /bin/sh
|
||||
set -e
|
||||
|
||||
# grub-mkconfig helper script.
|
||||
# Copyright (C) 2014 Red Hat, Inc
|
||||
# Author: Jaroslav Škarvada <jskarvad@redhat.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
tunedcfgdir=/etc/tuned
|
||||
tuned_bootcmdline_file=$tunedcfgdir/bootcmdline
|
||||
|
||||
. $tuned_bootcmdline_file
|
||||
|
||||
echo "set tuned_params=\"$TUNED_BOOT_CMDLINE\""
|
||||
echo "set tuned_initrd=\"$TUNED_BOOT_INITRD_ADD\""
|
||||
11
grub.d/01_users
Executable file
11
grub.d/01_users
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh -e
|
||||
cat << EOF
|
||||
if [ -f \${prefix}/user.cfg ]; then
|
||||
source \${prefix}/user.cfg
|
||||
if [ -n "\${GRUB2_PASSWORD}" ]; then
|
||||
set superusers="root"
|
||||
export superusers
|
||||
password_pbkdf2 root \${GRUB2_PASSWORD}
|
||||
fi
|
||||
fi
|
||||
EOF
|
||||
24
grub.d/08_fallback_counting
Executable file
24
grub.d/08_fallback_counting
Executable file
@@ -0,0 +1,24 @@
|
||||
#! /bin/sh -e
|
||||
# Fallback Countdown
|
||||
#
|
||||
# This snippet depends on 10_reset_boot_success and needs to be kept in sync.
|
||||
#
|
||||
# The boot_counter env var can be used to count down boot attempts after an
|
||||
# OSTree upgrade and choose the rollback deployment when 0 is reached.
|
||||
# Both boot_counter=X and boot_success=1 need to be set from userspace.
|
||||
cat << EOF
|
||||
insmod increment
|
||||
# Check if boot_counter exists and boot_success=0 to activate this behaviour.
|
||||
if [ -n "\${boot_counter}" -a "\${boot_success}" = "0" ]; then
|
||||
# if countdown has ended, choose to boot rollback deployment,
|
||||
# i.e. default=1 on OSTree-based systems.
|
||||
if [ "\${boot_counter}" = "0" -o "\${boot_counter}" = "-1" ]; then
|
||||
set default=1
|
||||
set boot_counter=-1
|
||||
# otherwise decrement boot_counter
|
||||
else
|
||||
decrement boot_counter
|
||||
fi
|
||||
save_env boot_counter
|
||||
fi
|
||||
EOF
|
||||
415
grub.d/10_linux
Executable file
415
grub.d/10_linux
Executable file
@@ -0,0 +1,415 @@
|
||||
#! /bin/sh
|
||||
set -e
|
||||
|
||||
# grub-mkconfig helper script.
|
||||
# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||
#
|
||||
# GRUB is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# GRUB 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
prefix="/usr"
|
||||
exec_prefix="/usr"
|
||||
datarootdir="/usr/share"
|
||||
|
||||
. "$pkgdatadir/grub-mkconfig_lib"
|
||||
|
||||
export TEXTDOMAIN=grub
|
||||
export TEXTDOMAINDIR="${datarootdir}/locale"
|
||||
|
||||
CLASS="--class gnu-linux --class gnu --class os --unrestricted"
|
||||
|
||||
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
|
||||
OS="$(eval $(grep PRETTY_NAME /etc/os-release) ; echo ${PRETTY_NAME})"
|
||||
CLASS="--class $(eval $(grep '^ID_LIKE=\|^ID=' /etc/os-release) ; [ -n "${ID_LIKE}" ] && echo ${ID_LIKE} || echo ${ID}) ${CLASS}"
|
||||
else
|
||||
OS="${GRUB_DISTRIBUTOR}"
|
||||
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}"
|
||||
fi
|
||||
|
||||
# loop-AES arranges things so that /dev/loop/X can be our root device, but
|
||||
# the initrds that Linux uses don't like that.
|
||||
case ${GRUB_DEVICE} in
|
||||
/dev/loop/*|/dev/loop[0-9])
|
||||
GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
|
||||
;;
|
||||
esac
|
||||
|
||||
# Default to disabling partition uuid support to maintian compatibility with
|
||||
# older kernels.
|
||||
GRUB_DISABLE_LINUX_PARTUUID=${GRUB_DISABLE_LINUX_PARTUUID-true}
|
||||
|
||||
# btrfs may reside on multiple devices. We cannot pass them as value of root= parameter
|
||||
# and mounting btrfs requires user space scanning, so force UUID in this case.
|
||||
if ( [ "x${GRUB_DEVICE_UUID}" = "x" ] && [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] ) \
|
||||
|| ( [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
|
||||
&& [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ] ) \
|
||||
|| ( ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
|
||||
&& ! test -e "/dev/disk/by-partuuid/${GRUB_DEVICE_PARTUUID}" ) \
|
||||
|| ( test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm ); then
|
||||
LINUX_ROOT_DEVICE=${GRUB_DEVICE}
|
||||
elif [ "x${GRUB_DEVICE_UUID}" = "x" ] \
|
||||
|| [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ]; then
|
||||
LINUX_ROOT_DEVICE=PARTUUID=${GRUB_DEVICE_PARTUUID}
|
||||
else
|
||||
LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
|
||||
fi
|
||||
|
||||
case x"$GRUB_FS" in
|
||||
xbtrfs)
|
||||
if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ]; then
|
||||
GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX} \${extra_cmdline}"
|
||||
else
|
||||
rootsubvol="`make_system_path_relative_to_its_root /`"
|
||||
rootsubvol="${rootsubvol#/}"
|
||||
if [ "x${rootsubvol}" != x ]; then
|
||||
GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
|
||||
fi
|
||||
fi;;
|
||||
xzfs)
|
||||
rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true`
|
||||
bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`"
|
||||
LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs}"
|
||||
;;
|
||||
esac
|
||||
|
||||
populate_header_warn()
|
||||
{
|
||||
cat <<EOF
|
||||
|
||||
# This section was generated by a script. Do not modify the generated file - all changes
|
||||
# will be lost the next time file is regenerated. Instead edit the BootLoaderSpec files.
|
||||
#
|
||||
# The blscfg command parses the BootLoaderSpec files stored in /boot/loader/entries and
|
||||
# populates the boot menu. Please refer to the Boot Loader Specification documentation
|
||||
# for the files format: https://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/.
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
mktitle ()
|
||||
{
|
||||
local title_type
|
||||
local version
|
||||
local OS_NAME
|
||||
local OS_VERS
|
||||
|
||||
title_type=$1 && shift
|
||||
version=$1 && shift
|
||||
|
||||
OS_NAME="$(eval $(grep ^NAME= /etc/os-release) ; echo ${NAME})"
|
||||
OS_VERS="$(eval $(grep ^VERSION= /etc/os-release) ; echo ${VERSION})"
|
||||
|
||||
case $title_type in
|
||||
recovery)
|
||||
title=$(printf '%s (%s) %s (recovery mode)' \
|
||||
"${OS_NAME}" "${version}" "${OS_VERS}")
|
||||
;;
|
||||
*)
|
||||
title=$(printf '%s (%s) %s' \
|
||||
"${OS_NAME}" "${version}" "${OS_VERS}")
|
||||
;;
|
||||
esac
|
||||
echo -n ${title}
|
||||
}
|
||||
|
||||
title_correction_code=
|
||||
|
||||
linux_entry ()
|
||||
{
|
||||
os="$1"
|
||||
version="$2"
|
||||
type="$3"
|
||||
isdebug="$4"
|
||||
args="$5"
|
||||
|
||||
if [ -z "$boot_device_id" ]; then
|
||||
boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
|
||||
fi
|
||||
|
||||
if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then
|
||||
if [ x$dirname = x/ ]; then
|
||||
if [ -z "${prepare_root_cache}" ]; then
|
||||
prepare_grub_to_access_device ${GRUB_DEVICE}
|
||||
fi
|
||||
else
|
||||
if [ -z "${prepare_boot_cache}" ]; then
|
||||
prepare_grub_to_access_device ${GRUB_DEVICE_BOOT}
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -d /sys/firmware/efi ]; then
|
||||
bootefi_device="`${grub_probe} --target=device /boot/efi/`"
|
||||
prepare_grub_to_access_device ${bootefi_device} boot
|
||||
else
|
||||
boot_device="`${grub_probe} --target=device /boot/`"
|
||||
prepare_grub_to_access_device ${boot_device} boot
|
||||
fi
|
||||
|
||||
populate_header_warn
|
||||
|
||||
cat << EOF
|
||||
# The kernelopts variable should be defined in the grubenv file. But to ensure that menu
|
||||
# entries populated from BootLoaderSpec files that use this variable work correctly even
|
||||
# without a grubenv file, define a fallback kernelopts variable if this has not been set.
|
||||
#
|
||||
# The kernelopts variable in the grubenv file can be modified using the grubby tool or by
|
||||
# executing the grub2-mkconfig tool. For the latter, the values of the GRUB_CMDLINE_LINUX
|
||||
# and GRUB_CMDLINE_LINUX_DEFAULT options from /etc/default/grub file are used to set both
|
||||
# the kernelopts variable in the grubenv file and the fallback kernelopts variable.
|
||||
if [ -z "\${kernelopts}" ]; then
|
||||
set kernelopts="root=${linux_root_device_thisversion} ro ${args}"
|
||||
fi
|
||||
|
||||
insmod blscfg
|
||||
blscfg
|
||||
EOF
|
||||
|
||||
if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then
|
||||
${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ x$type != xsimple ] ; then
|
||||
title=$(mktitle "$type" "$version")
|
||||
if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then
|
||||
replacement_title="$(echo "Advanced options for ${OS}" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')"
|
||||
quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)"
|
||||
title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;"
|
||||
fi
|
||||
if [ x$isdebug = xdebug ]; then
|
||||
title="$title${GRUB_LINUX_DEBUG_TITLE_POSTFIX}"
|
||||
fi
|
||||
echo "menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-$version-$type-$boot_device_id' {" | sed "s/^/$submenu_indentation/"
|
||||
else
|
||||
echo "menuentry '$(echo "$os" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/"
|
||||
fi
|
||||
if [ x$type != xrecovery ] ; then
|
||||
save_default_entry | grub_add_tab
|
||||
fi
|
||||
|
||||
# Use ELILO's generic "efifb" when it's known to be available.
|
||||
# FIXME: We need an interface to select vesafb in case efifb can't be used.
|
||||
if [ "x$GRUB_GFXPAYLOAD_LINUX" = x ]; then
|
||||
echo " load_video" | sed "s/^/$submenu_indentation/"
|
||||
if grep -qx "CONFIG_FB_EFI=y" "${config}" 2> /dev/null \
|
||||
&& grep -qx "CONFIG_VT_HW_CONSOLE_BINDING=y" "${config}" 2> /dev/null; then
|
||||
echo " set gfxpayload=keep" | sed "s/^/$submenu_indentation/"
|
||||
fi
|
||||
else
|
||||
if [ "x$GRUB_GFXPAYLOAD_LINUX" != xtext ]; then
|
||||
echo " load_video" | sed "s/^/$submenu_indentation/"
|
||||
fi
|
||||
echo " set gfxpayload=$GRUB_GFXPAYLOAD_LINUX" | sed "s/^/$submenu_indentation/"
|
||||
fi
|
||||
|
||||
echo " insmod gzio" | sed "s/^/$submenu_indentation/"
|
||||
|
||||
if [ x$dirname = x/ ]; then
|
||||
if [ -z "${prepare_root_cache}" ]; then
|
||||
prepare_root_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE} | grub_add_tab)"
|
||||
fi
|
||||
printf '%s\n' "${prepare_root_cache}" | sed "s/^/$submenu_indentation/"
|
||||
else
|
||||
if [ -z "${prepare_boot_cache}" ]; then
|
||||
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | grub_add_tab)"
|
||||
fi
|
||||
printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/"
|
||||
fi
|
||||
sed "s/^/$submenu_indentation/" << EOF
|
||||
linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
|
||||
EOF
|
||||
if test -n "${initrd}" ; then
|
||||
initrd_path=
|
||||
for i in ${initrd}; do
|
||||
initrd_path="${initrd_path} ${rel_dirname}/${i}"
|
||||
done
|
||||
sed "s/^/$submenu_indentation/" << EOF
|
||||
initrd $(echo $initrd_path)
|
||||
EOF
|
||||
fi
|
||||
if test -n "${fdt}" ; then
|
||||
sed "s/^/$submenu_indentation/" << EOF
|
||||
devicetree ${rel_dirname}/${fdt}
|
||||
EOF
|
||||
fi
|
||||
sed "s/^/$submenu_indentation/" << EOF
|
||||
}
|
||||
EOF
|
||||
}
|
||||
|
||||
machine=`uname -m`
|
||||
case "x$machine" in
|
||||
xi?86 | xx86_64)
|
||||
list=
|
||||
for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-* ; do
|
||||
if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi
|
||||
done ;;
|
||||
*)
|
||||
list=
|
||||
for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-* ; do
|
||||
if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi
|
||||
done ;;
|
||||
esac
|
||||
|
||||
if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then
|
||||
for i in /boot/ostree/*/vmlinuz-* ; do
|
||||
if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi
|
||||
done
|
||||
fi
|
||||
|
||||
case "$machine" in
|
||||
i?86) GENKERNEL_ARCH="x86" ;;
|
||||
mips|mips64) GENKERNEL_ARCH="mips" ;;
|
||||
mipsel|mips64el) GENKERNEL_ARCH="mipsel" ;;
|
||||
arm*) GENKERNEL_ARCH="arm" ;;
|
||||
*) GENKERNEL_ARCH="$machine" ;;
|
||||
esac
|
||||
|
||||
prepare_boot_cache=
|
||||
prepare_root_cache=
|
||||
boot_device_id=
|
||||
title_correction_code=
|
||||
|
||||
# Extra indentation to add to menu entries in a submenu. We're not in a submenu
|
||||
# yet, so it's empty. In a submenu it will be equal to '\t' (one tab).
|
||||
submenu_indentation=""
|
||||
|
||||
is_top_level=true
|
||||
while [ "x$list" != "x" ] ; do
|
||||
linux=`version_find_latest $list`
|
||||
if [ "x${GRUB_ENABLE_BLSCFG}" != "xtrue" ]; then
|
||||
gettext_printf "Found linux image: %s\n" "$linux" >&2
|
||||
fi
|
||||
|
||||
basename=`basename $linux`
|
||||
dirname=`dirname $linux`
|
||||
rel_dirname=`make_system_path_relative_to_its_root $dirname`
|
||||
version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
|
||||
alt_version=`echo $version | sed -e "s,\.old$,,g"`
|
||||
linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
|
||||
|
||||
initrd_early=
|
||||
for i in ${GRUB_EARLY_INITRD_LINUX_STOCK} \
|
||||
${GRUB_EARLY_INITRD_LINUX_CUSTOM}; do
|
||||
if test -e "${dirname}/${i}" ; then
|
||||
initrd_early="${initrd_early} ${i}"
|
||||
fi
|
||||
done
|
||||
|
||||
initrd_real=
|
||||
for i in "initrd.img-${version}" "initrd-${version}.img" "initrd-${version}.gz" \
|
||||
"initrd-${version}" "initramfs-${version}.img" \
|
||||
"initrd.img-${alt_version}" "initrd-${alt_version}.img" \
|
||||
"initrd-${alt_version}" "initramfs-${alt_version}.img" \
|
||||
"initramfs-genkernel-${version}" \
|
||||
"initramfs-genkernel-${alt_version}" \
|
||||
"initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \
|
||||
"initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}"; do
|
||||
if test -e "${dirname}/${i}" ; then
|
||||
initrd_real="${i}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
initrd=
|
||||
if test -n "${initrd_early}" || test -n "${initrd_real}"; then
|
||||
initrd="${initrd_early} ${initrd_real}"
|
||||
|
||||
initrd_display=
|
||||
for i in ${initrd}; do
|
||||
initrd_display="${initrd_display} ${dirname}/${i}"
|
||||
done
|
||||
if [ "x${GRUB_ENABLE_BLSCFG}" != "xtrue" ]; then
|
||||
gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2
|
||||
fi
|
||||
fi
|
||||
|
||||
fdt=
|
||||
for i in "dtb-${version}" "dtb-${alt_version}"; do
|
||||
if test -f "${dirname}/${i}/${GRUB_DEFAULT_DTB}" ; then
|
||||
fdt="${i}/${GRUB_DEFAULT_DTB}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
config=
|
||||
for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do
|
||||
if test -e "${i}" ; then
|
||||
config="${i}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
initramfs=
|
||||
if test -n "${config}" ; then
|
||||
initramfs=`grep CONFIG_INITRAMFS_SOURCE= "${config}" | cut -f2 -d= | tr -d \"`
|
||||
fi
|
||||
|
||||
if test -z "${initramfs}" && test -z "${initrd_real}" ; then
|
||||
# "UUID=" and "ZFS=" magic is parsed by initrd or initramfs. Since there's
|
||||
# no initrd or builtin initramfs, it can't work here.
|
||||
if [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] \
|
||||
|| [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ]; then
|
||||
|
||||
linux_root_device_thisversion=${GRUB_DEVICE}
|
||||
else
|
||||
linux_root_device_thisversion=PARTUUID=${GRUB_DEVICE_PARTUUID}
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "x${GRUB_DISABLE_SUBMENU}" = "xyes" ] || [ "x${GRUB_DISABLE_SUBMENU}" = "xy" ]; then
|
||||
GRUB_DISABLE_SUBMENU="true"
|
||||
fi
|
||||
|
||||
if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then
|
||||
linux_entry "${OS}" "${version}" simple standard \
|
||||
"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
|
||||
if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then
|
||||
linux_entry "${OS}" "${version}" simple debug \
|
||||
"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${GRUB_CMDLINE_LINUX_DEBUG}"
|
||||
fi
|
||||
|
||||
submenu_indentation="$grub_tab"
|
||||
|
||||
if [ -z "$boot_device_id" ]; then
|
||||
boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
|
||||
fi
|
||||
# TRANSLATORS: %s is replaced with an OS name
|
||||
echo "submenu '$(gettext_printf "Advanced options for %s" "${OS}" | grub_quote)' \$menuentry_id_option 'gnulinux-advanced-$boot_device_id' {"
|
||||
is_top_level=false
|
||||
fi
|
||||
|
||||
linux_entry "${OS}" "${version}" advanced standard \
|
||||
"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
|
||||
if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then
|
||||
linux_entry "${OS}" "${version}" advanced debug \
|
||||
"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${GRUB_CMDLINE_LINUX_DEBUG}"
|
||||
fi
|
||||
|
||||
if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
|
||||
linux_entry "${OS}" "${version}" recovery standard \
|
||||
"single ${GRUB_CMDLINE_LINUX}"
|
||||
fi
|
||||
|
||||
list=`echo $list | tr ' ' '\n' | fgrep -vx "$linux" | tr '\n' ' '`
|
||||
done
|
||||
|
||||
# If at least one kernel was found, then we need to
|
||||
# add a closing '}' for the submenu command.
|
||||
if [ x"$is_top_level" != xtrue ]; then
|
||||
echo '}'
|
||||
fi
|
||||
|
||||
echo "$title_correction_code"
|
||||
25
grub.d/10_reset_boot_success
Executable file
25
grub.d/10_reset_boot_success
Executable file
@@ -0,0 +1,25 @@
|
||||
#! /bin/sh -e
|
||||
# Reset Boot Success
|
||||
#
|
||||
# The 08_fallback_counting and 12_menu_auto_hide snippets rely on this one
|
||||
# and need to be kept in sync.
|
||||
#
|
||||
# The boot_success var needs to be set to 1 from userspace to mark a boot successful.
|
||||
cat << EOF
|
||||
# Hiding the menu is ok if last boot was ok or if this is a first boot attempt to boot the entry
|
||||
if [ "\${boot_success}" = "1" -o "\${boot_indeterminate}" = "1" ]; then
|
||||
set menu_hide_ok=1
|
||||
else
|
||||
set menu_hide_ok=0
|
||||
fi
|
||||
# Reset boot_indeterminate after a successful boot
|
||||
if [ "\${boot_success}" = "1" ] ; then
|
||||
set boot_indeterminate=0
|
||||
# Avoid boot_indeterminate causing the menu to be hidden more then once
|
||||
elif [ "\${boot_indeterminate}" = "1" ]; then
|
||||
set boot_indeterminate=2
|
||||
fi
|
||||
# Reset boot_success for current boot
|
||||
set boot_success=0
|
||||
save_env boot_success boot_indeterminate
|
||||
EOF
|
||||
35
grub.d/12_menu_auto_hide
Executable file
35
grub.d/12_menu_auto_hide
Executable file
@@ -0,0 +1,35 @@
|
||||
#! /bin/sh
|
||||
# Menu Auto Hide
|
||||
#
|
||||
# This snippet depends on 10_reset_boot_success and needs to be kept in sync.
|
||||
#
|
||||
# Disable / skip generating menu-auto-hide config parts on serial terminals
|
||||
for x in ${GRUB_TERMINAL_INPUT} ${GRUB_TERMINAL_OUTPUT}; do
|
||||
case "$x" in
|
||||
serial*)
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
cat << EOF
|
||||
if [ x\$feature_timeout_style = xy ] ; then
|
||||
if [ "\${menu_show_once}" ]; then
|
||||
unset menu_show_once
|
||||
save_env menu_show_once
|
||||
set timeout_style=menu
|
||||
set timeout=60
|
||||
elif [ "\${menu_auto_hide}" -a "\${menu_hide_ok}" = "1" ]; then
|
||||
set orig_timeout_style=\${timeout_style}
|
||||
set orig_timeout=\${timeout}
|
||||
if [ "\${fastboot}" = "1" ]; then
|
||||
# timeout_style=menu + timeout=0 avoids the countdown code keypress check
|
||||
set timeout_style=menu
|
||||
set timeout=0
|
||||
else
|
||||
set timeout_style=hidden
|
||||
set timeout=1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
EOF
|
||||
311
grub.d/20_linux_xen
Executable file
311
grub.d/20_linux_xen
Executable file
@@ -0,0 +1,311 @@
|
||||
#! /bin/sh
|
||||
set -e
|
||||
|
||||
# grub-mkconfig helper script.
|
||||
# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||
#
|
||||
# GRUB is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# GRUB 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
prefix="/usr"
|
||||
exec_prefix="/usr"
|
||||
datarootdir="/usr/share"
|
||||
|
||||
. "$pkgdatadir/grub-mkconfig_lib"
|
||||
|
||||
export TEXTDOMAIN=grub
|
||||
export TEXTDOMAINDIR="${datarootdir}/locale"
|
||||
|
||||
CLASS="--class gnu-linux --class gnu --class os --class xen"
|
||||
|
||||
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
|
||||
OS="$(sed 's, release .*$,,g' /etc/system-release)"
|
||||
else
|
||||
OS="${GRUB_DISTRIBUTOR}"
|
||||
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}"
|
||||
fi
|
||||
|
||||
# loop-AES arranges things so that /dev/loop/X can be our root device, but
|
||||
# the initrds that Linux uses don't like that.
|
||||
case ${GRUB_DEVICE} in
|
||||
/dev/loop/*|/dev/loop[0-9])
|
||||
GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
|
||||
;;
|
||||
esac
|
||||
|
||||
# Default to disabling partition uuid support to maintian compatibility with
|
||||
# older kernels.
|
||||
GRUB_DISABLE_LINUX_PARTUUID=${GRUB_DISABLE_LINUX_PARTUUID-true}
|
||||
|
||||
# btrfs may reside on multiple devices. We cannot pass them as value of root= parameter
|
||||
# and mounting btrfs requires user space scanning, so force UUID in this case.
|
||||
if ( [ "x${GRUB_DEVICE_UUID}" = "x" ] && [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] ) \
|
||||
|| ( [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
|
||||
&& [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ] ) \
|
||||
|| ( ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
|
||||
&& ! test -e "/dev/disk/by-partuuid/${GRUB_DEVICE_PARTUUID}" ) \
|
||||
|| ( test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm ); then
|
||||
LINUX_ROOT_DEVICE=${GRUB_DEVICE}
|
||||
elif [ "x${GRUB_DEVICE_UUID}" = "x" ] \
|
||||
|| [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ]; then
|
||||
LINUX_ROOT_DEVICE=PARTUUID=${GRUB_DEVICE_PARTUUID}
|
||||
else
|
||||
LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
|
||||
fi
|
||||
|
||||
# Allow overriding GRUB_CMDLINE_LINUX and GRUB_CMDLINE_LINUX_DEFAULT.
|
||||
if [ "${GRUB_CMDLINE_LINUX_XEN_REPLACE}" ]; then
|
||||
GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX_XEN_REPLACE}"
|
||||
fi
|
||||
if [ "${GRUB_CMDLINE_LINUX_XEN_REPLACE_DEFAULT}" ]; then
|
||||
GRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_XEN_REPLACE_DEFAULT}"
|
||||
fi
|
||||
|
||||
case x"$GRUB_FS" in
|
||||
xbtrfs)
|
||||
if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ]; then
|
||||
GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX} \${extra_cmdline}"
|
||||
else
|
||||
rootsubvol="`make_system_path_relative_to_its_root /`"
|
||||
rootsubvol="${rootsubvol#/}"
|
||||
if [ "x${rootsubvol}" != x ]; then
|
||||
GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
|
||||
fi
|
||||
fi;;
|
||||
xzfs)
|
||||
rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true`
|
||||
bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`"
|
||||
LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs}"
|
||||
;;
|
||||
esac
|
||||
|
||||
title_correction_code=
|
||||
|
||||
linux_entry ()
|
||||
{
|
||||
os="$1"
|
||||
version="$2"
|
||||
xen_version="$3"
|
||||
type="$4"
|
||||
args="$5"
|
||||
xen_args="$6"
|
||||
if [ -z "$boot_device_id" ]; then
|
||||
boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
|
||||
fi
|
||||
if [ x$type != xsimple ] ; then
|
||||
if [ x$type = xrecovery ] ; then
|
||||
title="$(gettext_printf "%s, with Xen %s and Linux %s (recovery mode)" "${os}" "${xen_version}" "${version}")"
|
||||
else
|
||||
title="$(gettext_printf "%s, with Xen %s and Linux %s" "${os}" "${xen_version}" "${version}")"
|
||||
fi
|
||||
replacement_title="$(echo "Advanced options for ${OS}" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')"
|
||||
if [ x"Xen ${xen_version}>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then
|
||||
quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)"
|
||||
title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;"
|
||||
grub_warn "$(gettext_printf "Please don't use old title \`%s' for GRUB_DEFAULT, use \`%s' (for versions before 2.00) or \`%s' (for 2.00 or later)" "$GRUB_ACTUAL_DEFAULT" "$replacement_title" "gnulinux-advanced-$boot_device_id>gnulinux-$version-$type-$boot_device_id")"
|
||||
fi
|
||||
echo "menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry_id_option 'xen-gnulinux-$version-$type-$boot_device_id' {" | sed "s/^/$submenu_indentation/"
|
||||
else
|
||||
title="$(gettext_printf "%s, with Xen hypervisor" "${os}")"
|
||||
echo "menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry_id_option 'xen-gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/"
|
||||
fi
|
||||
if [ x$type != xrecovery ] ; then
|
||||
save_default_entry | grub_add_tab | sed "s/^/$submenu_indentation/"
|
||||
fi
|
||||
|
||||
if [ -z "${prepare_boot_cache}" ]; then
|
||||
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | grub_add_tab)"
|
||||
fi
|
||||
printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/"
|
||||
xmessage="$(gettext_printf "Loading Xen %s ..." ${xen_version})"
|
||||
lmessage="$(gettext_printf "Loading Linux %s ..." ${version})"
|
||||
sed "s/^/$submenu_indentation/" << EOF
|
||||
echo '$(echo "$xmessage" | grub_quote)'
|
||||
if [ "\$grub_platform" = "pc" -o "\$grub_platform" = "" ]; then
|
||||
xen_rm_opts=
|
||||
else
|
||||
xen_rm_opts="no-real-mode edd=off"
|
||||
fi
|
||||
insmod ${module_loader}
|
||||
insmod ${xen_loader}
|
||||
${xen_loader} ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} \${xen_rm_opts}
|
||||
echo '$(echo "$lmessage" | grub_quote)'
|
||||
${module_loader} ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args}
|
||||
EOF
|
||||
if test -n "${initrd}" ; then
|
||||
# TRANSLATORS: ramdisk isn't identifier. Should be translated.
|
||||
message="$(gettext_printf "Loading initial ramdisk ...")"
|
||||
sed "s/^/$submenu_indentation/" << EOF
|
||||
echo '$(echo "$message" | grub_quote)'
|
||||
insmod ${module_loader}
|
||||
${module_loader} --nounzip ${rel_dirname}/${initrd}
|
||||
EOF
|
||||
fi
|
||||
sed "s/^/$submenu_indentation/" << EOF
|
||||
}
|
||||
EOF
|
||||
}
|
||||
|
||||
linux_list=
|
||||
for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* /boot/kernel-*; do
|
||||
if grub_file_is_not_garbage "$i"; then
|
||||
basename=$(basename $i)
|
||||
version=$(echo $basename | sed -e "s,^[^0-9]*-,,g")
|
||||
dirname=$(dirname $i)
|
||||
config=
|
||||
for j in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do
|
||||
if test -e "${j}" ; then
|
||||
config="${j}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if (grep -qx "CONFIG_XEN_DOM0=y" "${config}" 2> /dev/null || grep -qx "CONFIG_XEN_PRIVILEGED_GUEST=y" "${config}" 2> /dev/null); then linux_list="$linux_list $i" ; fi
|
||||
fi
|
||||
done
|
||||
if [ "x${linux_list}" = "x" ] ; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
file_is_not_sym () {
|
||||
case "$1" in
|
||||
*/xen-syms-*)
|
||||
return 1;;
|
||||
*)
|
||||
return 0;;
|
||||
esac
|
||||
}
|
||||
|
||||
xen_list=
|
||||
for i in /boot/xen*; do
|
||||
if grub_file_is_not_garbage "$i" && file_is_not_sym "$i" ; then xen_list="$xen_list $i" ; fi
|
||||
done
|
||||
prepare_boot_cache=
|
||||
boot_device_id=
|
||||
|
||||
title_correction_code=
|
||||
|
||||
machine=`uname -m`
|
||||
|
||||
case "$machine" in
|
||||
i?86) GENKERNEL_ARCH="x86" ;;
|
||||
mips|mips64) GENKERNEL_ARCH="mips" ;;
|
||||
mipsel|mips64el) GENKERNEL_ARCH="mipsel" ;;
|
||||
arm*) GENKERNEL_ARCH="arm" ;;
|
||||
*) GENKERNEL_ARCH="$machine" ;;
|
||||
esac
|
||||
|
||||
# Extra indentation to add to menu entries in a submenu. We're not in a submenu
|
||||
# yet, so it's empty. In a submenu it will be equal to '\t' (one tab).
|
||||
submenu_indentation=""
|
||||
|
||||
is_top_level=true
|
||||
|
||||
while [ "x${xen_list}" != "x" ] ; do
|
||||
list="${linux_list}"
|
||||
current_xen=`version_find_latest $xen_list`
|
||||
xen_basename=`basename ${current_xen}`
|
||||
xen_dirname=`dirname ${current_xen}`
|
||||
rel_xen_dirname=`make_system_path_relative_to_its_root $xen_dirname`
|
||||
xen_version=`echo $xen_basename | sed -e "s,.gz$,,g;s,^xen-,,g"`
|
||||
if [ -z "$boot_device_id" ]; then
|
||||
boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
|
||||
fi
|
||||
if [ "x$is_top_level" != xtrue ]; then
|
||||
echo " submenu '$(gettext_printf "Xen hypervisor, version %s" "${xen_version}" | grub_quote)' \$menuentry_id_option 'xen-hypervisor-$xen_version-$boot_device_id' {"
|
||||
fi
|
||||
if ($grub_file --is-arm64-efi $current_xen); then
|
||||
xen_loader="xen_hypervisor"
|
||||
module_loader="xen_module"
|
||||
else
|
||||
if ($grub_file --is-x86-multiboot2 $current_xen); then
|
||||
xen_loader="multiboot2"
|
||||
module_loader="module2"
|
||||
else
|
||||
xen_loader="multiboot"
|
||||
module_loader="module"
|
||||
fi
|
||||
fi
|
||||
while [ "x$list" != "x" ] ; do
|
||||
linux=`version_find_latest $list`
|
||||
gettext_printf "Found linux image: %s\n" "$linux" >&2
|
||||
basename=`basename $linux`
|
||||
dirname=`dirname $linux`
|
||||
rel_dirname=`make_system_path_relative_to_its_root $dirname`
|
||||
version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
|
||||
alt_version=`echo $version | sed -e "s,\.old$,,g"`
|
||||
linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
|
||||
|
||||
initrd=
|
||||
for i in "initrd.img-${version}" "initrd-${version}.img" "initrd-${version}.gz" \
|
||||
"initrd-${version}" "initramfs-${version}.img" \
|
||||
"initrd.img-${alt_version}" "initrd-${alt_version}.img" \
|
||||
"initrd-${alt_version}" "initramfs-${alt_version}.img" \
|
||||
"initramfs-genkernel-${version}" \
|
||||
"initramfs-genkernel-${alt_version}" \
|
||||
"initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \
|
||||
"initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}" ; do
|
||||
if test -e "${dirname}/${i}" ; then
|
||||
initrd="$i"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test -n "${initrd}" ; then
|
||||
gettext_printf "Found initrd image: %s\n" "${dirname}/${initrd}" >&2
|
||||
else
|
||||
# "UUID=" magic is parsed by initrds. Since there's no initrd, it can't work here.
|
||||
if [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] \
|
||||
|| [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ]; then
|
||||
|
||||
linux_root_device_thisversion=${GRUB_DEVICE}
|
||||
else
|
||||
linux_root_device_thisversion=PARTUUID=${GRUB_DEVICE_PARTUUID}
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then
|
||||
linux_entry "${OS}" "${version}" "${xen_version}" simple \
|
||||
"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}"
|
||||
|
||||
submenu_indentation="$grub_tab$grub_tab"
|
||||
|
||||
if [ -z "$boot_device_id" ]; then
|
||||
boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
|
||||
fi
|
||||
# TRANSLATORS: %s is replaced with an OS name
|
||||
echo "submenu '$(gettext_printf "Advanced options for %s (with Xen hypervisor)" "${OS}" | grub_quote)' \$menuentry_id_option 'gnulinux-advanced-$boot_device_id' {"
|
||||
echo " submenu '$(gettext_printf "Xen hypervisor, version %s" "${xen_version}" | grub_quote)' \$menuentry_id_option 'xen-hypervisor-$xen_version-$boot_device_id' {"
|
||||
is_top_level=false
|
||||
fi
|
||||
|
||||
linux_entry "${OS}" "${version}" "${xen_version}" advanced \
|
||||
"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}"
|
||||
if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
|
||||
linux_entry "${OS}" "${version}" "${xen_version}" recovery \
|
||||
"single ${GRUB_CMDLINE_LINUX}" "${GRUB_CMDLINE_XEN}"
|
||||
fi
|
||||
|
||||
list=`echo $list | tr ' ' '\n' | fgrep -vx "$linux" | tr '\n' ' '`
|
||||
done
|
||||
if [ x"$is_top_level" != xtrue ]; then
|
||||
echo ' }'
|
||||
fi
|
||||
xen_list=`echo $xen_list | tr ' ' '\n' | fgrep -vx "$current_xen" | tr '\n' ' '`
|
||||
done
|
||||
|
||||
# If at least one kernel was found, then we need to
|
||||
# add a closing '}' for the submenu command.
|
||||
if [ x"$is_top_level" != xtrue ]; then
|
||||
echo '}'
|
||||
fi
|
||||
|
||||
echo "$title_correction_code"
|
||||
114
grub.d/20_ppc_terminfo
Executable file
114
grub.d/20_ppc_terminfo
Executable file
@@ -0,0 +1,114 @@
|
||||
#! /bin/sh
|
||||
set -e
|
||||
|
||||
# grub-mkconfig helper script.
|
||||
# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||
#
|
||||
# GRUB is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# GRUB 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
prefix=/usr
|
||||
exec_prefix=/usr
|
||||
bindir=/usr/bin
|
||||
libdir=/usr/lib
|
||||
. "/usr/share/grub/grub-mkconfig_lib"
|
||||
|
||||
export TEXTDOMAIN=grub
|
||||
export TEXTDOMAINDIR=/usr/share/locale
|
||||
|
||||
X=80
|
||||
Y=24
|
||||
TERMINAL=ofconsole
|
||||
|
||||
argument () {
|
||||
opt=$1
|
||||
shift
|
||||
|
||||
if test $# -eq 0; then
|
||||
echo "$0: option requires an argument -- '$opt'" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
echo $1
|
||||
}
|
||||
|
||||
check_terminfo () {
|
||||
|
||||
while test $# -gt 0
|
||||
do
|
||||
option=$1
|
||||
shift
|
||||
|
||||
case "$option" in
|
||||
terminfo | TERMINFO)
|
||||
;;
|
||||
|
||||
-g)
|
||||
NEWXY=`argument $option "$@"`
|
||||
NEWX=`echo $NEWXY | cut -d x -f 1`
|
||||
NEWY=`echo $NEWXY | cut -d x -f 2`
|
||||
|
||||
if [ ${NEWX} -ge 80 ] ; then
|
||||
X=${NEWX}
|
||||
else
|
||||
echo "Warning: ${NEWX} is less than the minimum size of 80"
|
||||
fi
|
||||
|
||||
if [ ${NEWY} -ge 24 ] ; then
|
||||
Y=${NEWY}
|
||||
else
|
||||
echo "Warning: ${NEWY} is less than the minimum size of 24"
|
||||
fi
|
||||
|
||||
shift
|
||||
;;
|
||||
|
||||
*)
|
||||
# # accept console or ofconsole
|
||||
# if [ "$option" != "console" -a "$option" != "ofconsole" ] ; then
|
||||
# echo "Error: GRUB_TERMINFO unknown console: $option"
|
||||
# exit 1
|
||||
# fi
|
||||
# # perfer console
|
||||
# TERMINAL=console
|
||||
# accept ofconsole
|
||||
if [ "$option" != "ofconsole" ] ; then
|
||||
echo "Error: GRUB_TERMINFO unknown console: $option"
|
||||
exit 1
|
||||
fi
|
||||
# perfer console
|
||||
TERMINAL=ofconsole
|
||||
;;
|
||||
esac
|
||||
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
if ! uname -m | grep -q ppc ; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "x${GRUB_TERMINFO}" != "x" ] ; then
|
||||
F1=`echo ${GRUB_TERMINFO} | cut -d " " -f 1`
|
||||
|
||||
if [ "${F1}" != "terminfo" ] ; then
|
||||
echo "Error: GRUB_TERMINFO is set to \"${GRUB_TERMINFO}\" The first word should be terminfo."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
check_terminfo ${GRUB_TERMINFO}
|
||||
fi
|
||||
|
||||
cat << EOF
|
||||
terminfo -g ${X}x${Y} ${TERMINAL}
|
||||
EOF
|
||||
326
grub.d/30_os-prober
Executable file
326
grub.d/30_os-prober
Executable file
@@ -0,0 +1,326 @@
|
||||
#! /bin/sh
|
||||
set -e
|
||||
|
||||
# grub-mkconfig helper script.
|
||||
# Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.
|
||||
#
|
||||
# GRUB is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# GRUB 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
prefix="/usr"
|
||||
exec_prefix="/usr"
|
||||
datarootdir="/usr/share"
|
||||
|
||||
export TEXTDOMAIN=grub
|
||||
export TEXTDOMAINDIR="${datarootdir}/locale"
|
||||
|
||||
. "$pkgdatadir/grub-mkconfig_lib"
|
||||
|
||||
if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "`which os-prober 2> /dev/null`" ] || [ -z "`which linux-boot-prober 2> /dev/null`" ] ; then
|
||||
# missing os-prober and/or linux-boot-prober
|
||||
exit 0
|
||||
fi
|
||||
|
||||
OSPROBED="`os-prober | tr ' ' '^' | paste -s -d ' '`"
|
||||
if [ -z "${OSPROBED}" ] ; then
|
||||
# empty os-prober output, nothing doing
|
||||
exit 0
|
||||
fi
|
||||
|
||||
osx_entry() {
|
||||
found_other_os=1
|
||||
# TRANSLATORS: it refers on the OS residing on device %s
|
||||
onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
|
||||
hints=""
|
||||
for hint in `"${grub_probe}" --device ${device} --target=efi_hints 2> /dev/null` ; do
|
||||
hints="${hints} --hint=${hint}"
|
||||
done
|
||||
cat << EOF
|
||||
menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class osx --class darwin --class os \$menuentry_id_option 'osprober-xnu-$2-$(grub_get_device_id "${DEVICE}")' {
|
||||
EOF
|
||||
save_default_entry | grub_add_tab
|
||||
prepare_grub_to_access_device ${DEVICE} | grub_add_tab
|
||||
cat << EOF
|
||||
set gfxpayload=keep
|
||||
load_video
|
||||
insmod part_gpt
|
||||
insmod hfsplus
|
||||
search --no-floppy --fs-uuid --set=root ${hints} $(grub_get_device_id "${DEVICE}")
|
||||
chainloader (\$root)/System/Library/CoreServices/boot.efi
|
||||
boot
|
||||
}
|
||||
EOF
|
||||
}
|
||||
|
||||
used_osprober_linux_ids=
|
||||
|
||||
for OS in ${OSPROBED} ; do
|
||||
DEVICE="`echo ${OS} | cut -d ':' -f 1`"
|
||||
LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '^' ' '`"
|
||||
LABEL="`echo ${OS} | cut -d ':' -f 3 | tr '^' ' '`"
|
||||
BOOT="`echo ${OS} | cut -d ':' -f 4`"
|
||||
if UUID="`${grub_probe} --target=fs_uuid --device ${DEVICE%@*}`"; then
|
||||
EXPUUID="$UUID"
|
||||
|
||||
if [ x"${DEVICE#*@}" != x ] ; then
|
||||
EXPUUID="${EXPUUID}@${DEVICE#*@}"
|
||||
fi
|
||||
|
||||
if [ "x${GRUB_OS_PROBER_SKIP_LIST}" != "x" ] && [ "x`echo ${GRUB_OS_PROBER_SKIP_LIST} | grep -i -e '\b'${EXPUUID}'\b'`" != "x" ] ; then
|
||||
echo "Skipped ${LONGNAME} on ${DEVICE} by user request." >&2
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
|
||||
BTRFS="`echo ${OS} | cut -d ':' -f 5`"
|
||||
if [ "x$BTRFS" = "xbtrfs" ]; then
|
||||
BTRFSuuid="`echo ${OS} | cut -d ':' -f 6`"
|
||||
BTRFSsubvol="`echo ${OS} | cut -d ':' -f 7`"
|
||||
fi
|
||||
|
||||
if [ -z "${LONGNAME}" ] ; then
|
||||
LONGNAME="${LABEL}"
|
||||
fi
|
||||
|
||||
# os-prober returns text string followed by optional counter
|
||||
CLASS="--class $(echo "${LABEL}" | LC_ALL=C sed 's,[[:digit:]]*$,,' | cut -d' ' -f1 | tr 'A-Z' 'a-z' | LC_ALL=C sed 's,[^[:alnum:]_],_,g')"
|
||||
|
||||
gettext_printf "Found %s on %s\n" "${LONGNAME}" "${DEVICE}" >&2
|
||||
|
||||
case ${BOOT} in
|
||||
chain)
|
||||
found_other_os=1
|
||||
|
||||
onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
|
||||
cat << EOF
|
||||
menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' $CLASS --class os \$menuentry_id_option 'osprober-chain-$(grub_get_device_id "${DEVICE}")' {
|
||||
EOF
|
||||
save_default_entry | grub_add_tab
|
||||
prepare_grub_to_access_device ${DEVICE} | grub_add_tab
|
||||
|
||||
if [ x"`${grub_probe} --device ${DEVICE} --target=partmap`" = xmsdos ]; then
|
||||
cat << EOF
|
||||
parttool \${root} hidden-
|
||||
EOF
|
||||
fi
|
||||
|
||||
case ${LONGNAME} in
|
||||
Windows\ Vista*|Windows\ 7*|Windows\ Server\ 2008*)
|
||||
;;
|
||||
*)
|
||||
cat << EOF
|
||||
drivemap -s (hd0) \${root}
|
||||
EOF
|
||||
;;
|
||||
esac
|
||||
|
||||
cat <<EOF
|
||||
chainloader +1
|
||||
}
|
||||
EOF
|
||||
;;
|
||||
efi)
|
||||
found_other_os=1
|
||||
|
||||
EFIPATH=${DEVICE#*@}
|
||||
DEVICE=${DEVICE%@*}
|
||||
onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
|
||||
cat << EOF
|
||||
menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' $CLASS --class os \$menuentry_id_option 'osprober-efi-$(grub_get_device_id "${DEVICE}")' {
|
||||
EOF
|
||||
save_default_entry | sed -e "s/^/\t/"
|
||||
prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
|
||||
|
||||
cat <<EOF
|
||||
chainloader ${EFIPATH}
|
||||
}
|
||||
EOF
|
||||
;;
|
||||
linux)
|
||||
if [ "x$BTRFS" = "xbtrfs" ]; then
|
||||
LINUXPROBED="`linux-boot-prober btrfs ${BTRFSuuid} ${BTRFSsubvol} 2> /dev/null | tr ' ' '^' | paste -s -d ' '`"
|
||||
else
|
||||
LINUXPROBED="`linux-boot-prober ${DEVICE} 2> /dev/null | tr ' ' '^' | paste -s -d ' '`"
|
||||
fi
|
||||
prepare_boot_cache=
|
||||
boot_device_id=
|
||||
is_top_level=true
|
||||
title_correction_code=
|
||||
OS="${LONGNAME}"
|
||||
|
||||
for LINUX in ${LINUXPROBED} ; do
|
||||
LROOT="`echo ${LINUX} | cut -d ':' -f 1`"
|
||||
LBOOT="`echo ${LINUX} | cut -d ':' -f 2`"
|
||||
LLABEL="`echo ${LINUX} | cut -d ':' -f 3 | tr '^' ' '`"
|
||||
LKERNEL="`echo ${LINUX} | cut -d ':' -f 4`"
|
||||
LINITRD="`echo ${LINUX} | cut -d ':' -f 5`"
|
||||
LPARAMS="`echo ${LINUX} | cut -d ':' -f 6- | tr '^' ' '`"
|
||||
|
||||
if [ -z "${LLABEL}" ] ; then
|
||||
LLABEL="${LONGNAME}"
|
||||
fi
|
||||
|
||||
if [ "${LROOT}" != "${LBOOT}" ]; then
|
||||
LKERNEL="${LKERNEL#/boot}"
|
||||
LINITRD="${LINITRD#/boot}"
|
||||
fi
|
||||
|
||||
found_other_os=1
|
||||
onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
|
||||
recovery_params="$(echo "${LPARAMS}" | grep single)" || true
|
||||
counter=1
|
||||
while echo "$used_osprober_linux_ids" | grep 'osprober-gnulinux-$LKERNEL-${recovery_params}-$counter-$boot_device_id' > /dev/null; do
|
||||
counter=$((counter+1));
|
||||
done
|
||||
if [ -z "$boot_device_id" ]; then
|
||||
boot_device_id="$(grub_get_device_id "${DEVICE}")"
|
||||
fi
|
||||
used_osprober_linux_ids="$used_osprober_linux_ids 'osprober-gnulinux-$LKERNEL-${recovery_params}-$counter-$boot_device_id'"
|
||||
|
||||
if [ -z "${prepare_boot_cache}" ]; then
|
||||
prepare_boot_cache="$(prepare_grub_to_access_device ${LBOOT} | grub_add_tab)"
|
||||
fi
|
||||
|
||||
if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then
|
||||
cat << EOF
|
||||
menuentry '$(echo "$OS $onstr" | grub_quote)' $CLASS --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-simple-$boot_device_id' {
|
||||
EOF
|
||||
save_default_entry | grub_add_tab
|
||||
printf '%s\n' "${prepare_boot_cache}"
|
||||
cat << EOF
|
||||
linux ${LKERNEL} ${LPARAMS}
|
||||
EOF
|
||||
if [ -n "${LINITRD}" ] ; then
|
||||
cat << EOF
|
||||
initrd ${LINITRD}
|
||||
EOF
|
||||
fi
|
||||
cat << EOF
|
||||
}
|
||||
EOF
|
||||
echo "submenu '$(gettext_printf "Advanced options for %s" "${OS} $onstr" | grub_quote)' \$menuentry_id_option 'osprober-gnulinux-advanced-$boot_device_id' {"
|
||||
is_top_level=false
|
||||
fi
|
||||
title="${LLABEL} $onstr"
|
||||
cat << EOF
|
||||
menuentry '$(echo "$title" | grub_quote)' --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-$LKERNEL-${recovery_params}-$boot_device_id' {
|
||||
EOF
|
||||
save_default_entry | sed -e "s/^/$grub_tab$grub_tab/"
|
||||
printf '%s\n' "${prepare_boot_cache}" | grub_add_tab
|
||||
cat << EOF
|
||||
linux ${LKERNEL} ${LPARAMS}
|
||||
EOF
|
||||
if [ -n "${LINITRD}" ] ; then
|
||||
cat << EOF
|
||||
initrd ${LINITRD}
|
||||
EOF
|
||||
fi
|
||||
cat << EOF
|
||||
}
|
||||
EOF
|
||||
if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then
|
||||
replacement_title="$(echo "Advanced options for ${OS} $onstr" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')"
|
||||
quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)"
|
||||
title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;"
|
||||
grub_warn "$(gettext_printf "Please don't use old title \`%s' for GRUB_DEFAULT, use \`%s' (for versions before 2.00) or \`%s' (for 2.00 or later)" "$GRUB_ACTUAL_DEFAULT" "$replacement_title" "gnulinux-advanced-$boot_device_id>gnulinux-$version-$type-$boot_device_id")"
|
||||
fi
|
||||
done
|
||||
if [ x"$is_top_level" != xtrue ]; then
|
||||
echo '}'
|
||||
fi
|
||||
echo "$title_correction_code"
|
||||
;;
|
||||
macosx)
|
||||
for subdevice in ${DEVICE%[[:digit:]]*}* ; do
|
||||
parttype="`"${grub_probe}" --device ${device} --target=gpt_parttype "${subdevice}" 2> /dev/null`"
|
||||
if [[ "$parttype" = "426f6f74-0000-11aa-aa11-00306543ecac" ]]; then
|
||||
DEVICE="${subdevice}" osx_entry
|
||||
fi
|
||||
done
|
||||
;;
|
||||
hurd)
|
||||
found_other_os=1
|
||||
onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
|
||||
cat << EOF
|
||||
menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class hurd --class gnu --class os \$menuentry_id_option 'osprober-gnuhurd-/boot/gnumach.gz-false-$(grub_get_device_id "${DEVICE}")' {
|
||||
EOF
|
||||
save_default_entry | grub_add_tab
|
||||
prepare_grub_to_access_device ${DEVICE} | grub_add_tab
|
||||
grub_device="`${grub_probe} --device ${DEVICE} --target=drive`"
|
||||
mach_device="`echo "${grub_device}" | sed -e 's/(\(hd.*\),msdos\(.*\))/\1s\2/'`"
|
||||
grub_fs="`${grub_probe} --device ${DEVICE} --target=fs`"
|
||||
case "${grub_fs}" in
|
||||
*fs) hurd_fs="${grub_fs}" ;;
|
||||
*) hurd_fs="${grub_fs}fs" ;;
|
||||
esac
|
||||
cat << EOF
|
||||
multiboot /boot/gnumach.gz root=device:${mach_device}
|
||||
module /hurd/${hurd_fs}.static ${hurd_fs} --readonly \\
|
||||
--multiboot-command-line='\${kernel-command-line}' \\
|
||||
--host-priv-port='\${host-port}' \\
|
||||
--device-master-port='\${device-port}' \\
|
||||
--exec-server-task='\${exec-task}' -T typed '\${root}' \\
|
||||
'\$(task-create)' '\$(task-resume)'
|
||||
module /lib/ld.so.1 exec /hurd/exec '\$(exec-task=task-create)'
|
||||
}
|
||||
EOF
|
||||
;;
|
||||
minix)
|
||||
found_other_os=1
|
||||
cat << EOF
|
||||
menuentry "${LONGNAME} (on ${DEVICE}, Multiboot)" {
|
||||
EOF
|
||||
save_default_entry | sed -e "s/^/\t/"
|
||||
prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
|
||||
cat << EOF
|
||||
multiboot /boot/image_latest
|
||||
}
|
||||
EOF
|
||||
;;
|
||||
*)
|
||||
case ${DEVICE} in
|
||||
*.efi)
|
||||
cat << EOF
|
||||
menuentry '$(echo "${LONGNAME}" | grub_quote)' {
|
||||
EOF
|
||||
save_default_entry | grub_add_tab
|
||||
cat << EOF
|
||||
chainloader /EFI/${DEVICE}
|
||||
boot
|
||||
}
|
||||
EOF
|
||||
;;
|
||||
*)
|
||||
echo -n " "
|
||||
# TRANSLATORS: %s is replaced by OS name.
|
||||
gettext_printf "%s is not yet supported by grub-mkconfig.\n" "${LONGNAME}" >&2
|
||||
;;
|
||||
esac
|
||||
esac
|
||||
done
|
||||
|
||||
# We override the results of the menu_auto_hide code here, this is a bit ugly,
|
||||
# but grub-mkconfig writes out the file linearly, so this is the only way
|
||||
if [ "${found_other_os}" = "1" ]; then
|
||||
cat << EOF
|
||||
# Other OS found, undo autohiding of menu unless menu_auto_hide=2
|
||||
if [ "\${orig_timeout_style}" -a "\${menu_auto_hide}" != "2" ]; then
|
||||
set timeout_style=\${orig_timeout_style}
|
||||
set timeout=\${orig_timeout}
|
||||
fi
|
||||
EOF
|
||||
fi
|
||||
46
grub.d/30_uefi-firmware
Executable file
46
grub.d/30_uefi-firmware
Executable file
@@ -0,0 +1,46 @@
|
||||
#! /bin/sh
|
||||
set -e
|
||||
|
||||
# grub-mkconfig helper script.
|
||||
# Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
#
|
||||
# GRUB is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# GRUB 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
prefix="/usr"
|
||||
exec_prefix="/usr"
|
||||
datarootdir="/usr/share"
|
||||
|
||||
export TEXTDOMAIN=grub
|
||||
export TEXTDOMAINDIR="${datarootdir}/locale"
|
||||
|
||||
. "/usr/share/grub/grub-mkconfig_lib"
|
||||
|
||||
efi_vars_dir=/sys/firmware/efi/efivars
|
||||
EFI_GLOBAL_VARIABLE=8be4df61-93ca-11d2-aa0d-00e098032b8c
|
||||
OsIndications="$efi_vars_dir/OsIndicationsSupported-$EFI_GLOBAL_VARIABLE"
|
||||
|
||||
if [ -e "$OsIndications" ] && \
|
||||
[ "$(( $(printf 0x%x \'"$(cat $OsIndications | cut -b5)") & 1 ))" = 1 ]; then
|
||||
LABEL="System setup"
|
||||
|
||||
gettext_printf "Adding boot menu entry for EFI firmware configuration\n" >&2
|
||||
|
||||
onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
|
||||
|
||||
cat << EOF
|
||||
menuentry '$LABEL' \$menuentry_id_option 'uefi-firmware' {
|
||||
fwsetup
|
||||
}
|
||||
EOF
|
||||
fi
|
||||
5
grub.d/40_custom
Executable file
5
grub.d/40_custom
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
exec tail -n +3 $0
|
||||
# This file provides an easy way to add custom menu entries. Simply type the
|
||||
# menu entries you want to add after this comment. Be careful not to change
|
||||
# the 'exec tail' line above.
|
||||
9
grub.d/41_custom
Executable file
9
grub.d/41_custom
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
cat <<EOF
|
||||
if [ -f \${config_directory}/custom.cfg ]; then
|
||||
source \${config_directory}/custom.cfg
|
||||
elif [ -z "\${config_directory}" -a -f \$prefix/custom.cfg ]; then
|
||||
source \$prefix/custom.cfg;
|
||||
fi
|
||||
EOF
|
||||
|
||||
11
grub.d/README
Normal file
11
grub.d/README
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
All executable files in this directory are processed in shell expansion order.
|
||||
|
||||
00_*: Reserved for 00_header.
|
||||
10_*: Native boot entries.
|
||||
20_*: Third party apps (e.g. memtest86+).
|
||||
|
||||
The number namespace in-between is configurable by system installer and/or
|
||||
administrator. For example, you can add an entry to boot another OS as
|
||||
01_otheros, 11_otheros, etc, depending on the position you want it to occupy in
|
||||
the menu; and then adjust the default setting via /etc/default/grub.
|
||||
Reference in New Issue
Block a user