]> git.decadent.org.uk Git - dak.git/commitdiff
Merge remote branch 'ansgar/signatures-2' into merge
authorJoerg Jaspert <joerg@debian.org>
Sat, 21 May 2011 22:42:31 +0000 (00:42 +0200)
committerJoerg Jaspert <joerg@debian.org>
Sat, 21 May 2011 22:42:31 +0000 (00:42 +0200)
* ansgar/signatures-2:
  tests/test_parse_changes.py: add another testcase
  daklib/gpg.py: capture stderr
  tests/test_parse_changes.py: do not require signatures
  daklib/utils.py (parse_deb822): include PGP armor in filecontents
  tests/test_parse_changes.py: update for new SignedFile exceptions
  daklib/utils.py (parse_deb822): use SignedFile to handle PGP signature
  tests: dsc/4.dsc is invalid
  examine-package: use SignedFile to remove PGP armor
  daklib/gpg.py: small library for PGP-signed files

Signed-off-by: Joerg Jaspert <joerg@debian.org>
dak/examine_package.py
tools/debianqueued-0.9/debianqueued

index 482eceec72a72c00ac83873690135bc6558b7fcd..5cb1a77e9a6fb8dcbd3e62d511056d4dfe08edd8 100755 (executable)
@@ -118,6 +118,7 @@ ansi_colours = {
   'main': "\033[36m",
   'contrib': "\033[33m",
   'nonfree': "\033[31m",
+  'provides': "\033[35m",
   'arch': "\033[32m",
   'end': "\033[0m",
   'bold': "\033[1m",
@@ -128,6 +129,7 @@ html_colours = {
   'main': ('<span style="color: aqua">',"</span>"),
   'contrib': ('<span style="color: yellow">',"</span>"),
   'nonfree': ('<span style="color: red">',"</span>"),
+  'provides': ('<span style="color: magenta">',"</span>"),
   'arch': ('<span style="color: green">',"</span>"),
   'bold': ('<span style="font-weight: bold">',"</span>"),
   'maintainer': ('<span style="color: green">',"</span>"),
@@ -323,6 +325,30 @@ def read_changes_or_dsc (suite, filename, session = None):
     filecontents = '\n'.join(map(lambda x: format_field(x,dsc[x.lower()]), keysinorder))+'\n'
     return filecontents
 
+def get_provides(suite):
+    provides = set()
+    session = DBConn().session()
+    query = '''SELECT DISTINCT value
+               FROM binaries_metadata m
+               JOIN bin_associations b
+               ON b.bin = m.bin_id
+               WHERE key_id = (
+                 SELECT key_id
+                 FROM metadata_keys
+                 WHERE key = 'Provides' )
+               AND b.suite = (
+                 SELECT id
+                 FROM suite
+                 WHERE suite_name = '%(suite)s'
+                 OR codename = '%(suite)s')''' % \
+            {'suite': suite}
+    for p in session.execute(query):
+        for e in p:
+            for i in e.split(','):
+                provides.add(i.strip())
+    session.close()
+    return provides
+
 def create_depends_string (suite, depends_tree, session = None):
     result = ""
     if suite == 'experimental':
@@ -330,6 +356,7 @@ def create_depends_string (suite, depends_tree, session = None):
     else:
         suite_list = [suite]
 
+    provides = set()
     comma_count = 1
     for l in depends_tree:
         if (comma_count >= 2):
@@ -357,7 +384,12 @@ def create_depends_string (suite, depends_tree, session = None):
                 adepends = d['name']
                 if d['version'] != '' :
                     adepends += " (%s)" % (d['version'])
-                result += colour_output(adepends, "bold")
+                if not provides:
+                    provides = get_provides(suite)
+                if d['name'] in provides:
+                    result += colour_output(adepends, "provides")
+                else:
+                    result += colour_output(adepends, "bold")
             or_count += 1
         comma_count += 1
     return result
index e229ac076996bf19a798735866c795ad9c46f370..048276ca15e0c97b7d409bbd5023a8954b9e5418 100755 (executable)
@@ -694,7 +694,7 @@ sub process_changes($\@) {
        $pgplines,     @files,     @filenames,  @changes_stats,
        $failure_file, $retries,   $last_retry, $upload_time,
        $file,         $do_report, $ls_l,       $problems_reported,
-       $errs,         $pkgname,   $signator
+       $errs,         $pkgname,   $signator,   $extralines
      );
   local (*CHANGES);
   local (*FAILS);
@@ -711,12 +711,19 @@ sub process_changes($\@) {
   open( CHANGES, "<$changes" )
     or die "Cannot open ${main::current_incoming_short}/$changes: $!\n";
   $pgplines        = 0;
+  $extralines      = 0;
   $main::mail_addr = "";
   @files           = ();
 outer_loop: while (<CHANGES>) {
     if (/^---+(BEGIN|END) PGP .*---+$/) {
       ++$pgplines;
-    } elsif (/^Maintainer:\s*/i) {
+      next;
+    }
+    if ( $pgplines < 1 or $pgplines >= 3 ) {
+      $extralines++;
+      next;
+    }
+    if (/^Maintainer:\s*/i) {
       chomp( $main::mail_addr = $' );
       $main::mail_addr = $1 if $main::mail_addr =~ /<([^>]*)>/;
     } elsif (/^Source:\s*/i) {
@@ -762,6 +769,12 @@ outer_loop: while (<CHANGES>) {
   @$keep_list = @filenames;
 
   # some consistency checks
+  if ( $extralines ) {
+    msg( "log,mail",
+"$main::current_incoming_short/$changes contained lines outside the pgp signed "
+."part, cannot process\n" );
+    goto remove_only_changes;
+  } ## end if ( $extralines )
   if ( !$main::mail_addr ) {
     msg( "log,mail",
 "$main::current_incoming_short/$changes doesn't contain a Maintainer: field; "