From 2f1c1577e74c36d17aa9f8956e95c42018c71925 Mon Sep 17 00:00:00 2001 From: Christian Göttsche Date: Tue, 17 Dec 2019 00:10:01 +0100 Subject: add option to export tarballs with upstream signature Add option `--upstream-signatures=[on|auto|off]` to export-orig. Add option `--git-upstream-signatures=[on|auto|off]` to buildpackage. Closes: 872864 --- gbp/pkg/pristinetar.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'gbp/pkg/pristinetar.py') diff --git a/gbp/pkg/pristinetar.py b/gbp/pkg/pristinetar.py index 5c0892b7..e8534076 100644 --- a/gbp/pkg/pristinetar.py +++ b/gbp/pkg/pristinetar.py @@ -63,25 +63,38 @@ class PristineTar(Command): @param archive_regexp: archive name to look for (regexp wildcards allowed) @type archive_regexp: C{str} """ - return True if self.get_commit(archive_regexp) else False + return True if self.get_commit(archive_regexp)[0] else False + + def _commit_contains_file(self, commit, regexp): + """Does the given commit contain a file with the given regex""" + files = self.repo.get_commit_info(commit)['files'] + cregex = re.compile(regexp) + for _, v in files.items(): + for f in v: + if cregex.match(f.decode()): + return True + return False def get_commit(self, archive_regexp): """ Get the pristine-tar commit of a package matching I{archive_regexp}. + Checks also whether the commit contains a signature file. @param archive_regexp: archive name to look for (regexp wildcards allowed) @type archive_regexp: C{str} + @return: Commit, True if commit contains a signature file + @rtype: C{tuple} of C{str} and C{bool} """ if not self.repo.has_pristine_tar_branch(): - return None + return None, False regex = ('pristine-tar .* %s' % archive_regexp) commits = self.repo.grep_log(regex, self.branch, merges=False) if commits: commit = commits[-1] gbp.log.debug("Found pristine-tar commit at '%s'" % commit) - return commit - return None + return commit, self._commit_contains_file(commit, '%s.asc' % archive_regexp) + return None, False def checkout(self, archive, quiet=False, signaturefile=None): """ -- cgit v1.2.3