From 7de9f129883b95374240fa177948e12ddd17a342 Mon Sep 17 00:00:00 2001 From: Mehdi Dogguy Date: Fri, 12 Jun 2009 12:37:55 +0200 Subject: add filter-pristine-tar to filter upstream tarball before passing it to pristine-tar Closes: #520722 --- gbp/command_wrappers.py | 13 +++++++++++++ gbp/config.py | 3 +++ gbp/deb_utils.py | 11 +++++++++++ 3 files changed, 27 insertions(+) (limited to 'gbp') diff --git a/gbp/command_wrappers.py b/gbp/command_wrappers.py index 1439cc59..8cfa7cb9 100644 --- a/gbp/command_wrappers.py +++ b/gbp/command_wrappers.py @@ -132,6 +132,19 @@ class UnpackTarArchive(Command): Command.__init__(self, 'tar', exclude + ['-C', dir, decompress, '-xf', archive ]) self.run_error = 'Couldn\'t unpack "%s"' % self.archive +class RepackTarArchive(Command): + """Wrap tar to Repack a gzipped tar archive""" + def __init__(self, archive, dir, dest): + self.archive = archive + self.dir = dir + + if archive.lower().endswith(".bz2"): + compress = "--bzip2" + else: + compress = "--gzip" + + Command.__init__(self, 'tar', ['-C', dir, compress, '-cf', archive, dest]) + self.run_error = 'Couldn\'t repack "%s"' % self.archive class RemoveTree(Command): "Wrap rm to remove a whole directory tree" diff --git a/gbp/config.py b/gbp/config.py index 6fa223a6..0ffcc327 100644 --- a/gbp/config.py +++ b/gbp/config.py @@ -30,6 +30,7 @@ class GbpOptionParser(OptionParser): 'debian-branch' : 'master', 'upstream-branch' : 'upstream', 'pristine-tar' : 'False', + 'filter-pristine-tar' : 'False', 'sign-tags' : 'False', 'no-create-orig' : 'False', 'keyid' : '', @@ -66,6 +67,8 @@ class GbpOptionParser(OptionParser): "GPG keyid to sign tags with, default is '%(keyid)s'", 'pristine-tar': "use pristine-tar to create .orig.tar.gz, default is '%(pristine-tar)s'", + 'filter-pristine-tar': + "Filter pristine-tar when filter option is used", 'filter': "files to filter out during import (can be given multiple times)", 'git-author': diff --git a/gbp/deb_utils.py b/gbp/deb_utils.py index f20033a0..c439ba36 100644 --- a/gbp/deb_utils.py +++ b/gbp/deb_utils.py @@ -199,6 +199,17 @@ def unpack_orig(archive, tmpdir, filters): raise GbpError return unpackArchive.dir +def repack_orig(archive, tmpdir, dest): + """ + recreate a new .orig.tar.gz from tmpdir (useful when using filter option) + """ + try: + repackArchive = gbpc.RepackTarArchive(archive, tmpdir, dest) + repackArchive() + except gbpc.CommandExecFailed: + print >>sys.stderr, "Failed to create %s" % archive + raise GbpError + return repackArchive.dir def tar_toplevel(dir): """tar archives can contain a leading directory not""" -- cgit v1.2.3