Package: git-buildpackage Tags: patch Severity: wishlist When upstream had their own pristine-tar branch, it was not possible to use it directly because the .orig.tar.xx is debian specific. This adds the possibility to define a pattern like
{name}_{version}.tar.{compression}
with {name} and {compression} non-mandatory
---
gbp.conf | 2 ++
gbp/config.py | 1 +
gbp/deb.py | 13 +++++++++++++
git-buildpackage | 10 ++++++++--
4 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/gbp.conf b/gbp.conf
index 22ac648..777093d 100644
--- a/gbp.conf
+++ b/gbp.conf
@@ -14,6 +14,8 @@
#debian-tag = debian/%(version)s
# use pristine-tar:
#pristine-tar = True
+# when building the pristine-tar archive, it is in the format:
+#archive-format = {name}_{version}.orig.tar.{compression}
# don't check if debian-branch == current branch:
#ignore-branch = True
# Use color when on a terminal, alternatives: on/true, off/false or auto
diff --git a/gbp/config.py b/gbp/config.py
index 14e72b3..64f2e07 100644
--- a/gbp/config.py
+++ b/gbp/config.py
@@ -59,6 +59,7 @@ class GbpOptionParser(OptionParser):
'cleaner' : 'debuild -d clean',
'debian-branch' : 'master',
'upstream-branch' : 'upstream',
+ 'archive-format' : '{name}_{version}.orig.tar.{compression}',
'pristine-tar' : 'False',
'filter-pristine-tar' : 'False',
'sign-tags' : 'False',
diff --git a/gbp/deb.py b/gbp/deb.py
index 930e626..52bb359 100644
--- a/gbp/deb.py
+++ b/gbp/deb.py
@@ -253,6 +253,19 @@ def orig_file(cp, compression):
ext = compressor_opts[compression][1]
return "%s_%s.orig.tar.%s" % (cp['Source'], cp['Upstream-Version'], ext)
+def upstream_archive(cp, compression, template):
+ """
+ The name of the upstream tarball matching the template.
+ The template is a simple string containing at least '{version}'.
+ It is also possible to use '{name}' and '{compression}', even though
optional.
+ """
+
+ # Ugly hack to allow the user not to use every symbol while keeping a
usable syntax
+ python_friendly = lambda m: "{{0.{0}}}".format(m.groupdict()['symbol'])
+ format_data = type('Bogus', (object,), {'compression':
compressor_opts[compression][1],
+ 'name': cp['Source'],
+ 'version': cp['Upstream-Version']})
+ return re.sub("\{(?P<symbol>(name|version|compression))\}",
python_friendly, template).format(format_data)
def is_native(cp):
"""
diff --git a/git-buildpackage b/git-buildpackage
index 31fc6ce..e2e9e8d 100755
--- a/git-buildpackage
+++ b/git-buildpackage
@@ -21,7 +21,6 @@
import ConfigParser
import errno
import os, os.path
-import pipes
import sys
import time
import tempfile
@@ -201,7 +200,12 @@ def pristine_tar_build_orig(repo, cp, output_dir, options):
pt = PristineTar()
if not repo.has_branch(pt.branch):
gbp.log.warn('Pristine-tar branch "%s" not found' % pt.branch)
- pt.checkout(os.path.join(output_dir, du.orig_file(cp,
options.comp_type)))
+
+ tarball = os.path.join(output_dir, du.upstream_archive(cp,
options.comp_type, options.arch_format))
+ pt.checkout(tarball)
+ orig_file = os.path.join(output_dir, du.orig_file(cp,
options.comp_type))
+ if orig_file != tarball:
+ shutil.move(tarball, orig_file)
return True
else:
return False
@@ -368,6 +372,8 @@ def parse_args(argv, prefix):
help="don't create orig.tar.gz", action="store_true")
orig_group.add_config_file_option(option_name="tarball-dir",
dest="tarball_dir", type="path",
help="location to look for external tarballs")
+ orig_group.add_config_file_option(option_name="archive-format",
dest="arch_format",
+ help="Format of the upstream archive. Default is
'%(archive-format)s'")
orig_group.add_config_file_option(option_name="compression",
dest="comp_type",
help="Compression type, default is '%(compression)s'")
orig_group.add_config_file_option(option_name="compression-level",
dest="comp_level",
--
1.7.5.3
signature.asc
Description: Digital signature

