Allow sets to get through world file validation and
authorZac Medico <zmedico@gentoo.org>
Fri, 26 Oct 2007 05:18:38 +0000 (05:18 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 26 Oct 2007 05:18:38 +0000 (05:18 -0000)
expand properly. It's now possible to put @system
in the world file and get the old behavior where
world includes system.

svn path=/main/trunk/; revision=8307

pym/portage/sets/__init__.py
pym/portage/sets/files.py

index 315747f10e6256219b972b0264ea49cefafbfd81..9f562820b4dcb59870d0854707ee96555d0ee57b 100644 (file)
@@ -101,7 +101,7 @@ class SetConfig(SafeConfigParser):
                for n in myset.getNonAtoms():
                        if n[0] == SETPREFIX and n[1:] in self.aliases:
                                if n[1:] not in ignorelist:
-                                       myatoms.update(self.getSetAtoms(n), ignorelist=ignorelist)
+                                       myatoms.update(self.getSetAtoms(n[1:]))
                return myatoms
 
 def make_default_config(settings, trees):
index f0dfd78e2561c46eb37fc62366c6a297eea1a079..010966c2ad0697e3d928f0b4fb9e1dec39973d22 100644 (file)
@@ -4,13 +4,14 @@
 
 import errno
 import os
+from itertools import chain
 
 from portage.util import grabfile, write_atomic, ensure_dirs
 from portage.const import PRIVATE_PATH, USER_CONFIG_PATH
 from portage.locks import lockfile, unlockfile
 from portage import portage_gid
 from portage.sets.base import PackageSet, EditablePackageSet
-from portage.sets import SetConfigError
+from portage.sets import SetConfigError, SETPREFIX
 from portage.env.loaders import ItemFileLoader, KeyListFileLoader
 from portage.env.validators import ValidAtomValidator
 from portage import dep_getkey, cpv_getkey
@@ -25,7 +26,7 @@ class StaticFileSet(EditablePackageSet):
                self._filename = filename
                self._mtime = None
                self.description = "Package set loaded from file %s" % self._filename
-               self.loader = ItemFileLoader(self._filename, ValidAtomValidator)
+               self.loader = ItemFileLoader(self._filename, self._validate)
 
                metadata = grabfile(self._filename + ".metadata")
                key = None
@@ -45,9 +46,13 @@ class StaticFileSet(EditablePackageSet):
                else:
                        if key != None:
                                setattr(self, key, " ".join(value))
-       
+
+       def _validate(self, atom):
+               return ValidAtomValidator(atom)
+
        def write(self):
-               write_atomic(self._filename, "\n".join(sorted(self._atoms))+"\n")
+               write_atomic(self._filename, "\n".join(sorted(
+                       chain(self._atoms, self._nonatoms)))+"\n")
        
        def load(self):
                try:
@@ -127,6 +132,11 @@ class WorldSet(StaticFileSet):
                super(WorldSet, self).__init__(os.path.join(os.sep, root, PRIVATE_PATH.lstrip(os.sep), "world"))
                self._lock = None
 
+       def _validate(self, atom):
+               if atom.startswith(SETPREFIX):
+                       return True
+               return ValidAtomValidator(atom)
+
        def _ensure_dirs(self):
                ensure_dirs(os.path.dirname(self._filename), gid=portage_gid, mode=02750, mask=02)