On 29.02.2012 07:10, Jordan Uggla wrote:
In my first patch I rather stupidly asked gettext for a translation of "%s".
Updated patch below does not have this mistake.

I attach the update on the top of menuid.
I think it would be bad to break every time user changes the configuration entry. So I'd prefer to remove this option. Now there is however a problem with migration. I see following possibilities: 1) Check in grub-mkconfig & co that GRUB_DEFAULT/saved_entry from envblk contains old or old Ubuntu-style entries and if it does add a stanza like:
if [ x"$default" = x"<entry>" ]; then
  default="<new name>"
fi
and issue a warning
2) Like (1) but replace a warning with error and issue no stanza
3) Like (1) but perform no check and issue no warning and simply generate stanzas for all possible entries. Would result in a lot of clutter 4) Like (3) make check independent of stanzas and use it for issuing the warning

Right now I believe that (1) is the most reasonable

@Colin Watson: given the problems with current Ubuntu submenu patch and a migration way like in (1) is it possible to replace Ubuntu patch with Jordan's one for 12.10?

--
Regards
Vladimir 'φ-coder/phcoder' Serbinenko

=== modified file 'util/grub.d/10_linux.in'
--- util/grub.d/10_linux.in	2012-03-03 12:12:41 +0000
+++ util/grub.d/10_linux.in	2012-03-03 13:07:51 +0000
@@ -70,18 +70,25 @@
 {
   os="$1"
   version="$2"
-  recovery="$3"
+  type="$3"
   args="$4"
-  if ${recovery} ; then
-    title="$(gettext_quoted "%s, with Linux %s (recovery mode)")"
-  else
-    title="$(gettext_quoted "%s, with Linux %s")"
-  fi
+
+  case $type in
+  recovery)
+    title="$(gettext_quoted "%s, with Linux %s (recovery mode)")" ;;
+  *)
+    title="$(gettext_quoted "%s, with Linux %s")" ;;
+  esac
   if [ -z "$boot_device_id" ]; then
       boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
   fi
-  printf "menuentry '${title}' ${CLASS} \$menuentry_id_option 'gnulinux-$version-$recovery-$boot_device_id' {\n" "${os}" "${version}"
-  if ! ${recovery} ; then
+  case $type in
+  if [ x$type != xsimple ] ; then
+      printf "menuentry '${title}' ${CLASS} \$menuentry_id_option 'gnulinux-$version-$type-$boot_device_id' {\n" "${os}" "${version}"
+  else
+      echo "menuentry '${os}' ${CLASS} \$menuentry_id_option 'gnulinux-simple-$boot_device_id' {"
+  fi      
+  if [ x$type != xrecovery ] ; then
       save_default_entry | sed -e "s/^/\t/"
   fi
 
@@ -156,6 +163,11 @@
 prepare_root_cache=
 boot_device_id=
 
+# 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$list" != "x" ] ; do
   linux=`version_find_latest $list`
   gettext_printf "Found linux image: %s\n" "$linux" >&2
@@ -200,12 +212,35 @@
     linux_root_device_thisversion=${GRUB_DEVICE}
   fi
 
-  linux_entry "${OS}" "${version}" false \
-      "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
+  if [ "x$is_first_entry" = xtrue ]; then
+    linux_entry "${OS}" "${version}" simple \
+    "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
+
+    submenu_indentation="\t"
+    
+    if [ -z "$boot_device_id" ]; then
+	boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
+    fi
+    cat << EOF
+submenu '$(gettext_quoted "Advanced options for ${OS}")' \$menuentry_id_option 'gnulinux-advanced-$boot_device_id' {
+EOF
+  fi
+
+  linux_entry "${OS}" "${version}" advanced \
+              "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" \
+              | sed "s/^/$submenu_indentation/"
   if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
-    linux_entry "${OS}" "${version}" true \
-	"single ${GRUB_CMDLINE_LINUX}"
+    linux_entry "${OS}" "${version}" recovery \
+                "single ${GRUB_CMDLINE_LINUX}" \
+                | sed "s/^/$submenu_indentation/"
   fi
 
   list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
+  is_first_entry=false
 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

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to