xcp-1.6-updates/xen-4.1.hg
changeset 23211:c404dbf9b3c6
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>
xen-unstable changeset: 24001:152049468175
Backport-requested-by: Pasi Karkkainen <pasik@iki.fi>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
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>
xen-unstable changeset: 24001:152049468175
Backport-requested-by: Pasi Karkkainen <pasik@iki.fi>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
author | Michael Young <m.a.young@durham.ac.uk> |
---|---|
date | Tue Jan 10 17:08:22 2012 +0000 (2012-01-10) |
parents | feb23d232cd9 |
children | 49d73f014077 |
files | tools/pygrub/src/GrubConf.py |
line diff
1.1 --- a/tools/pygrub/src/GrubConf.py Tue Jan 10 17:08:17 2012 +0000 1.2 +++ b/tools/pygrub/src/GrubConf.py Tue Jan 10 17:08:22 2012 +0000 1.3 @@ -370,6 +370,7 @@ class Grub2ConfigFile(_GrubConfigFile): 1.4 in_function = False 1.5 img = None 1.6 title = "" 1.7 + menu_level=0 1.8 for l in lines: 1.9 l = l.strip() 1.10 # skip blank lines 1.11 @@ -396,10 +397,18 @@ class Grub2ConfigFile(_GrubConfigFile): 1.12 img = [] 1.13 title = title_match.group(1) 1.14 continue 1.15 - 1.16 + 1.17 + if l.startswith("submenu"): 1.18 + menu_level += 1 1.19 + continue 1.20 + 1.21 if l.startswith("}"): 1.22 if img is None: 1.23 - raise RuntimeError, "syntax error: closing brace without menuentry" 1.24 + if menu_level > 0: 1.25 + menu_level -= 1 1.26 + continue 1.27 + else: 1.28 + raise RuntimeError, "syntax error: closing brace without menuentry" 1.29 1.30 self.add_image(Grub2Image(title, img)) 1.31 img = None