From d681e932b63a21aeaa7d07f4bfb533b583e4c1ae Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Sun, 3 Jul 2016 19:41:26 +0200 Subject: Use 'component' and 'additional tarball' since this is what dpkg-source(1) uses. Git-Dch: Ignore --- docs/manpages/gbp-buildpackage.sgml | 6 ++-- gbp/deb/__init__.py | 6 ++-- gbp/deb/policy.py | 6 ++-- gbp/deb/pristinetar.py | 4 +-- gbp/deb/upstreamsource.py | 2 +- gbp/scripts/buildpackage.py | 47 ++++++++++++++++---------------- gbp/scripts/import_dsc.py | 4 +-- tests/component/deb/test_buildpackage.py | 8 +++--- tests/component/deb/test_import_dsc.py | 4 +-- 9 files changed, 43 insertions(+), 44 deletions(-) diff --git a/docs/manpages/gbp-buildpackage.sgml b/docs/manpages/gbp-buildpackage.sgml index e1966f9..20b3630 100644 --- a/docs/manpages/gbp-buildpackage.sgml +++ b/docs/manpages/gbp-buildpackage.sgml @@ -52,7 +52,7 @@ DIRECTORY TYPE LEVEL - SUBTARBALL + component DIRECTORY TREEISH @@ -575,12 +575,12 @@ - SUBTARBALL + COMPONENT When generating tarballs create an additional original - tarball of directory SUBTARBALL + tarball of directory COMPONENT in the source tree. Using additional original tarballs is a feature of the 3.0 (quilt) source format. See the dpkg-source manpage for details. Note that the diff --git a/gbp/deb/__init__.py b/gbp/deb/__init__.py index 234d781..b3b8225 100644 --- a/gbp/deb/__init__.py +++ b/gbp/deb/__init__.py @@ -80,7 +80,7 @@ def parse_changelog_repo(repo, branch, filename): return ChangeLog(repo.show(sha)) -def orig_file(cp, compression, subtarball=None): +def orig_file(cp, compression, component=None): """ The name of the orig file belonging to changelog cp @@ -88,13 +88,13 @@ def orig_file(cp, compression, subtarball=None): 'foo_1.0.orig.tar.bz2' >>> orig_file({'Source': 'bar', 'Upstream-Version': '0.0~git1234'}, "xz") 'bar_0.0~git1234.orig.tar.xz' - >>> orig_file({'Source': 'bar', 'Upstream-Version': '0.0~git1234'}, "xz", subtarball="sub1") + >>> orig_file({'Source': 'bar', 'Upstream-Version': '0.0~git1234'}, "xz", component="sub1") 'bar_0.0~git1234.orig-sub1.tar.xz' """ return DebianPkgPolicy.build_tarball_name(cp['Source'], cp['Upstream-Version'], compression, - subtarball=subtarball) + component=component) def get_arch(): diff --git a/gbp/deb/policy.py b/gbp/deb/policy.py index 7522160..75e7879 100644 --- a/gbp/deb/policy.py +++ b/gbp/deb/policy.py @@ -62,7 +62,7 @@ class DebianPkgPolicy(PkgPolicy): debianversion_chars = 'a-zA-Z\\d.~+-' @staticmethod - def build_tarball_name(name, version, compression, dir=None, subtarball=None): + def build_tarball_name(name, version, compression, dir=None, component=None): """ Given a source package's I{name}, I{version} and I{compression} return the name of the corresponding upstream tarball. @@ -71,7 +71,7 @@ class DebianPkgPolicy(PkgPolicy): 'foo_1.0.orig.tar.bz2' >>> DebianPkgPolicy.build_tarball_name('bar', '0.0~git1234', 'xz') 'bar_0.0~git1234.orig.tar.xz' - >>> DebianPkgPolicy.build_tarball_name('bar', '0.0~git1234', 'xz', subtarball="foo") + >>> DebianPkgPolicy.build_tarball_name('bar', '0.0~git1234', 'xz', component="foo") 'bar_0.0~git1234.orig-foo.tar.xz' @param name: the source package's name @@ -86,7 +86,7 @@ class DebianPkgPolicy(PkgPolicy): @rtype: C{str} """ ext = compressor_opts[compression][1] - sub = '-{0}'.format(subtarball) if subtarball else '' + sub = '-{0}'.format(component) if component else '' tarball = "%s_%s.orig%s.tar.%s" % (name, version, sub, ext) if dir: tarball = os.path.join(dir, tarball) diff --git a/gbp/deb/pristinetar.py b/gbp/deb/pristinetar.py index 09e4d4e..ab7fbd6 100644 --- a/gbp/deb/pristinetar.py +++ b/gbp/deb/pristinetar.py @@ -43,7 +43,7 @@ class DebianPristineTar(PristineTar): return super(DebianPristineTar, self).has_commit(name_regexp) - def checkout(self, package, version, comp_type, output_dir, subtarball=None): + def checkout(self, package, version, comp_type, output_dir, component=None): """ Checkout the orig tarball for package I{package} of I{version} and compression type I{comp_type} to I{output_dir} @@ -61,6 +61,6 @@ class DebianPristineTar(PristineTar): version, comp_type, output_dir, - subtarball=subtarball) + component=component) super(DebianPristineTar, self).checkout(name) diff --git a/gbp/deb/upstreamsource.py b/gbp/deb/upstreamsource.py index 651043e..4895627 100644 --- a/gbp/deb/upstreamsource.py +++ b/gbp/deb/upstreamsource.py @@ -34,7 +34,7 @@ class DebianUpstreamSource(UpstreamSource): DebianPkgPolicy) -def unpack_subtarball(dest, component, tarball, filters): +def unpack_component_tarball(dest, component, tarball, filters): """ Unpack the tarball I{tarball} into dest naming it I{component}. Apply filters during unpack. diff --git a/gbp/scripts/buildpackage.py b/gbp/scripts/buildpackage.py index 4090287..eb704c7 100755 --- a/gbp/scripts/buildpackage.py +++ b/gbp/scripts/buildpackage.py @@ -1,4 +1,3 @@ - # vim: set fileencoding=utf-8 : # # (C) 2006-2016 Guido Günther @@ -45,14 +44,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, subtarball=None): +def git_archive(repo, cp, output_dir, treeish, comp_type, comp_level, with_submodules, component=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, subtarball=subtarball)) + output = os.path.join(output_dir, du.orig_file(cp, comp_type, component=component)) prefix = "%s-%s" % (cp['Source'], cp['Upstream-Version']) try: @@ -89,8 +88,8 @@ def prepare_upstream_tarball(repo, cp, options, tarball_dir, output_dir): options.tarball_dir) orig_files = [du.orig_file(cp, options.comp_type)] - if options.subtarballs: - orig_files += [du.orig_file(cp, options.comp_type, sub) for sub in options.subtarballs] + if options.components: + orig_files += [du.orig_file(cp, options.comp_type, c) for c in options.components] # look in tarball_dir first, if found force a symlink to it if options.tarball_dir: @@ -253,12 +252,12 @@ def pristine_tar_build_orig(repo, cp, output_dir, options): repo.pristine_tar.branch) # Make sure the upstream tree exists, it might not be there in - # case of subtarballs since we don't keep a ref to it - if options.subtarballs: + # case of components since we don't keep a ref to it + if options.components: try: upstream_tag = repo.version_to_tag(options.upstream_tag, cp.upstream_version) tree_name = "%s^{tree}" % upstream_tag - repo.tree_drop_dirs(tree_name, options.subtarballs) + repo.tree_drop_dirs(tree_name, options.components) except GitRepositoryError: raise GbpError("Couldn't find upstream tree '%s' to create orig tarball via pristine-tar" % tree_name) @@ -267,12 +266,12 @@ def pristine_tar_build_orig(repo, cp, output_dir, options): cp.upstream_version, options.comp_type, output_dir) - for subtarball in options.subtarballs: + for component in options.components: repo.pristine_tar.checkout(cp.name, cp.upstream_version, options.comp_type, output_dir, - subtarball=subtarball) + component=component) return True except CommandExecFailed: if options.pristine_tar_commit: @@ -321,26 +320,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)) - main_tree = repo.tree_drop_dirs(upstream_tree, options.subtarballs) + main_tree = repo.tree_drop_dirs(upstream_tree, options.components) 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) + for component in options.components: + subtree = repo.tree_get_dir(upstream_tree, component) 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)) + raise GbpError("No tree for '%s' found in '%s' to create additional tarball from" % (component, upstream_tree)) + gbp.log.info("Creating additional tarball '%s' from '%s'" % (du.orig_file(cp, + options.comp_type, + component=component), + 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)) + component=component): + raise GbpError("Cannot create additional tarball %s at '%s'" % (component, output_dir)) return upstream_tree @@ -544,8 +543,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=[]) + orig_group.add_option("--git-component", action="append", metavar='COMPONENT', + dest="components", 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") @@ -611,8 +610,8 @@ 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_commit: - gbp.log.warning("Subtarballs specified, pristine-tar-commit not yet supported - disabling it.") + if options.components and options.pristine_tar_commit: + gbp.log.warning("Components specified, pristine-tar-commit not yet supported - disabling it.") options.pristine_tar_commit = False return options, args, dpkg_args diff --git a/gbp/scripts/import_dsc.py b/gbp/scripts/import_dsc.py index f343b7f..f7c8a97 100644 --- a/gbp/scripts/import_dsc.py +++ b/gbp/scripts/import_dsc.py @@ -27,7 +27,7 @@ import pipes import time import gbp.command_wrappers as gbpc from gbp.deb.dscfile import DscFile -from gbp.deb.upstreamsource import DebianUpstreamSource, unpack_subtarball +from gbp.deb.upstreamsource import DebianUpstreamSource, unpack_component_tarball from gbp.deb.git import (DebianGitRepository, GitRepositoryError) from gbp.deb.changelog import ChangeLog from gbp.git import rfc822_date_to_git @@ -335,7 +335,7 @@ def main(argv): upstream.unpack(dirs['tmp'], options.filters) for (component, tarball) in src.additional_tarballs.items(): gbp.log.info("Found component tarball '%s'" % os.path.basename(tarball)) - unpack_subtarball(upstream.unpacked, component, tarball, options.filters) + unpack_component_tarball(upstream.unpacked, component, tarball, options.filters) format = [(options.upstream_tag, "Upstream"), (options.debian_tag, "Debian")][src.native] tag = repo.version_to_tag(format[0], src.upstream_version) diff --git a/tests/component/deb/test_buildpackage.py b/tests/component/deb/test_buildpackage.py index 19dfa82..fe1e140 100644 --- a/tests/component/deb/test_buildpackage.py +++ b/tests/component/deb/test_buildpackage.py @@ -106,7 +106,7 @@ class TestBuildpackage(ComponentTestBase): "GBP_BRANCH", "GBP_SHA1"]) - def test_subtarball_generation(self): + def test_component_generation(self): """Test that generating tarball and additional tarball works without pristine-tar""" pkg = 'hello-debhelper' dsc = self._dsc_name(pkg, '2.8-1', 'dsc-3.0-additional-tarballs') @@ -120,7 +120,7 @@ class TestBuildpackage(ComponentTestBase): for t in tarballs: self.assertFalse(os.path.exists(t), "Tarball %s must not exist" % t) ret = buildpackage(['arg0', - '--git-subtarball=foo', + '--git-component=foo', '--git-no-pristine-tar', '--git-posttag=printenv > posttag.out', '--git-builder=touch builder-run.stamp', @@ -129,7 +129,7 @@ class TestBuildpackage(ComponentTestBase): for t in tarballs: self.assertTrue(os.path.exists(t), "Tarball %s not found" % t) - def test_pristinetar_subtarball_generation(self): + def test_pristinetar_component_generation(self): """Test that generating tarball and additional tarball works with pristine-tar""" pkg = 'hello-debhelper' dsc = self._dsc_name(pkg, '2.8-1', 'dsc-3.0-additional-tarballs') @@ -143,7 +143,7 @@ class TestBuildpackage(ComponentTestBase): for t in tarballs: self.assertFalse(os.path.exists(t), "Tarball %s must not exist" % t) ret = buildpackage(['arg0', - '--git-subtarball=foo', + '--git-component=foo', '--git-pristine-tar', '--git-posttag=printenv > posttag.out', '--git-builder=touch builder-run.stamp', diff --git a/tests/component/deb/test_import_dsc.py b/tests/component/deb/test_import_dsc.py index 549b5e3..d7a96ff 100644 --- a/tests/component/deb/test_import_dsc.py +++ b/tests/component/deb/test_import_dsc.py @@ -112,7 +112,7 @@ class TestImportDsc(ComponentTestBase): ok_(commits == expected, "Found %d commit instead of %d" % (commits, expected)) dsc = DscFile.parse(dscfile) - # Check if we can rebuild the tarball and subtarball + # Check if we can rebuild the tarball and component ptars = [('hello-debhelper_2.8.orig.tar.gz', 'pristine-tar', '', dsc.tgz), ('hello-debhelper_2.8.orig-foo.tar.gz', 'pristine-tar^', 'foo', dsc.additional_tarballs['foo'])] @@ -121,7 +121,7 @@ class TestImportDsc(ComponentTestBase): for f, w, s, o in ptars: eq_(repo.get_subject(w), 'pristine-tar data for %s' % f) old = self.hash_file(o) - p.checkout('hello-debhelper', '2.8', 'gzip', outdir, subtarball=s) + p.checkout('hello-debhelper', '2.8', 'gzip', outdir, component=s) new = self.hash_file(os.path.join(outdir, f)) eq_(old, new, "Checksum %s of regenerated tarball %s does not match original %s" % (f, old, new)) -- cgit v1.2.3