summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/portage/sets/__init__.py4
-rw-r--r--pym/portage/sets/files.py24
2 files changed, 24 insertions, 4 deletions
diff --git a/pym/portage/sets/__init__.py b/pym/portage/sets/__init__.py
index cab64279b..91ddc3573 100644
--- a/pym/portage/sets/__init__.py
+++ b/pym/portage/sets/__init__.py
@@ -42,7 +42,7 @@ class PackageSet(object):
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
@@ -78,7 +78,7 @@ class PackageSet(object):
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)
diff --git a/pym/portage/sets/files.py b/pym/portage/sets/files.py
index 9558cc7a3..7fa5fb24d 100644
--- a/pym/portage/sets/files.py
+++ b/pym/portage/sets/files.py
@@ -2,7 +2,10 @@
# 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
@@ -41,7 +44,7 @@ class StaticFileSet(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
@@ -54,3 +57,20 @@ class ConfigFileSet(PackageSet):
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