summaryrefslogtreecommitdiffstats
path: root/pym/portage/update.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-09-09 09:34:49 -0700
committerZac Medico <zmedico@gentoo.org>2010-09-09 09:34:49 -0700
commit7a26634d5d7d02c49dce17b81d8271d509abd4d0 (patch)
treef17af8369e9589e70737fbf814bf543b36cc3d73 /pym/portage/update.py
parent8381b7d50228d7a9dc2a8d4bf7b142e678c4e98e (diff)
downloadportage-7a26634d5d7d02c49dce17b81d8271d509abd4d0.tar.gz
portage-7a26634d5d7d02c49dce17b81d8271d509abd4d0.tar.bz2
portage-7a26634d5d7d02c49dce17b81d8271d509abd4d0.zip
In update_config_files(), add a comment line showing a package move
that has been applied. This is intended to reduce the risk given that /etc/portage is in CONFIG_PROTECT_MASK, as discussed in bug
Diffstat (limited to 'pym/portage/update.py')
-rw-r--r--pym/portage/update.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/pym/portage/update.py b/pym/portage/update.py
index 62dbf93f0..37cab2503 100644
--- a/pym/portage/update.py
+++ b/pym/portage/update.py
@@ -262,7 +262,11 @@ def update_config_files(config_root, protect, protect_mask, update_iter, match_c
for repo_name, update_iter in update_items:
for update_cmd in update_iter:
for x, contents in file_contents.items():
+ skip_next = False
for pos, line in enumerate(contents):
+ if skip_next:
+ skip_next = False
+ continue
if ignore_line_re.match(line):
continue
atom = line.split()[0]
@@ -274,7 +278,16 @@ def update_config_files(config_root, protect, protect_mask, update_iter, match_c
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)
+ # add a comment with the update command, so
+ # the user can clearly see what happened
+ contents[pos] = "# %s\n" % \
+ " ".join("%s" % (x,) for x in update_cmd)
+ contents.insert(pos + 1,
+ line.replace("%s" % (atom,),
+ "%s" % (new_atom,), 1))
+ # we've inserted an additional line, so we need to
+ # skip it when it's reached in the next iteration
+ skip_next = True
update_files[x] = 1
sys.stdout.write("p")
sys.stdout.flush()