xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: xen-devel@lists.xensource.com
Cc: Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCH] pygrub: improve grub 2 support
Date: Tue, 26 Jan 2010 15:17:08 +0000	[thread overview]
Message-ID: <447ced826dceb354428f.1264519028@localhost.localdomain> (raw)

* The "default" value can be a quoted string (containing an integer)
  so strip the quotes before interpreting.
* The "set" command takes a variable with an arbitrary name so instead
  of whitelisting the ones to ignore simply silently accept any set
  command with an unknown variable.
* Ignore the echo command.
* Handle the function { ... } syntax. Previously pygrub would error
  out with a syntax error on the closing "}" because it thought it was
  the closing bracket of a menuentry.

This makes pygrub2 work with the configuration files generated by
Debian Squeeze today.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 0629d3df8023 -r 447ced826dce tools/pygrub/src/GrubConf.py
--- a/tools/pygrub/src/GrubConf.py	Tue Jan 26 15:06:17 2010 +0000
+++ b/tools/pygrub/src/GrubConf.py	Tue Jan 26 15:16:40 2010 +0000
@@ -219,6 +219,7 @@
     def _get_default(self):
         return self._default
     def _set_default(self, val):
+        val = val.strip("\"")
         if val == "saved":
             self._default = 0
         else:
@@ -315,6 +316,8 @@
                 setattr(self, self.commands[com], arg.strip())
             else:
                 logging.info("Ignored image directive %s" %(com,))
+        elif com.startswith('set:'):
+            pass
         else:
             logging.warning("Unknown image directive %s" %(com,))
 
@@ -328,6 +331,7 @@
     commands = {'set:root': 'root',
                 'linux': 'kernel',
                 'initrd': 'initrd',
+                'echo': None,
                 'insmod': None,
                 'search': None}
     
@@ -346,6 +350,7 @@
         else:
             lines = buf.split("\n")
 
+        in_function = False
         img = None
         title = ""
         for l in lines:
@@ -356,6 +361,16 @@
             # skip comments
             if l.startswith('#'):
                 continue
+
+            # skip function declarations
+            if l.startswith('function'):
+                in_function = True
+                continue
+            if in_function:
+                if l.startswith('}'):
+                    in_function = False
+                continue
+
             # new image
             title_match = re.match('^menuentry "(.*)" {', l)
             if title_match:
@@ -388,6 +403,8 @@
                     setattr(self, self.commands[com], arg.strip())
                 else:
                     logging.info("Ignored directive %s" %(com,))
+            elif com.startswith('set:'):
+                pass
             else:
                 logging.warning("Unknown directive %s" %(com,))
             
@@ -400,11 +417,10 @@
     commands = {'set:default': 'default',
                 'set:root': 'root',
                 'set:timeout': 'timeout',
-                'set:gfxmode': None,
-                'set:menu_color_normal': None,
-                'set:menu_color_highlight': None,
                 'terminal': None,
                 'insmod': None,
+                'load_env': None,
+                'save_env': None,
                 'search': None,
                 'if': None,
                 'fi': None,

                 reply	other threads:[~2010-01-26 15:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=447ced826dceb354428f.1264519028@localhost.localdomain \
    --to=ian.campbell@citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).