mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 01:14:15 +02:00
[aur] initial retrievement of update requirements implementation
This commit is contained in:
@@ -90,6 +90,15 @@ class SoftwareManager(ABC):
|
|||||||
"""
|
"""
|
||||||
return pkgs
|
return pkgs
|
||||||
|
|
||||||
|
def get_update_requirements(self, pkgs: List[SoftwarePackage], watcher: ProcessWatcher) -> List[SoftwarePackage]:
|
||||||
|
"""
|
||||||
|
return additional required software that needs to be installed before updating a list of packages
|
||||||
|
:param pkgs:
|
||||||
|
:param watcher
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
return []
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def update(self, pkg: SoftwarePackage, root_password: str, watcher: ProcessWatcher) -> bool:
|
def update(self, pkg: SoftwarePackage, root_password: str, watcher: ProcessWatcher) -> bool:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -1081,3 +1081,39 @@ class ArchManager(SoftwareManager):
|
|||||||
sorted_names[pkg.name] = idx
|
sorted_names[pkg.name] = idx
|
||||||
|
|
||||||
return sorted_names[pkg.name]
|
return sorted_names[pkg.name]
|
||||||
|
|
||||||
|
def get_update_requirements(self, pkgs: List[ArchPackage], watcher: ProcessWatcher) -> List[ArchPackage]:
|
||||||
|
deps = self._map_known_missing_deps({p.get_base_name(): 'aur' for p in pkgs}, watcher)
|
||||||
|
|
||||||
|
if deps:
|
||||||
|
pkg_names = {p.name for p in pkgs}
|
||||||
|
return [ArchPackage(name=pkg[0]) for pkg in deps if pkg[0] not in pkg_names]
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
|
# def add_srcinfo(pkg: ArchPackage):
|
||||||
|
# try:
|
||||||
|
# srcinfo = self.aur_client.get_src_info(pkg.get_base_name())
|
||||||
|
# pkg.src_info = srcinfo
|
||||||
|
# pkg.dependencies = self.aur_client.extract_required_dependencies(pkg.src_info)
|
||||||
|
# except:
|
||||||
|
# self.logger.warning("Could not retrieve the SRCINFO for package {}".format(pkg.name))
|
||||||
|
#
|
||||||
|
# threads = []
|
||||||
|
#
|
||||||
|
# for p in pkgs:
|
||||||
|
# t = Thread(target=add_srcinfo, args=(p,))
|
||||||
|
# t.start()
|
||||||
|
# threads.append(t)
|
||||||
|
#
|
||||||
|
# for t in threads:
|
||||||
|
# t.join()
|
||||||
|
#
|
||||||
|
# for p in pkgs:
|
||||||
|
# if p.src_info and p.dependencies:
|
||||||
|
# self.inst
|
||||||
|
# else:
|
||||||
|
# self.logger.warning("Not checking update requirements for package {}".format(pkg.name))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import datetime
|
import datetime
|
||||||
from typing import List
|
from typing import List, Set
|
||||||
|
|
||||||
from bauh.api.abstract.model import SoftwarePackage
|
from bauh.api.abstract.model import SoftwarePackage
|
||||||
from bauh.commons import resource
|
from bauh.commons import resource
|
||||||
@@ -14,7 +14,7 @@ class ArchPackage(SoftwarePackage):
|
|||||||
package_base: str = None, votes: int = None, popularity: float = None,
|
package_base: str = None, votes: int = None, popularity: float = None,
|
||||||
first_submitted: datetime.datetime = None, last_modified: datetime.datetime = None,
|
first_submitted: datetime.datetime = None, last_modified: datetime.datetime = None,
|
||||||
maintainer: str = None, url_download: str = None, pkgbuild: str = None, mirror: str = None,
|
maintainer: str = None, url_download: str = None, pkgbuild: str = None, mirror: str = None,
|
||||||
desktop_entry: str = None, installed: bool = False):
|
desktop_entry: str = None, installed: bool = False, srcinfo: dict = None, dependencies: Set[str] = None):
|
||||||
|
|
||||||
super(ArchPackage, self).__init__(name=name, version=version, latest_version=latest_version, description=description, installed=installed)
|
super(ArchPackage, self).__init__(name=name, version=version, latest_version=latest_version, description=description, installed=installed)
|
||||||
self.package_base = package_base
|
self.package_base = package_base
|
||||||
@@ -30,6 +30,8 @@ class ArchPackage(SoftwarePackage):
|
|||||||
self.icon_path = None
|
self.icon_path = None
|
||||||
self.downgrade_enabled = False
|
self.downgrade_enabled = False
|
||||||
self.desktop_entry = desktop_entry
|
self.desktop_entry = desktop_entry
|
||||||
|
self.src_info = srcinfo
|
||||||
|
self.dependencies = dependencies
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def disk_cache_path(pkgname: str, mirror: str):
|
def disk_cache_path(pkgname: str, mirror: str):
|
||||||
|
|||||||
@@ -446,3 +446,28 @@ class GenericSoftwareManager(SoftwareManager):
|
|||||||
sorted_list.extend(pkgs)
|
sorted_list.extend(pkgs)
|
||||||
|
|
||||||
return sorted_list
|
return sorted_list
|
||||||
|
|
||||||
|
def get_update_requirements(self, pkgs: List[SoftwarePackage], watcher: ProcessWatcher) -> 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)
|
||||||
|
|
||||||
|
required = []
|
||||||
|
|
||||||
|
if by_manager:
|
||||||
|
for man, pkgs in by_manager.items():
|
||||||
|
ti = time.time()
|
||||||
|
required.extend(man.get_update_requirements(pkgs, watcher))
|
||||||
|
tf = time.time()
|
||||||
|
self.logger.info(man.__class__.__name__ + " took {0:.2f} seconds".format(tf - ti))
|
||||||
|
|
||||||
|
return required
|
||||||
|
|||||||
@@ -107,11 +107,14 @@ class UpdateSelectedApps(AsyncAction):
|
|||||||
|
|
||||||
app_config = config.read_config()
|
app_config = config.read_config()
|
||||||
|
|
||||||
|
models = [view.model for view in self.pkgs]
|
||||||
|
required_pkgs = self.manager.get_update_requirements(models, self)
|
||||||
|
|
||||||
if bool(app_config['updates']['sort_packages']):
|
if bool(app_config['updates']['sort_packages']):
|
||||||
self.change_substatus(self.i18n['action.update.status.sorting'])
|
self.change_substatus(self.i18n['action.update.status.sorting'])
|
||||||
sorted_pkgs = self.manager.sort_update_order([view.model for view in self.pkgs])
|
sorted_pkgs = self.manager.sort_update_order()
|
||||||
else:
|
else:
|
||||||
sorted_pkgs = [view.model for view in self.pkgs]
|
sorted_pkgs = models
|
||||||
|
|
||||||
for pkg in sorted_pkgs:
|
for pkg in sorted_pkgs:
|
||||||
self.change_substatus('')
|
self.change_substatus('')
|
||||||
|
|||||||
Reference in New Issue
Block a user