diff options
author | Guido Günther <agx@sigxcpu.org> | 2011-07-24 14:52:12 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2011-07-25 17:12:35 +0200 |
commit | 73604962a177d654c4196d6ff7d9dd74f71aea37 (patch) | |
tree | 8bffc0940e2dae861aa2a877fdc671a3508ee6a1 /gbp | |
parent | 011b4d4e891b91dd8f9f140295c412b4a277663e (diff) |
Support importing zip archives
This can now be easily extended to support other formats
Diffstat (limited to 'gbp')
-rw-r--r-- | gbp/command_wrappers.py | 10 | ||||
-rw-r--r-- | gbp/deb.py | 24 |
2 files changed, 32 insertions, 2 deletions
diff --git a/gbp/command_wrappers.py b/gbp/command_wrappers.py index 64300cf..2f77a7b 100644 --- a/gbp/command_wrappers.py +++ b/gbp/command_wrappers.py @@ -200,6 +200,16 @@ class DpkgSourceExtract(Command): Command.__call__(self, [dsc, output_dir]) +class UnpackZipArchive(Command): + """Wrap zip to Unpack a zip file""" + def __init__(self, archive, dir): + self.archive = archive + self.dir = dir + + Command.__init__(self, 'unzip', [ "-q", archive, '-d', dir ]) + self.run_error = 'Couldn\'t unpack "%s"' % self.archive + + class GitCommand(Command): "Mother/Father of all git commands" def __init__(self, cmd, args=[], **kwargs): @@ -407,11 +407,31 @@ def unpack_orig(archive, tmpdir, filters): unpackArchive = gbpc.UnpackTarArchive(archive, tmpdir, filters) unpackArchive() except gbpc.CommandExecFailed: - print >>sys.stderr, "Unpacking of %s failed" % archive + # unpackArchive already printed an error message raise GbpError return unpackArchive.dir +def unpack_upstream_source(archive, tmpdir, filters): + """ + Unpack upstream sources into tmpdir + + @return: Return true if the importet archive is suitable as an upstream + tarball + @rtype: boolean + """ + ext = os.path.splitext(archive)[1] + if ext in [ ".zip", ".xpi" ]: + try: + gbpc.UnpackZipArchive(archive, tmpdir)() + except gbpc.CommandExecFailed: + raise GbpError, "Unpacking of %s failed" % archive + return False + else: + unpack_orig(archive, tmpdir, filters) + return True + + def repack_orig(archive, tmpdir, dest): """ recreate a new .orig.tar.gz from tmpdir (useful when using filter option) @@ -420,7 +440,7 @@ def repack_orig(archive, tmpdir, dest): repackArchive = gbpc.RepackTarArchive(archive, tmpdir, dest) repackArchive() except gbpc.CommandExecFailed: - print >>sys.stderr, "Failed to create %s" % archive + # repackArchive already printed an error raise GbpError return repackArchive.dir |