Move the world file trimming out of dblink.unmerge() since the world file is package...
authorZac Medico <zmedico@gentoo.org>
Thu, 13 Jul 2006 23:33:05 +0000 (23:33 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 13 Jul 2006 23:33:05 +0000 (23:33 -0000)
svn path=/main/trunk/; revision=3868

bin/emerge
pym/portage.py

index d834fcda1716ada6068c06885e85000525796581..305c4b3d36a87de5528459db2e01f224a51298a9 100755 (executable)
@@ -595,6 +595,32 @@ def getlist(settings, mode):
 
        return mynewlines
 
+def clean_world(vardb, cpv):
+       """Remove a package from the world file when unmerged."""
+       world_filename = os.path.join(vardb.root, portage.WORLD_FILE)
+       worldlist = portage_util.grabfile(world_filename)
+       mykey = portage.cpv_getkey(cpv)
+       newworldlist = []
+       for x in worldlist:
+               if portage.dep_getkey(x) == mykey:
+                       matches = vardb.match(x, use_cache=0)
+                       if not matches:
+                               #zap our world entry
+                               pass
+                       elif len(matches) == 1 and matches[0] == cpv:
+                               #zap our world entry
+                               pass
+                       else:
+                               #others are around; keep it.
+                               newworldlist.append(x)
+               else:
+                       #this doesn't match the package we're unmerging; keep it.
+                       newworldlist.append(x)
+
+       portage_util.ensure_dirs(os.path.join(vardb.root, portage.PRIVATE_PATH),
+               uid=portage.portage_gid, mode=02770)
+       portage_util.write_atomic(world_filename, "\n".join(newworldlist))
+
 def genericdict(mylist):
        mynewdict={}
        for x in mylist:
@@ -2303,13 +2329,13 @@ def unmerge(settings, myopts, vartree, unmerge_action, unmerge_files,
                        retval = portage.unmerge(mysplit[0], mysplit[1], settings["ROOT"],
                                mysettings, unmerge_action not in ["clean","prune"],
                                vartree=vartree, ldpath_mtimes=ldpath_mtimes)
-                       if retval:
+                       if retval != os.EX_OK:
                                emergelog(xterm_titles, " !!! unmerge FAILURE: "+y)
                        else:
+                               clean_world(vartree.dbapi, y)
                                emergelog(xterm_titles, " >>> unmerge success: "+y)
        return 1
 
-
 def chk_updated_info_files(root, infodirs, prev_mtimes, retval):
 
        print
index 4ff350ce73e1a6409d9ebad629a168c4bc7f9e95..00f6a427fefbb7d356f1a41040bc1aadf17c8d6b 100644 (file)
@@ -6126,40 +6126,6 @@ class dblink:
                #remove self from vartree database so that our own virtual gets zapped if we're the last node
                self.vartree.zap(self.mycpv)
 
-               # New code to remove stuff from the world and virtuals files when unmerged.
-               if trimworld:
-                       worldlist = grabfile(os.path.join(self.myroot, WORLD_FILE))
-                       mykey=cpv_getkey(self.mycpv)
-                       newworldlist=[]
-                       for x in worldlist:
-                               if dep_getkey(x)==mykey:
-                                       matches = self.vartree.dbapi.match(x,use_cache=0)
-                                       if not matches:
-                                               #zap our world entry
-                                               pass
-                                       elif (len(matches)==1) and (matches[0]==self.mycpv):
-                                               #zap our world entry
-                                               pass
-                                       else:
-                                               #others are around; keep it.
-                                               newworldlist.append(x)
-                               else:
-                                       #this doesn't match the package we're unmerging; keep it.
-                                       newworldlist.append(x)
-
-                       # if the base dir doesn't exist, create it.
-                       # (spanky noticed bug)
-                       # XXX: dumb question, but abstracting the root uid might be wise/useful for
-                       # 2nd pkg manager installation setups.
-                       my_private_path = os.path.join(self.myroot, PRIVATE_PATH)
-                       if not os.path.exists(my_private_path):
-                               os.makedirs(my_private_path, mode=0755)
-                               os.chown(my_private_path, 0, portage_gid)
-                               os.chmod(my_private_path, 02770)
-
-                       write_atomic(os.path.join(self.myroot, WORLD_FILE),
-                       "\n".join(newworldlist))
-
                #do original postrm
                if myebuildpath and os.path.exists(myebuildpath):
                        # XXX: This should be the old config, not the current one.