summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOtavio Pontes <otaviobp@gmail.com>2010-08-02 23:58:55 +0000
committerOtavio Pontes <otaviobp@gmail.com>2010-08-02 23:58:55 +0000
commitda1ae19864ce14fbe11286e10b1e136fe816c83f (patch)
treea0b72c967468dbcfa07ba33286ca9fe167eec8cf
parentAdding test routine to check if the correct ebuild is beeing used to (diff)
parent* Make _world_repo_match() try to match both atoms, so it still works (diff)
downloadportage-multirepo-da1ae19864ce14fbe11286e10b1e136fe816c83f.tar.gz
portage-multirepo-da1ae19864ce14fbe11286e10b1e136fe816c83f.tar.bz2
portage-multirepo-da1ae19864ce14fbe11286e10b1e136fe816c83f.zip
Merge branch 'master' of git://git.overlays.gentoo.org/proj/portage
-rwxr-xr-xbin/dispatch-conf23
-rwxr-xr-xbin/quickpkg7
-rw-r--r--pym/_emerge/actions.py3
-rw-r--r--pym/_emerge/main.py4
-rw-r--r--pym/portage/_global_updates.py71
-rw-r--r--pym/portage/update.py53
6 files changed, 99 insertions, 62 deletions
diff --git a/bin/dispatch-conf b/bin/dispatch-conf
index fc9cdd51..1e21a521 100755
--- a/bin/dispatch-conf
+++ b/bin/dispatch-conf
@@ -13,11 +13,8 @@
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 = portage.util.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', '')))
diff --git a/bin/quickpkg b/bin/quickpkg
index 8e74c2c3..b703ee67 100755
--- a/bin/quickpkg
+++ b/bin/quickpkg
@@ -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
diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index 9c2c36c6..5a1a4f38 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -2600,7 +2600,8 @@ def action_sync(settings, trees, mtimedb, myopts, myaction, repo_name=None):
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"],
diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index b56e43e9..e6c41e10 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -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(":")
diff --git a/pym/portage/_global_updates.py b/pym/portage/_global_updates.py
index d3f55902..ed514112 100644
--- a/pym/portage/_global_updates.py
+++ b/pym/portage/_global_updates.py
@@ -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):
"""
@@ -26,20 +27,18 @@ def _global_updates(trees, prev_mtimes):
@param prev_mtimes: A dictionary containing mtimes of files located in
$PORTDIR/profiles/updates/.
@type prev_mtimes: dict
- @rtype: None or List
- @return: None if no were no updates, otherwise a list of update commands
- that have been performed.
+ @rtype: bool
+ @return: True if update commands have been performed, otherwise False
"""
# only do this if we're root and not running repoman/ebuild digest
+ retupd = False
if secpass < 2 or \
"SANDBOX_ACTIVE" in os.environ or \
len(trees) != 1:
- return 0
+ return retupd
root = "/"
- mysettings = trees["/"]["vartree"].settings
- retupd = []
-
+ mysettings = trees[root]["vartree"].settings
portdb = trees[root]["porttree"].dbapi
vardb = trees[root]["vartree"].dbapi
bindb = trees[root]["bintree"].dbapi
@@ -103,7 +102,8 @@ def _global_updates(trees, prev_mtimes):
else:
for msg in errors:
writemsg("%s\n" % msg, noiselevel=-1)
- retupd.extend(myupd)
+ if myupd:
+ retupd = True
master_repo = portdb.getRepositoryName(portdb.porttree_root)
if master_repo in repo_map:
@@ -127,6 +127,8 @@ def _global_updates(trees, prev_mtimes):
can find a match for old atom name, warn about that.
"""
matches = vardb.match(atoma)
+ if not matches:
+ matches = vardb.match(atomb)
if matches and \
repo_match(vardb.aux_get(best(matches), ['repository'])[0]):
if portdb.match(atoma):
@@ -142,10 +144,6 @@ def _global_updates(trees, prev_mtimes):
if _world_repo_match(atom, new_atom):
world_list[pos] = new_atom
world_modified = True
- update_config_files(root,
- mysettings.get("CONFIG_PROTECT","").split(),
- mysettings.get("CONFIG_PROTECT_MASK","").split(),
- myupd, match_callback=_world_repo_match)
for update_cmd in myupd:
if update_cmd[0] == "move":
@@ -165,9 +163,41 @@ def _global_updates(trees, prev_mtimes):
if moves:
writemsg_stdout(moves * "S")
+ if world_modified:
+ world_list.sort()
+ write_atomic(world_file,
+ "".join("%s\n" % (x,) for x in world_list))
+ if world_warnings:
+ # XXX: print warning that we've updated world entries
+ # and the old name still matches something (from an overlay)?
+ pass
+
+ if retupd:
+
+ def _config_repo_match(repo_name, atoma, atomb):
+ """
+ Check whether to perform a world change from atoma to atomb.
+ If best vardb match for atoma comes from the same repository
+ as the update file, allow that. Additionally, if portdb still
+ can find a match for old atom name, warn about that.
+ """
+ matches = vardb.match(atoma)
+ if not matches:
+ matches = vardb.match(atomb)
+ if not matches:
+ return False
+ repository = vardb.aux_get(best(matches), ['repository'])[0]
+ return repository == repo_name or \
+ (repo_name == master_repo and repository not in repo_map)
+
+ update_config_files(root,
+ shlex_split(mysettings.get("CONFIG_PROTECT", "")),
+ shlex_split(mysettings.get("CONFIG_PROTECT_MASK", "")),
+ repo_map, match_callback=_config_repo_match)
+
# The above global updates proceed quickly, so they
# are considered a single mtimedb transaction.
- if len(timestamps) > 0:
+ if timestamps:
# We do not update the mtime in the mtimedb
# until after _all_ of the above updates have
# been processed because the mtimedb will
@@ -175,7 +205,6 @@ def _global_updates(trees, prev_mtimes):
for mykey, mtime in timestamps.items():
prev_mtimes[mykey] = mtime
- if retupd:
do_upgrade_packagesmessage = False
# We gotta do the brute force updates for these now.
if mysettings.get("PORTAGE_CALLER") == "fixpackages" or \
@@ -204,14 +233,4 @@ def _global_updates(trees, prev_mtimes):
writemsg_stdout(bold(_("Note: This can take a very long time.")))
writemsg_stdout("\n")
- if world_modified:
- world_list.sort()
- write_atomic(world_file,
- "".join("%s\n" % (x,) for x in world_list))
- if world_warnings:
- # XXX: print warning that we've updated world entries
- # and the old name still matches something (from an overlay)?
- pass
-
- if retupd:
- return retupd
+ return retupd
diff --git a/pym/portage/update.py b/pym/portage/update.py
index b24c9cb0..7892f537 100644
--- a/pym/portage/update.py
+++ b/pym/portage/update.py
@@ -187,10 +187,18 @@ def update_config_files(config_root, protect, protect_mask, update_iter, match_c
config_root - location of files to update
protect - list of paths from CONFIG_PROTECT
protect_mask - list of paths from CONFIG_PROTECT_MASK
- update_iter - list of update commands as returned from parse_updates()
- match_callback - a callback which will be called with old and new atoms
+ update_iter - list of update commands as returned from parse_updates(),
+ or dict of {repo_name: list}
+ match_callback - a callback which will be called with three arguments:
+ match_callback(repo_name, old_atom, new_atom)
and should return boolean value determining whether to perform the update"""
+ repo_dict = None
+ if isinstance(update_iter, dict):
+ repo_dict = update_iter
+ if match_callback is None:
+ def match_callback(repo_name, atoma, atomb):
+ return True
config_root = normalize_path(config_root)
update_files = {}
file_contents = {}
@@ -242,24 +250,29 @@ def update_config_files(config_root, protect, protect_mask, update_iter, match_c
# update /etc/portage/packages.*
ignore_line_re = re.compile(r'^#|^\s*$')
- for update_cmd in update_iter:
- for x, contents in file_contents.items():
- for pos, line in enumerate(contents):
- if ignore_line_re.match(line):
- continue
- atom = line.split()[0]
- if atom.startswith("-"):
- # package.mask supports incrementals
- atom = atom[1:]
- if not isvalidatom(atom):
- continue
- new_atom = update_dbentry(update_cmd, atom)
- if atom != new_atom:
- if match_callback(atom, new_atom):
- contents[pos] = line.replace(atom, new_atom)
- update_files[x] = 1
- sys.stdout.write("p")
- sys.stdout.flush()
+ if repo_dict is None:
+ update_items = [(None, update_iter)]
+ else:
+ update_items = [x for x in repo_dict.items() if x[0] != 'DEFAULT']
+ for repo_name, update_iter in update_items:
+ for update_cmd in update_iter:
+ for x, contents in file_contents.items():
+ for pos, line in enumerate(contents):
+ if ignore_line_re.match(line):
+ continue
+ atom = line.split()[0]
+ if atom[:1] == "-":
+ # package.mask supports incrementals
+ atom = atom[1:]
+ if not isvalidatom(atom):
+ continue
+ new_atom = update_dbentry(update_cmd, atom)
+ if atom != new_atom:
+ if match_callback(repo_name, atom, new_atom):
+ contents[pos] = line.replace(atom, new_atom, 1)
+ update_files[x] = 1
+ sys.stdout.write("p")
+ sys.stdout.flush()
protect_obj = ConfigProtect(
config_root, protect, protect_mask)