diff options
author | Guido Günther <agx@sigxcpu.org> | 2011-07-25 17:40:11 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2011-07-25 21:22:30 +0200 |
commit | f0ba62c753ff08fe6ad1e30108e9668d984adfd0 (patch) | |
tree | cdba968b06664c3ccaabfd3b9c50652db77742fe /gbp | |
parent | 33d5156335a6a602102d7387624e05729d46d5ff (diff) |
Drop unpack_orig and tar_toplevel
Diffstat (limited to 'gbp')
-rw-r--r-- | gbp/deb.py | 62 |
1 files changed, 31 insertions, 31 deletions
@@ -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() |