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'
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}
@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)
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}.
@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"""
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}
>>> 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
"""
"""
+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
"""
+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