aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2016-05-27 10:10:57 +0200
committerGuido Günther <agx@sigxcpu.org>2016-05-27 10:10:57 +0200
commit508656d13baddfc7d0d727d16df8b6fe57000b3c (patch)
tree33edb37b03343a3e95039f694c459e1e82dcc813
parent22435b270da1676412b10d4f233f945c5b120b2e (diff)
buildpackage: Support pristine-tar with multiple tarballs
but disable pristine-tar-commit in this case for now
-rwxr-xr-xgbp/scripts/buildpackage.py23
-rw-r--r--tests/component/deb/test_buildpackage.py58
2 files changed, 61 insertions, 20 deletions
diff --git a/gbp/scripts/buildpackage.py b/gbp/scripts/buildpackage.py
index 6965815..ced5348 100755
--- a/gbp/scripts/buildpackage.py
+++ b/gbp/scripts/buildpackage.py
@@ -251,11 +251,28 @@ def pristine_tar_build_orig(repo, cp, output_dir, options):
if not repo.has_branch(repo.pristine_tar_branch):
gbp.log.warn('Pristine-tar branch "%s" not found' %
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:
+ 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)
+ except GitRepositoryError:
+ raise GbpError("Couldn't find upstream tree '%s' to create orig tarball via pristine-tar" % tree_name)
+
try:
repo.pristine_tar.checkout(cp.name,
cp.upstream_version,
options.comp_type,
output_dir)
+ for subtarball in options.subtarballs:
+ repo.pristine_tar.checkout(cp.name,
+ cp.upstream_version,
+ options.comp_type,
+ output_dir,
+ subtarball=subtarball)
return True
except CommandExecFailed:
if options.pristine_tar_commit:
@@ -594,9 +611,9 @@ 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
+ if options.subtarballs and options.pristine_tar_commit:
+ gbp.log.warning("Subtarballs specified, pristine-tar-commit not yet supported - disabling it.")
+ options.pristine_tar_commit = False
return options, args, dpkg_args
diff --git a/tests/component/deb/test_buildpackage.py b/tests/component/deb/test_buildpackage.py
index edfe1dd..19dfa82 100644
--- a/tests/component/deb/test_buildpackage.py
+++ b/tests/component/deb/test_buildpackage.py
@@ -22,7 +22,7 @@ from tests.component import (ComponentTestBase,
ComponentTestGitRepository)
from tests.component.deb import DEB_TEST_DATA_DIR
-from nose.tools import ok_, eq_
+from nose.tools import ok_, eq_, assert_false, assert_true
from gbp.scripts.import_dsc import main as import_dsc
from gbp.scripts.buildpackage import main as buildpackage
@@ -45,13 +45,14 @@ class TestBuildpackage(ComponentTestBase):
for var in vars:
ok_(var in env, "%s not found in %s" % (var, env))
- def _test_buildpackage(self, pkg, dir, version):
- def _dsc(pkg, version):
- return os.path.join(DEB_TEST_DATA_DIR,
- dir,
- '%s_%s.dsc' % (pkg, version))
+ @staticmethod
+ def _dsc_name(pkg, version, dir):
+ return os.path.join(DEB_TEST_DATA_DIR,
+ dir,
+ '%s_%s.dsc' % (pkg, version))
- dsc = _dsc(pkg, version)
+ def _test_buildpackage(self, pkg, dir, version):
+ dsc = self._dsc_name(pkg, version, dir)
assert import_dsc(['arg0', dsc]) == 0
ComponentTestGitRepository(pkg)
os.chdir(pkg)
@@ -106,21 +107,44 @@ class TestBuildpackage(ComponentTestBase):
"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"]
+ """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')
+ tarballs = ["../%s_2.8.orig-foo.tar.gz" % pkg,
+ "../%s_2.8.orig.tar.gz" % pkg]
+
+ assert import_dsc(['arg0', '--no-pristine-tar', dsc]) == 0
+ repo = ComponentTestGitRepository(pkg)
+ os.chdir(pkg)
+ assert_false(repo.has_branch('pristine-tar'), "Pristine-tar branch must not exist")
+ for t in tarballs:
+ self.assertFalse(os.path.exists(t), "Tarball %s must not exist" % t)
+ ret = buildpackage(['arg0',
+ '--git-subtarball=foo',
+ '--git-no-pristine-tar',
+ '--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)
- assert import_dsc(['arg0', dsc]) == 0
- os.chdir('hello-debhelper')
+ def test_pristinetar_subtarball_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')
+ tarballs = ["../%s_2.8.orig-foo.tar.gz" % pkg,
+ "../%s_2.8.orig.tar.gz" % pkg]
+
+ assert import_dsc(['arg0', '--pristine-tar', dsc]) == 0
+ repo = ComponentTestGitRepository(pkg)
+ os.chdir(pkg)
+ assert_true(repo.has_branch('pristine-tar'), "Pristine-tar branch must exist")
for t in tarballs:
self.assertFalse(os.path.exists(t), "Tarball %s must not exist" % t)
ret = buildpackage(['arg0',
'--git-subtarball=foo',
+ '--git-pristine-tar',
'--git-posttag=printenv > posttag.out',
'--git-builder=touch builder-run.stamp',
'--git-cleaner=/bin/true'])