aboutsummaryrefslogtreecommitdiffhomepage
path: root/gbp
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2011-07-25 17:40:11 +0200
committerGuido Günther <agx@sigxcpu.org>2011-07-25 21:22:30 +0200
commitf0ba62c753ff08fe6ad1e30108e9668d984adfd0 (patch)
treecdba968b06664c3ccaabfd3b9c50652db77742fe /gbp
parent33d5156335a6a602102d7387624e05729d46d5ff (diff)
Drop unpack_orig and tar_toplevel
Diffstat (limited to 'gbp')
-rw-r--r--gbp/deb.py62
1 files changed, 31 insertions, 31 deletions
diff --git a/gbp/deb.py b/gbp/deb.py
index 806f2fc6..f88ff682 100644
--- a/gbp/deb.py
+++ b/gbp/deb.py
@@ -227,7 +227,7 @@ class UpstreamSource(object):
raise GbpError, "Filters must be a list"
self._unpack_archive(dir, filters)
- self.unpacked = tar_toplevel(dir)
+ self.unpacked = self._unpacked_toplevel(dir)
def _unpack_archive(self, dir, filters):
"""
@@ -235,12 +235,37 @@ class UpstreamSource(object):
"""
ext = os.path.splitext(self.path)[1]
if ext in [ ".zip", ".xpi" ]:
- try:
- gbpc.UnpackZipArchive(self.path, dir)()
- except gbpc.CommandExecFailed:
- raise GbpError, "Unpacking of %s failed" % self.path
+ self._unpack_zip(dir)
else:
- unpack_orig(self.path, dir, filters)
+ self._unpack_tar(dir, filters)
+
+ def _unpack_zip(self, dir):
+ try:
+ gbpc.UnpackZipArchive(self.path, dir)()
+ except gbpc.CommandExecFailed:
+ raise GbpError, "Unpacking of %s failed" % self.path
+
+ def _unpacked_toplevel(self, dir):
+ """unpacked archives can contain a leading directory not"""
+ unpacked = glob.glob('%s/*' % dir)
+ unpacked.extend(glob.glob("%s/.*" % dir)) # include hidden files and folders
+ # Check that dir contains nothing but a single folder:
+ if len(unpacked) == 1 and os.path.isdir(unpacked[0]):
+ return unpacked[0]
+ else:
+ return dir
+
+ def _unpack_tar(self, dir, filters):
+ """
+ unpack a .orig.tar.gz to tmpdir, leave the cleanup to the caller in case of
+ an error
+ """
+ try:
+ unpackArchive = gbpc.UnpackTarArchive(self.path, dir, filters)
+ unpackArchive()
+ except gbpc.CommandExecFailed:
+ # unpackArchive already printed an error message
+ raise GbpError
def pack(self, newarchive, filters=[]):
"""
@@ -504,31 +529,6 @@ def do_uscan():
return parse_uscan(out)
-def unpack_orig(archive, tmpdir, filters):
- """
- unpack a .orig.tar.gz to tmpdir, leave the cleanup to the caller in case of
- an error
- """
- try:
- unpackArchive = gbpc.UnpackTarArchive(archive, tmpdir, filters)
- unpackArchive()
- except gbpc.CommandExecFailed:
- # unpackArchive already printed an error message
- raise GbpError
- return unpackArchive.dir
-
-
-def tar_toplevel(dir):
- """tar archives can contain a leading directory not"""
- unpacked = glob.glob('%s/*' % dir)
- unpacked.extend(glob.glob("%s/.*" % dir)) # include hidden files and folders
- # Check that dir contains nothing but a single folder:
- if len(unpacked) == 1 and os.path.isdir(unpacked[0]):
- return unpacked[0]
- else:
- return dir
-
-
def get_arch():
pipe = subprocess.Popen(["dpkg", "--print-architecture"], shell=False, stdout=subprocess.PIPE)
arch = pipe.stdout.readline().strip()