# 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):
# 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
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)
#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 = {}
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
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]