xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] pygrub: Ignore GRUB2 if statements
@ 2016-04-07 14:09 Ross Lagerwall
  2016-04-07 14:09 ` [PATCH 2/2] libfsimage: Add support for btrfs Ross Lagerwall
  2016-04-07 16:57 ` [PATCH 1/2] pygrub: Ignore GRUB2 if statements Ian Jackson
  0 siblings, 2 replies; 4+ messages in thread
From: Ross Lagerwall @ 2016-04-07 14:09 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Ian Jackson, Ross Lagerwall

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@citrix.com>
---
 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@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-04-07 16:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-07 14:09 [PATCH 1/2] pygrub: Ignore GRUB2 if statements Ross Lagerwall
2016-04-07 14:09 ` [PATCH 2/2] libfsimage: Add support for btrfs Ross Lagerwall
2016-04-07 16:59   ` Ian Jackson
2016-04-07 16:57 ` [PATCH 1/2] pygrub: Ignore GRUB2 if statements Ian Jackson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).