mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 01:14:15 +02:00
[flatpak] sorting packages before updating
This commit is contained in:
@@ -79,21 +79,21 @@ class AURClient:
|
||||
self.logger.info('{p} is based on {b}. Retrieving {b} .SRCINFO'.format(p=info_name, b=info_base))
|
||||
return self.get_src_info(info_base)
|
||||
|
||||
def extract_all_dependencies(self, pkginfo: dict) -> Set[str]:
|
||||
def extract_required_dependencies(self, pkginfo: dict) -> Set[str]:
|
||||
deps = set()
|
||||
for attr in ('makedepends', 'depends', 'checkdepends'):
|
||||
if pkginfo.get(attr):
|
||||
deps.update([pacman.RE_DEP_OPERATORS.split(dep)[0] for dep in info[attr]])
|
||||
deps.update([pacman.RE_DEP_OPERATORS.split(dep)[0] for dep in pkginfo[attr]])
|
||||
|
||||
return deps
|
||||
|
||||
def get_all_dependencies(self, name: str) -> Set[str]:
|
||||
def get_required_dependencies(self, name: str) -> Set[str]:
|
||||
info = self.get_src_info(name)
|
||||
|
||||
if not info:
|
||||
raise PackageNotFoundException(name)
|
||||
|
||||
return self.extract_all_dependencies(info)
|
||||
return self.extract_required_dependencies(info)
|
||||
|
||||
def _map_names_as_queries(self, names) -> str:
|
||||
return '&'.join(['arg[{}]={}'.format(i, urllib.parse.quote(n)) for i, n in enumerate(names)])
|
||||
|
||||
@@ -1009,7 +1009,7 @@ class ArchManager(SoftwareManager):
|
||||
for n in names:
|
||||
names_map[n] = pkg
|
||||
|
||||
pkg_deps[pkg] = self.aur_client.extract_all_dependencies(srcinfo)
|
||||
pkg_deps[pkg] = self.aur_client.extract_required_dependencies(srcinfo)
|
||||
except:
|
||||
pkg_deps[pkg] = None
|
||||
self.logger.warning("Could not retrieve dependencies for '{}'".format(pkg.name))
|
||||
|
||||
@@ -71,7 +71,7 @@ class DependenciesAnalyser:
|
||||
|
||||
missing_sub = []
|
||||
for rdep in missing_root:
|
||||
subdeps = self.aur_client.get_all_dependencies(rdep[0]) if rdep[1] == 'aur' else pacman.read_dependencies(rdep[0])
|
||||
subdeps = self.aur_client.get_required_dependencies(rdep[0]) if rdep[1] == 'aur' else pacman.read_dependencies(rdep[0])
|
||||
subdeps_not_analysis = {sd for sd in subdeps if sd not in global_in_analysis}
|
||||
|
||||
if subdeps_not_analysis:
|
||||
@@ -93,7 +93,7 @@ class DependenciesAnalyser:
|
||||
in_analyses = {*names}
|
||||
|
||||
for name in names:
|
||||
subdeps = self.aur_client.get_all_dependencies(name) if mirror == 'aur' else pacman.read_dependencies(name)
|
||||
subdeps = self.aur_client.get_required_dependencies(name) if mirror == 'aur' else pacman.read_dependencies(name)
|
||||
|
||||
if subdeps:
|
||||
missing_subdeps = self.get_missing_packages(subdeps, in_analysis=in_analyses)
|
||||
|
||||
@@ -469,3 +469,28 @@ class FlatpakManager(SoftwareManager):
|
||||
except:
|
||||
return False, [traceback.format_exc()]
|
||||
|
||||
def sort_update_order(self, pkgs: List[FlatpakApplication]) -> List[FlatpakApplication]:
|
||||
partials, runtimes, apps = [], [], []
|
||||
|
||||
for p in pkgs:
|
||||
if p.runtime:
|
||||
if p.partial:
|
||||
partials.append(p)
|
||||
else:
|
||||
runtimes.append(p)
|
||||
else:
|
||||
apps.append(p)
|
||||
|
||||
if not runtimes:
|
||||
return [*partials, *apps]
|
||||
elif partials:
|
||||
all_runtimes = []
|
||||
for runtime in runtimes:
|
||||
for partial in partials:
|
||||
if partial.base_id == runtime.id:
|
||||
all_runtimes.append(partial)
|
||||
|
||||
all_runtimes.append(runtime)
|
||||
return [*all_runtimes, *apps]
|
||||
else:
|
||||
return [*runtimes, *apps]
|
||||
|
||||
@@ -10,7 +10,7 @@ class FlatpakApplication(SoftwarePackage):
|
||||
|
||||
def __init__(self, id: str = None, name: str = None, version: str = None, latest_version: str = None, description: str = None,
|
||||
branch: str = None, arch: str = None, origin: str = None, runtime: bool = False, ref: str = None, commit: str = None,
|
||||
installation: str = None, i18n: I18n = None):
|
||||
installation: str = None, i18n: I18n = None, partial: bool = False):
|
||||
super(FlatpakApplication, self).__init__(id=id, name=name, version=version,
|
||||
latest_version=latest_version, description=description)
|
||||
self.ref = ref
|
||||
@@ -19,7 +19,7 @@ class FlatpakApplication(SoftwarePackage):
|
||||
self.origin = origin
|
||||
self.runtime = runtime
|
||||
self.commit = commit
|
||||
self.partial = False
|
||||
self.partial = partial
|
||||
self.installation = installation if installation else 'system'
|
||||
self.i18n = i18n
|
||||
self.base_id = None
|
||||
|
||||
Reference in New Issue
Block a user