mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 10:40:03 +01:00
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>
This commit is contained in:
1 parent
26543b1280
commit
0c385b2eff
1 file changed
+11
-2
@@ -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
|
||||
|
||||