[Piuparts-commits] [SCM] piuparts git repository branch, bikeshed, updated. 0.52-19-g9617a30

Andreas Beckmann anbe at debian.org
Tue May 28 12:53:22 UTC 2013


The following commit has been merged in the bikeshed branch:
commit 27165fc1cc1041be71d15a33852f8c97a9ae2165
Author: Andreas Beckmann <anbe at debian.org>
Date:   Sun May 26 15:17:10 2013 +0200

    p-[msr]: switch to load_packages_urls()
    
    avoid code duplication and support merging several packages files
    
    Signed-off-by: Andreas Beckmann <anbe at debian.org>

diff --git a/debian/changelog b/debian/changelog
index bcd58f1..340417c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -10,6 +10,9 @@ piuparts (0.53) UNRELEASED; urgency=low
   * piupartslib/conf.py:
   * piupartslib/packagesdb.py:
     - Add load_packages_urls() methods.
+  * piuparts-{master-backend,slave,report}.py:
+    - Switch to load_*_urls(get_*_urls()) for loading Packages/Sources files,
+      adding support for arbitrarily composed virtual distros.
   * piuparts-master-backend.py:
   * piuparts-slave.py:
   * piuparts-analyze.py:
diff --git a/master-bin/detect_well_known_errors.py b/master-bin/detect_well_known_errors.py
index a5a7d57..e609325 100755
--- a/master-bin/detect_well_known_errors.py
+++ b/master-bin/detect_well_known_errors.py
@@ -485,14 +485,11 @@ def process_section(section, config, problem_list,
 
         sectiondir = os.path.join(config['master-directory'], section)
         pkgsdb = piupartslib.packagesdb.PackagesDB(prefix=sectiondir)
-
-        pkgs_url = distro_config.get_packages_url(
-                   section_config.get_distro(),
-                   section_config.get_area(),
-                   section_config.get_arch())
-        pkg_fl = piupartslib.open_packages_url(pkgs_url)
-        pkgsdb.read_packages_file(pkg_fl)
-        pkg_fl.close()
+        pkgsdb.load_packages_urls(
+                distro_config.get_packages_urls(
+                    section_config.get_distro(),
+                    section_config.get_area(),
+                    section_config.get_arch()))
 
         pkgsdb.compute_package_states()
         pkgsdb.calc_rrdep_counts()
diff --git a/piuparts-master-backend.py b/piuparts-master-backend.py
index 1e83ec4..c2f30fa 100644
--- a/piuparts-master-backend.py
+++ b/piuparts-master-backend.py
@@ -206,20 +206,19 @@ class Master(Protocol):
             for dep in deps:
                 self._load_package_database(dep)
             db.set_dependency_databases([self._package_databases[dep] for dep in deps])
-        packages_url = distro_config.get_packages_url(
-                config.get_distro(), config.get_area(), config.get_arch())
-        logging.info("Fetching %s" % packages_url)
-        packages_file = piupartslib.open_packages_url(packages_url)
-        db.read_packages_file(packages_file)
-        packages_file.close()
+        db.load_packages_urls(
+                distro_config.get_packages_urls(
+                    config.get_distro(),
+                    config.get_area(),
+                    config.get_arch()))
         if config.get_distro() != config.get_final_distro():
             # take version numbers (or None) from final distro
-            packages_url = distro_config.get_packages_url(
-                    config.get_final_distro(), config.get_area(), config.get_arch())
-            logging.info("Fetching %s" % packages_url)
-            packages_file = piupartslib.open_packages_url(packages_url)
-            db2 = piupartslib.packagesdb.PackagesFile(packages_file)
-            packages_file.close()
+            db2 = piupartslib.packagesdb.PackagesFile()
+            db2.load_packages_urls(
+                distro_config.get_packages_urls(
+                    config.get_final_distro(),
+                    config.get_area(),
+                    config.get_arch()))
             for package in db.get_all_packages():
                 if package["Package"] in db2:
                     package["Version"] = db2[package["Package"]]["Version"]
diff --git a/piuparts-report.py b/piuparts-report.py
index 86f7c71..948d5d3 100644
--- a/piuparts-report.py
+++ b/piuparts-report.py
@@ -620,13 +620,11 @@ class Section:
         self._binary_db.compute_package_states()
         self._binary_db.calc_rrdep_counts()
 
-        sources_url = self._distro_config.get_sources_url(
-                self._config.get_distro(), self._config.get_area())
-        logging.info("Fetching %s" % sources_url)
-        sources_file = piupartslib.open_packages_url(sources_url)
         self._source_db = piupartslib.packagesdb.PackagesDB()
-        self._source_db.read_packages_file(sources_file)
-        sources_file.close()
+        self._source_db.load_packages_urls(
+                self._distro_config.get_sources_urls(
+                    self._config.get_distro(),
+                    self._config.get_area()))
 
         self._log_name_cache = {}
 
@@ -654,20 +652,19 @@ class Section:
         else:
             # only cache the big base databases that don't have additional dependencies
             self._packagedb_cache[section] = db
-        packages_url = self._distro_config.get_packages_url(
-                config.get_distro(), config.get_area(), config.get_arch())
-        logging.info("Fetching %s" % packages_url)
-        packages_file = piupartslib.open_packages_url(packages_url)
-        db.read_packages_file(packages_file)
-        packages_file.close()
+        db.load_packages_urls(
+                self._distro_config.get_packages_urls(
+                    config.get_distro(),
+                    config.get_area(),
+                    config.get_arch()))
         if config.get_distro() != config.get_final_distro():
             # take version numbers (or None) from final distro
-            packages_url = self._distro_config.get_packages_url(
-                    config.get_final_distro(), config.get_area(), config.get_arch())
-            logging.info("Fetching %s" % packages_url)
-            packages_file = piupartslib.open_packages_url(packages_url)
-            db2 = piupartslib.packagesdb.PackagesFile(packages_file)
-            packages_file.close()
+            db2 = piupartslib.packagesdb.PackagesFile()
+            db2.load_packages_urls(
+                self._distro_config.get_packages_urls(
+                    config.get_final_distro(),
+                    config.get_area(),
+                    config.get_arch()))
             for package in db.get_all_packages():
                 if package["Package"] in db2:
                     package["Version"] = db2[package["Package"]]["Version"]
@@ -1189,8 +1186,9 @@ class Section:
 
         tablerows += "<tr class=\"normalrow\"> <td class=\"labelcell2\">Total</td> <td class=\"labelcell2\" colspan=\"2\">%d</td></tr>\n" % total_packages
         htmlpage = string.Template(HTML_HEADER + SECTION_INDEX_BODY_TEMPLATE + HTML_FOOTER)
-        packages_url = self._distro_config.get_packages_url(
-                self._config.get_distro(), self._config.get_area(), self._config.get_arch())
+        # FIXME: list all urls instead of just one
+        packages_url = self._distro_config.get_packages_urls(
+                self._config.get_distro(), self._config.get_area(), self._config.get_arch())[0]
         vendor = "Debian"
         if len(self._config.get_distros()) > 1:
             description = "%s %s: package installation in %s" % (
diff --git a/piuparts-slave.py b/piuparts-slave.py
index a2f7af7..47a05f4 100644
--- a/piuparts-slave.py
+++ b/piuparts-slave.py
@@ -580,12 +580,13 @@ class Section:
         for distro in [self._config.get_distro()] + self._config.get_distros():
             if distro not in packages_files:
                 try:
-                    packages_url = self._distro_config.get_packages_url(
-                            distro, self._config.get_area(), self._config.get_arch())
-                    logging.debug("Fetching %s" % packages_url)
-                    f = piupartslib.open_packages_url(packages_url)
-                    packages_files[distro] = piupartslib.packagesdb.PackagesFile(f)
-                    f.close()
+                    pf = piupartslib.packagesdb.PackagesFile()
+                    pf.load_packages_urls(
+                            self._distro_config.get_packages_urls(
+                                distro,
+                                self._config.get_area(),
+                                self._config.get_arch()))
+                    packages_files[distro] = pf
                 except IOError:
                     logging.error("failed to fetch packages file for %s" % distro)
                     self._error_wait_until = time.time() + 900

-- 
piuparts git repository



More information about the Piuparts-commits mailing list