From b3847803064ae84cd401de20ac8ec55ffd342edb Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Thu, 5 Jun 2008 17:17:49 +0000 Subject: [PATCH] Merged from trunk 10577:10582 | 10578 | Use sets for more accurate cache modification counts | | zmedico | BlockerCache and vardbapi. | | 10580 | Mention PORTAGE_RO_DISTDIRS in the DISTDIR docs. | | zmedico | | | 10582 | Bug #224713 - Avoid TypeError when make.conf is missing: | | zmedico | TypeError: argument of type 'NoneType' is not iterable | svn path=/main/branches/prefix/; revision=10585 --- man/make.conf.5 | 7 ++++++- pym/_emerge/__init__.py | 10 +++++----- pym/portage/__init__.py | 2 ++ pym/portage/dbapi/vartree.py | 8 ++++---- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/man/make.conf.5 b/man/make.conf.5 index f854a2538..b24844b6b 100644 --- a/man/make.conf.5 +++ b/man/make.conf.5 @@ -102,7 +102,12 @@ Defines the location of your local source file repository. After packages are built, it is safe to remove any and all files from this directory since they will be automatically fetched on demand for a given build. If you would like to selectively prune obsolete files from this directory, see -\fBeclean\fR(1) from the gentoolkit package. Note +\fBeclean\fR(1) from the gentoolkit package. + +Use the \fBPORTAGE_RO_DISTDIRS\fR variable to specify one or +more read-only directories containing distfiles. + +Note that locations under /usr/portage are not necessarily safe for data storage. See the \fBPORTDIR\fR documentation for more information. .br diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index bb3bab358..773de639f 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -1497,7 +1497,7 @@ class BlockerCache(DictMixin): portage.CACHE_PATH.lstrip(os.path.sep), "vdb_blockers.pickle") self._cache_version = "1" self._cache_data = None - self._modified = 0 + self._modified = set() self._load() def _load(self): @@ -1567,7 +1567,7 @@ class BlockerCache(DictMixin): self._cache_data = {"version":self._cache_version} self._cache_data["blockers"] = {} self._cache_data["virtuals"] = self._virtuals - self._modified = 0 + self._modified.clear() def flush(self): """If the current user has permission and the internal blocker cache @@ -1585,7 +1585,7 @@ class BlockerCache(DictMixin): "virtuals" : vardb.settings.getvirtuals() } """ - if self._modified >= self._cache_threshold and \ + if len(self._modified) >= self._cache_threshold and \ secpass >= 2: try: f = portage.util.atomic_ofstream(self._cache_filename) @@ -1595,7 +1595,7 @@ class BlockerCache(DictMixin): self._cache_filename, gid=portage.portage_gid, mode=0644) except (IOError, OSError), e: pass - self._modified = 0 + self._modified.clear() def __setitem__(self, cpv, blocker_data): """ @@ -1609,7 +1609,7 @@ class BlockerCache(DictMixin): """ self._cache_data["blockers"][cpv] = \ (blocker_data.counter, tuple(str(x) for x in blocker_data.atoms)) - self._modified += 1 + self._modified.add(cpv) def __iter__(self): return iter(self._cache_data["blockers"]) diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 551a47b1f..a498c748c 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -1279,6 +1279,8 @@ class config(object): make_conf = getconfig( os.path.join(config_root, MAKE_CONF_FILE.lstrip(os.path.sep)), tolerant=tolerant, allow_sourcing=True) + if make_conf is None: + make_conf = {} # Allow ROOT setting to come from make.conf if it's not overridden # by the constructor argument (from the calling environment). diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 664189833..dd6cba471 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -663,7 +663,7 @@ class vardbapi(dbapi): users have read access and benefit from faster metadata lookups (as long as at least part of the cache is still valid).""" if self._aux_cache is not None and \ - self._aux_cache["modified"] >= self._aux_cache_threshold and \ + len(self._aux_cache["modified"]) >= self._aux_cache_threshold and \ secpass >= 2: valid_nodes = set(self.cpv_all()) for cpv in self._aux_cache["packages"].keys(): @@ -678,7 +678,7 @@ class vardbapi(dbapi): self._aux_cache_filename, gid=portage_gid, mode=0644) except (IOError, OSError), e: pass - self._aux_cache["modified"] = 0 + self._aux_cache["modified"] = set() def aux_get(self, mycpv, wants): """This automatically caches selected keys that are frequently needed @@ -723,7 +723,7 @@ class vardbapi(dbapi): not self._aux_cache.get("packages"): self._aux_cache = {"version": self._aux_cache_version} self._aux_cache["packages"] = {} - self._aux_cache["modified"] = 0 + self._aux_cache["modified"] = set() mydir = self.getpath(mycpv) mydir_stat = None try: @@ -768,7 +768,7 @@ class vardbapi(dbapi): for aux_key in cache_these: cache_data[aux_key] = mydata[aux_key] self._aux_cache["packages"][mycpv] = (mydir_mtime, cache_data) - self._aux_cache["modified"] += 1 + self._aux_cache["modified"].add(mycpv) return [mydata[x] for x in wants] def _aux_get(self, mycpv, wants): -- 2.26.2