Use submenus in grub-mkconfig.
* util/grub-mkconfig.in: Define GRUB_ACTUAL_DEFAULT. * util/grub-mkconfig_lib.in (grub_quote): New function. (gettext_printf): Use gettext and not gettext_quoted to fix several messages. * util/grub.d/10_hurd.in: Use submenus. * util/grub.d/10_kfreebsd.in: Likewise. * util/grub.d/10_linux.in: Likewise. * util/grub.d/10_netbsd.in: Likewise. * util/grub.d/20_linux_xen.in: Likewise. * util/grub.d/30_os-prober.in: Likewise. * util/grub.d/10_illumos.in: Add missing quoting. * util/grub.d/10_windows.in: Likewise.
This commit is contained in:
parent
d9bef9bc43
commit
0cdc126ca2
11 changed files with 424 additions and 154 deletions
|
@ -74,34 +74,47 @@ case x"$GRUBFS" in
|
|||
GRUB_CMDLINE_LINUX="boot=zfs rpool=${RPOOL} bootfs=${RPOOL}${bootfs} ${cmdline} ${GRUB_CMDLINE_LINUX}";;
|
||||
esac
|
||||
|
||||
title_correction_code=
|
||||
|
||||
linux_entry ()
|
||||
{
|
||||
os="$1"
|
||||
version="$2"
|
||||
xen_version="$3"
|
||||
recovery="$4"
|
||||
type="$4"
|
||||
args="$5"
|
||||
xen_args="$6"
|
||||
if ${recovery} ; then
|
||||
title="$(gettext_quoted "%s, with Xen %s and Linux %s (recovery mode)")"
|
||||
else
|
||||
title="$(gettext_quoted "%s, with Xen %s and Linux %s")"
|
||||
fi
|
||||
if [ -z "$boot_device_id" ]; then
|
||||
boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
|
||||
fi
|
||||
printf "menuentry '${title}' ${CLASS} \$menuentry_id_option 'xen-gnulinux-$version-$recovery-$boot_device_id' {\n" "${os}" "${xen_version}" "${version}"
|
||||
if ! ${recovery} ; then
|
||||
save_default_entry | sed -e "s/^/\t/"
|
||||
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 | sed -e "s/^/\t/" | sed "s/^/$submenu_indentation/"
|
||||
fi
|
||||
|
||||
if [ -z "${prepare_boot_cache}" ]; then
|
||||
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
|
||||
fi
|
||||
printf '%s\n' "${prepare_boot_cache}"
|
||||
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})"
|
||||
cat << EOF
|
||||
sed "s/^/$submenu_indentation/" << EOF
|
||||
echo '$xmessage'
|
||||
multiboot ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args}
|
||||
echo '$lmessage'
|
||||
|
@ -110,12 +123,12 @@ EOF
|
|||
if test -n "${initrd}" ; then
|
||||
# TRANSLATORS: ramdisk isn't identifier. Should be translated.
|
||||
message="$(gettext_printf "Loading initial ramdisk ...")"
|
||||
cat << EOF
|
||||
sed "s/^/$submenu_indentation/" << EOF
|
||||
echo '$message'
|
||||
module ${rel_dirname}/${initrd}
|
||||
EOF
|
||||
fi
|
||||
cat << EOF
|
||||
sed "s/^/$submenu_indentation/" << EOF
|
||||
}
|
||||
EOF
|
||||
}
|
||||
|
@ -144,6 +157,14 @@ xen_list=`for i in /boot/xen*; do
|
|||
prepare_boot_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_first_entry=true
|
||||
|
||||
while [ "x${xen_list}" != "x" ] ; do
|
||||
list="${linux_list}"
|
||||
current_xen=`version_find_latest $xen_list`
|
||||
|
@ -154,7 +175,9 @@ while [ "x${xen_list}" != "x" ] ; do
|
|||
if [ -z "$boot_device_id" ]; then
|
||||
boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
|
||||
fi
|
||||
echo "submenu \"Xen ${xen_version}\" \$menuentry_id_option 'xen-hypervisor-$xen_version-$boot_device_id' {"
|
||||
if [ "x$is_first_entry" != 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
|
||||
while [ "x$list" != "x" ] ; do
|
||||
linux=`version_find_latest $list`
|
||||
gettext_printf "Found linux image: %s\n" "$linux" >&2
|
||||
|
@ -183,15 +206,40 @@ while [ "x${xen_list}" != "x" ] ; do
|
|||
linux_root_device_thisversion=${GRUB_DEVICE}
|
||||
fi
|
||||
|
||||
linux_entry "${OS}" "${version}" "${xen_version}" false \
|
||||
if [ "x$is_first_entry" = xtrue ]; then
|
||||
linux_entry "${OS}" "${version}" "${xen_version}" simple \
|
||||
"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}"
|
||||
|
||||
submenu_indentation="\t\t"
|
||||
|
||||
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' {"
|
||||
fi
|
||||
is_first_entry=false
|
||||
|
||||
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}" true \
|
||||
linux_entry "${OS}" "${version}" "${xen_version}" recovery \
|
||||
"single ${GRUB_CMDLINE_LINUX}" "${GRUB_CMDLINE_XEN}"
|
||||
fi
|
||||
|
||||
list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
|
||||
done
|
||||
echo "}"
|
||||
if [ x"$is_first_entry" != xtrue ]; then
|
||||
echo ' }'
|
||||
fi
|
||||
xen_list=`echo $xen_list | tr ' ' '\n' | grep -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_first_entry" != xtrue ]; then
|
||||
echo '}'
|
||||
fi
|
||||
|
||||
echo "$title_correction_code"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue