WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-3.4-testing] pygrub: further improve grub2 support

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-3.4-testing] pygrub: further improve grub2 support
From: "Xen patchbot-3.4-testing" <patchbot-3.4-testing@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 24 Mar 2010 04:30:58 -0700
Delivery-date: Wed, 24 Mar 2010 04:31:28 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1269429348 0
# Node ID 5386459a2c33d41d81a15027bed7f28b3b39f112
# Parent  b7d623c0a8bd783d41d2e7dcfefd5c727df74476
pygrub: further improve grub2 support

      * Improve syntax error messages to say what actually went wrong
        instead of giving an arbitrary and basically useless
        integer.
      * Improve handling of quoted values used with the "set" command,
        previously only the default variable was special cased to
        handle quoting.
      * Allow for extra options to the menuentry command, syntax now
        appears to be
                        menuentry "TITLE" --option1 --option2 {...}

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
xen-unstable changeset:   21033:25446394d21f
xen-unstable date:        Mon Mar 15 13:23:07 2010 +0000
---
 tools/pygrub/src/GrubConf.py |   25 +++++++++++++++----------
 1 files changed, 15 insertions(+), 10 deletions(-)

diff -r b7d623c0a8bd -r 5386459a2c33 tools/pygrub/src/GrubConf.py
--- a/tools/pygrub/src/GrubConf.py      Wed Mar 24 11:14:00 2010 +0000
+++ b/tools/pygrub/src/GrubConf.py      Wed Mar 24 11:15:48 2010 +0000
@@ -185,7 +185,6 @@ class _GrubConfigFile(object):
     def _get_default(self):
         return self._default
     def _set_default(self, val):
-        val = val.strip("\"")
         if val == "saved":
             self._default = 0
         else:
@@ -263,6 +262,14 @@ class GrubConfigFile(_GrubConfigFile):
         if img:
             self.add_image(GrubImage(title, img))
 
+def grub2_handle_set(arg):
+    (com,arg) = grub_split(arg,2)
+    com="set:" + com
+    m = re.match("([\"\'])(.*)\\1", arg)
+    if m is not None:
+        arg=m.group(2) 
+    return (com,arg)
+
 class Grub2Image(_GrubImage):
     def __init__(self, title, lines):
         _GrubImage.__init__(self, title, lines)
@@ -271,9 +278,8 @@ class Grub2Image(_GrubImage):
         (com, arg) = grub_exact_split(line, 2)
 
         if com == "set":
-            (com,arg) = grub_split(arg,2)
-            com="set:" + com
-                
+            (com,arg) = grub2_handle_set(arg)
+            
         if self.commands.has_key(com):
             if self.commands[com] is not None:
                 setattr(self, self.commands[com], arg.strip())
@@ -335,17 +341,17 @@ class Grub2ConfigFile(_GrubConfigFile):
                 continue
 
             # new image
-            title_match = re.match('^menuentry "(.*)" {', l)
+            title_match = re.match('^menuentry "(.*)" (.*){', l)
             if title_match:
                 if img is not None:
-                    raise RuntimeError, "syntax error 1 %d %s" % (len(img),img)
+                    raise RuntimeError, "syntax error: cannot nest menuentry 
(%d %s)" % (len(img),img)
                 img = []
                 title = title_match.group(1)
                 continue
             
             if l.startswith("}"):
                 if img is None:
-                    raise RuntimeError, "syntax error 2 %d %s" % (len(img),img)
+                    raise RuntimeError, "syntax error: closing brace without 
menuentry"
 
                 self.add_image(Grub2Image(title, img))
                 img = None
@@ -358,8 +364,7 @@ class Grub2ConfigFile(_GrubConfigFile):
             (com, arg) = grub_exact_split(l, 2)
         
             if com == "set":
-                (com,arg) = grub_split(arg,2)
-                com="set:" + com
+                (com,arg) = grub2_handle_set(arg)
                 
             if self.commands.has_key(com):
                 if self.commands[com] is not None:
@@ -372,7 +377,7 @@ class Grub2ConfigFile(_GrubConfigFile):
                 logging.warning("Unknown directive %s" %(com,))
             
         if img is not None:
-            raise RuntimeError, "syntax error 3 %d %s" % (len(img),img)
+            raise RuntimeError, "syntax error: end of file with open 
menuentry(%d %s)" % (len(img),img)
 
     commands = {'set:default': 'default',
                 'set:root': 'root',

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-3.4-testing] pygrub: further improve grub2 support, Xen patchbot-3.4-testing <=