Message ID | 1460038181-4463-1-git-send-email-ross.lagerwall@citrix.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Ross Lagerwall writes ("[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. I think this has a risk of breaking things, doesn't it ? I mean, existing setups might contain `if's and the relevant parts would no longer be processed. So I think this isn't a backport candidate. And really I would like an alternative, less risky fix, which would be a backport candidate. Can you think of an alternative approach ? Thanks, Ian.
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
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(-)