From e55ec4d927dc5f6e0b3765c48846bc149bb07a45 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sat, 20 Apr 2013 12:53:09 +0100 Subject: [PATCH] Added --extract-only option This lets you see what's in the archive, although you'd have to do the rest of the process manually if you wanted to continue from there. --- unpacker.py | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/unpacker.py b/unpacker.py index a958737..261497c 100644 --- a/unpacker.py +++ b/unpacker.py @@ -117,6 +117,7 @@ class GUI(): if self.add_to_menu_option.get_active(): install.add_to_menu(toplevel_uris) +extract_only = False tmp = tempfile.mkdtemp(prefix = '0export-') try: w = None @@ -132,6 +133,7 @@ try: "Run self-extracting installer" % setup_path) parser.add_option("-v", "--verbose", help="more verbose output", action='count') + parser.add_option("-x", "--extract-only", help="stop after extracting", action='count') (options, args) = parser.parse_args() @@ -143,6 +145,8 @@ try: else: logger.setLevel(logging.DEBUG) + extract_only = options.extract_only + if len(args) == 0 and 'DISPLAY' in os.environ: import pygtk; pygtk.require('2.0') import gtk @@ -191,22 +195,27 @@ try: for root, dirs, files in os.walk(os.path.join(tmp, 'zeroinstall')): os.chmod(root, 0500) - sys.path.insert(0, tmp) - sys.argv[0] = os.path.join(tmp, 'install.py') + if not extract_only: + sys.path.insert(0, tmp) + sys.argv[0] = os.path.join(tmp, 'install.py') - print "Installing..." - import install - installer = install.Installer() - toplevel_uris = installer.do_install(self_stream, progress_bar, archive_offset) - self_stream.close() + print "Installing..." + import install + installer = install.Installer() + toplevel_uris = installer.do_install(self_stream, progress_bar, archive_offset) + self_stream.close() - if w: - w.finish_install() + if w: + w.finish_install() finally: - print "Removing temporary files..." - for root, dirs, files in os.walk(os.path.join(tmp, 'zeroinstall')): - os.chmod(root, 0700) - shutil.rmtree(tmp) + if extract_only: + print("Extracted files are in %s" % tmp) + sys.exit(0) + else: + print "Removing temporary files..." + for root, dirs, files in os.walk(os.path.join(tmp, 'zeroinstall')): + os.chmod(root, 0700) + shutil.rmtree(tmp) if options.verbose: zero_install_options = ['--verbose'] -- 2.11.4.GIT