[Reportbug-commits] [SCM] Reportbug - reports bugs in the Debian distribution branch, master, updated. 6.0-70-g2118025

Sandro Tosi morph at debian.org
Fri Nov 4 22:25:55 UTC 2011


The following commit has been merged in the master branch:
commit 211802564a16717f29b7de8208841662b127cbd5
Author: Sandro Tosi <morph at debian.org>
Date:   Fri Nov 4 23:13:19 2011 +0100

    Use madison.cgi (from QA) to check for newer versions available; thanks to Bernd Zeimetz for the report; Closes: #601679

diff --git a/bin/reportbug b/bin/reportbug
index 53097e7..4ba955d 100755
--- a/bin/reportbug
+++ b/bin/reportbug
@@ -921,7 +921,7 @@ def main():
     parser.add_option('--configure', action='store_true',
                       help='reconfigure reportbug for this user')
     parser.add_option('--check-available', action='store_true',
-                      help='check for new releases at packages.debian.org')
+                      help='check for new releases on various sites')
     parser.add_option('--no-check-available', action='store_false',
                       dest='check_available', help='do not check for new '
                       'releases')
@@ -1587,10 +1587,10 @@ class UI(object):
             arch = utils.get_arch()
             check_more = (mode > MODE_STANDARD)
             if check_more:
-                ewrite('Checking for newer versions at packages.debian.org,'+
+                ewrite('Checking for newer versions at madison,'+
                   ' incoming.debian.org and http://ftp-master.debian.org/new.html\n')
             else:
-                ewrite('Checking for newer versions at packages.debian.org...\n')
+                ewrite('Checking for newer versions at madison...\n')
             (avail, toonew) = checkversions.check_available(
                 package, pkgversion, timeout=self.options.timeout,
                 check_incoming=check_more, check_newqueue=check_more,
diff --git a/debian/changelog b/debian/changelog
index a7dfd5c..47c815e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -21,8 +21,10 @@ reportbug (6.3) UNRELEASED; urgency=low
     mail header different than the default, the From address. It reverts the
     change in #614879; thanks to Kevin Locke for the report and discussion;
     Closes: #640249
+  * Use madison.cgi (from QA) to check for newer versions available; thanks to
+    Bernd Zeimetz for the report; Closes: #601679
 
- -- Sandro Tosi <morph at debian.org>  Tue, 01 Nov 2011 13:46:10 +0100
+ -- Sandro Tosi <morph at debian.org>  Fri, 04 Nov 2011 23:12:37 +0100
 
 reportbug (6.2.2) unstable; urgency=low
 
diff --git a/reportbug/checkversions.py b/reportbug/checkversions.py
index 4eaaa7e..1fd4e83 100644
--- a/reportbug/checkversions.py
+++ b/reportbug/checkversions.py
@@ -38,7 +38,7 @@ from reportbug.exceptions import (
 # needed to parse new.822
 from debian.deb822 import Deb822
 
-PACKAGES_URL = 'http://packages.debian.org/%s'
+RMADISON_URL = 'http://qa.debian.org/madison.php?package=%s&text=on'
 INCOMING_URL = 'http://incoming.debian.org/'
 NEWQUEUE_URL = 'http://ftp-master.debian.org/new.822'
 
@@ -66,44 +66,6 @@ class BaseParser(sgmllib.SGMLParser):
         if not mode and data is not None: data = ' '.join(data.split())
         return data
 
-class PackagesParser(BaseParser):
-    def __init__(self, arch='i386'):
-        BaseParser.__init__(self)
-        self.versions = {}
-        self.row = None
-        arch = r'\s(all|'+re.escape(arch)+r')\b'
-        self.arch = re.compile(arch)
-        self.dist = None
-
-    def start_li(self, attrs):
-        if self.row is not None:
-            self.end_li()
-        self.row = []
-
-    def start_a(self, attrs):
-        if self.row is not None:
-            self.save_bgn()
-
-    def end_a(self):
-        if self.row is not None and self.savedata:
-            self.dist = self.save_end()
-
-    def lineend(self):
-        line = self.save_end().strip()
-        if self.arch.search(line):
-            version = line.split(': ', 1)
-            self.versions[self.dist] = version[0]
-
-    def start_br(self, attrs):
-        if self.savedata:
-            self.lineend()
-        self.save_bgn()
-
-    def end_li(self):
-        if self.savedata:
-            self.lineend()
-        self.row = None
-
 class IncomingParser(sgmllib.SGMLParser):
     def __init__(self, package, arch='i386'):
         sgmllib.SGMLParser.__init__(self)
@@ -143,7 +105,7 @@ def get_versions_available(package, timeout, dists=None, http_proxy=None, arch='
         dists = ('stable', 'testing', 'unstable')
 
     try:
-        page = open_url(PACKAGES_URL % package, http_proxy, timeout)
+        page = open_url(RMADISON_URL % package)
     except NoNetwork:
         return {}
     except urllib2.HTTPError, x:
@@ -152,28 +114,21 @@ def get_versions_available(package, timeout, dists=None, http_proxy=None, arch='
     if not page:
         return {}
 
-    parser = PackagesParser(arch)
-    for line in page:
-        parser.feed(line)
-    parser.close()
-    try:
-        page.fp._sock.recv = None
-    except:
-        pass
+    # read the content of the page, remove spaces, empty lines
+    content = page.read().replace(' ', '').strip()
     page.close()
 
-##     content = page.read()
-##     parser.feed(content)
-##     parser.close()
-##     page.close()
-
+    arch = utils.get_arch()
     versions = {}
-    for dist in dists:
-        for version in parser.versions.keys():
-            if re.search(r'\b%s\b' % dist, version):
-                versions[dist] = parser.versions[version]
-    del parser
-    del page
+    for line in content.split('\n'):
+        l = line.split('|')
+        # map suites name (returned by madison) to dist name
+        dist = utils.SUITES2DISTS.get(l[2], '')
+        if dist in dists:
+            # select only those lines that refers to source pkg
+            # or to binary packages available on the current arch
+            if 'source' in l[3] or arch in l[3]:
+                versions[dist] = l[1]
 
     return versions
 
diff --git a/reportbug/utils.py b/reportbug/utils.py
index eec026a..87b3122 100644
--- a/reportbug/utils.py
+++ b/reportbug/utils.py
@@ -87,6 +87,11 @@ NEWBIELINE = """Dear Maintainer,
 fhs_directories = ['/', '/usr', '/usr/share', '/var', '/usr/X11R6',
                    '/usr/man', '/usr/doc', '/usr/bin']
 
+# A map between suites and distributions names
+SUITES2DISTS = {'squeeze': 'stable',
+                'wheezy': 'testing',
+                'sid': 'unstable'}
+
 def realpath(filename):
     filename = os.path.abspath(filename)
 

-- 
Reportbug - reports bugs in the Debian distribution



More information about the Reportbug-commits mailing list