aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMehdi Dogguy <dogguy@pps.jussieu.fr>2009-06-12 12:37:55 +0200
committerGuido Günther <agx@sigxcpu.org>2009-06-13 22:20:13 +0200
commit7de9f129883b95374240fa177948e12ddd17a342 (patch)
tree65e3c5cd1715e5d5265b1c0b71b310307ea823b3
parent882f9716762fb086046f58b5c22ff658e69a2298 (diff)
add filter-pristine-tar
to filter upstream tarball before passing it to pristine-tar Closes: #520722
-rw-r--r--docs/manpages/git-import-orig.sgml9
-rw-r--r--gbp.conf2
-rw-r--r--gbp/command_wrappers.py13
-rw-r--r--gbp/config.py3
-rw-r--r--gbp/deb_utils.py11
-rwxr-xr-xgit-import-orig11
6 files changed, 48 insertions, 1 deletions
diff --git a/docs/manpages/git-import-orig.sgml b/docs/manpages/git-import-orig.sgml
index 2c0d44da..7c19adf6 100644
--- a/docs/manpages/git-import-orig.sgml
+++ b/docs/manpages/git-import-orig.sgml
@@ -32,6 +32,7 @@
<arg><option>--upstream-tag=</option><replaceable>tag-format</replaceable></arg>
<arg><option>--filter=</option><replaceable>pattern</replaceable></arg>
<arg><option>--[no-]pristine-tar</option></arg>
+ <arg><option>--[no-]filter-pristine-tar</option></arg>
<arg choice="plain"><replaceable>upstream-source</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
@@ -136,6 +137,14 @@
<para>generate pristine-tar delta file</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--filter-pristine-tar</option>
+ </term>
+ <listitem>
+ <para>if using a filter also filter the files out of the tarball
+ passed to pristine tar</para>
+ </listitem>
+ </varlistentry>
</variablelist>
</refsect1>
<refsect1>
diff --git a/gbp.conf b/gbp.conf
index 7a1029e6..ce6fc111 100644
--- a/gbp.conf
+++ b/gbp.conf
@@ -37,6 +37,8 @@
#upstream-branch = newupstream
#debian-branch = dfsgclean
#filter = .svn
+# filter out files from tarball passed to pristine tar
+#filter-pristine-tar = True
# Options only affecting git-import-dsc
[git-import-dsc]
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"""
diff --git a/git-import-orig b/git-import-orig
index acb012ce..9e47bf84 100755
--- a/git-import-orig
+++ b/git-import-orig
@@ -27,7 +27,7 @@ import subprocess
import tarfile
import time
import gbp.command_wrappers as gbpc
-from gbp.deb_utils import parse_changelog, unpack_orig, NoChangelogError, has_epoch, tar_toplevel, guess_upstream_version
+from gbp.deb_utils import parse_changelog, unpack_orig, repack_orig, NoChangelogError, has_epoch, tar_toplevel, guess_upstream_version
from gbp.git_utils import (GitRepositoryError, GitRepository, build_tag)
from gbp.config import GbpOptionParser
from gbp.errors import (GbpError, GbpNothingImported)
@@ -228,6 +228,7 @@ def main(argv):
parser.add_config_file_option(option_name="upstream-tag", dest="upstream_tag")
parser.add_config_file_option(option_name="filter", dest="filters", action="append")
parser.add_boolean_config_file_option(option_name="pristine-tar", dest="pristine_tar")
+ parser.add_boolean_config_file_option(option_name="filter-pristine-tar", dest="filter_pristine_tar")
(options, args) = parser.parse_args(argv[1:])
if options.verbose:
@@ -292,6 +293,14 @@ on howto create it otherwise use --upstream-branch to specify it.
if options.verbose:
print "Unpacked %s to '%s'" % (archive , tmpdir)
orig_dir = tar_toplevel(tmpdir)
+ if options.pristine_tar and options.filter_pristine_tar and len(options.filters) > 0:
+ if options.verbose:
+ print "Filter pristine-tar: repacking %s from '%s'" % (archive, tmpdir)
+ archive = os.path.join(
+ os.path.dirname(archive),
+ os.path.basename(archive).replace(".tar", ".gbp.tar")
+ )
+ repack_orig(archive, tmpdir, os.path.basename(orig_dir))
try:
cp = parse_changelog('debian/changelog')
pristine_orig = symlink_orig(archive, cp['Source'], version)