summaryrefslogtreecommitdiffstats
path: root/pym/portage/update.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-08-01 01:14:51 -0700
committerZac Medico <zmedico@gentoo.org>2010-08-01 01:14:51 -0700
commit7f59dca5ca8a7a8fd5cda5912174698b93dc0dac (patch)
treec20be4baa92d0abcf77ffd38e8e11c4cb16d81eb /pym/portage/update.py
parent3282ac5c7b9ec7102a8ac6683c1647366cee0ba8 (diff)
downloadportage-7f59dca5ca8a7a8fd5cda5912174698b93dc0dac.tar.gz
portage-7f59dca5ca8a7a8fd5cda5912174698b93dc0dac.tar.bz2
portage-7f59dca5ca8a7a8fd5cda5912174698b93dc0dac.zip
Make update_config_files() take a dict of {repo_name: list} since it's more
efficient this way, and this function can't be called separately for each repo if /etc/portage is under CONFIG_PROTECT (because it would produce separate updated files for each repo).
Diffstat (limited to 'pym/portage/update.py')
-rw-r--r--pym/portage/update.py53
1 files changed, 33 insertions, 20 deletions
diff --git a/pym/portage/update.py b/pym/portage/update.py
index b24c9cb0c..7892f537d 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)