handle packages load from aur by package name also

In general package names array may not contain package base, thus it
leads to inability to load packages from aur by its base during update
process
This commit is contained in:
2023-07-01 15:55:04 +03:00
parent f5fe200247
commit 95f52f7ebe
2 changed files with 46 additions and 5 deletions

View File

@ -20,6 +20,7 @@
from collections.abc import Iterable
from ahriman.core.build_tools.sources import Sources
from ahriman.core.exceptions import UnknownPackageError
from ahriman.core.repository.cleaner import Cleaner
from ahriman.models.package import Package
from ahriman.models.package_source import PackageSource
@ -53,6 +54,19 @@ class UpdateHandler(Cleaner):
Returns:
list[Package]: list of packages which are out-of-dated
"""
def load_remote(package: Package) -> Package:
source = package.remote.source if package.remote is not None else None
# try to load package from base and if none found try to load by separated packages
for probe in [package.base] + sorted(package.packages.keys()):
try:
if source == PackageSource.Repository:
return Package.from_official(probe, self.pacman, None)
return Package.from_aur(probe, self.pacman, None)
except UnknownPackageError:
continue
raise UnknownPackageError(package.base)
result: list[Package] = []
for local in self.packages():
@ -61,13 +75,9 @@ class UpdateHandler(Cleaner):
continue
if filter_packages and local.base not in filter_packages:
continue
source = local.remote.source if local.remote is not None else None
try:
if source == PackageSource.Repository:
remote = Package.from_official(local.base, self.pacman, None)
else:
remote = Package.from_aur(local.base, self.pacman, None)
remote = load_remote(local)
if local.is_outdated(
remote, self.paths,