[Piuparts-commits] [SCM] piuparts git repository branch, bikeshed, updated. 0.51-51-g1c35bbd

Andreas Beckmann anbe at debian.org
Mon May 27 11:11:46 UTC 2013


The following commit has been merged in the bikeshed branch:
commit d8a5488e9e453d89443f2e679d50f0ad0512cf4a
Author: David Steele <dsteele at gmail.com>
Date:   Sat Mar 2 18:23:10 2013 -0500

    Remove need for chdir() before loading packagesdb.
    
    ... in piuparts-report and detect_well_known_errors.
    
    Establish the full path to the directory as 'prefix'.
    The calc_rrdep_counts() call is hiding the potential need for the
    directory to be correct in other places. Removing the rrdep calc
    would otherwise cause a crash.
    
    Signed-off-by: Andreas Beckmann <anbe at debian.org>

diff --git a/master-bin/detect_well_known_errors.py b/master-bin/detect_well_known_errors.py
index 3dc0264..1d0f213 100755
--- a/master-bin/detect_well_known_errors.py
+++ b/master-bin/detect_well_known_errors.py
@@ -481,13 +481,11 @@ def process_section( section, config, problem_list,
     add_cnt = make_kprs( logdict, kprdict, problem_list )
 
     if not pkgsdb:
-        oldcwd = os.getcwd()
-        os.chdir(config['master-directory'])
-
         distro_config = piupartslib.conf.DistroConfig(
                         DISTRO_CONFIG_FILE, section_config["mirror"])
 
-        pkgsdb = piupartslib.packagesdb.PackagesDB(prefix=section)
+        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(),
@@ -500,8 +498,6 @@ def process_section( section, config, problem_list,
         pkgsdb.compute_package_states()
         pkgsdb.calc_rrdep_counts()
 
-        os.chdir(oldcwd)
-
     failures = FailureManager( logdict )
     failures.sort_by_bugged_and_rdeps(pkgsdb)
 
diff --git a/piuparts-report.py b/piuparts-report.py
index eb7d714..2ac2b58 100644
--- a/piuparts-report.py
+++ b/piuparts-report.py
@@ -613,15 +613,12 @@ class Section:
         self._doc_root = doc_root
 
         logging.debug("Loading and parsing Packages file")
-        oldcwd = os.getcwd()
-        os.chdir(master_directory)
         self._packagedb_cache = packagedb_cache
         self._package_databases = {}
-        self._load_package_database(section)
+        self._load_package_database(section, master_directory)
         self._binary_db = self._package_databases[section]
         self._binary_db.compute_package_states()
         self._binary_db.calc_rrdep_counts()
-        os.chdir(oldcwd)
 
         sources_url = self._distro_config.get_sources_url(
                 self._config.get_distro(), self._config.get_area())
@@ -633,7 +630,7 @@ class Section:
 
         self._log_name_cache = {}
 
-    def _load_package_database(self, section):
+    def _load_package_database(self, section, master_directory):
         if section in self._package_databases:
             return
         elif section in self._packagedb_cache:
@@ -646,12 +643,13 @@ class Section:
             # this is a base database eligible for caching
             # only cache the most recent base database
             self._packagedb_cache.clear()
-        db = piupartslib.packagesdb.PackagesDB(prefix=section)
+        sectiondir = os.path.join(master_directory, section)
+        db = piupartslib.packagesdb.PackagesDB(prefix=sectiondir)
         self._package_databases[section] = db
         if config["depends-sections"]:
             deps = config["depends-sections"].split()
             for dep in deps:
-                self._load_package_database(dep)
+                self._load_package_database(dep, master_directory)
             db.set_dependency_databases([self._package_databases[dep] for dep in deps])
         else:
             # only cache the big base databases that don't have additional dependencies

-- 
piuparts git repository



More information about the Piuparts-commits mailing list