summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-06-02 22:20:51 -0700
committerZac Medico <zmedico@gentoo.org>2011-06-02 22:20:51 -0700
commit06e52616eb461c260ef8a006578babb04a4b5848 (patch)
treeea2c70242d27cb859bb8ff7b1989e62ae9e315d5 /pym
parent336f02148b0a90e1933d7ca68a32f3bd5e9433d6 (diff)
downloadportage-06e52616eb461c260ef8a006578babb04a4b5848.tar.gz
portage-06e52616eb461c260ef8a006578babb04a4b5848.tar.bz2
portage-06e52616eb461c260ef8a006578babb04a4b5848.zip
autounmask-write: force configpro if non-existent
We want to force new_protect_filename to ensure that the user will see all our changes via etc-update, even if file_to_write_to doesn't exist yet.
Diffstat (limited to 'pym')
-rw-r--r--pym/_emerge/depgraph.py7
-rw-r--r--pym/portage/util/__init__.py9
2 files changed, 12 insertions, 4 deletions
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index b71d3648d..b60fd19fb 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -5846,7 +5846,12 @@ class depgraph(object):
if file_contents is not None:
file_contents.extend(changes)
if protect_obj[root].isprotected(file_to_write_to):
- file_to_write_to = new_protect_filename(file_to_write_to)
+ # We want to force new_protect_filename to ensure
+ # that the user will see all our changes via
+ # etc-update, even if file_to_write_to doesn't
+ # exist yet, so we specify force=True.
+ file_to_write_to = new_protect_filename(file_to_write_to,
+ force=True)
try:
write_atomic(file_to_write_to, "".join(file_contents))
except PortageException:
diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py
index 94e4451ad..138553a16 100644
--- a/pym/portage/util/__init__.py
+++ b/pym/portage/util/__init__.py
@@ -1473,9 +1473,11 @@ class ConfigProtect(object):
masked = len(pmpath)
return protected > masked
-def new_protect_filename(mydest, newmd5=None):
+def new_protect_filename(mydest, newmd5=None, force=False):
"""Resolves a config-protect filename for merging, optionally
- using the last filename if the md5 matches.
+ using the last filename if the md5 matches. If force is True,
+ then a new filename will be generated even if mydest does not
+ exist yet.
(dest,md5) ==> 'string' --- path_to_target_filename
(dest) ==> ('next', 'highest') --- next_target and most-recent_target
"""
@@ -1489,7 +1491,8 @@ def new_protect_filename(mydest, newmd5=None):
prot_num = -1
last_pfile = ""
- if not os.path.exists(mydest):
+ if not force and \
+ not os.path.exists(mydest):
return mydest
real_filename = os.path.basename(mydest)