[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] tools/pygrub: --not-really option for debugging



# HG changeset patch
# User Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
# Date 1278089873 -3600
# Node ID b2a89e9e463090762d250f27ab6c1e870fe6a86d
# Parent  f35512e244ffefaf14a9c92ab245411b875f349f
tools/pygrub: --not-really option for debugging

Add a --not-really option to pygrub that lets us see what files it would
have extracted instead of actually extracting them.

Signed-off-by: Tim Deegan <Tim.Deegan@xxxxxxxxxx>
---
 tools/pygrub/src/pygrub |   39 ++++++++++++++++++++++++---------------
 1 files changed, 24 insertions(+), 15 deletions(-)

diff -r f35512e244ff -r b2a89e9e4630 tools/pygrub/src/pygrub
--- a/tools/pygrub/src/pygrub   Fri Jul 02 17:56:05 2010 +0100
+++ b/tools/pygrub/src/pygrub   Fri Jul 02 17:57:53 2010 +0100
@@ -634,13 +634,13 @@ if __name__ == "__main__":
     sel = None
     
     def usage():
-        print >> sys.stderr, "Usage: %s [-q|--quiet] [-i|--interactive] 
[--output=] [--kernel=] [--ramdisk=] [--args=] [--entry=] <image>" 
%(sys.argv[0],)
+        print >> sys.stderr, "Usage: %s [-q|--quiet] [-i|--interactive] 
[-n|--not-really] [--output=] [--kernel=] [--ramdisk=] [--args=] [--entry=] 
<image>" %(sys.argv[0],)
 
     try:
-        opts, args = getopt.gnu_getopt(sys.argv[1:], 'qih::',
-                                   ["quiet", "interactive", "help", "output=",
-                                    "entry=", "kernel=", "ramdisk=", "args=",
-                                    "isconfig"])
+        opts, args = getopt.gnu_getopt(sys.argv[1:], 'qinh::',
+                                   ["quiet", "interactive", "not-really", 
+                                    "help", "output=", "entry=", "kernel=", 
+                                    "ramdisk=", "args=", "isconfig"])
     except getopt.GetoptError:
         usage()
         sys.exit(1)
@@ -654,6 +654,7 @@ if __name__ == "__main__":
     entry = None
     interactive = True
     isconfig = False
+    not_really = False
 
     # what was passed in
     incfg = { "kernel": None, "ramdisk": None, "args": "" }
@@ -667,6 +668,8 @@ if __name__ == "__main__":
             interactive = False
         elif o in ("-i", "--interactive"):
             interactive = True
+        elif o in ("-n", "--not-really"):
+            not_really = True
         elif o in ("-h", "--help"):
             usage()
             sys.exit()
@@ -715,18 +718,24 @@ if __name__ == "__main__":
     if not chosencfg["kernel"]:
         chosencfg = run_grub(file, entry, fs, incfg["args"])
 
-    data = fs.open_file(chosencfg["kernel"]).read()
-    (tfd, bootcfg["kernel"]) = tempfile.mkstemp(prefix="boot_kernel.",
-        dir="/var/run/xend/boot")
-    os.write(tfd, data)
-    os.close(tfd)
-
-    if chosencfg["ramdisk"]:
-        data = fs.open_file(chosencfg["ramdisk"],).read()
-        (tfd, bootcfg["ramdisk"]) = tempfile.mkstemp(prefix="boot_ramdisk.",
-            dir="/var/run/xend/boot")
+    if not_really:
+        bootcfg["kernel"] = "<kernel:%s>" % chosencfg["kernel"]
+    else:
+        data = fs.open_file(chosencfg["kernel"]).read()
+        (tfd, bootcfg["kernel"]) = tempfile.mkstemp(prefix="boot_kernel.",
+                                                    dir="/var/run/xend/boot")
         os.write(tfd, data)
         os.close(tfd)
+
+    if chosencfg["ramdisk"]:
+        if not_really:
+            bootcfg["ramdisk"] = "<ramdisk:%s>" % chosencfg["ramdisk"]
+        else:
+            data = fs.open_file(chosencfg["ramdisk"],).read()
+            (tfd, bootcfg["ramdisk"]) = tempfile.mkstemp(
+                prefix="boot_ramdisk.", dir="/var/run/xend/boot")
+            os.write(tfd, data)
+            os.close(tfd)
     else:
         initrd = None
 

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.