Merged from trunk 10359:10377
authorFabian Groffen <grobian@gentoo.org>
Wed, 21 May 2008 17:37:05 +0000 (17:37 -0000)
committerFabian Groffen <grobian@gentoo.org>
Wed, 21 May 2008 17:37:05 +0000 (17:37 -0000)
   | 10360   | Tweak vardbapi.aux_get() cache logic a bit.                  |
   | zmedico |                                                              |

   | 10361   | In unmerge(), flush the vardbapi aux_get() cache to disk     |
   | zmedico | before releasing the vardb lock.                             |

   | 10364   | Exclude "env" from use in variable substitution since we     |
   | zmedico | want to avoid any interaction with the calling environment   |
   |         | that might lead to unexpected results.                       |

   | 10367   | Fix vardbapi.aux_get() logic so that it will correctly pull  |
   | zmedico | the metadata value corresponding to an unrecognized metadata |
   |         | key.                                                         |

   | 10369   | Validate and normalize target_root earlier in the config     |
   | zmedico | constructor.                                                 |

   | 10372   | Adjust code order to organize it a bit. (branches/2.1.2      |
   | zmedico | r10371)                                                      |

   | 10373   | Inside vardbapi.aux_get(), do more validation on the cache   |
   | zmedico | data to ensure it contains the expected data types.          |

   | 10375   | In vardbapi.aux_get(), don't mark cacheed metadata invalid   |
   | zmedico | just because some of the values are missing.                 |

   | 10377   | Simplify cache code in vardbapi.aux_get().                   |
   | zmedico |                                                              |

svn path=/main/branches/prefix/; revision=10385

pym/_emerge/__init__.py
pym/portage/__init__.py
pym/portage/dbapi/vartree.py

index 7f2950179e9868f3cb26b77718d8dcc4b66634e0..118d12ff8b5d5723efc215f375347d4bb41357fc 100644 (file)
@@ -6361,6 +6361,7 @@ def unmerge(root_config, myopts, unmerge_action,
                        return 0
        finally:
                if vdb_lock:
+                       vartree.dbapi.flush_cache()
                        portage.locks.unlockdir(vdb_lock)
        
        from portage.sets.base import EditablePackageSet
index 610d2a7ed9c78cf7964bbb2dcf5618f54ebce38e..10dd132708b701383cac04c388e0086f8fa9f61d 100644 (file)
@@ -1285,18 +1285,27 @@ class config(object):
                        if target_root is None:
                                target_root = "/"
 
+                       target_root = normalize_path(os.path.abspath(
+                               target_root)).rstrip(os.path.sep) + os.path.sep
+
+                       portage.util.ensure_dirs(target_root + EPREFIX_LSTRIP)
+                       check_var_directory("ROOT", target_root + EPREFIX_LSTRIP)
+
                        # The expand_map is used for variable substitution
                        # in getconfig() calls, and the getconfig() calls
                        # update expand_map with the value of each variable
                        # assignment that occurs. Variable substitution occurs
-                       # in the following order:
+                       # in the following order, which corresponds to the
+                       # order of appearance in self.lookuplist:
                        #
                        #   * env.d
-                       #   * env
                        #   * make.globals
                        #   * make.defaults
                        #   * make.conf
                        #
+                       # Notably absent is "env", since we want to avoid any
+                       # interaction with the calling environment that might
+                       # lead to unexpected results.
                        expand_map = {}
 
                        env_d = getconfig(os.path.join(target_root + EPREFIX_LSTRIP, "etc", "profile.env"),
@@ -1308,12 +1317,6 @@ class config(object):
 
                        # backupenv is used for calculating incremental variables.
                        self.backupenv = os.environ.copy()
-                       expand_map.update(self.backupenv)
-
-                       # make.globals should not be relative to config_root
-                       # because it only contains constants.
-                       self.mygcfg = getconfig(os.path.join(BPREFIX, "etc", "make.globals"),
-                               expand=expand_map)
 
                        if env_d:
                                # Remove duplicate values so they don't override updated
@@ -1329,6 +1332,11 @@ class config(object):
 
                        self.configdict["env"] = self.backupenv.copy()
 
+                       # make.globals should not be relative to config_root
+                       # because it only contains constants.
+                       self.mygcfg = getconfig(os.path.join(BPREFIX, "etc", "make.globals"),
+                               expand=expand_map)
+
                        if self.mygcfg is None:
                                self.mygcfg = {}
 
@@ -1396,12 +1404,6 @@ class config(object):
                                        cfg.pop(blacklisted, None)
                        del blacklisted, cfg
 
-                       target_root = normalize_path(os.path.abspath(
-                               target_root)).rstrip(os.path.sep) + os.path.sep
-
-                       portage.util.ensure_dirs(target_root + EPREFIX_LSTRIP)
-                       check_var_directory("ROOT", target_root + EPREFIX_LSTRIP)
-
                        self["PORTAGE_CONFIGROOT"] = config_root
                        self.backup_changes("PORTAGE_CONFIGROOT")
                        self["ROOT"] = target_root
index 5f4e947a2b7644d806c738444d6fc4bf8f8abff1..dc6de78cda1f57c0d83de530201e21da71f6048b 100644 (file)
@@ -715,33 +715,36 @@ class vardbapi(dbapi):
                        raise KeyError(mycpv)
                mydir_mtime = long(mydir_stat.st_mtime)
                pkg_data = self._aux_cache["packages"].get(mycpv)
+               pull_me = cache_these.union(wants)
                mydata = {}
                cache_valid = False
                cache_incomplete = False
+               cache_mtime = None
+               metadata = None
+               if pkg_data is not None:
+                       if not isinstance(pkg_data, tuple) or len(pkg_data) != 2:
+                               pkg_data = None
+                       else:
+                               cache_mtime, metadata = pkg_data
+                               if not isinstance(cache_mtime, (long, int)) or \
+                                       not isinstance(metadata, dict):
+                                       pkg_data = None
+
                if pkg_data:
                        cache_mtime, metadata = pkg_data
                        cache_valid = cache_mtime == mydir_mtime
                if cache_valid:
-                       cache_incomplete = cache_these.difference(metadata)
-                       if cache_incomplete:
-                               # Allow self._aux_cache_keys to change without a cache version
-                               # bump and efficiently recycle partial cache whenever possible.
-                               cache_valid = False
-                               pull_me = cache_incomplete.union(wants)
-                       else:
-                               pull_me = set(wants).difference(cache_these)
                        mydata.update(metadata)
-               else:
-                       pull_me = cache_these
+                       pull_me.difference_update(metadata)
 
                if pull_me:
                        # pull any needed data and cache it
                        aux_keys = list(pull_me)
                        for k, v in izip(aux_keys, self._aux_get(mycpv, aux_keys)):
                                mydata[k] = v
-                       if not cache_valid or cache_incomplete:
+                       if not cache_valid or cache_these.difference(metadata):
                                cache_data = {}
-                               if cache_incomplete:
+                               if cache_valid and metadata:
                                        cache_data.update(metadata)
                                for aux_key in cache_these:
                                        cache_data[aux_key] = mydata[aux_key]