diff options
author | Zac Medico <zmedico@gentoo.org> | 2007-05-31 04:49:16 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2007-05-31 04:49:16 +0000 |
commit | ba32174f699657690d4a710e4de84fe7ce16c6aa (patch) | |
tree | b59f901e2d2a8ca98713779b42e742a46fec7531 | |
parent | ad5abe215bcf7ee73faa6e27c3f8f99141dc4622 (diff) | |
download | portage-ba32174f699657690d4a710e4de84fe7ce16c6aa.tar.gz portage-ba32174f699657690d4a710e4de84fe7ce16c6aa.tar.bz2 portage-ba32174f699657690d4a710e4de84fe7ce16c6aa.zip |
Create one unified dbapi.update_ents() method and use it for both fixpackages and the emaint move{inst,bin} targets.
svn path=/main/trunk/; revision=6686
-rwxr-xr-x | bin/emaint | 18 | ||||
-rw-r--r-- | pym/portage/__init__.py | 5 | ||||
-rw-r--r-- | pym/portage/dbapi/__init__.py | 25 | ||||
-rw-r--r-- | pym/portage/dbapi/bintree.py | 23 | ||||
-rw-r--r-- | pym/portage/dbapi/vartree.py | 13 |
5 files changed, 31 insertions, 53 deletions
diff --git a/bin/emaint b/bin/emaint index 174b4540d..1c179df10 100755 --- a/bin/emaint +++ b/bin/emaint @@ -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): diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index c61c0bda9..1448133f2 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -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 diff --git a/pym/portage/dbapi/__init__.py b/pym/portage/dbapi/__init__.py index b4ec89e53..fce395b00 100644 --- a/pym/portage/dbapi/__init__.py +++ b/pym/portage/dbapi/__init__.py @@ -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) diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index 7942a45dc..66d89cb0b 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -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 diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 3c4077e70..2283b5a31 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -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] |