Always use shlex_split() to split CONFIG_PROTECT{,_MASK}.
authorZac Medico <zmedico@gentoo.org>
Sun, 1 Aug 2010 04:45:18 +0000 (21:45 -0700)
committerZac Medico <zmedico@gentoo.org>
Sun, 1 Aug 2010 04:45:18 +0000 (21:45 -0700)
bin/dispatch-conf
bin/quickpkg
pym/_emerge/actions.py
pym/_emerge/main.py
pym/portage/_global_updates.py

index fc9cdd513a127025f30587e75768d15e0452352f..a7556a3a3d4fc48e3f625289a21713d51c1570eb 100755 (executable)
 
 from __future__ import print_function
 
-if not hasattr(__builtins__, "set"):
-    from sets import Set as set
-
-from stat import *
-from random import *
+from stat import ST_GID, ST_MODE, ST_UID
+from random import random
 import atexit, re, shutil, stat, sys
 
 try:
@@ -74,7 +71,7 @@ class dispatch:
         confs = []
         count = 0
 
-
+        config_root = '/'
         self.options = portage.dispatch_conf.read_config(MANDATORY_OPTS)
 
         if "log-file" in self.options:
@@ -91,7 +88,7 @@ class dispatch:
         # Build list of extant configs
         #
 
-        for path in config_paths.split ():
+        for path in config_paths:
             path = portage.normalize_path(path)
             try:
                 mymode = os.stat(path).st_mode
@@ -116,6 +113,10 @@ class dispatch:
         # config file freezing support
         frozen_files = set(self.options.get("frozen-files", "").split())
         auto_zapped = []
+        protect_obj = ConfigProtect(
+            config_root, config_paths,
+            portage.util.shlex_split(
+            portage.settings.get('CONFIG_PROTECT_MASK', '')))
 
         #
         # Remove new configs identical to current
@@ -190,7 +191,8 @@ class dispatch:
                 except OSError:
                     pass
                 return False
-            elif unmodified or same_cvs or same_wsc or conf ['dir'] in portage.settings ['CONFIG_PROTECT_MASK'].split ():
+            elif unmodified or same_cvs or same_wsc or \
+                not protect_obj.isprotected(conf['current']):
                 self.replace(newconf, conf['current'])
                 self.post_process(conf['current'])
                 if newconf == mrgconf:
@@ -426,6 +428,7 @@ d = dispatch ()
 
 if len(sys.argv) > 1:
     # for testing
-    d.grind (" ".join(sys.argv[1:]))
+    d.grind(sys.argv[1:])
 else:
-    d.grind (portage.settings ['CONFIG_PROTECT'])
+    d.grind(portage.util.shlex_split(
+        portage.settings.get('CONFIG_PROTECT', '')))
index 8e74c2c346fcbe5d742f88042ae0e9821fae2024..b703ee6759403ae2105b458e41ee65256b7fd47d 100755 (executable)
@@ -23,12 +23,13 @@ from portage import xpak
 from portage.dbapi.dep_expand import dep_expand
 from portage.dep import flatten, paren_reduce, use_reduce
 from portage.exception import InvalidAtom, InvalidData, InvalidDependString, PackageSetNotFound
-from portage.util import ConfigProtect, ensure_dirs
+from portage.util import ConfigProtect, ensure_dirs, shlex_split
 from portage.dbapi.vartree import dblink, tar_contents
 from portage.checksum import perform_md5
 from portage.sets import load_default_config, SETPREFIX
 
 def quickpkg_atom(options, infos, arg, eout):
+       settings = portage.settings
        root = portage.settings["ROOT"]
        trees = portage.db[root]
        vartree = trees["vartree"]
@@ -96,8 +97,8 @@ def quickpkg_atom(options, infos, arg, eout):
                        protect = None
                        if not include_config:
                                confprot = ConfigProtect(root,
-                                       portage.settings.get("CONFIG_PROTECT","").split(),
-                                       portage.settings.get("CONFIG_PROTECT_MASK","").split())
+                                       shlex_split(settings.get("CONFIG_PROTECT", "")),
+                                       shlex_split(settings.get("CONFIG_PROTECT_MASK", "")))
                                def protect(filename):
                                        if not confprot.isprotected(filename):
                                                return False
index 16c329bbe5eb418d398dfca12b80ec69db536f34..bbab613b32028e5d6b24f6460a56c98853abcfb4 100644 (file)
@@ -2304,7 +2304,8 @@ def action_sync(settings, trees, mtimedb, myopts, myaction):
                trees[settings["ROOT"]]["vartree"].dbapi.match(
                portage.const.PORTAGE_PACKAGE_ATOM))
 
-       chk_updated_cfg_files("/", settings.get("CONFIG_PROTECT","").split())
+       chk_updated_cfg_files("/",
+               portage.util.shlex_split(settings.get("CONFIG_PROTECT", "")))
 
        if myaction != "metadata":
                postsync = os.path.join(settings["PORTAGE_CONFIGROOT"],
index 5f0a7663af01c206f78bb50ee34b89c638aacf61..16d9897de74fe9da21842c45b81e30a786461f67 100644 (file)
@@ -33,7 +33,7 @@ import portage.exception
 from portage.data import secpass
 from portage.dbapi.dep_expand import dep_expand
 from portage.util import normalize_path as normpath
-from portage.util import writemsg, writemsg_level, writemsg_stdout
+from portage.util import shlex_split, writemsg_level, writemsg_stdout
 from portage.sets import SETPREFIX
 from portage._global_updates import _global_updates
 
@@ -320,7 +320,7 @@ def post_emerge(root_config, myopts, mtimedb, retval):
        settings.regenerate()
        settings.lock()
 
-       config_protect = settings.get("CONFIG_PROTECT","").split()
+       config_protect = shlex_split(settings.get("CONFIG_PROTECT", ""))
        infodirs = settings.get("INFOPATH","").split(":") + \
                settings.get("INFODIR","").split(":")
 
index d3f55902d5c78b450f3f3a1544f91a1a5517cb58..7468417ac62df47e5a047be2df1f616f817617f8 100644 (file)
@@ -12,7 +12,8 @@ from portage.exception import DirectoryNotFound
 from portage.localization import _
 from portage.output import bold, colorize
 from portage.update import grab_updates, parse_updates, update_config_files, update_dbentry
-from portage.util import grabfile, writemsg, writemsg_stdout, write_atomic
+from portage.util import grabfile, shlex_split, \
+       writemsg, writemsg_stdout, write_atomic
 
 def _global_updates(trees, prev_mtimes):
        """
@@ -143,8 +144,8 @@ def _global_updates(trees, prev_mtimes):
                                                        world_list[pos] = new_atom
                                                        world_modified = True
                        update_config_files(root,
-                               mysettings.get("CONFIG_PROTECT","").split(),
-                               mysettings.get("CONFIG_PROTECT_MASK","").split(),
+                               shlex_split(mysettings.get("CONFIG_PROTECT", "")),
+                               shlex_split(mysettings.get("CONFIG_PROTECT_MASK", "")),
                                myupd, match_callback=_world_repo_match)
 
                        for update_cmd in myupd: