grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems with grub-reboot/savedefault/default=saved


From: Jordan Uggla
Subject: Re: Problems with grub-reboot/savedefault/default=saved
Date: Sun, 20 Dec 2009 00:37:17 -0800
User-agent: Thunderbird 2.0.0.23 (X11/20090817)

I found another bug. For some reason grub-reboot ( the utility )  
checks if prev_saved_entry ( which has just been set equal to 
saved_entry ) is empty ( zero length or unset ), and if it is 
unsets it. This makes grub-reboot again equivalent to 
grub-set-default the first time you use it. Instead I changed it 
so that if prev_saved_entry is empty it gets set to "0" because 
default=0 is the same as default="" but the grub.cfg detects 
that you've used grub-reboot by checking if prev_saved_entry is 
not empty.

I've attached a fix for this and also updated my previous 
patches so they apply cleanly and are consistent with the new 
changes from the savedefault branch that were merged into 
experimental ( using set var=value instead of just var=value ).
-- 
Jordan Uggla ( Jordan_U on irc.freenode.net )
=== modified file 'util/grub-mkconfig_lib.in'
--- old/util/grub-mkconfig_lib.in       2009-12-17 17:34:56 +0000
+++ new/util/grub-mkconfig_lib.in       2009-12-16 20:12:30 +0000
@@ -97,8 +97,10 @@
 save_default_entry ()
 {
   if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then
-    echo 'set saved_entry=${chosen}'
-    echo 'save_env saved_entry'
+    echo 'if [ ${boot_once} != true ]; then'
+    echo '     set saved_entry=${chosen}'
+    echo '     save_env saved_entry'
+    echo 'fi'
   fi
 }
 

=== modified file 'util/grub.d/00_header.in'
--- old/util/grub.d/00_header.in        2009-12-17 17:34:56 +0000
+++ new/util/grub.d/00_header.in        2009-12-16 20:12:30 +0000
@@ -48,6 +48,7 @@
   save_env saved_entry
   set prev_saved_entry=
   save_env prev_saved_entry
+  set boot_once=true
 fi
 EOF
 

=== modified file 'util/grub-mkconfig.in'
--- old/util/grub-mkconfig.in   2009-12-12 00:43:32 +0000
+++ new/util/grub-mkconfig.in   2009-12-16 20:22:36 +0000
@@ -220,7 +220,8 @@
   GRUB_DISABLE_LINUX_UUID \
   GRUB_DISABLE_LINUX_RECOVERY \
   GRUB_GFXMODE \
-  GRUB_DISABLE_OS_PROBER
+  GRUB_DISABLE_OS_PROBER \
+  GRUB_SAVEDEFAULT
 
 if test "x${grub_cfg}" != "x"; then
   rm -f ${grub_cfg}.new

=== modified file 'util/grub-mkconfig_lib.in'
--- old/util/grub-mkconfig_lib.in       2009-12-16 20:12:30 +0000
+++ new/util/grub-mkconfig_lib.in       2009-12-16 20:22:36 +0000
@@ -96,7 +96,7 @@
 
 save_default_entry ()
 {
-  if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then
+  if [ "x${GRUB_SAVEDEFAULT}" = "xtrue" ] ; then
     echo 'if [ ${boot_once} != true ]; then'
     echo '     set saved_entry=${chosen}'
     echo '     save_env saved_entry'

=== modified file 'util/grub-mkconfig_lib.in'
--- old/util/grub-mkconfig_lib.in       2009-12-16 20:22:36 +0000
+++ new/util/grub-mkconfig_lib.in       2009-12-16 20:25:37 +0000
@@ -97,10 +97,7 @@
 save_default_entry ()
 {
   if [ "x${GRUB_SAVEDEFAULT}" = "xtrue" ] ; then
-    echo 'if [ ${boot_once} != true ]; then'
-    echo '     set saved_entry=${chosen}'
-    echo '     save_env saved_entry'
-    echo 'fi'
+    echo 'savedefault'
   fi
 }
 

=== modified file 'util/grub.d/00_header.in'
--- old/util/grub.d/00_header.in        2009-12-16 20:12:30 +0000
+++ new/util/grub.d/00_header.in        2009-12-16 20:25:37 +0000
@@ -50,6 +50,14 @@
   save_env prev_saved_entry
   set boot_once=true
 fi
+
+function savedefault {
+  if [ \${boot_once} != true ]; then
+    set saved_entry=\${chosen}
+    save_env saved_entry
+  fi
+}
+
 EOF
 
 case ${GRUB_TERMINAL_INPUT}:${GRUB_TERMINAL_OUTPUT} in

=== modified file 'util/grub.d/00_header.in'
--- old/util/grub.d/00_header.in        2009-12-16 20:25:37 +0000
+++ new/util/grub.d/00_header.in        2009-12-20 01:45:32 +0000
@@ -45,10 +45,13 @@
 set default="${GRUB_DEFAULT}"
 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
+  if save_env saved_entry; then
+    set prev_saved_entry=
+    save_env prev_saved_entry
+    set boot_once=true
+  else
+    set default=\${prev_saved_entry}
+  fi
 fi
 
 function savedefault {

=== modified file 'util/grub-reboot.in'
--- old/util/grub-reboot.in     2009-12-08 01:00:26 +0000
+++ new/util/grub-reboot.in     2009-12-20 06:57:34 +0000
@@ -96,7 +96,10 @@
 if [ "$prev_saved_entry" ]; then
     $grub_editenv ${grubdir}/grubenv set prev_saved_entry="$prev_saved_entry"
 else
-    $grub_editenv ${grubdir}/grubenv unset prev_saved_entry
+    #Set prev_saved_entry to zero. Setting the default to "0" is the same as
+    #setting it to "" but because of the way grub-reboot is currently
+    #implemented prev_saved_entry can't be zero length.
+    $grub_editenv ${grubdir}/grubenv set prev_saved_entry=0
 fi
 $grub_editenv ${grubdir}/grubenv set saved_entry="$entry"
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]