|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 1/2] pygrub: Ignore GRUB2 if statements
SLES 12's default GRUB config has the following code before any entries:
if [ -n "$extra_cmdline" ]; then
submenu "Bootable snapshot #$snapshot_num" {
menuentry "If OK, run 'snapper rollback' and reboot." { true; }
}
fi
This prevents pygrub from booting using the default entry. Since I'm not
aware of any distro GRUB config which puts useful entries within
conditionals, ignore them.
Signed-off-by: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
---
tools/pygrub/src/GrubConf.py | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/tools/pygrub/src/GrubConf.py b/tools/pygrub/src/GrubConf.py
index dc810d5..cf9aa8b 100644
--- a/tools/pygrub/src/GrubConf.py
+++ b/tools/pygrub/src/GrubConf.py
@@ -373,6 +373,7 @@ class Grub2ConfigFile(_GrubConfigFile):
lines = buf.split("\n")
in_function = False
+ in_if = False
img = None
title = ""
menu_level=0
@@ -389,9 +390,14 @@ class Grub2ConfigFile(_GrubConfigFile):
if l.startswith('function'):
in_function = True
continue
- if in_function:
+ elif l.startswith('if'):
+ in_if = True
+ continue
+ if in_function or in_if:
if l.startswith('}'):
in_function = False
+ elif l.startswith('fi'):
+ in_if = False
continue
# new image
--
2.4.3
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |