Fix package moves/slotmoves to work with slot deps.
authorZac Medico <zmedico@gentoo.org>
Thu, 5 Oct 2006 11:15:05 +0000 (11:15 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 5 Oct 2006 11:15:05 +0000 (11:15 -0000)
svn path=/main/trunk/; revision=4597

pym/portage_update.py

index b6a724560b9a93db66f39d658d52f22a1d9dff14..f9622778915aa0984668dcd1a2de56fe9978fb61 100644 (file)
@@ -7,6 +7,7 @@ import errno, os, re, sys
 from portage_util import ConfigProtect, grabfile, new_protect_filename, \
        normalize_path, write_atomic, writemsg
 from portage_exception import DirectoryNotFound, PortageException
+from portage_versions import ververify
 from portage_dep import dep_getkey, isvalidatom, isjustname
 from portage_const import USER_CONFIG_PATH, WORLD_FILE
 
@@ -17,10 +18,20 @@ def update_dbentry(update_cmd, mycontent):
                old_value, new_value = update_cmd[1], update_cmd[2]
                if mycontent.count(old_value):
                        old_value = re.escape(old_value);
-                       mycontent = re.sub(old_value+"$", new_value, mycontent)
-                       mycontent = re.sub(old_value+"(\\s)", new_value+"\\1", mycontent)
-                       mycontent = re.sub(old_value+"(-[^a-zA-Z])", new_value+"\\1", mycontent)
-                       mycontent = re.sub(old_value+"([^a-zA-Z0-9-])", new_value+"\\1", mycontent)
+                       mycontent = re.sub(old_value+"(:|$|\\s)", new_value+"\\1", mycontent)
+                       def myreplace(matchobj):
+                               if ververify(matchobj.group(2)):
+                                       return "%s-%s" % (new_value, matchobj.group(2))
+                               else:
+                                       return "".join(matchobj.groups())
+                       mycontent = re.sub("(%s-)(\\S*)" % old_value, myreplace, mycontent)
+       elif update_cmd[0] == "slotmove":
+               pkg, origslot, newslot = update_cmd[1:]
+               old_value = "%s:%s" % (pkg, origslot)
+               if mycontent.count(old_value):
+                       old_value = re.escape(old_value)
+                       new_value = "%s:%s" % (pkg, newslot)
+                       mycontent = re.sub(old_value+"($|\\s)", new_value+"\\1", mycontent)
        return mycontent
 
 def update_dbentries(update_iter, mydata):