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"),
# 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
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 = {}
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
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]