diff options
author | Guido Günther <agx@sigxcpu.org> | 2017-02-13 20:25:47 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2017-02-13 20:29:24 +0100 |
commit | 0146f4b452c535e4f81a4ba7e9b90a33c6d6d0b1 (patch) | |
tree | 6f63b51275b906f4791b077d57cbea7d32f7a2e9 | |
parent | ec9f9135f5c31a3f52d342e2faac2b44647709dc (diff) |
Use the source package instead of the chagenlog for tarball names
to improve readability.
Git-Dch: Ignore
-rw-r--r-- | gbp/deb/__init__.py | 19 | ||||
-rwxr-xr-x | gbp/scripts/buildpackage.py | 22 | ||||
-rw-r--r-- | tests/04_test_submodules.py | 1 | ||||
-rw-r--r-- | tests/05_test_detection.py | 26 |
4 files changed, 29 insertions, 39 deletions
diff --git a/gbp/deb/__init__.py b/gbp/deb/__init__.py index 6a240ec1..5b0d8bd0 100644 --- a/gbp/deb/__init__.py +++ b/gbp/deb/__init__.py @@ -1,6 +1,6 @@ # vim: set fileencoding=utf-8 : # -# (C) 2006,2007,2011 Guido Günther <agx@sigxcpu.org> +# (C) 2006,2007,2011,2017 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 @@ -81,20 +81,13 @@ def parse_changelog_repo(repo, branch, filename): return ChangeLog(repo.show(sha)) -def orig_file(cp, compression, component=None): +def orig_file(source, compression, component=None): """ - The name of the orig file belonging to changelog cp - - >>> orig_file({'Source': 'foo', 'Upstream-Version': '1.0'}, "bzip2") - '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", component="sub1") - 'bar_0.0~git1234.orig-sub1.tar.xz' + The name of the orig file belonging to source package I{source} """ - return DebianPkgPolicy.build_tarball_name(cp['Source'], - cp['Upstream-Version'], - compression, + return DebianPkgPolicy.build_tarball_name(source.name, + source.upstream_version, + compression=compression, component=component) diff --git a/gbp/scripts/buildpackage.py b/gbp/scripts/buildpackage.py index 96ba4304..3cb49f01 100755 --- a/gbp/scripts/buildpackage.py +++ b/gbp/scripts/buildpackage.py @@ -55,7 +55,7 @@ def git_archive(repo, source, output_dir, treeish, comp_type, comp_level, with_s except KeyError: raise GbpError("Unsupported compression type '%s'" % comp_type) - output = os.path.join(output_dir, du.orig_file(source.changelog, comp_type, component=component)) + output = os.path.join(output_dir, du.orig_file(source, comp_type, component=component)) prefix = "%s-%s" % (source.name, source.upstream_version) try: @@ -91,9 +91,9 @@ def prepare_upstream_tarball(repo, source, options, tarball_dir, output_dir): source, options.tarball_dir) - orig_files = [du.orig_file(source.changelog, options.comp_type)] + orig_files = [du.orig_file(source, options.comp_type)] if options.components: - orig_files += [du.orig_file(source.changelog, options.comp_type, c) for c in options.components] + orig_files += [du.orig_file(source, 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: @@ -169,7 +169,7 @@ def export_source(repo, tree, source, options, dest_dir, tarball_dir): if source.is_native(): raise GbpError("Cannot overlay Debian native package") extract_orig(os.path.join(tarball_dir, - du.orig_file(source.changelog, + du.orig_file(source, options.comp_type)), dest_dir) @@ -353,7 +353,7 @@ def git_archive_build_orig(repo, source, output_dir, options): @rtype: C{str} """ upstream_tree = get_upstream_tree(repo, source, options) - gbp.log.info("Creating %s from '%s'" % (du.orig_file(source.changelog, + gbp.log.info("Creating %s from '%s'" % (du.orig_file(source, options.comp_type), upstream_tree)) comp_level = int(options.comp_level) if options.comp_level != '' else None @@ -372,7 +372,7 @@ def git_archive_build_orig(repo, source, output_dir, options): 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(source.changelog, options.comp_type, component=component), + % (du.orig_file(source, options.comp_type, component=component), subtree)) if not git_archive(repo, source, output_dir, subtree, options.comp_type, @@ -398,7 +398,7 @@ def guess_comp_type(repo, comp_type, source, tarball_dir): tarball_dir = '..' detected = None for comp in compressor_opts.keys(): - if du.DebianPkgPolicy.has_orig(du.orig_file(source.changelog, comp), tarball_dir): + if du.DebianPkgPolicy.has_orig(du.orig_file(source, comp), tarball_dir): if detected is not None: raise GbpError("Multiple orig tarballs found.") detected = comp @@ -767,7 +767,7 @@ def main(argv): if options.postbuild: changes = os.path.abspath("%s/../%s_%s_%s.changes" % (build_dir, - source.sourcepkg, + source.changelog.name, source.changelog.noepoch, changes_file_suffix(dpkg_args))) gbp.log.debug("Looking for changes file %s" % changes) @@ -782,13 +782,13 @@ def main(argv): else: commit = head - tag = repo.version_to_tag(options.debian_tag, source.changelog.version) - gbp.log.info("Tagging %s as %s" % (source.changelog.version, tag)) + tag = repo.version_to_tag(options.debian_tag, source.version) + gbp.log.info("Tagging %s as %s" % (source.version, tag)) if options.retag and repo.has_tag(tag): repo.delete_tag(tag) tag_msg = format_str(options.debian_tag_msg, dict(pkg=source.sourcepkg, - version=source.changelog.version)) + version=source.version)) repo.create_tag(name=tag, msg=tag_msg, sign=options.sign_tags, diff --git a/tests/04_test_submodules.py b/tests/04_test_submodules.py index b0b08f8a..7d3c0339 100644 --- a/tests/04_test_submodules.py +++ b/tests/04_test_submodules.py @@ -128,7 +128,6 @@ def test_create_tarballs(): def __init__(self, version): self.name = 'test' self.upstream_version = version - self.changelog = {"Source": "test", "Upstream-Version": version} # Tarball with submodules s = source('0.1') ok_(buildpackage.git_archive(REPO, s, str(TMPDIR), "HEAD", "bzip2", diff --git a/tests/05_test_detection.py b/tests/05_test_detection.py index ba524fc9..9ba808f9 100644 --- a/tests/05_test_detection.py +++ b/tests/05_test_detection.py @@ -33,11 +33,9 @@ class TestDetection(unittest.TestCase): class source(object): name = 'source' upstream_version = '1.2' - changelog = {'Source': 'source', 'Upstream-Version': '1.2'} def setUp(self): self.tmpdir = context.new_tmpdir(__name__) - self.cp = self.source.changelog def tearDown(self): context.teardown() @@ -75,56 +73,56 @@ class TestDetection(unittest.TestCase): self.assertEqual("bzip2", guessed) def test_has_orig_single_false(self): - self.assertFalse(DebianPkgPolicy.has_origs([orig_file(self.cp, 'gzip')], str(self.tmpdir))) + self.assertFalse(DebianPkgPolicy.has_origs([orig_file(self.source, 'gzip')], str(self.tmpdir))) def test_has_orig_single_true(self): open(self.tmpdir.join('source_1.2.orig.tar.gz'), "w").close() - self.assertTrue(DebianPkgPolicy.has_origs([orig_file(self.cp, 'gzip')], str(self.tmpdir))) + self.assertTrue(DebianPkgPolicy.has_origs([orig_file(self.source, 'gzip')], str(self.tmpdir))) def test_has_orig_multiple_false(self): - orig_files = [orig_file(self.cp, 'gzip')] + \ - [orig_file(self.cp, 'gzip', sub) for sub in ['foo', 'bar']] + orig_files = [orig_file(self.source, 'gzip')] + \ + [orig_file(self.source, 'gzip', sub) for sub in ['foo', 'bar']] self.assertFalse(DebianPkgPolicy.has_origs(orig_files, str(self.tmpdir))) def test_has_orig_multiple_true(self): for ext in ['', '-foo', '-bar']: open(self.tmpdir.join('source_1.2.orig%s.tar.gz' % ext), "w").close() - orig_files = [orig_file(self.cp, 'gzip')] + \ - [orig_file(self.cp, 'gzip', sub) for sub in ['foo', 'bar']] + orig_files = [orig_file(self.source, 'gzip')] + \ + [orig_file(self.source, 'gzip', sub) for sub in ['foo', 'bar']] self.assertTrue(DebianPkgPolicy.has_origs(orig_files, str(self.tmpdir))) def test_guess_comp_type_bzip2(self): repo = MockGitRepository(with_branch=False) guessed = buildpackage.guess_comp_type( - repo, 'bzip2', self.cp, None) + repo, 'bzip2', self.source, None) self.assertEqual("bzip2", guessed) def test_guess_comp_type_gzip(self): repo = MockGitRepository(with_branch=False) guessed = buildpackage.guess_comp_type( - repo, 'gzip', self.cp, None) + repo, 'gzip', self.source, None) self.assertEqual("gzip", guessed) def test_guess_comp_type_bz(self): repo = MockGitRepository(with_branch=False) guessed = buildpackage.guess_comp_type( - repo, 'xz', self.cp, None) + repo, 'xz', self.source, None) self.assertEqual("xz", guessed) def test_guess_comp_type_lzma(self): repo = MockGitRepository(with_branch=False) guessed = buildpackage.guess_comp_type( - repo, 'lzma', self.cp, None) + repo, 'lzma', self.source, None) self.assertEqual("lzma", guessed) def test_guess_comp_type_bz2(self): repo = MockGitRepository(with_branch=False) guessed = buildpackage.guess_comp_type( - repo, 'bz2', self.cp, None) + repo, 'bz2', self.source, None) self.assertEqual("bzip2", guessed) def test_guess_comp_type_gz(self): repo = MockGitRepository(with_branch=False) guessed = buildpackage.guess_comp_type( - repo, 'gz', self.cp, None) + repo, 'gz', self.source, None) self.assertEqual("gzip", guessed) |