For bug #157370, make `emerge --regen` cleanse stale cache entries.
authorZac Medico <zmedico@gentoo.org>
Fri, 8 Dec 2006 06:28:28 +0000 (06:28 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 8 Dec 2006 06:28:28 +0000 (06:28 -0000)
svn path=/main/trunk/; revision=5220

bin/emerge

index 66030eda68fd8c971aadbcf9103b57215acf6803..0ebac0b0c9f32257da231030b0fa22b3624239df 100755 (executable)
@@ -3622,6 +3622,15 @@ def action_regen(settings, portdb):
                pass
        sys.stdout.flush()
        mynodes = portdb.cp_all()
+       from cache.cache_errors import CacheError
+       dead_nodes = {}
+       for mytree in portdb.porttrees:
+               try:
+                       dead_nodes[mytree] = set(portdb.auxdb[mytree].iterkeys())
+               except CacheError, e:
+                       print "\n  error listing cache entries for " + \
+                               "'%s': %s, continuing..." % (mytree, e)
+                       dead_nodes = None
        for x in mynodes:
                mymatches = portdb.xmatch("match-all",x)
                portage.writemsg_stdout("processing %s\n" % x)
@@ -3633,6 +3642,18 @@ def action_regen(settings, portdb):
                                raise
                        except Exception, e:
                                print "\n  error processing %(cpv)s, continuing... (%(e)s)" % {"cpv":y,"e":str(e)}
+                       if dead_nodes:
+                               for mytree in portdb.porttrees:
+                                       if portdb.findname2(y, mytree=mytree)[0]:
+                                               dead_nodes[mytree].discard(y)
+       if dead_nodes:
+               for mytree, nodes in dead_nodes.iteritems():
+                       auxdb = portdb.auxdb[mytree]
+                       for y in nodes:
+                               try:
+                                       del auxdb[y]
+                               except KeyError, CacheError:
+                                       pass
        print "done!"
 
 def action_config(settings, trees, myopts, myfiles):