</term>
<listitem>
<para>Specifies the upstream tarball compression type. This will be
- used to locate and build the upstream tarball if necessary.</para>
+ used to locate and build the upstream tarball if necessary. The
+ default is <replaceable>auto</replaceable> which derives the
+ compression type from the pristine-tar branch if available and falls
+ back to gzip otherwise. Other options are
+ <replaceable>gzip</replaceable>, <replaceable>bzip2</replaceable>,
+ <replaceable>lzma</replaceable> and <replaceable>xz</replaceable>.
+ </para>
</listitem>
</varlistentry>
<varlistentry>
return [ True, False ]['-' in cp['Version']]
+def get_compression(orig_file):
+ "Given an orig file return the compression used"
+ ext = orig_file.rsplit('.',1)[1]
+ for (c, o) in compressor_opts.iteritems():
+ if o[1] == ext:
+ return c
+ return None
+
+
def has_epoch(cp):
"""does the topmost version number contain an epoch"""
try:
for line in commit:
yield line
+ def get_subject(self, commit):
+ """Gets the subject of a commit"""
+ self.__check_path()
+ out, ret = self.__git_getoutput('show', ['--format=%s', commit])
+ if ret:
+ raise GitRepositoryError, "Error getting subject of commit %s" % commit
+ return out[0].strip()
+
def find_tag(self, branch):
"find the closest tag to a branch's head"
tag, ret = self.__git_getoutput('describe', [ "--abbrev=0", branch ])
#!/usr/bin/python -u
# vim: set fileencoding=utf-8 :
#
-# (C) 2006,2007,2008 Guido Guenther <agx@sigxcpu.org>
+# (C) 2006-2010 Guido Guenther <agx@sigxcpu.org>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
import gbp.deb as du
from gbp.git import (GitRepositoryError, GitRepository, build_tag)
from gbp.command_wrappers import (GitTag, Command, RunAtCommand, CommandExecFailed,
- PristineTar, RemoveTree, GitAdd)
+ PristineTar, RemoveTree, GitAdd, PristineTar)
from gbp.config import (GbpOptionParser, GbpOptionGroup)
from gbp.errors import GbpError
from glob import glob
# Remove that single folder:
os.rmdir(tar_topdir)
+
+def guess_comp_type(repo, comp_type):
+ """Guess compression type"""
+
+ if comp_type != 'auto':
+ try:
+ dummy = du.compressor_opts[comp_type]
+ except KeyError:
+ print >>sys.stderr, "Unknown compression type - guessing."
+ comp_type = 'auto'
+ else:
+ if not repo.has_branch(PristineTar.branch):
+ comp_type = 'gzip'
+ print >>sys.stderr, "No pristine tar branch found - assuming %s." % comp_type
+ else:
+ tarball = repo.get_subject(PristineTar.branch)
+ comp_type = du.get_compression(tarball)
+ if not comp_type:
+ comp_type = 'gzip'
+ print >>sys.stderr, "Unknown compression type of %s, assuming %s" % (tarball, comp_type)
+ return comp_type
+
+
def main(argv):
changelog = 'debian/changelog'
retval = 0
else:
tarball_dir = output_dir
+ options.comp_type = guess_comp_type (repo, options.comp_type)
# Get/build the orig.tar.gz if necessary:
if not du.is_native(cp):
orig_file = du.orig_file(cp, options.comp_type)