Create one unified dbapi.update_ents() method and use it for both fixpackages and...
authorZac Medico <zmedico@gentoo.org>
Thu, 31 May 2007 04:49:16 +0000 (04:49 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 31 May 2007 04:49:16 +0000 (04:49 -0000)
svn path=/main/trunk/; revision=6686

bin/emaint
pym/portage/__init__.py
pym/portage/dbapi/__init__.py
pym/portage/dbapi/bintree.py
pym/portage/dbapi/vartree.py

index 174b4540dd3e28df3ed61d7a055ee2747ef0c004..1c179df10cf4a39995fb135b24c4b6dd82b1f378 100755 (executable)
@@ -246,23 +246,7 @@ class MoveHandler(object):
 
                # Searching for updates in all the metadata is relatively slow, so this
                # is where the progress bar comes out of indeterminate mode.
-               cpv_all = self._tree.dbapi.cpv_all()
-               cpv_all.sort()
-               maxval = len(cpv_all)
-               aux_get = self._tree.dbapi.aux_get
-               aux_update = self._tree.dbapi.aux_update
-               update_keys = self._update_keys
-               from itertools import izip
-               from portage.update import update_dbentries
-               if onProgress:
-                       onProgress(maxval, 0)
-               for i, cpv in enumerate(cpv_all):
-                       metadata = dict(izip(update_keys, aux_get(cpv, update_keys)))
-                       metadata_updates = update_dbentries(updates, metadata)
-                       if metadata_updates:
-                               aux_update(cpv, metadata_updates)
-                       if onProgress:
-                               onProgress(maxval, i+1)
+               self._tree.dbapi.update_ents(updates, onProgress=onProgress)
                return errors
 
 class MoveInstalled(MoveHandler):
index c61c0bda91787e957c6723bda25ea04134d2ecec..1448133f26ba160437c43a9022ec70475b73affc 100644 (file)
@@ -5097,7 +5097,10 @@ def global_updates(mysettings, trees, prev_mtimes):
                # We gotta do the brute force updates for these now.
                if mysettings["PORTAGE_CALLER"] == "fixpackages" or \
                "fixpackages" in mysettings.features:
-                       trees["/"]["bintree"].update_ents(myupd)
+                       def onProgress(maxval, curval):
+                               writemsg_stdout("*")
+                       vardb.update_ents(myupd, onProgress=onProgress)
+                       bindb.update_ents(myupd, onProgress=onProgress)
                else:
                        do_upgrade_packagesmessage = 1
 
index b4ec89e53fb45473b38a6526ed76ac4eb6c7368b..fce395b00321a530bb55fd8e48243931811c1c19 100644 (file)
@@ -53,3 +53,28 @@ class dbapi(object):
                else:
                        writemsg("!!! Invalid db entry: %s\n" % mypath, noiselevel=-1)
 
+       def update_ents(self, updates, onProgress=None):
+               """
+               Update metadata of all packages for packages moves.
+               @param updates: A list of move commands
+               @type updates: List
+               @param onProgress: A progress callback function
+               @type onProgress: a callable that takes 2 integer arguments: maxval and curval
+               """
+               cpv_all = self.cpv_all()
+               cpv_all.sort()
+               maxval = len(cpv_all)
+               aux_get = self.aux_get
+               aux_update = self.aux_update
+               update_keys = ["DEPEND", "RDEPEND", "PDEPEND", "PROVIDE"]
+               from itertools import izip
+               from portage.update import update_dbentries
+               if onProgress:
+                       onProgress(maxval, 0)
+               for i, cpv in enumerate(cpv_all):
+                       metadata = dict(izip(update_keys, aux_get(cpv, update_keys)))
+                       metadata_updates = update_dbentries(updates, metadata)
+                       if metadata_updates:
+                               aux_update(cpv, metadata_updates)
+                       if onProgress:
+                               onProgress(maxval, i+1)
index 7942a45dc66d6e5057509031534ad9c9ace52987..66d89cb0ba764d750cab92b7ed87bbcaca6ea7f5 100644 (file)
@@ -111,6 +111,7 @@ class binarytree(object):
                        #self.pkgdir=settings["PKGDIR"]
                        self.pkgdir = normalize_path(pkgdir)
                        self.dbapi = bindbapi(self, settings=settings)
+                       self.update_ents = self.dbapi.update_ents
                        self.populated = 0
                        self.tree = {}
                        self.remotepkgs = {}
@@ -267,28 +268,6 @@ class binarytree(object):
                        mytbz2.recompose_mem(portage.xpak.xpak_mem(mydata))
                return moves
 
-       def update_ents(self, update_iter):
-               if len(update_iter) == 0:
-                       return
-               if not self.populated:
-                       self.populate()
-
-               for mycpv in self.dbapi.cp_all():
-                       tbz2path = self.getname(mycpv)
-                       if os.path.exists(tbz2path) and not os.access(tbz2path,os.W_OK):
-                               writemsg("!!! Cannot update readonly binary: "+mycpv+"\n",
-                                       noiselevel=-1)
-                               continue
-                       #print ">>> Updating binary data:",mycpv
-                       writemsg_stdout("*")
-                       mytbz2 = portage.xpak.tbz2(tbz2path)
-                       mydata = mytbz2.get_data()
-                       updated_items = update_dbentries(update_iter, mydata)
-                       if len(updated_items) > 0:
-                               mydata.update(updated_items)
-                               mytbz2.recompose_mem(portage.xpak.xpak_mem(mydata))
-               return 1
-
        def prevent_collision(self, cpv):
                """Make sure that the file location ${PKGDIR}/All/${PF}.tbz2 is safe to
                use for a given cpv.  If a collision will occur with an existing
index 3c4077e70b567114058a81f880658972b7bdc7b0..2283b5a31ff9bd22fe0f4aead9bc64c2664111a7 100644 (file)
@@ -316,19 +316,6 @@ class vardbapi(dbapi):
                        fixdbentries([mylist], newpath)
                return moves
 
-       def update_ents(self, update_iter):
-               """Run fixdbentries on all installed packages (time consuming).  Like
-               fixpackages, this should be run from a helper script and display
-               a progress indicator."""
-               dbdir = os.path.join(self.root, VDB_PATH)
-               for catdir in listdir(dbdir):
-                       catdir = dbdir+"/"+catdir
-                       if os.path.isdir(catdir):
-                               for pkgdir in listdir(catdir):
-                                       pkgdir = catdir+"/"+pkgdir
-                                       if os.path.isdir(pkgdir):
-                                               fixdbentries(update_iter, pkgdir)
-
        def move_slot_ent(self, mylist):
                pkg = mylist[1]
                origslot = mylist[2]