aboutsummaryrefslogtreecommitdiffstats
path: root/tools/pygrub
diff options
context:
space:
mode:
authorMichael Young <m.a.young@durham.ac.uk>2011-10-25 19:20:06 +0100
committerMichael Young <m.a.young@durham.ac.uk>2011-10-25 19:20:06 +0100
commit0c385b2eff8ba3cfeec367d70a26e68e860fa4bb (patch)
treeda163f95da93317a915b678a674d74c33202b346 /tools/pygrub
parent26543b12807d22d0198af636b97e56c12c3f04ad (diff)
downloadxen-0c385b2eff8ba3cfeec367d70a26e68e860fa4bb.tar.gz
xen-0c385b2eff8ba3cfeec367d70a26e68e860fa4bb.tar.bz2
xen-0c385b2eff8ba3cfeec367d70a26e68e860fa4bb.zip
pygrub: cope with configurations with submenus
The grub2 configuration file in Fedora 16 can have one or more menuentrys in a submenu, with configuration of the form submenu "Xen 4.1" { menuentry ... { ... } } (this example occurs when the xen hypervisor is installed on the guest) Ignore the submenu line and the corresponding } Signed-off-by: Michael Young <m.a.young@durham.ac.uk> Acked-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'tools/pygrub')
-rw-r--r--tools/pygrub/src/GrubConf.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/tools/pygrub/src/GrubConf.py b/tools/pygrub/src/GrubConf.py
index 26861af24f..a31e30a46f 100644
--- a/tools/pygrub/src/GrubConf.py
+++ b/tools/pygrub/src/GrubConf.py
@@ -370,6 +370,7 @@ class Grub2ConfigFile(_GrubConfigFile):
in_function = False
img = None
title = ""
+ menu_level=0
for l in lines:
l = l.strip()
# skip blank lines
@@ -396,10 +397,18 @@ class Grub2ConfigFile(_GrubConfigFile):
img = []
title = title_match.group(1)
continue
-
+
+ if l.startswith("submenu"):
+ menu_level += 1
+ continue
+
if l.startswith("}"):
if img is None:
- raise RuntimeError, "syntax error: closing brace without menuentry"
+ if menu_level > 0:
+ menu_level -= 1
+ continue
+ else:
+ raise RuntimeError, "syntax error: closing brace without menuentry"
self.add_image(Grub2Image(title, img))
img = None