return op in self._operations
def getAtoms(self):
- if not self._loaded and not self._loading:
+ if not (self._loaded or self._loading):
self._loading = True
self.load()
self._loaded = True
return ""
def _updateAtomMap(self):
- for a in self.getAtoms():
+ for a in self._atoms:
cp = dep_getkey(a)
self._atommap.setdefault(cp, set())
self._atommap[cp].add(a)
# Distributed under the terms of the GNU General Public License v2
# $Id$
-from portage.util import grabfile, grabfile_package, grabdict_package, write_atomic
+from portage.util import grabfile, grabfile_package, grabdict_package, write_atomic, ensure_dirs
+from portage.const import PRIVATE_PATH
+from portage.locks import lockfile, unlockfile
+from portage import portage_gid
import os
from portage.sets import PackageSet, EditablePackageSet
mtime = os.stat(self._filename).st_mtime
except (OSError, IOError):
mtime = None
- if not self._loaded or self._mtime != mtime:
+ if (not self._loaded or self._mtime != mtime):
self._setAtoms(grabfile_package(self._filename, recursive=True))
self._mtime = mtime
def load(self):
self._setAtoms(grabdict_package(self._filename, recursive=True).keys())
+class WorldSet(StaticFileSet):
+ description = "Set of packages that were directly installed by the user"
+
+ def __init__(self, name, root):
+ super(WorldSet, self).__init__(name, os.path.join(os.sep, root, PRIVATE_PATH, "world"))
+ self._lock = None
+
+ def _ensure_dirs(self):
+ ensure_dirs(os.path.dirname(self._filename), gid=portage_gid, mode=02750, mask=02)
+
+ def lock(self):
+ self._ensure_dirs()
+ self._lock = lockfile(self._filename, wantnewlockfile=1)
+
+ def unlock(self):
+ unlockfile(self._lock)
+ self._lock = None