summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Drung <bdrung@debian.org>2014-03-10 23:51:09 +0100
committerBenjamin Drung <bdrung@debian.org>2014-03-10 23:51:09 +0100
commit691bcf999bd2e73324e42f43cfea201a02b96439 (patch)
tree7379336e1af05c1e19c6b2ad452cc3df24077279
parent94e9f9b84e23a2f9af71dcf2df03d91a08d6206e (diff)
xpi-repack: Remove temporary directory even when errors occur.
-rwxr-xr-xxpi-repack46
1 files changed, 23 insertions, 23 deletions
diff --git a/xpi-repack b/xpi-repack
index f18580f..9b9663b 100755
--- a/xpi-repack
+++ b/xpi-repack
@@ -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):