Skip to contentSkip to conversation

backwards compatibility in grub.cfg

PATCH Robert Millan 3 participants 7 messages May 30, 2008 – Jun 1, 2008

lore
Share & tools
lore
#0 lore raw

Hi,

I'm adding this to the Debian package. We need this for backwards compatibility in case the new update-grub is used in combination with an older install of GRUB in /boot/grub (which will surely happen a lot).

I'm wondering if it makes sense to commit this in official GRUB too. For people installing by hand it's not a problem, and distributors can sort it out themselves, I guess, but it may also be helpful. What do you think?

(we have similar checks like "if font " in 00_header, but this is much uglier)

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What good is a phone call… if you are unable to speak?
(as seen on /.)
util/update-grub_lib.in renamed from grub2/util/update-grub_lib.in +1 -2
diff -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/util/update-grub_lib.in ./util/update-grub_lib.in
@@ -116,10 +116,9 @@ prepare_grub_to_access_device ()
 
   # If there's a filesystem UUID that GRUB is capable of identifiing, use it;
   # otherwise set root as per value in device.map.
+  echo "set root=`${grub_probe} --device ${device} --target=drive`"
   if fs_uuid="`grub-probe --device ${device} --target=fs_uuid 2> /dev/null`" ; then
     echo "search --fs-uuid --set ${fs_uuid}"
-  else
-    echo "set root=`${grub_probe} --device ${device} --target=drive`"
   fi
 
   # Abstraction modules aren't auto-loaded.
#1 lore raw

util/update-grub_lib.in prepare_grub_to_access_device () · line 121

Quoted 10 lines · Robert Millan

diff -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/util/update-grub_lib.in ./util/update-grub_lib.in

util/update-grub_lib.in renamed from grub2/util/update-grub_lib.in +1 -0
@@ -116,10 +116,9 @@ prepare_grub_to_access_device ()
 
   # If there's a filesystem UUID that GRUB is capable of identifiing, use it;
   # otherwise set root as per value in device.map.
+  echo "set root=`${grub_probe} --device ${device} --target=drive`"
   if fs_uuid="`grub-probe --device ${device} --target=fs_uuid 2> /dev/null`" ; then
 

Outside of the scope of the patch, but shouldn't '${grub_probe}' be used instead of 'grub-probe' in the rest of the script?

Same issue is in update-grub.in: grub_probe is set but never used, so update-grub fails if /usr/sbin is not in PATH.

Signature · 1 line
Christian Franke
#3 lore raw
In reply to Robert Millan
Quoted 7 lines · Robert Millan

Hi,

I'm adding this to the Debian package. We need this for backwards compatibility in case the new update-grub is used in combination with an older install of GRUB in /boot/grub (which will surely happen a lot).

I'm wondering if it makes sense to commit this in official GRUB too.

I think it's a good idea. Suppose that UUID changes for whatever reason. Then it would be a fallback.

Maybe we could put a conditional into grub.cfg:

if !search --fs-uuid ...
set root=...
fi

Just make sure that the old GRUB will actually grok it.

Signature · 2 lines
Regards,
Pavel Roskin
#4 lore raw
Quoted 12 lines · Pavel Roskin
Quoted 7 lines · Robert Millan

Hi,

I'm adding this to the Debian package. We need this for backwards compatibility in case the new update-grub is used in combination with an older install of GRUB in /boot/grub (which will surely happen a lot).

I'm wondering if it makes sense to commit this in official GRUB too.

I think it's a good idea. Suppose that UUID changes for whatever reason. Then it would be a fallback.

Quoted 7 lines

Maybe we could put a conditional into grub.cfg:

if !search --fs-uuid ...
set root=...
fi

Just make sure that the old GRUB will actually grok it.

Yeah, that would be the "nice" way to do it, but it doesn't work. And the funny thing is, that if we fix it and start using it, it defeats the point of backwards compatibility :-)

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What good is a phone call… if you are unable to speak?
(as seen on /.)
#2 lore raw
In reply to Christian Franke
Quoted 19 lines · Christian Franke

util/update-grub_lib.in prepare_grub_to_access_device () · line 123

Quoted 13 lines · Robert Millan

diff -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/util/update-grub_lib.in ./util/update-grub_lib.in

util/update-grub_lib.in renamed from grub2/util/update-grub_lib.in +1 -0
@@ -116,10 +116,9 @@ prepare_grub_to_access_device ()
 
  # If there's a filesystem UUID that GRUB is capable of identifiing, use 
  it;
  # otherwise set root as per value in device.map.
+  echo "set root=`${grub_probe} --device ${device} --target=drive`"
  if fs_uuid="`grub-probe --device ${device} --target=fs_uuid 2> 
  /dev/null`" ; then
 

Outside of the scope of the patch, but shouldn't '${grub_probe}' be used instead of 'grub-probe' in the rest of the script?

Quoted 2 lines

Same issue is in update-grub.in: grub_probe is set but never used, so update-grub fails if /usr/sbin is not in PATH.

Fixed.

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What good is a phone call… if you are unable to speak?
(as seen on /.)
#5 lore raw
In reply to Robert Millan
Quoted 3 lines · Robert Millan

Yeah, that would be the "nice" way to do it, but it doesn't work. And the funny thing is, that if we fix it and start using it, it defeats the point of backwards compatibility :-)

OK then. And we should make sure that "if !search --future-option" does the right thing from now on.

Signature · 2 lines
Regards,
Pavel Roskin
#6 lore raw
Quoted 8 lines · Pavel Roskin
Quoted 3 lines · Robert Millan

Yeah, that would be the "nice" way to do it, but it doesn't work. And the funny thing is, that if we fix it and start using it, it defeats the point of backwards compatibility :-)

OK then. And we should make sure that "if !search --future-option" does the right thing from now on.

I'm afraid I get terribly confused when it comes to the scripting engine...

FWIW, I committed the backward compatibility support.

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What good is a phone call… if you are unable to speak?
(as seen on /.)