most efficient to process all repos at once.
# Searching for updates in all the metadata is relatively slow, so this
# is where the progress bar comes out of indeterminate mode.
- for repo, updates in allupdates.items():
- self._tree.dbapi.update_ents(updates, onProgress=onProgress, repo=repo)
+ self._tree.dbapi.update_ents(allupdates, onProgress=onProgress)
return errors
class MoveInstalled(MoveHandler):
world_list = grabfile(world_file)
world_modified = False
world_warnings = set()
+ updpath_map = {}
+ repo_map = {}
for repo_name in portdb.getRepositories():
repo = portdb.getRepositoryPath(repo_name)
# as a backwards-compatibility measure, fallback to PORTDIR
updpath = os.path.join(portdb.porttree_root, "profiles", "updates")
+ if updpath in updpath_map:
+ repo_map[repo_name] = updpath_map[updpath]
+ continue
+
try:
if mysettings.get("PORTAGE_CALLER") == "fixpackages":
update_data = grab_updates(updpath)
update_data = grab_updates(updpath, prev_mtimes)
except DirectoryNotFound:
continue
- myupd = None
+ myupd = []
+ updpath_map[updpath] = myupd
+ repo_map[repo_name] = myupd
if len(update_data) > 0:
do_upgrade_packagesmessage = 0
- myupd = []
timestamps = {}
for mykey, mystat, mycontent in update_data:
writemsg_stdout("\n\n")
writemsg("%s\n" % msg, noiselevel=-1)
retupd.extend(myupd)
+ for repo_name, myupd in repo_map.items():
def _world_repo_match(atoma, atomb):
"""
Check whether to perform a world change from atoma to atomb.
for mykey, mtime in timestamps.items():
prev_mtimes[mykey] = mtime
+ if repo_map:
# We gotta do the brute force updates for these now.
if mysettings.get("PORTAGE_CALLER") == "fixpackages" or \
"fixpackages" in mysettings.features:
def onUpdate(maxval, curval):
if curval > 0:
writemsg_stdout("#")
- vardb.update_ents(myupd, onUpdate=onUpdate, repo=repo_name)
+ vardb.update_ents(repo_map, onUpdate=onUpdate)
if bindb:
def onUpdate(maxval, curval):
if curval > 0:
writemsg_stdout("*")
- bindb.update_ents(myupd, onUpdate=onUpdate, repo=repo_name)
+ bindb.update_ents(repo_map, onUpdate=onUpdate)
else:
do_upgrade_packagesmessage = 1
else:
writemsg("!!! Invalid db entry: %s\n" % mypath, noiselevel=-1)
- def update_ents(self, updates, onProgress=None, onUpdate=None, repo=None):
+ def update_ents(self, updates, onProgress=None, onUpdate=None):
"""
Update metadata of all packages for package moves.
- @param updates: A list of move commands
- @type updates: List
+ @param updates: A list of move commands, or dict of {repo_name: list}
+ @type updates: list or dict
@param onProgress: A progress callback function
@type onProgress: a callable that takes 2 integer arguments: maxval and curval
@param onUpdate: A progress callback function called only
for packages that are modified by updates.
@type onUpdate: a callable that takes 2 integer arguments:
maxval and curval
- @param repo: Name of the repository which packages should be updated
- @type repo: string
"""
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"]
+ meta_keys = ["DEPEND", "RDEPEND", "PDEPEND", "PROVIDE", 'repository']
+ repo_dict = None
+ if isinstance(updates, dict):
+ repo_dict = updates
from portage.update import update_dbentries
if onUpdate:
onUpdate(maxval, 0)
if onProgress:
onProgress(maxval, 0)
for i, cpv in enumerate(cpv_all):
- if repo and aux_get(cpv, ['repository'])[0] != repo:
- continue
- metadata = dict(zip(update_keys, aux_get(cpv, update_keys)))
- metadata_updates = update_dbentries(updates, metadata)
+ metadata = dict(zip(meta_keys, aux_get(cpv, meta_keys)))
+ repo = metadata.pop('repository')
+ if repo_dict is None:
+ updates_list = updates
+ else:
+ updates_list = repo_dict.get(repo)
+ if updates_list is None:
+ continue
+
+ metadata_updates = update_dbentries(updates_list, metadata)
if metadata_updates:
aux_update(cpv, metadata_updates)
if onUpdate: