aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2016-05-27 10:04:26 +0200
committerGuido Günther <agx@sigxcpu.org>2016-05-27 10:04:26 +0200
commitcfcac022a68d7157f5db8a9d0c77e72bcc6c6ff5 (patch)
tree3d69cc319533a6c9be742aff57b24aed44d742d2
parent0a99f3f8e484260fa7ef2e14ee881e9ad4bf0f84 (diff)
buildpackage: Allow to generate subtarballs
This does not support pristine-tar yet.
-rw-r--r--docs/manpages/gbp-buildpackage.sgml22
-rwxr-xr-xgbp/scripts/buildpackage.py34
-rw-r--r--tests/component/deb/test_buildpackage.py23
3 files changed, 74 insertions, 5 deletions
diff --git a/docs/manpages/gbp-buildpackage.sgml b/docs/manpages/gbp-buildpackage.sgml
index 2970719..9de8d9f 100644
--- a/docs/manpages/gbp-buildpackage.sgml
+++ b/docs/manpages/gbp-buildpackage.sgml
@@ -52,6 +52,7 @@
<arg><option>--git-tarball-dir=</option><replaceable>DIRECTORY</replaceable></arg>
<arg><option>--git-compression=</option><replaceable>TYPE</replaceable></arg>
<arg><option>--git-compression-level=</option><replaceable>LEVEL</replaceable></arg>
+ <arg><option>--git-subtarball=</option><replaceable>SUBTARBALL</replaceable></arg>
<arg><option>--git-export-dir=</option><replaceable>DIRECTORY</replaceable></arg>
<arg><option>--git-export=</option><replaceable>TREEISH</replaceable></arg>
<arg><option>--git-[no-]pristine-tar</option></arg>
@@ -574,6 +575,23 @@
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>--git-subtarball=</option><replaceable>SUBTARBALL</replaceable>
+ </term>
+ <listitem>
+ <para>
+ When generating tarballs create an additional original
+ tarball of directory <replaceable>SUBTARBALL</replaceable>
+ in the source tree. Using additional original tarballs is
+ a feature of the 3.0 (quilt) souce format. See
+ the <command>dpkg-source</command> manpage for details. Note that the
+ <replaceable>--git-pristine-tar-commit</replaceable>
+ option is currently incompatible with this option. It also can't be
+ set via &gbp.conf; since it's considered an experimental feature and
+ might change incompatibly.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term><option>--git[-no]-purge</option>
</term>
<listitem>
@@ -682,6 +700,10 @@
<refentrytitle>cowbuilder</refentrytitle>
<manvolnum>8</manvolnum>
</citerefentry>,
+ <citerefentry>
+ <refentrytitle>dpkg-source</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </citerefentry>,
<xref linkend="man.gbp.conf"/>,
&man.seealso.common;
</para>
diff --git a/gbp/scripts/buildpackage.py b/gbp/scripts/buildpackage.py
index 2cea541..e494155 100755
--- a/gbp/scripts/buildpackage.py
+++ b/gbp/scripts/buildpackage.py
@@ -1,6 +1,7 @@
+
# vim: set fileencoding=utf-8 :
#
-# (C) 2006-2015 Guido Günther <agx@sigxcpu.org>
+# (C) 2006-2016 Guido Günther <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
@@ -44,14 +45,14 @@ from gbp.scripts.common.buildpackage import (index_name, wc_name,
from gbp.pkg import compressor_opts, compressor_aliases, parse_archive_filename
#{ upstream tarball preparation
-def git_archive(repo, cp, output_dir, treeish, comp_type, comp_level, with_submodules):
+def git_archive(repo, cp, output_dir, treeish, comp_type, comp_level, with_submodules, subtarball=None):
"create a compressed orig tarball in output_dir using git_archive"
try:
comp_opts = compressor_opts[comp_type][0]
except KeyError:
raise GbpError("Unsupported compression type '%s'" % comp_type)
- output = os.path.join(output_dir, du.orig_file(cp, comp_type))
+ output = os.path.join(output_dir, du.orig_file(cp, comp_type, subtarball=subtarball))
prefix = "%s-%s" % (cp['Source'], cp['Upstream-Version'])
try:
@@ -89,6 +90,7 @@ def prepare_upstream_tarball(repo, cp, options, tarball_dir, output_dir):
orig_file = du.orig_file(cp, options.comp_type)
# look in tarball_dir first, if found force a symlink to it
+ # FIXME: check for and symlink component tarballs as well
if options.tarball_dir:
gbp.log.debug("Looking for orig tarball '%s' at '%s'" % (orig_file, tarball_dir))
if not du.DebianPkgPolicy.symlink_orig(orig_file, tarball_dir, output_dir, force=True):
@@ -98,6 +100,7 @@ def prepare_upstream_tarball(repo, cp, options, tarball_dir, output_dir):
if options.no_create_orig:
return
# Create tarball if missing or forced
+ # FIXME: check for component tarballs as well
if not du.DebianPkgPolicy.has_orig(orig_file, output_dir) or options.force_create:
if not pristine_tar_build_orig(repo, cp, output_dir, options):
upstream_tree = git_archive_build_orig(repo, cp, output_dir, options)
@@ -281,7 +284,7 @@ def get_upstream_tree(repo, cp, options):
def git_archive_build_orig(repo, cp, output_dir, options):
"""
- Build orig tarball using git-archive
+ Build orig tarball(s) using git-archive
@param cp: the changelog of the package we're acting on
@type cp: L{ChangeLog}
@@ -298,11 +301,26 @@ def git_archive_build_orig(repo, cp, output_dir, options):
upstream_tree))
gbp.log.debug("Building upstream tarball with compression '%s -%s'" %
(options.comp_type, options.comp_level))
- if not git_archive(repo, cp, output_dir, upstream_tree,
+ main_tree = repo.tree_drop_dirs(upstream_tree, options.subtarballs)
+ if not git_archive(repo, cp, output_dir, main_tree,
options.comp_type,
options.comp_level,
options.with_submodules):
raise GbpError("Cannot create upstream tarball at '%s'" % output_dir)
+ for subtarball in options.subtarballs:
+ subtree = repo.tree_get_dir(upstream_tree, subtarball)
+ if not subtree:
+ raise GbpError("No tree for '%s' found in '%s' to create subtarball from" % (subtarball, upstream_tree))
+ gbp.log.info("Creating subtarball '%s' from '%s'" % (du.orig_file(cp,
+ options.comp_type,
+ subtarball=subtarball),
+ subtree))
+ if not git_archive(repo, cp, output_dir, subtree,
+ options.comp_type,
+ options.comp_level,
+ options.with_submodules,
+ subtarball=subtarball):
+ raise GbpError("Cannot create upstream component tarball %s at '%s'" % (subtarball, output_dir))
return upstream_tree
@@ -506,6 +524,8 @@ def build_parser(name, prefix=None):
help="Compression type, default is '%(compression)s'")
orig_group.add_config_file_option(option_name="compression-level", dest="comp_level",
help="Compression level, default is '%(compression-level)s'")
+ orig_group.add_option("--git-subtarball", action="append", metavar='SUBTARBALL',
+ dest="subtarballs", help="subtarsball to generate, can be given multiple times", default=[])
branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch")
branch_group.add_config_file_option(option_name="debian-branch", dest="debian_branch")
branch_group.add_boolean_config_file_option(option_name = "ignore-branch", dest="ignore_branch")
@@ -571,6 +591,10 @@ def parse_args(argv, prefix):
gbp.log.warning("--git-dont-purge is depreceted, use --git-no-purge instead")
options.purge = False
+ if options.subtarballs and options.pristine_tar:
+ gbp.log.warning("Subtarblls specified, pristine-tar not yet supported - disabling it.")
+ options.pristine_tar = False
+
return options, args, dpkg_args
diff --git a/tests/component/deb/test_buildpackage.py b/tests/component/deb/test_buildpackage.py
index 7b280a2..edfe1dd 100644
--- a/tests/component/deb/test_buildpackage.py
+++ b/tests/component/deb/test_buildpackage.py
@@ -104,3 +104,26 @@ class TestBuildpackage(ComponentTestBase):
self.check_hook_vars('posttag', ["GBP_TAG",
"GBP_BRANCH",
"GBP_SHA1"])
+
+ def test_subtarball_generation(self):
+ """Test that generating tarball and additional tarball works"""
+ def _dsc(version):
+ return os.path.join(DEB_TEST_DATA_DIR,
+ 'dsc-3.0-additional-tarballs',
+ 'hello-debhelper_%s.dsc' % version)
+ dsc = _dsc('2.8-1')
+ tarballs = ["../hello-debhelper_2.8.orig-foo.tar.gz",
+ "../hello-debhelper_2.8.orig.tar.gz"]
+
+ assert import_dsc(['arg0', dsc]) == 0
+ os.chdir('hello-debhelper')
+ for t in tarballs:
+ self.assertFalse(os.path.exists(t), "Tarball %s must not exist" % t)
+ ret = buildpackage(['arg0',
+ '--git-subtarball=foo',
+ '--git-posttag=printenv > posttag.out',
+ '--git-builder=touch builder-run.stamp',
+ '--git-cleaner=/bin/true'])
+ ok_(ret == 0, "Building the package failed")
+ for t in tarballs:
+ self.assertTrue(os.path.exists(t), "Tarball %s not found" % t)