From c55f511297e804637d41ed176ac3f6cc7e6cc472 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 2 Jul 2010 17:57:53 +0100 Subject: 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 --- tools/pygrub/src/pygrub | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) (limited to 'tools/pygrub') diff --git a/tools/pygrub/src/pygrub b/tools/pygrub/src/pygrub index 9c99ba8ce6..0c1619da5e 100644 --- a/tools/pygrub/src/pygrub +++ b/tools/pygrub/src/pygrub @@ -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=] " %(sys.argv[0],) + print >> sys.stderr, "Usage: %s [-q|--quiet] [-i|--interactive] [-n|--not-really] [--output=] [--kernel=] [--ramdisk=] [--args=] [--entry=] " %(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"] = "" % 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"] = "" % 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 -- cgit v1.2.3