diff options
-rwxr-xr-x | xpi-repack | 46 |
1 files changed, 23 insertions, 23 deletions
@@ -39,29 +39,29 @@ def remove_recursive(path): def repack_xpi(script_name, package, upstream_version, xpi_file, verbose): # extract xpi file tmp_dir = tempfile.mkdtemp(prefix=script_name+".") - extract_dir = package + "-" + upstream_version - full_extract_dir = os.path.join(tmp_dir, extract_dir) - subprocess.check_call(["xpi-unpack", xpi_file, full_extract_dir]) - - # check, if source 3.0 (quilt) format is used - extension = ".gz" - if os.path.isfile("debian/source/format"): - source_format = open("debian/source/format").readline().strip() - if source_format == "3.0 (quilt)": - extension = ".bz2" - - # pack source - tar_file = package + "_" + upstream_version + ".orig.tar" - full_tar_file = os.path.realpath(os.path.join(os.path.dirname(xpi_file), - tar_file)) - cmd = ["tar", "-ca", "-C", tmp_dir, "-f", full_tar_file + extension, - extract_dir] - if verbose: - print " ".join(cmd) - subprocess.check_call(cmd) - - # remove temporary directory - remove_recursive(tmp_dir) + try: + extract_dir = package + "-" + upstream_version + full_extract_dir = os.path.join(tmp_dir, extract_dir) + subprocess.check_call(["xpi-unpack", xpi_file, full_extract_dir]) + + # check, if source 3.0 (quilt) format is used + extension = ".gz" + if os.path.isfile("debian/source/format"): + source_format = open("debian/source/format").readline().strip() + if source_format == "3.0 (quilt)": + extension = ".bz2" + + # pack source + directory = os.path.realpath(os.path.dirname(xpi_file)) + tar_file = package + "_" + upstream_version + ".orig.tar" + extension + full_tar_file = os.path.join(directory, tar_file) + cmd = ["tar", "-ca", "-C", tmp_dir, "-f", full_tar_file, extract_dir] + if verbose: + print " ".join(cmd) + subprocess.check_call(cmd) + finally: + # remove temporary directory + remove_recursive(tmp_dir) def get_source_package_name(script_name): |