From cbcc38bf5e2ee96bcb9e2bf1b884d7d3b747b8f7 Mon Sep 17 00:00:00 2001
From: Julien Cristau <jcristau@debian.org>
Date: Thu, 10 Jan 2013 21:13:24 +0100
Subject: [PATCH] britney: kill read_sources

We can infer the sources from the Packages files.

Signed-off-by: Julien Cristau <jcristau@debian.org>
---
 britney.py |   56 ++++++++------------------------------------------------
 1 file changed, 8 insertions(+), 48 deletions(-)

diff --git a/britney.py b/britney.py
index 0b03d30..89c57ec 100755
--- a/britney.py
+++ b/britney.py
@@ -45,8 +45,8 @@ Britney loads the source packages from the `Sources' file and the binary
 packages from the `Packages_${arch}' files, where ${arch} is substituted
 with the supported architectures. While loading the data, the software
 analyzes the dependencies and builds a directed weighted graph in memory
-with all the interconnections between the packages (see Britney.read_sources
-and Britney.read_binaries).
+with all the interconnections between the packages (see
+Britney.read_binaries).
 
 Other than source and binary packages, Britney loads the following data:
 
@@ -279,7 +279,7 @@ class Britney(object):
         # long time, try increasing SIZEOFHASHMAP in lib/dpkg.c and rebuilding
         if not self.options.nuninst_cache:
             self.__log("Building the list of non-installable packages for the full archive", type="I")
-            self.sources['testing'] = self.read_sources(self.options.testing)
+            self.sources['testing'] = {}
             self.binaries['testing'] = {}
             nuninst = {}
             for arch in self.options.architectures:
@@ -306,14 +306,10 @@ class Britney(object):
         # if this takes a very long time, try increasing SIZEOFHASHMAP in
         # lib/dpkg.c and rebuilding
         if 'testing' not in self.sources:
-            self.sources['testing'] = self.read_sources(self.options.testing)
-        self.sources['unstable'] = self.read_sources(self.options.unstable)
-        self.sources['tpu'] = self.read_sources(self.options.tpu)
-
-        if hasattr(self.options, 'pu'):
-            self.sources['pu'] = self.read_sources(self.options.pu)
-        else:
-            self.sources['pu'] = {}
+            self.sources['testing'] = {}
+        self.sources['unstable'] = {}
+        self.sources['tpu'] = {}
+        self.sources['pu'] = {}
 
         if 'testing' not in self.binaries:
             self.binaries['testing'] = {}
@@ -433,42 +429,6 @@ class Britney(object):
                 else: packages[k][PROVIDES] = None
             self.systems[a] = buildSystem(a, packages)
 
-    def read_sources(self, basedir):
-        """Read the list of source packages from the specified directory
-        
-        The source packages are read from the `Sources' file within the
-        directory specified as `basedir' parameter. Considering the
-        large amount of memory needed, not all the fields are loaded
-        in memory. The available fields are Version, Maintainer and Section.
-
-        The method returns a list where every item represents a source
-        package as a dictionary.
-        """
-        sources = {}
-        filename = os.path.join(basedir, "Sources")
-        self.__log("Loading source packages from %s" % filename)
-
-        Packages = apt_pkg.TagFile(open(filename))
-        get_field = Packages.section.get
-        step = Packages.step
-
-        while step():
-            pkg = get_field('Package')
-            ver = get_field('Version')
-            # There may be multiple versions of the source package
-            # (in unstable) if some architectures have out-of-date
-            # binaries.  We only ever consider the source with the
-            # largest version for migration.
-            if pkg in sources and apt_pkg.version_compare(sources[pkg][0], ver) > 0:
-                continue
-            sources[pkg] = [ver,
-                            get_field('Section'),
-                            [],
-                            get_field('Maintainer'),
-                            False,
-                           ]
-        return sources
-
     def read_binaries(self, basedir, distribution, arch):
         """Read the list of binary packages from the specified directory
         
@@ -557,7 +517,7 @@ class Britney(object):
                 sources[distribution][dpkg[SOURCE]][BINARIES].append(pkg + "/" + arch)
             # if the source package doesn't exist, create a fake one
             else:
-                sources[distribution][dpkg[SOURCE]] = [dpkg[SOURCEVER], 'faux', [pkg + "/" + arch], None, True]
+                sources[distribution][dpkg[SOURCE]] = [dpkg[SOURCEVER], dpkg[SECTION], [pkg + "/" + arch], None, dpkg[SECTION] == 'faux']
 
             # register virtual packages and real packages that provide them
             if dpkg[PROVIDES]:
-- 
1.7.10.4

