From 9990b889d8775ed700ae28c3f17ce3b600eb27bd Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Sun, 13 Mar 2016 17:37:14 +0100 Subject: import_dsc: Make 'gbp import-dsc' aware of component tarballs instead of plain failing just import the additional tarball but disable pristine-tar until we sorted out how to export things again. Closes: #561072 --- gbp/scripts/import_dsc.py | 20 +++++++++++--------- tests/component/deb/data | 2 +- tests/component/deb/test_import_dsc.py | 12 ++++++++++-- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/gbp/scripts/import_dsc.py b/gbp/scripts/import_dsc.py index be74bd03..d4a11b27 100644 --- a/gbp/scripts/import_dsc.py +++ b/gbp/scripts/import_dsc.py @@ -197,13 +197,13 @@ def move_tag_stamp(repo, format, version): repo.move_tag(old, new) -def set_bare_repo_options(options): - """Modify options for import into a bare repository""" +def disable_pristine_tar(options, reason): + """Disable pristine tar if enabled""" if options.pristine_tar: - gbp.log.info("Bare repository: setting %s option" - % (["", " '--no-pristine-tar'"][options.pristine_tar], )) + gbp.log.info("%s: setting '--no-pristine-tar' option" % reason) options.pristine_tar = False + def build_parser(name): try: parser = GbpOptionParserDebian(command=os.path.basename(name), prefix='', @@ -317,10 +317,6 @@ def main(argv): if options.verbose: print_dsc(src) - if src.additional_tarballs: - raise GbpError("Cannot import package with additional tarballs but found '%s'" % - ", ".join([os.path.basename(t) for t in src.additional_tarballs])) - if needs_repo: if os.path.exists(src.pkg): raise GbpError("Directory '%s' already exists. If you want to import into it, " @@ -331,11 +327,17 @@ def main(argv): os.chdir(repo.path) if repo.bare: - set_bare_repo_options(options) + disable_pristine_tar(options, "Bare repository") + elif src.additional_tarballs: + disable_pristine_tar(options, "Component tarballs found") dirs['tmp'] = os.path.abspath(tempfile.mkdtemp(dir='..')) upstream = DebianUpstreamSource(src.tgz) upstream.unpack(dirs['tmp'], options.filters) + for tarball in src.additional_tarballs: + gbp.log.info("Found component tarball '%s'" % os.path.basename(tarball)) + subtarball = DebianUpstreamSource(tarball) + subtarball.unpack(upstream.unpacked, 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/data b/tests/component/deb/data index 60892e9d..b53e6ec2 160000 --- a/tests/component/deb/data +++ b/tests/component/deb/data @@ -1 +1 @@ -Subproject commit 60892e9d88e88a94147ffc5ae6f4016a598f0d22 +Subproject commit b53e6ec2a785e1d9df3fbb2590f8fe9743629108 diff --git a/tests/component/deb/test_import_dsc.py b/tests/component/deb/test_import_dsc.py index 760b3657..7a82ce0c 100644 --- a/tests/component/deb/test_import_dsc.py +++ b/tests/component/deb/test_import_dsc.py @@ -97,8 +97,16 @@ class TestImportDsc(ComponentTestBase): '--pristine-tar', '--debian-branch=master', '--upstream-branch=upstream', - dsc]) == 1 - self._check_log(0, "gbp:error: Cannot import package with additional tarballs but found 'hello-debhelper_2.8.orig-foo.tar.gz") + dsc]) == 0 + repo = ComponentTestGitRepository('hello-debhelper') + self._check_repo_state(repo, 'master', ['master', 'upstream']) + commits, expected = len(repo.get_commits()), 2 + + for file in ['foo/test1', 'foo/test2']: + ok_(file in repo.ls_tree('HEAD'), + "Could not find component tarball file %s in %s" % (file, repo.ls_tree('HEAD'))) + + ok_(commits == expected, "Found %d commit instead of %d" % (commits, expected)) def test_existing_dir(self): """ -- cgit v1.2.3