Commit dacca59e authored by Guido Günther's avatar Guido Günther

pristine-tar: support checking in/out upstream signatures

parent a55d19f2
......@@ -96,3 +96,11 @@ class DebianPkgPolicy(PkgPolicy):
if dir:
tarball = os.path.join(dir, tarball)
return tarball
@staticmethod
def build_signature_name(*args, **kwargs):
"""
Given a source package's I{name}, I{version} and I{compression}
return the name of the corresponding upstream tarball signature file.
"""
return DebianPkgPolicy.build_tarball_name(*args, **kwargs) + '.asc'
......@@ -45,7 +45,7 @@ class DebianPristineTar(PristineTar):
return super(DebianPristineTar, self).has_commit(name_regexp)
def checkout(self, package, version, comp_type, output_dir, component=None,
quiet=False):
quiet=False, signature=False):
"""
Checkout the orig tarball for package I{package} of I{version} and
compression type I{comp_type} to I{output_dir}
......@@ -59,9 +59,18 @@ class DebianPristineTar(PristineTar):
@param output_dir: the directory to put the tarball into
@type output_dir: C{str}
"""
signaturefile = None
name = DebianPkgPolicy.build_tarball_name(package,
version,
comp_type,
output_dir,
component=component)
super(DebianPristineTar, self).checkout(name, quiet=quiet)
if signature:
signaturefile = DebianPkgPolicy.build_signature_name(package,
version,
comp_type,
output_dir,
component=component)
super(DebianPristineTar, self).checkout(name,
quiet=quiet,
signaturefile=signaturefile)
......@@ -83,17 +83,20 @@ class PristineTar(Command):
return commit
return None
def checkout(self, archive, quiet=False):
def checkout(self, archive, quiet=False, signaturefile=None):
"""
Checkout an orig archive from pristine-tar branch
@param archive: the name of the orig archive
@type archive: C{str}
"""
args = ['checkout', archive]
self.run_error = 'Pristine-tar couldn\'t checkout "%s": {stderr_or_reason}' % os.path.basename(archive)
self.__call__(['checkout', archive], quiet=quiet)
if signaturefile:
args += ['-s', signaturefile]
self.__call__(args, quiet=quiet)
def commit(self, archive, upstream, quiet=False):
def commit(self, archive, upstream, quiet=False, signaturefile=None):
"""
Commit an archive I{archive} to the pristine tar branch using upstream
branch ${upstream}.
......@@ -103,9 +106,12 @@ class PristineTar(Command):
@param upstream: the upstream branch to diff against
@type upstream: C{str}
"""
args = ['commit', archive, upstream]
self.run_error = ("Couldn't commit to '%s' with upstream '%s': {stderr_or_reason}" %
(self.branch, upstream))
self.__call__(['commit', archive, upstream], quiet=quiet)
if signaturefile:
args += ['-s', signaturefile]
self.__call__(args, quiet=quiet)
def verify(self, archive, quiet=False):
"""Verify an archive's I{archive} checksum using to the pristine tar branch"""
......
......@@ -76,7 +76,7 @@ def test_commit_dir():
def test_create_tarball():
"""
Create a tarball from a git tree
Create a tarball from a git tree and add a stub signature
Methods tested:
- L{gbp.deb.git.DebianGitRepository.archive}
......@@ -85,6 +85,8 @@ def test_create_tarball():
>>> repo = gbp.deb.git.DebianGitRepository(dirs['repo'])
>>> repo.archive('tar', 'upstream/', '../upstream_1.0.orig.tar', 'upstream')
>>> gbp.command_wrappers.Command('gzip', [ '-n', '%s/../upstream_1.0.orig.tar' % dirs['repo']])()
>>> with open('%s/../upstream_1.0.orig.tar.gz.asc' % dirs['repo'], 'w') as f: f.write("sig")
3
"""
......@@ -101,6 +103,20 @@ def test_pristine_tar_commit():
"""
def test_pristine_tar_commit_with_sig():
"""
Commit the delta to the pristine-tar branch including a signature
Methods tested:
- L{gbp.deb.pristinetar.DebianPristineTar.commit}
>>> import gbp.deb.git
>>> repo = gbp.deb.git.DebianGitRepository(dirs['repo'])
>>> repo.pristine_tar.commit('../upstream_1.0.orig.tar.gz', 'upstream',
... signaturefile='../upstream_1.0.orig.tar.gz.asc')
"""
def test_pristine_has_commit():
"""
Find delta on the pristine tar branch
......@@ -137,6 +153,27 @@ def test_pristine_tar_checkout():
"""
def test_pristine_tar_checkout_with_sig():
"""
Checkout a tarball using pristine-tar
Methods tested:
- L{gbp.deb.pristinetar.DebianPristineTar.checkout}
>>> import gbp.deb.git
>>> from gbp.deb.policy import DebianPkgPolicy
>>> repo = gbp.deb.git.DebianGitRepository(dirs['repo'])
>>> sf = os.path.join(repo.path,
... DebianPkgPolicy.build_signature_name('upstream', '1.0', 'gzip', '..'))
>>> os.unlink(sf)
>>> repo.pristine_tar.checkout('upstream', '1.0', 'gzip', '..',
... signature=True)
>>> os.path.exists(sf)
True
"""
def test_pristine_tar_verify():
"""
Verify a tarball using pristine-tar
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment