Blame | Last modification | View Log | RSS feed
#! /bin/shset -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=grubexport TEXTDOMAINDIR="${datarootdir}/locale". "$pkgdatadir/grub-mkconfig_lib"if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ] &&[ "x${GRUB_FS}" = "xbtrfs" ] ; thencat <<EOFset btrfs_relative_path="y"export btrfs_relative_pathEOFfi# 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} ; doecho "insmod $i"doneif [ "x${GRUB_DEFAULT}" = "x" ] ; then GRUB_DEFAULT=0 ; fiif [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then GRUB_DEFAULT='${saved_entry}' ; fiif [ "x${GRUB_TIMEOUT}" = "x" ] ; then GRUB_TIMEOUT=5 ; fiif [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=auto ; fiif [ "x${GRUB_DEFAULT_BUTTON}" = "x" ] ; then GRUB_DEFAULT_BUTTON="$GRUB_DEFAULT" ; fiif [ "x${GRUB_DEFAULT_BUTTON}" = "xsaved" ] ; then GRUB_DEFAULT_BUTTON='${saved_entry}' ; fiif [ "x${GRUB_TIMEOUT_BUTTON}" = "x" ] ; then GRUB_TIMEOUT_BUTTON="$GRUB_TIMEOUT" ; ficat << EOFset pager=1if [ -f \${config_directory}/grubenv ]; thenload_env -f \${config_directory}/grubenvelif [ -s \$prefix/grubenv ]; thenload_envfiEOFif [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; thencat <<EOFif cmostest $GRUB_BUTTON_CMOS_ADDRESS ; thenset default="${GRUB_DEFAULT_BUTTON}"elif [ "\${next_entry}" ] ; thenset default="\${next_entry}"set next_entry=save_env next_entryset boot_once=trueelseset default="${GRUB_DEFAULT}"fiEOFelsecat <<EOFif [ "\${next_entry}" ] ; thenset default="\${next_entry}"set next_entry=save_env next_entryset boot_once=trueelseset default="${GRUB_DEFAULT}"fiEOFficat <<EOFif [ x"\${feature_menuentry_id}" = xy ]; thenmenuentry_id_option="--id"elsemenuentry_id_option=""fiexport menuentry_id_optionif [ "\${prev_saved_entry}" ]; thenset saved_entry="\${prev_saved_entry}"save_env saved_entryset prev_saved_entry=save_env prev_saved_entryset boot_once=truefifunction savedefault {if [ -z "\${boot_once}" ]; thensaved_entry="\${chosen}"save_env saved_entryfi}function load_video {EOFif [ -n "${GRUB_VIDEO_BACKEND}" ]; thencat <<EOFinsmod ${GRUB_VIDEO_BACKEND}EOFelse# If all_video.mod isn't available load all modules available# with versions prior to introduction of all_video.modcat <<EOFif [ x\$feature_all_video_module = xy ]; theninsmod all_videoelseinsmod efi_gopinsmod efi_ugainsmod ieee1275_fbinsmod vbeinsmod vgainsmod video_bochsinsmod video_cirrusfiEOFficat <<EOF}EOFserial=0;gfxterm=0;for x in ${GRUB_TERMINAL_INPUT} ${GRUB_TERMINAL_OUTPUT}; doif [ xserial = "x$x" ]; thenserial=1;fiif [ xgfxterm = "x$x" ]; thengfxterm=1;fidoneif [ "x$serial" = x1 ]; thenif [ "x${GRUB_SERIAL_COMMAND}" = "x" ] ; thengrub_warn "$(gettext "Requested serial terminal but GRUB_SERIAL_COMMAND is unspecified. Default parameters will be used.")"GRUB_SERIAL_COMMAND=serialfiecho "${GRUB_SERIAL_COMMAND}"fiif [ "x$gfxterm" = x1 ]; thenif [ -n "$GRUB_FONT" ] ; then# Make the font accessibleprepare_grub_to_access_device `${grub_probe} --target=device "${GRUB_FONT}"`cat << EOFif loadfont `make_system_path_relative_to_its_root "${GRUB_FONT}"` ; thenEOFelsefor dir in "${pkgdatadir}" "`echo '/boot/grub2' | sed "s,//*,/,g"`" /usr/share/grub ; dofor basename in unicode unifont ascii; dopath="${dir}/${basename}.pf2"if is_path_readable_by_grub "${path}" > /dev/null ; thenfont_path="${path}"elsecontinuefibreak 2donedoneif [ -n "${font_path}" ] ; thencat << EOFif [ x\$feature_default_font_path = xy ] ; thenfont=unicodeelseEOF# Make the font accessibleprepare_grub_to_access_device `${grub_probe} --target=device "${font_path}"`cat << EOFfont="`make_system_path_relative_to_its_root "${font_path}"`"fiif loadfont \$font ; thenEOFelsecat << EOFif loadfont unicode ; thenEOFfificat << EOFset gfxmode=${GRUB_GFXMODE}load_videoinsmod gfxtermEOF# Gettext variables and moduleif [ "x${LANG}" != "xC" ] && [ "x${LANG}" != "x" ]; thencat << EOFset locale_dir=\$prefix/localeset lang=${grub_lang}insmod gettextEOFficat <<EOFfiEOFficase x${GRUB_TERMINAL_INPUT} inx)# Just use the native terminal;;x*)cat << EOFterminal_input ${GRUB_TERMINAL_INPUT}EOF;;esaccase x${GRUB_TERMINAL_OUTPUT} inx)# Just use the native terminal;;x*)cat << EOFterminal_output ${GRUB_TERMINAL_OUTPUT}EOF;;esacif [ "x$gfxterm" = x1 ]; thenif [ "x$GRUB_THEME" != x ] && [ -f "$GRUB_THEME" ] \&& is_path_readable_by_grub "$GRUB_THEME"; thengettext_printf "Found theme: %s\n" "$GRUB_THEME" >&2prepare_grub_to_access_device `${grub_probe} --target=device "$GRUB_THEME"`cat << EOFinsmod gfxmenuEOFthemedir="`dirname "$GRUB_THEME"`"for x in "$themedir"/*.pf2 "$themedir"/f/*.pf2; doif [ -f "$x" ]; thencat << EOFloadfont (\$root)`make_system_path_relative_to_its_root $x`EOFfidoneif [ x"`echo "$themedir"/*.jpg`" != x"$themedir/*.jpg" ] || [ x"`echo "$themedir"/*.jpeg`" != x"$themedir/*.jpeg" ]; thencat << EOFinsmod jpegEOFfiif [ x"`echo "$themedir"/*.png`" != x"$themedir/*.png" ]; thencat << EOFinsmod pngEOFfiif [ x"`echo "$themedir"/*.tga`" != x"$themedir/*.tga" ]; thencat << EOFinsmod tgaEOFficat << EOFset theme=(\$root)`make_system_path_relative_to_its_root $GRUB_THEME`export themeEOFelif [ "x$GRUB_BACKGROUND" != x ] && [ -f "$GRUB_BACKGROUND" ] \&& is_path_readable_by_grub "$GRUB_BACKGROUND"; thengettext_printf "Found background: %s\n" "$GRUB_BACKGROUND" >&2case "$GRUB_BACKGROUND" in*.png) reader=png ;;*.tga) reader=tga ;;*.jpg|*.jpeg) reader=jpeg ;;*) gettext "Unsupported image format" >&2; echo >&2; exit 1 ;;esacprepare_grub_to_access_device `${grub_probe} --target=device "$GRUB_BACKGROUND"`cat << EOFinsmod $readerbackground_image -m stretch `make_system_path_relative_to_its_root "$GRUB_BACKGROUND"`EOFfifimake_timeout (){if [ "x${3}" != "x" ] ; thentimeout="${2}"style="${3}"elif [ "x${1}" != "x" ] && [ "x${1}" != "x0" ] ; then# Handle the deprecated GRUB_HIDDEN_TIMEOUT scheme.timeout="${1}"if [ "x${2}" != "x0" ] ; thengrub_warn "$(gettext "Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.")"fiif [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; thenstyle="hidden"verbose=elsestyle="countdown"verbose=" --verbose"fielse# No hidden timeout, so treat as GRUB_TIMEOUT_STYLE=menutimeout="${2}"style="menu"ficat << EOFif [ x\$feature_timeout_style = xy ] ; thenset timeout_style=${style}set timeout=${timeout}EOFif [ "x${style}" = "xmenu" ] ; thencat << EOF# Fallback normal timeout code in case the timeout_style feature is# unavailable.elseset timeout=${timeout}EOFelsecat << EOF# Fallback hidden-timeout code in case the timeout_style feature is# unavailable.elif sleep${verbose} --interruptible ${timeout} ; thenset timeout=0EOFficat << EOFfiEOF}if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; thencat <<EOFif cmostest $GRUB_BUTTON_CMOS_ADDRESS ; thenEOFmake_timeout "${GRUB_HIDDEN_TIMEOUT_BUTTON}" "${GRUB_TIMEOUT_BUTTON}" "${GRUB_TIMEOUT_STYLE_BUTTON}"echo elsemake_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}" "${GRUB_TIMEOUT_STYLE}"echo fielsemake_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}" "${GRUB_TIMEOUT_STYLE}"fiif [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ] && [ "x$GRUB_BUTTON_CMOS_CLEAN" = "xyes" ]; thencat <<EOFcmosclean $GRUB_BUTTON_CMOS_ADDRESSEOFfi# Play an initial tuneif [ "x${GRUB_INIT_TUNE}" != "x" ] ; thenecho "play ${GRUB_INIT_TUNE}"fiif [ "x${GRUB_BADRAM}" != "x" ] ; thenecho "badram ${GRUB_BADRAM}"fi