tag 470398 +patch
thanks
Hi, I have attached an updated patch for this feature request.
linux-alternatives.patch implements the alternatives logic in
10_linux. It also discards the restore explicit case, it can be
specified as an alternative. autoexport-alternatives.patch makes
grub-mkconfig automatically export all needed variables defined in
/etc/default/grub. And finally doc-alternatives.patch modifies the
documentation. If someone that is subscribed to the upstream list or
to savannah can forward this upstream, it would be really nice. I
don't really think this is too complicated, as indicated in the
upstream bug report.
--
Saludos,
Felipe Sateler
--- a/10_linux 2010-06-04 20:49:34.000000000 -0400
+++ b/10_linux 2010-06-05 15:37:44.000000000 -0400
@@ -54,14 +54,15 @@
{
os="$1"
version="$2"
- recovery="$3"
+ name="$3"
args="$4"
- if ${recovery} ; then
- title="$(gettext "%s, with Linux %s (recovery mode)")"
+ if [ -n "${name}" ] ; then
+ title="$(gettext "%s, with Linux %s (%s)")"
else
- title="$(gettext "%s, with Linux %s")"
+ # An extra space doesn't hurt
+ title="$(gettext "%s, with Linux %s %s")"
fi
- printf "menuentry \"${title}\" ${CLASS} {\n" "${os}" "${version}"
+ printf "menuentry \"${title}\" ${CLASS} {\n" "${os}" "${version}" "${name}"
save_default_entry | sed -e "s/^/\t/"
if [ "x$GRUB_GFXPAYLOAD_LINUX" != x ]; then
@@ -119,13 +120,17 @@
# "UUID=" magic is parsed by initrds. Since there's no initrd, it can't work here.
linux_root_device_thisversion=${GRUB_DEVICE}
fi
-
- linux_entry "${OS}" "${version}" false \
+ # Default version always goes in, without name
+ linux_entry "${OS}" "${version}" "" \
"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
- if [ "x${GRUB_DISABLE_LINUX_RECOVERY}" != "xtrue" ]; then
- linux_entry "${OS}" "${version}" true \
- "single ${GRUB_CMDLINE_LINUX}"
- fi
+ # Now put all alternatives
+ for alternative in ${GRUB_LINUX_ALTERNATIVES} ; do
+ var_name=`echo GRUB_CMDLINE_LINUX_${alternative}`
+ options="${GRUB_CMDLINE_LINUX} `eval echo \\$$var_name`"
+ var_name=`echo GRUB_NAME_LINUX_${alternative}`
+ name=`eval echo \\$$var_name`
+ linux_entry "${OS}" "${version}" "${name}" "${options}"
+ done
list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
done
--- a/grub-mkconfig 2010-06-05 15:33:58.000000000 -0400
+++ b/grub-mkconfig 2010-06-05 15:36:00.000000000 -0400
@@ -218,7 +218,6 @@
GRUB_TERMINAL_OUTPUT \
GRUB_SERIAL_COMMAND \
GRUB_DISABLE_LINUX_UUID \
- GRUB_DISABLE_LINUX_RECOVERY \
GRUB_GFXMODE \
GRUB_THEME \
GRUB_GFXPAYLOAD_LINUX \
@@ -226,6 +225,15 @@
GRUB_INIT_TUNE \
GRUB_SAVEDEFAULT
+# Export alternatives variables
+if [ -n "${GRUB_LINUX_ALTERNATIVES}" ]; then
+ export GRUB_LINUX_ALTERNATIVES
+ for alternative in ${GRUB_LINUX_ALTERNATIVES}; do
+ export GRUB_CMDLINE_LINUX_${alternative}
+ export GRUB_NAME_LINUX_${alternative}
+ done
+fi
+
if test "x${grub_cfg}" != "x"; then
rm -f ${grub_cfg}.new
exec > ${grub_cfg}.new
--- a/grub.texi
+++ b/grub.texi
@@ -888,13 +888,23 @@ A command to configure the serial port when using the serial console.
@xref{serial}. Defaults to @samp{serial}.
@item GRUB_CMDLINE_LINUX
-Command-line arguments to add to menu entries for the Linux kernel.
-
-...@item GRUB_CMDLINE_LINUX_DEFAULT
-Unless @samp{GRUB_DISABLE_LINUX_RECOVERY} is set, two menu entries will be
-generated for each Linux kernel: one default entry and one entry for
-recovery mode. This option lists command-line arguments to add only to the
-default menu entry, after those listed in @samp{GRUB_CMDLINE_LINUX}.
+Command-line arguments to add to all menu entries for the Linux kernel.
+
+...@item GRUB_LINUX_ALTERNATIVES
+...@itemx GRUB_CMDLINE_LINUX_DEFAULT
+...@itemx grub_cmdline_lin...@{alternative@}
+...@itemx grub_name_lin...@{alternative@}
+Set @samp{GRUB_LINUX_ALTERNATIVES} to a series of names of alternative boot
+configuations, if desired. A default entry with no extra name is always
+generated, use @samp{GRUB_CMDLINE_LINUX_DEFAULT} to provide the extra command
+line arguments for the default version.
+
+For each alternative listed in @samp{GRUB_LINUX_ALTERNATIVES}, define
+...@samp{grub_cmdline_linux_@{alternat...@}} and
+...@samp{grub_name_linux_@{alternat...@}} where @sa...@{alternative@}} must
+case-sensitively match the alternative name listed. The name will be
+displayed in parenthesis after the OS name, and the extra command line
+arguments appended to the boot line.
@item GRUB_CMDLINE_NETBSD
@itemx GRUB_CMDLINE_NETBSD_DEFAULT
@@ -908,9 +918,6 @@ the Linux kernel, using a @samp{root=UUID=...} kernel parameter. This is
usually more reliable, but in some cases it may not be appropriate. To
disable the use of UUIDs, set this option to @samp{true}.
-...@item GRUB_DISABLE_LINUX_RECOVERY
-Disable the generation of recovery mode menu entries for Linux.
-
@item GRUB_DISABLE_NETBSD_RECOVERY
Disable the generation of recovery mode menu entries for NetBSD.