[Pkg-mozext-commits] [mozilla-devscripts] 05/12: xpi-repack: Remove temporary directory even when errors occur.

Benjamin Drung bdrung at moszumanska.debian.org
Mon Mar 10 23:36:47 UTC 2014


This is an automated email from the git hooks/post-receive script.

bdrung pushed a commit to branch master
in repository mozilla-devscripts.

commit 691bcf999bd2e73324e42f43cfea201a02b96439
Author: Benjamin Drung <bdrung at debian.org>
Date:   Mon Mar 10 23:51:09 2014 +0100

    xpi-repack: Remove temporary directory even when errors occur.
---
 xpi-repack | 46 +++++++++++++++++++++++-----------------------
 1 file 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):

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/mozilla-devscripts.git



More information about the Pkg-mozext-commits mailing list