Update symlinks during package moves for bug #138394. This patch is from trunk r3687.
authorZac Medico <zmedico@gentoo.org>
Mon, 31 Jul 2006 19:00:10 +0000 (19:00 -0000)
committerZac Medico <zmedico@gentoo.org>
Mon, 31 Jul 2006 19:00:10 +0000 (19:00 -0000)
svn path=/main/branches/2.1/; revision=4072

pym/portage.py

index c15b3e443031840b6b2127907299eb0be3d1c9cd..880417652788d1cb4cae870af12abdab61786d0d 100644 (file)
@@ -5543,6 +5543,7 @@ class binarytree(packagetree):
                for cp in [origcp,newcp]:
                        if not (isvalidatom(cp) and isjustname(cp)):
                                raise portage_exception.InvalidPackageName(cp)
+               origcat = origcp.split("/")[0]
                mynewcat=newcp.split("/")[0]
                origmatches=self.dbapi.cp_list(origcp)
                if not origmatches:
@@ -5585,6 +5586,31 @@ class binarytree(packagetree):
                        if (mynewpkg != myoldpkg):
                                os.rename(tbz2path,self.getname(mynewcpv))
                        self.dbapi.cpv_inject(mynewcpv)
+
+                       # remove the old symlink and category directory, then create
+                       # the new ones.
+                       try:
+                               os.unlink(os.path.join(self.pkgdir, origcat, myoldpkg) + ".tbz2")
+                       except OSError, e:
+                               if e.errno != errno.ENOENT:
+                                       raise
+                       try:
+                               os.rmdir(os.path.join(self.pkgdir, origcat))
+                       except OSError, e:
+                               if e.errno not in (errno.ENOENT, errno.ENOTEMPTY):
+                                       raise
+                       try:
+                               os.makedirs(os.path.join(self.pkgdir, mynewcat))
+                       except OSError, e:
+                               if e.errno != errno.EEXIST:
+                                       raise
+                       try:
+                               os.unlink(os.path.join(self.pkgdir, mynewcat, mynewpkg) + ".tbz2")
+                       except OSError, e:
+                               if e.errno != errno.ENOENT:
+                                       raise
+                       os.symlink(os.path.join("..", "All", mynewpkg) + ".tbz2",
+                               os.path.join(self.pkgdir, mynewcat, mynewpkg) + ".tbz2")
                return 1
 
        def move_slot_ent(self, mylist):