[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#639041: PTS mail interface doesn't have an up-to-date list of packages



On 24/08/2011 14:44, Raphael Hertzog wrote:
> Hi,
> 
> On Wed, 24 Aug 2011, Giovanni Mascellani wrote:
>> Actually I don't know nearly anything of Perl, so I doubt I can
>> contribute to that part. The binary <-> source mapping is actually
>> already available, it is computed by sources_to_xml.py and then pickled
>> and stored in www/base/sources_mapping. It should be easy to store it
>> (also) in a format that Perl can import (for example JSON). And it
>> should also be easy to instruct Perl to read such file, provided that
>> you know Perl.
> 
> Or you could directly generate something that uses the same format as
> sources.map in www/base/ too and update the path to the file in
> perl/common.pl.

Did it in the patch attached. I give no guarantee for the Perl part,
while the Python part is also tested.

Of course I still have no permissions to directly commit this patch.

Giovanni.
-- 
Giovanni Mascellani <mascellani@poisson.phc.unipi.it>
Pisa, Italy

Web: http://poisson.phc.unipi.it/~mascellani
Jabber: g.mascellani@jabber.org / giovanni@elabor.homelinux.org
From 21425b747124d5a2d77ed365059f93528d01cd84 Mon Sep 17 00:00:00 2001
From: Giovanni Mascellani <mascellani@poisson.phc.unipi.it>
Date: Wed, 24 Aug 2011 15:42:36 +0200
Subject: [PATCH] sources_to_xml.py now creates sources.map for the Perl mail
 interface.

Before their removals, there were two different sources.map files,
one with two columns and one with three columns. The second column,
probably the distribution name, was discarded by common.pl.

Now sources_to_xml.py generates the two columns variant, so this patch
also makes common.pl reading the two columns variant.
---
 pts/perl/common.pl            |    4 ++--
 pts/www/bin/sources_to_xml.py |   14 ++++++++++++++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/pts/perl/common.pl b/pts/perl/common.pl
index 54f0402..24814f7 100644
--- a/pts/perl/common.pl
+++ b/pts/perl/common.pl
@@ -19,7 +19,7 @@ $db_bounces_filename = "$pts_dir/db/bounces.db";
 $sendmail = '/usr/sbin/sendmail';
 $sendmaildefault = '/usr/sbin/sendmail -f bounces@packages.qa.debian.org';
 $sendmailnobody = '/usr/sbin/sendmail -f bounces-likely-spam@packages.qa.debian.org';
-$sources = "/org/packages.qa.debian.org/www/incoming/sources";
+$sources = "/org/packages.qa.debian.org/www/base/sources.map";
 $pts_email = 'pts@qa.debian.org';
 @available_tags = qw(default bts bts-control cvs summary ddtp
 		     upload-source upload-binary katie-other
@@ -189,7 +189,7 @@ sub load_sources {
     return if (scalar(keys %bin2src));
     open(SOURCES, "< $sources") || warn "Can't open $sources: $!\n";
     while(defined($_=<SOURCES>)) {
-    	my ($bin, $comp, $src) = (split(/\s+/));
+    	my ($bin, $src) = (split(/\s+/));
 	$bin2src{lc($bin)} = lc($src);
 	$src{lc($src)} = 1;
     }
diff --git a/pts/www/bin/sources_to_xml.py b/pts/www/bin/sources_to_xml.py
index 92aba01..f9b00c7 100755
--- a/pts/www/bin/sources_to_xml.py
+++ b/pts/www/bin/sources_to_xml.py
@@ -225,6 +225,20 @@ cPickle.dump(source_to_binaries, f, 0)
 cPickle.dump(binary_to_sources, f, 0)
 f.close()
 
+# Also store a copy in the old sources.map format, to be used by the
+# Perl mail interface
+with open(os.path.join(odir, "sources.map"), 'w') as f:
+    for binary, source in binary_to_sources.iteritems():
+
+        # If the package is in current (i.e., unstable), we use it
+        if source['current'] is not None:
+            print >> f, "%s %s" % (binary, source['current'])
+
+        # Otherwise we pick an arbitrary one among all the available
+        # distributions
+        else:
+            print >> f, "%s %s" % (binary, source['merged'][0])
+
 # Scan the old package/distribution that existed and check if they
 # still exist ... if they don't, remove the associated xml file.
 for key in old_done.keys():
-- 
1.7.5.4

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: