[aur] initial implementation to determine the best update order

This commit is contained in:
Vinícius Moreira
2020-02-05 18:46:55 -03:00
parent a11f418759
commit a10851a16f
11 changed files with 260 additions and 11 deletions

View File

@@ -419,3 +419,28 @@ class GenericSoftwareManager(SoftwareManager):
self.settings_manager = None
return res
def sort_update_order(self, pkgs: List[SoftwarePackage]) -> List[SoftwarePackage]:
by_manager = {}
for pkg in pkgs:
man = self._get_manager_for(pkg)
if man:
man_pkgs = by_manager.get(man)
if man_pkgs is None:
man_pkgs = []
by_manager[man] = man_pkgs
man_pkgs.append(pkg)
sorted_list = []
if by_manager:
for man, pkgs in by_manager.items():
ti = time.time()
sorted_list.extend(man.sort_update_order(pkgs))
tf = time.time()
self.logger.info(man.__class__.__name__ + " took {0:.2f} seconds".format(tf - ti))
return sorted_list

View File

@@ -103,19 +103,23 @@ class UpdateSelectedApps(AsyncAction):
if self.apps_to_update:
updated, updated_types = 0, set()
for app in self.apps_to_update:
name = app.model.name if not RE_VERSION_IN_NAME.findall(app.model.name) else app.model.name.split('version')[0].strip()
self.change_substatus(self.i18n['action.update.status.sorting'])
sorted_pkgs = self.manager.sort_update_order([view.model for view in self.apps_to_update])
self.change_status('{} {} {}...'.format(self.i18n['manage_window.status.upgrading'], name, app.model.version))
success = bool(self.manager.update(app.model, self.root_password, self))
for pkg in sorted_pkgs:
name = pkg.name if not RE_VERSION_IN_NAME.findall(pkg.name) else pkg.name.split('version')[0].strip()
self.change_status('{} {} {}...'.format(self.i18n['manage_window.status.upgrading'], name, pkg.version))
success = bool(self.manager.update(pkg, self.root_password, self))
self.change_substatus('')
if not success:
break
else:
updated += 1
updated_types.add(app.model.__class__)
updated_types.add(pkg.__class__)
self.signal_output.emit('\n')
self.notify_finished({'success': success, 'updated': updated, 'types': updated_types})

View File

@@ -265,4 +265,5 @@ locale.it=italià
interval=interval
installation=instal·lació
download=download
clean=netejar
clean=netejar
action.update.status.sorting=Determinant el millor ordre dactualització

View File

@@ -220,4 +220,5 @@ locale.it=italienisch
interval=intervall
installation=Installation
download=download
clean=reinigen
clean=reinigen
action.update.status.sorting=Determining the best update order

View File

@@ -227,4 +227,5 @@ locale.it=italian
interval=interval
installation=installation
download=download
clean=clean
clean=clean
action.update.status.sorting=Determining the best update order

View File

@@ -268,4 +268,5 @@ locale.it=italiano
interval=intervalo
installation=instalación
download=descarga
clean=limpiar
clean=limpiar
action.update.status.sorting=Determinando el mejor orden de actualización

View File

@@ -220,4 +220,5 @@ locale.it=italiano
interval=intervallo
installation=installazione
download=download
clean=pulire
clean=pulire
action.update.status.sorting=Sto determinando il miglior ordine di aggiornamento

View File

@@ -271,4 +271,5 @@ locale.it=italiano
interval=intervalo
installation=instalação
download=download
clean=limpar
clean=limpar
action.update.status.sorting=Determinando a melhor ordem de atualização