mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 02:24:16 +02:00
[fix][arch] actually fixing some installed 'not-signed' repository packages
This commit is contained in:
@@ -80,8 +80,11 @@ class AURClient:
|
|||||||
return self.http_client.get_json(URL_SEARCH + words)
|
return self.http_client.get_json(URL_SEARCH + words)
|
||||||
|
|
||||||
def get_info(self, names: Iterable[str]) -> List[dict]:
|
def get_info(self, names: Iterable[str]) -> List[dict]:
|
||||||
|
try:
|
||||||
res = self.http_client.get_json(URL_INFO + self._map_names_as_queries(names))
|
res = self.http_client.get_json(URL_INFO + self._map_names_as_queries(names))
|
||||||
return res['results'] if res and res.get('results') else []
|
return res['results'] if res and res.get('results') else []
|
||||||
|
except:
|
||||||
|
return []
|
||||||
|
|
||||||
def get_src_info(self, name: str) -> dict:
|
def get_src_info(self, name: str) -> dict:
|
||||||
srcinfo = self.srcinfo_cache.get(name)
|
srcinfo = self.srcinfo_cache.get(name)
|
||||||
@@ -171,6 +174,7 @@ class AURClient:
|
|||||||
self.logger.info("Finished")
|
self.logger.info("Finished")
|
||||||
|
|
||||||
def read_index(self) -> Iterable[str]:
|
def read_index(self) -> Iterable[str]:
|
||||||
|
try:
|
||||||
index = self.read_local_index()
|
index = self.read_local_index()
|
||||||
|
|
||||||
if not index:
|
if not index:
|
||||||
@@ -183,6 +187,8 @@ class AURClient:
|
|||||||
self.logger.warning("Could not load AUR index on the context")
|
self.logger.warning("Could not load AUR index on the context")
|
||||||
else:
|
else:
|
||||||
return index.values()
|
return index.values()
|
||||||
|
except:
|
||||||
|
return set()
|
||||||
|
|
||||||
def clean_caches(self):
|
def clean_caches(self):
|
||||||
self.srcinfo_cache.clear()
|
self.srcinfo_cache.clear()
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ from bauh.api.abstract.model import PackageUpdate, PackageHistory, SoftwarePacka
|
|||||||
from bauh.api.abstract.view import MessageType, FormComponent, InputOption, SingleSelectComponent, SelectViewType, \
|
from bauh.api.abstract.view import MessageType, FormComponent, InputOption, SingleSelectComponent, SelectViewType, \
|
||||||
ViewComponent, PanelComponent, MultipleSelectComponent, TextInputComponent, TextComponent
|
ViewComponent, PanelComponent, MultipleSelectComponent, TextInputComponent, TextComponent
|
||||||
from bauh.api.constants import TEMP_DIR
|
from bauh.api.constants import TEMP_DIR
|
||||||
from bauh.commons import user
|
from bauh.commons import user, internet
|
||||||
from bauh.commons.category import CategoriesDownloader
|
from bauh.commons.category import CategoriesDownloader
|
||||||
from bauh.commons.config import save_config
|
from bauh.commons.config import save_config
|
||||||
from bauh.commons.html import bold
|
from bauh.commons.html import bold
|
||||||
@@ -284,21 +284,21 @@ class ArchManager(SoftwareManager):
|
|||||||
database.register_sync(self.logger)
|
database.register_sync(self.logger)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _upgrade_search_result(self, apidata: dict, installed_pkgs: dict, downgrade_enabled: bool, res: SearchResult, disk_loader: DiskCacheLoader):
|
def _upgrade_search_result(self, apidata: dict, installed_pkgs: Dict[str, ArchPackage], downgrade_enabled: bool, res: SearchResult, disk_loader: DiskCacheLoader):
|
||||||
app = self.mapper.map_api_data(apidata, installed_pkgs['not_signed'], self.categories)
|
pkg = installed_pkgs.get(apidata['Name'])
|
||||||
app.downgrade_enabled = downgrade_enabled
|
|
||||||
|
|
||||||
if app.installed:
|
if not pkg:
|
||||||
res.installed.append(app)
|
pkg = self.mapper.map_api_data(apidata, None, self.categories)
|
||||||
|
pkg.downgrade_enabled = downgrade_enabled
|
||||||
|
|
||||||
if disk_loader:
|
if pkg.installed:
|
||||||
disk_loader.fill(app)
|
res.installed.append(pkg)
|
||||||
else:
|
else:
|
||||||
res.new.append(app)
|
res.new.append(pkg)
|
||||||
|
|
||||||
Thread(target=self.mapper.fill_package_build, args=(app,), daemon=True).start()
|
Thread(target=self.mapper.fill_package_build, args=(pkg,), daemon=True).start()
|
||||||
|
|
||||||
def _search_in_repos_and_fill(self, words: str, disk_loader: DiskCacheLoader, read_installed: Thread, installed: dict, res: SearchResult):
|
def _search_in_repos_and_fill(self, words: str, disk_loader: DiskCacheLoader, read_installed: Thread, installed: List[ArchPackage], res: SearchResult):
|
||||||
repo_search = pacman.search(words)
|
repo_search = pacman.search(words)
|
||||||
|
|
||||||
if not repo_search: # the package may not be mapped on the databases anymore
|
if not repo_search: # the package may not be mapped on the databases anymore
|
||||||
@@ -320,27 +320,26 @@ class ArchManager(SoftwareManager):
|
|||||||
if repo_pkgs:
|
if repo_pkgs:
|
||||||
read_installed.join()
|
read_installed.join()
|
||||||
|
|
||||||
|
repo_installed = {p.name: p for p in installed if p.repository != 'aur'} if installed else {}
|
||||||
|
|
||||||
for pkg in repo_pkgs:
|
for pkg in repo_pkgs:
|
||||||
if installed['signed'] and pkg.name in installed['signed']:
|
pkg_installed = repo_installed.get(pkg.name)
|
||||||
pkg.installed = True
|
if pkg_installed:
|
||||||
|
res.installed.append(pkg_installed)
|
||||||
if disk_loader:
|
|
||||||
disk_loader.fill(pkg)
|
|
||||||
|
|
||||||
res.installed.append(pkg)
|
|
||||||
else:
|
else:
|
||||||
pkg.installed = False
|
pkg.installed = False
|
||||||
res.new.append(pkg)
|
res.new.append(pkg)
|
||||||
|
|
||||||
def _search_in_aur_and_fill(self, words: str, disk_loader: DiskCacheLoader, read_installed: Thread, installed: dict, res: SearchResult):
|
def _search_in_aur_and_fill(self, words: str, disk_loader: DiskCacheLoader, read_installed: Thread, installed: List[ArchPackage], res: SearchResult):
|
||||||
api_res = self.aur_client.search(words)
|
api_res = self.aur_client.search(words)
|
||||||
|
|
||||||
if api_res and api_res.get('results'):
|
if api_res and api_res.get('results'):
|
||||||
read_installed.join()
|
read_installed.join()
|
||||||
|
aur_installed = {p.name: p for p in installed if p.repository == 'aur'}
|
||||||
|
|
||||||
downgrade_enabled = git.is_enabled()
|
downgrade_enabled = git.is_enabled()
|
||||||
for pkgdata in api_res['results']:
|
for pkgdata in api_res['results']:
|
||||||
self._upgrade_search_result(pkgdata, installed, downgrade_enabled, res, disk_loader)
|
self._upgrade_search_result(pkgdata, aur_installed, downgrade_enabled, res, disk_loader)
|
||||||
|
|
||||||
else: # if there are no results from the API (it could be because there were too many), tries the names index:
|
else: # if there are no results from the API (it could be because there were too many), tries the names index:
|
||||||
if self.index_aur:
|
if self.index_aur:
|
||||||
@@ -361,10 +360,11 @@ class ArchManager(SoftwareManager):
|
|||||||
|
|
||||||
if pkgsinfo:
|
if pkgsinfo:
|
||||||
read_installed.join()
|
read_installed.join()
|
||||||
|
aur_installed = {p.name: p for p in installed if p.repository == 'aur'}
|
||||||
downgrade_enabled = git.is_enabled()
|
downgrade_enabled = git.is_enabled()
|
||||||
|
|
||||||
for pkgdata in pkgsinfo:
|
for pkgdata in pkgsinfo:
|
||||||
self._upgrade_search_result(pkgdata, installed, downgrade_enabled, res, disk_loader)
|
self._upgrade_search_result(pkgdata, aur_installed, downgrade_enabled, res, disk_loader)
|
||||||
|
|
||||||
def search(self, words: str, disk_loader: DiskCacheLoader, limit: int = -1, is_url: bool = False) -> SearchResult:
|
def search(self, words: str, disk_loader: DiskCacheLoader, limit: int = -1, is_url: bool = False) -> SearchResult:
|
||||||
if is_url:
|
if is_url:
|
||||||
@@ -375,11 +375,11 @@ class ArchManager(SoftwareManager):
|
|||||||
if not any([arch_config['repositories'], arch_config['aur']]):
|
if not any([arch_config['repositories'], arch_config['aur']]):
|
||||||
return SearchResult([], [], 0)
|
return SearchResult([], [], 0)
|
||||||
|
|
||||||
installed = {}
|
installed = []
|
||||||
repo_map = pacman.map_repositories()
|
read_installed = Thread(target=lambda: installed.extend(self.read_installed(disk_loader=disk_loader,
|
||||||
read_installed = Thread(target=lambda: installed.update(pacman.map_installed(repositories=arch_config['repositories'],
|
only_apps=False,
|
||||||
aur=arch_config['aur'],
|
limit=-1,
|
||||||
repo_map=repo_map)), daemon=True)
|
internet_available=True).installed), daemon=True)
|
||||||
read_installed.start()
|
read_installed.start()
|
||||||
|
|
||||||
res = SearchResult([], [], 0)
|
res = SearchResult([], [], 0)
|
||||||
@@ -404,30 +404,30 @@ class ArchManager(SoftwareManager):
|
|||||||
res.total = len(res.installed) + len(res.new)
|
res.total = len(res.installed) + len(res.new)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _fill_aur_pkgs(self, not_signed: dict, pkgs: list, disk_loader: DiskCacheLoader, internet_available: bool):
|
def _fill_aur_pkgs(self, aur_pkgs: dict, output: list, disk_loader: DiskCacheLoader, internet_available: bool):
|
||||||
downgrade_enabled = git.is_enabled()
|
downgrade_enabled = git.is_enabled()
|
||||||
|
|
||||||
if internet_available:
|
if internet_available:
|
||||||
try:
|
try:
|
||||||
pkgsinfo = self.aur_client.get_info(not_signed.keys())
|
pkgsinfo = self.aur_client.get_info(aur_pkgs.keys())
|
||||||
|
|
||||||
if pkgsinfo:
|
if pkgsinfo:
|
||||||
for pkgdata in pkgsinfo:
|
for pkgdata in pkgsinfo:
|
||||||
pkg = self.mapper.map_api_data(pkgdata, not_signed, self.categories)
|
pkg = self.mapper.map_api_data(pkgdata, aur_pkgs, self.categories)
|
||||||
pkg.downgrade_enabled = downgrade_enabled
|
pkg.downgrade_enabled = downgrade_enabled
|
||||||
|
|
||||||
if disk_loader:
|
if disk_loader:
|
||||||
disk_loader.fill(pkg)
|
disk_loader.fill(pkg)
|
||||||
pkg.status = PackageStatus.READY
|
pkg.status = PackageStatus.READY
|
||||||
|
|
||||||
pkgs.append(pkg)
|
output.append(pkg)
|
||||||
|
|
||||||
return
|
return
|
||||||
except requests.exceptions.ConnectionError:
|
except requests.exceptions.ConnectionError:
|
||||||
self.logger.warning('Could not retrieve installed AUR packages API data. It seems the internet connection is off.')
|
self.logger.warning('Could not retrieve installed AUR packages API data. It seems the internet connection is off.')
|
||||||
self.logger.info("Reading only local AUR packages data")
|
self.logger.info("Reading only local AUR packages data")
|
||||||
|
|
||||||
for name, data in not_signed.items():
|
for name, data in aur_pkgs.items():
|
||||||
pkg = ArchPackage(name=name, version=data.get('version'),
|
pkg = ArchPackage(name=name, version=data.get('version'),
|
||||||
latest_version=data.get('version'), description=data.get('description'),
|
latest_version=data.get('version'), description=data.get('description'),
|
||||||
installed=True, repository='aur', i18n=self.i18n)
|
installed=True, repository='aur', i18n=self.i18n)
|
||||||
@@ -439,34 +439,38 @@ class ArchManager(SoftwareManager):
|
|||||||
disk_loader.fill(pkg)
|
disk_loader.fill(pkg)
|
||||||
pkg.status = PackageStatus.READY
|
pkg.status = PackageStatus.READY
|
||||||
|
|
||||||
pkgs.append(pkg)
|
output.append(pkg)
|
||||||
|
|
||||||
def _fill_repo_updates(self, updates: dict):
|
def _fill_repo_updates(self, updates: dict):
|
||||||
updates.update(pacman.list_repository_updates())
|
updates.update(pacman.list_repository_updates())
|
||||||
|
|
||||||
def _fill_repo_pkgs(self, signed: dict, pkgs: list, repo_map: Dict[str, str], disk_loader: DiskCacheLoader):
|
def _fill_repo_pkgs(self, repo_pkgs: dict, pkgs: list, disk_loader: DiskCacheLoader):
|
||||||
updates = {}
|
updates = {}
|
||||||
|
|
||||||
thread_updates = Thread(target=self._fill_repo_updates, args=(updates,), daemon=True)
|
thread_updates = Thread(target=self._fill_repo_updates, args=(updates,), daemon=True)
|
||||||
thread_updates.start()
|
thread_updates.start()
|
||||||
|
|
||||||
if len(repo_map) != len(signed):
|
repo_map = pacman.map_repositories(repo_pkgs)
|
||||||
self.logger.warning("Not mapped all signed packages repositories. Mapped: {}. Total: {}".format(len(repo_map), len(signed)))
|
if len(repo_map) != len(repo_pkgs):
|
||||||
|
self.logger.warning("Not mapped all signed packages repositories. Mapped: {}. Total: {}".format(len(repo_map), len(repo_pkgs)))
|
||||||
|
|
||||||
thread_updates.join()
|
thread_updates.join()
|
||||||
|
|
||||||
self.logger.info("Repository updates found" if updates else "No repository updates found")
|
self.logger.info("Repository updates found" if updates else "No repository updates found")
|
||||||
|
|
||||||
for name, data in signed.items():
|
for name, data in repo_pkgs.items():
|
||||||
|
pkgversion = data.get('version')
|
||||||
|
pkgrepo = repo_map.get(name)
|
||||||
pkg = ArchPackage(name=name,
|
pkg = ArchPackage(name=name,
|
||||||
version=data.get('version'),
|
version=pkgversion,
|
||||||
latest_version=data.get('version'),
|
latest_version=pkgversion,
|
||||||
description=data.get('description'),
|
description=data.get('description'),
|
||||||
|
maintainer=pkgrepo,
|
||||||
i18n=self.i18n,
|
i18n=self.i18n,
|
||||||
installed=True,
|
installed=True,
|
||||||
repository=repo_map.get(name))
|
repository=pkgrepo,
|
||||||
pkg.categories = self.categories.get(pkg.name)
|
categories=self.categories.get(name))
|
||||||
pkg.downgrade_enabled = True
|
pkg.downgrade_enabled = False
|
||||||
|
|
||||||
if updates:
|
if updates:
|
||||||
update_version = updates.get(pkg.name)
|
update_version = updates.get(pkg.name)
|
||||||
@@ -483,20 +487,40 @@ class ArchManager(SoftwareManager):
|
|||||||
def read_installed(self, disk_loader: DiskCacheLoader, limit: int = -1, only_apps: bool = False, pkg_types: Set[Type[SoftwarePackage]] = None, internet_available: bool = None) -> SearchResult:
|
def read_installed(self, disk_loader: DiskCacheLoader, limit: int = -1, only_apps: bool = False, pkg_types: Set[Type[SoftwarePackage]] = None, internet_available: bool = None) -> SearchResult:
|
||||||
self.aur_client.clean_caches()
|
self.aur_client.clean_caches()
|
||||||
arch_config = read_config()
|
arch_config = read_config()
|
||||||
repo_map = pacman.map_repositories()
|
|
||||||
installed = pacman.map_installed(repo_map=repo_map, repositories=arch_config['repositories'], aur=arch_config['aur'])
|
|
||||||
|
|
||||||
pkgs = []
|
installed = pacman.map_installed()
|
||||||
if installed and (installed['not_signed'] or installed['signed']):
|
|
||||||
map_threads = []
|
aur_pkgs, repo_pkgs = None, None
|
||||||
|
|
||||||
|
if arch_config['repositories'] and installed['signed']:
|
||||||
|
repo_pkgs = installed['signed']
|
||||||
|
|
||||||
if installed['not_signed']:
|
if installed['not_signed']:
|
||||||
t = Thread(target=self._fill_aur_pkgs, args=(installed['not_signed'], pkgs, disk_loader, internet_available), daemon=True)
|
if self.index_aur:
|
||||||
|
self.index_aur.join()
|
||||||
|
|
||||||
|
aur_index = self.aur_client.read_index()
|
||||||
|
|
||||||
|
for pkg in {*installed['not_signed']}:
|
||||||
|
if pkg not in aur_index:
|
||||||
|
if repo_pkgs is not None:
|
||||||
|
repo_pkgs[pkg] = installed['not_signed'][pkg]
|
||||||
|
|
||||||
|
del installed['not_signed'][pkg]
|
||||||
|
|
||||||
|
aur_pkgs = installed['not_signed']
|
||||||
|
|
||||||
|
pkgs = []
|
||||||
|
if repo_pkgs or aur_pkgs:
|
||||||
|
map_threads = []
|
||||||
|
|
||||||
|
if aur_pkgs:
|
||||||
|
t = Thread(target=self._fill_aur_pkgs, args=(aur_pkgs, pkgs, disk_loader, internet_available), daemon=True)
|
||||||
t.start()
|
t.start()
|
||||||
map_threads.append(t)
|
map_threads.append(t)
|
||||||
|
|
||||||
if installed['signed']:
|
if repo_pkgs:
|
||||||
t = Thread(target=self._fill_repo_pkgs, args=(installed['signed'], pkgs, repo_map, disk_loader), daemon=True)
|
t = Thread(target=self._fill_repo_pkgs, args=(repo_pkgs, pkgs, disk_loader), daemon=True)
|
||||||
t.start()
|
t.start()
|
||||||
map_threads.append(t)
|
map_threads.append(t)
|
||||||
|
|
||||||
@@ -733,7 +757,16 @@ class ArchManager(SoftwareManager):
|
|||||||
handler.watcher.print("Repository packages successfully upgraded")
|
handler.watcher.print("Repository packages successfully upgraded")
|
||||||
handler.watcher.change_substatus(self.i18n['arch.upgrade.caching_pkgs_data'])
|
handler.watcher.change_substatus(self.i18n['arch.upgrade.caching_pkgs_data'])
|
||||||
repo_map = pacman.map_repositories(pkgs)
|
repo_map = pacman.map_repositories(pkgs)
|
||||||
disk.save_several(pkgs, repo_map=repo_map, overwrite=True, maintainer=None)
|
|
||||||
|
pkg_map = {}
|
||||||
|
for name in pkgs:
|
||||||
|
repo = repo_map.get(name)
|
||||||
|
pkg_map[name] = ArchPackage(name=name,
|
||||||
|
repository=repo,
|
||||||
|
maintainer=repo,
|
||||||
|
categories=self.categories.get(name))
|
||||||
|
|
||||||
|
disk.save_several(pkg_map, overwrite=True, maintainer=None)
|
||||||
return True
|
return True
|
||||||
elif 'conflicting files' in upgrade_output:
|
elif 'conflicting files' in upgrade_output:
|
||||||
files = self._map_conflicting_file(upgrade_output)
|
files = self._map_conflicting_file(upgrade_output)
|
||||||
@@ -1373,18 +1406,6 @@ class ArchManager(SoftwareManager):
|
|||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _map_unknown_missing_deps(self, deps: List[str], watcher: ProcessWatcher, check_subdeps: bool = True) -> List[Tuple[str, str]]:
|
|
||||||
depnames = {RE_SPLIT_VERSION.split(dep)[0] for dep in deps}
|
|
||||||
dep_repos = self._map_repos(depnames)
|
|
||||||
|
|
||||||
if len(depnames) != len(dep_repos): # checking if a dependency could not be found in any repository
|
|
||||||
for dep in depnames:
|
|
||||||
if dep not in dep_repos:
|
|
||||||
message.show_dep_not_found(dep, self.i18n, watcher)
|
|
||||||
return
|
|
||||||
|
|
||||||
return self.deps_analyser.map_known_missing_deps(dep_repos, watcher, check_subdeps)
|
|
||||||
|
|
||||||
def _ask_and_install_missing_deps(self, context: TransactionContext, missing_deps: List[Tuple[str, str]]) -> bool:
|
def _ask_and_install_missing_deps(self, context: TransactionContext, missing_deps: List[Tuple[str, str]]) -> bool:
|
||||||
context.watcher.change_substatus(self.i18n['arch.missing_deps_found'].format(bold(context.name)))
|
context.watcher.change_substatus(self.i18n['arch.missing_deps_found'].format(bold(context.name)))
|
||||||
|
|
||||||
@@ -1626,19 +1647,31 @@ class ArchManager(SoftwareManager):
|
|||||||
|
|
||||||
if installed:
|
if installed:
|
||||||
context.watcher.change_substatus(self.i18n['status.caching_data'].format(bold(context.name)))
|
context.watcher.change_substatus(self.i18n['status.caching_data'].format(bold(context.name)))
|
||||||
pkgnames = {context.name}
|
|
||||||
repo_map = {context.name: context.repository}
|
|
||||||
|
|
||||||
if context.missing_deps:
|
cache_map = {context.name: ArchPackage(name=context.name,
|
||||||
for dep in context.missing_deps:
|
repository=context.repository,
|
||||||
pkgnames.add(dep[0])
|
|
||||||
repo_map[dep[0]] = dep[1]
|
|
||||||
|
|
||||||
disk.save_several(pkgnames=pkgnames,
|
|
||||||
repo_map=repo_map,
|
|
||||||
maintainer=context.maintainer,
|
maintainer=context.maintainer,
|
||||||
overwrite=True,
|
categories=self.categories.get(context.name))}
|
||||||
categories=self.categories)
|
if context.missing_deps:
|
||||||
|
aur_deps = {dep[0] for dep in context.missing_deps if dep[1] == 'aur'}
|
||||||
|
|
||||||
|
if aur_deps:
|
||||||
|
aur_data = self.aur_client.get_info(aur_deps)
|
||||||
|
|
||||||
|
if aur_data:
|
||||||
|
aur_data = {info['Name']: info for info in aur_data}
|
||||||
|
else:
|
||||||
|
aur_data = {n: {} for n in aur_deps}
|
||||||
|
else:
|
||||||
|
aur_data = None
|
||||||
|
|
||||||
|
for dep in context.missing_deps:
|
||||||
|
cache_map[dep[0]] = ArchPackage(name=dep[0],
|
||||||
|
repository=dep[1],
|
||||||
|
maintainer=dep[1] if dep[1] != 'aur' else (aur_data[dep[0]].get('Maintainer') if aur_data else None),
|
||||||
|
categories=self.categories.get(context.name))
|
||||||
|
|
||||||
|
disk.save_several(pkgs=cache_map, maintainer=None, overwrite=True)
|
||||||
|
|
||||||
self._update_progress(context, 100)
|
self._update_progress(context, 100)
|
||||||
|
|
||||||
@@ -1848,7 +1881,8 @@ class ArchManager(SoftwareManager):
|
|||||||
arch_config = read_config(update_file=True)
|
arch_config = read_config(update_file=True)
|
||||||
|
|
||||||
if arch_config['aur'] or arch_config['repositories']:
|
if arch_config['aur'] or arch_config['repositories']:
|
||||||
ArchDiskCacheUpdater(task_manager, arch_config, self.i18n, self.context.logger).start()
|
ArchDiskCacheUpdater(task_man=task_manager, arch_config=arch_config, i18n=self.i18n, logger=self.context.logger,
|
||||||
|
controller=self, internet_available=internet_available).start()
|
||||||
|
|
||||||
if arch_config['aur']:
|
if arch_config['aur']:
|
||||||
ArchCompilationOptimizer(arch_config, self.i18n, self.context.logger, task_manager).start()
|
ArchCompilationOptimizer(arch_config, self.i18n, self.context.logger, task_manager).start()
|
||||||
@@ -2085,18 +2119,15 @@ class ArchManager(SoftwareManager):
|
|||||||
|
|
||||||
def upgrade_system(self, root_password: str, watcher: ProcessWatcher) -> bool:
|
def upgrade_system(self, root_password: str, watcher: ProcessWatcher) -> bool:
|
||||||
repo_map = pacman.map_repositories()
|
repo_map = pacman.map_repositories()
|
||||||
installed = pacman.map_installed(repo_map=repo_map, repositories=True, aur=False)
|
installed = self.read_installed(limit=-1, only_apps=False, pkg_types=None, internet_available=internet.is_available(), disk_loader=None).installed
|
||||||
|
|
||||||
if not installed or not installed['signed']:
|
if not installed:
|
||||||
watcher.show_message(title=self.i18n['arch.custom_action.upgrade_system'],
|
watcher.show_message(title=self.i18n['arch.custom_action.upgrade_system'],
|
||||||
body=self.i18n['arch.custom_action.upgrade_system.no_updates'],
|
body=self.i18n['arch.custom_action.upgrade_system.no_updates'],
|
||||||
type_=MessageType.INFO)
|
type_=MessageType.INFO)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
pkgs = []
|
to_update = [p for p in installed if p.repository != 'aur' and p.update]
|
||||||
self._fill_repo_pkgs(installed['signed'], pkgs, None)
|
|
||||||
|
|
||||||
to_update = [p for p in pkgs if p.update]
|
|
||||||
|
|
||||||
if not to_update:
|
if not to_update:
|
||||||
watcher.show_message(title=self.i18n['arch.custom_action.upgrade_system'],
|
watcher.show_message(title=self.i18n['arch.custom_action.upgrade_system'],
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import json
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Dict, Iterable
|
from typing import List, Dict
|
||||||
|
|
||||||
from bauh.gems.arch import pacman
|
from bauh.gems.arch import pacman
|
||||||
from bauh.gems.arch.model import ArchPackage
|
from bauh.gems.arch.model import ArchPackage
|
||||||
@@ -48,12 +48,11 @@ def set_icon_path(pkg: ArchPackage, icon_name: str = None):
|
|||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
def save_several(pkgnames: Iterable[str], repo_map: Dict[str, str], overwrite: bool = True, maintainer: str = None,
|
def save_several(pkgs: Dict[str, ArchPackage], overwrite: bool = True, maintainer: str = None, when_prepared=None, after_written=None) -> int:
|
||||||
categories: dict = None, when_prepared=None, after_written=None) -> int:
|
|
||||||
if overwrite:
|
if overwrite:
|
||||||
to_cache = pkgnames
|
to_cache = {p.name for p in pkgs.values()}
|
||||||
else:
|
else:
|
||||||
to_cache = {n for n in pkgnames if not os.path.exists(ArchPackage.disk_cache_path(n))}
|
to_cache = {p.name for p in pkgs.values() if not os.path.exists(p.get_disk_cache_path())}
|
||||||
|
|
||||||
desktop_files = pacman.list_desktop_entries(to_cache)
|
desktop_files = pacman.list_desktop_entries(to_cache)
|
||||||
|
|
||||||
@@ -78,18 +77,18 @@ def save_several(pkgnames: Iterable[str], repo_map: Dict[str, str], overwrite: b
|
|||||||
if pkg not in desktop_matches:
|
if pkg not in desktop_matches:
|
||||||
no_exact_match.add(pkg)
|
no_exact_match.add(pkg)
|
||||||
if no_exact_match: # check every not matched app individually
|
if no_exact_match: # check every not matched app individually
|
||||||
for pkg in no_exact_match:
|
for pkgname in no_exact_match:
|
||||||
entries = pacman.list_desktop_entries({pkg})
|
entries = pacman.list_desktop_entries({pkgname})
|
||||||
|
|
||||||
if entries:
|
if entries:
|
||||||
if len(entries) > 1:
|
if len(entries) > 1:
|
||||||
for e in entries:
|
for e in entries:
|
||||||
if e.startswith('/usr/share/applications') and os.path.isfile(e):
|
if e.startswith('/usr/share/applications') and os.path.isfile(e):
|
||||||
desktop_matches[pkg] = e
|
desktop_matches[pkgname] = e
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(entries[0]):
|
if os.path.isfile(entries[0]):
|
||||||
desktop_matches[pkg] = entries[0]
|
desktop_matches[pkgname] = entries[0]
|
||||||
|
|
||||||
if not desktop_matches:
|
if not desktop_matches:
|
||||||
no_desktop_files = to_cache
|
no_desktop_files = to_cache
|
||||||
@@ -97,10 +96,10 @@ def save_several(pkgnames: Iterable[str], repo_map: Dict[str, str], overwrite: b
|
|||||||
if len(desktop_matches) != len(to_cache):
|
if len(desktop_matches) != len(to_cache):
|
||||||
no_desktop_files = {p for p in to_cache if p not in desktop_matches}
|
no_desktop_files = {p for p in to_cache if p not in desktop_matches}
|
||||||
|
|
||||||
pkgs, apps_icons_noabspath = [], []
|
instances, apps_icons_noabspath = [], []
|
||||||
|
|
||||||
for pkgname, file in desktop_matches.items():
|
for pkgname, file in desktop_matches.items():
|
||||||
p = ArchPackage(name=pkgname, repository=repo_map.get(pkgname))
|
p = pkgs[pkgname]
|
||||||
|
|
||||||
with open(file) as f:
|
with open(file) as f:
|
||||||
try:
|
try:
|
||||||
@@ -124,7 +123,7 @@ def save_several(pkgnames: Iterable[str], repo_map: Dict[str, str], overwrite: b
|
|||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
pkgs.append(p)
|
instances.append(p)
|
||||||
|
|
||||||
if when_prepared:
|
if when_prepared:
|
||||||
when_prepared(p.name)
|
when_prepared(p.name)
|
||||||
@@ -135,17 +134,17 @@ def save_several(pkgnames: Iterable[str], repo_map: Dict[str, str], overwrite: b
|
|||||||
for p in apps_icons_noabspath:
|
for p in apps_icons_noabspath:
|
||||||
fill_icon_path(p, icon_paths, False)
|
fill_icon_path(p, icon_paths, False)
|
||||||
|
|
||||||
for p in pkgs:
|
for p in instances:
|
||||||
to_write.append(p)
|
to_write.append(p)
|
||||||
else:
|
else:
|
||||||
no_desktop_files = {*pkgnames}
|
no_desktop_files = {n for n in to_cache}
|
||||||
|
|
||||||
if no_desktop_files:
|
if no_desktop_files:
|
||||||
bin_paths = pacman.list_bin_paths(no_desktop_files)
|
bin_paths = pacman.list_bin_paths(no_desktop_files)
|
||||||
icon_paths = pacman.list_icon_paths(no_desktop_files)
|
icon_paths = pacman.list_icon_paths(no_desktop_files)
|
||||||
|
|
||||||
for n in no_desktop_files:
|
for n in no_desktop_files:
|
||||||
p = ArchPackage(name=n, repository=repo_map.get(n))
|
p = pkgs[n]
|
||||||
|
|
||||||
if bin_paths:
|
if bin_paths:
|
||||||
clean_name = RE_CLEAN_NAME.sub('', p.name)
|
clean_name = RE_CLEAN_NAME.sub('', p.name)
|
||||||
@@ -166,9 +165,6 @@ def save_several(pkgnames: Iterable[str], repo_map: Dict[str, str], overwrite: b
|
|||||||
if to_write:
|
if to_write:
|
||||||
written = set()
|
written = set()
|
||||||
for p in to_write:
|
for p in to_write:
|
||||||
if categories:
|
|
||||||
p.categories = categories.get(p.name)
|
|
||||||
|
|
||||||
if maintainer and not p.maintainer:
|
if maintainer and not p.maintainer:
|
||||||
p.maintainer = maintainer
|
p.maintainer = maintainer
|
||||||
|
|
||||||
@@ -180,11 +176,11 @@ def save_several(pkgnames: Iterable[str], repo_map: Dict[str, str], overwrite: b
|
|||||||
written.add(p.name)
|
written.add(p.name)
|
||||||
|
|
||||||
if len(to_write) != len(to_cache):
|
if len(to_write) != len(to_cache):
|
||||||
for n in pkgnames:
|
for pkgname in to_cache:
|
||||||
if n not in written:
|
if pkgname not in written:
|
||||||
Path(ArchPackage.disk_cache_path(n)).mkdir(parents=True, exist_ok=True)
|
Path(ArchPackage.disk_cache_path(pkgname)).mkdir(parents=True, exist_ok=True)
|
||||||
if after_written:
|
if after_written:
|
||||||
after_written(n)
|
after_written(pkgname)
|
||||||
|
|
||||||
return len(to_write)
|
return len(to_write)
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ class ArchDataMapper:
|
|||||||
pkg.pkgbuild = res.text
|
pkg.pkgbuild = res.text
|
||||||
|
|
||||||
def map_api_data(self, apidata: dict, installed: dict, categories: dict) -> ArchPackage:
|
def map_api_data(self, apidata: dict, installed: dict, categories: dict) -> ArchPackage:
|
||||||
data = installed.get(apidata.get('Name'))
|
data = installed.get(apidata.get('Name')) if installed else None
|
||||||
app = ArchPackage(name=apidata.get('Name'), installed=bool(data), repository='aur', i18n=self.i18n)
|
app = ArchPackage(name=apidata.get('Name'), installed=bool(data), repository='aur', i18n=self.i18n)
|
||||||
app.status = PackageStatus.LOADING_DATA
|
app.status = PackageStatus.LOADING_DATA
|
||||||
|
|
||||||
|
|||||||
@@ -16,9 +16,10 @@ class ArchPackage(SoftwarePackage):
|
|||||||
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, repository: str = None,
|
maintainer: str = None, url_download: str = None, pkgbuild: str = None, repository: str = None,
|
||||||
desktop_entry: str = None, installed: bool = False, srcinfo: dict = None, dependencies: Set[str] = None,
|
desktop_entry: str = None, installed: bool = False, srcinfo: dict = None, dependencies: Set[str] = None,
|
||||||
i18n: I18n = None):
|
categories: List[str] = None, i18n: I18n = 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, categories=categories)
|
||||||
self.package_base = package_base
|
self.package_base = package_base
|
||||||
self.votes = votes
|
self.votes = votes
|
||||||
self.popularity = popularity
|
self.popularity = popularity
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ def is_available_in_repositories(pkg_name: str) -> bool:
|
|||||||
|
|
||||||
|
|
||||||
def get_info(pkg_name, remote: bool = False) -> str:
|
def get_info(pkg_name, remote: bool = False) -> str:
|
||||||
return run_cmd('pacman -{}i {}'.format('Q' if not remote else 'S', pkg_name))
|
return run_cmd('pacman -{}i {}'.format('Q' if not remote else 'S', pkg_name), print_error=False)
|
||||||
|
|
||||||
|
|
||||||
def get_info_list(pkg_name: str, remote: bool = False) -> List[tuple]:
|
def get_info_list(pkg_name: str, remote: bool = False) -> List[tuple]:
|
||||||
@@ -92,7 +92,7 @@ def _fill_ignored(res: dict):
|
|||||||
res['pkgs'] = list_ignored_packages()
|
res['pkgs'] = list_ignored_packages()
|
||||||
|
|
||||||
|
|
||||||
def map_installed(repo_map: Dict[str, str], repositories: bool = True, aur: bool = True) -> dict: # returns a dict with with package names as keys and versions as values
|
def map_installed() -> dict: # returns a dict with with package names as keys and versions as values
|
||||||
ignored = {}
|
ignored = {}
|
||||||
thread_ignored = Thread(target=_fill_ignored, args=(ignored,), daemon=True)
|
thread_ignored = Thread(target=_fill_ignored, args=(ignored,), daemon=True)
|
||||||
thread_ignored.start()
|
thread_ignored.start()
|
||||||
@@ -109,21 +109,15 @@ def map_installed(repo_map: Dict[str, str], repositories: bool = True, aur: bool
|
|||||||
elif field_tuple[0].startswith('D'):
|
elif field_tuple[0].startswith('D'):
|
||||||
current_pkg['description'] = field_tuple[1].strip()
|
current_pkg['description'] = field_tuple[1].strip()
|
||||||
elif field_tuple[0].startswith('Va'):
|
elif field_tuple[0].startswith('Va'):
|
||||||
if field_tuple[1].strip().lower() == 'none' and aur:
|
if field_tuple[1].strip().lower() == 'none':
|
||||||
pkgs['not_signed'][current_pkg['name']] = current_pkg
|
pkgs['not_signed'][current_pkg['name']] = current_pkg
|
||||||
del current_pkg['name']
|
del current_pkg['name']
|
||||||
elif repositories:
|
else:
|
||||||
pkgs['signed'][current_pkg['name']] = current_pkg
|
pkgs['signed'][current_pkg['name']] = current_pkg
|
||||||
del current_pkg['name']
|
del current_pkg['name']
|
||||||
|
|
||||||
current_pkg = {}
|
current_pkg = {}
|
||||||
|
|
||||||
if pkgs['not_signed']:
|
|
||||||
for name in {*pkgs['not_signed'].keys()}:
|
|
||||||
if repo_map.get(name):
|
|
||||||
pkgs['signed'][name] = pkgs['not_signed'][name]
|
|
||||||
del pkgs['not_signed'][name]
|
|
||||||
|
|
||||||
if pkgs['signed'] or pkgs['not_signed']:
|
if pkgs['signed'] or pkgs['not_signed']:
|
||||||
thread_ignored.join()
|
thread_ignored.join()
|
||||||
|
|
||||||
@@ -438,7 +432,7 @@ def get_build_date(pkgname: str) -> str:
|
|||||||
|
|
||||||
|
|
||||||
def search(words: str) -> Dict[str, dict]:
|
def search(words: str) -> Dict[str, dict]:
|
||||||
output = run_cmd('pacman -Ss ' + words)
|
output = run_cmd('pacman -Ss ' + words, print_error=False)
|
||||||
|
|
||||||
if output:
|
if output:
|
||||||
found, current = {}, {}
|
found, current = {}, {}
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ from bauh.commons.system import run_cmd, new_root_subprocess, ProcessHandler
|
|||||||
from bauh.gems.arch import pacman, disk, CUSTOM_MAKEPKG_FILE, CONFIG_DIR, BUILD_DIR, \
|
from bauh.gems.arch import pacman, disk, CUSTOM_MAKEPKG_FILE, CONFIG_DIR, BUILD_DIR, \
|
||||||
AUR_INDEX_FILE, get_icon_path, database, mirrors
|
AUR_INDEX_FILE, get_icon_path, database, mirrors
|
||||||
from bauh.gems.arch.aur import URL_INDEX
|
from bauh.gems.arch.aur import URL_INDEX
|
||||||
from bauh.gems.arch.model import ArchPackage
|
|
||||||
from bauh.view.util.translation import I18n
|
from bauh.view.util.translation import I18n
|
||||||
|
|
||||||
URL_INFO = 'https://aur.archlinux.org/rpc/?v=5&type=info&arg={}'
|
URL_INFO = 'https://aur.archlinux.org/rpc/?v=5&type=info&arg={}'
|
||||||
@@ -60,7 +59,7 @@ class AURIndexUpdater(Thread):
|
|||||||
|
|
||||||
class ArchDiskCacheUpdater(Thread):
|
class ArchDiskCacheUpdater(Thread):
|
||||||
|
|
||||||
def __init__(self, task_man: TaskManager, arch_config: dict, i18n: I18n, logger: logging.Logger):
|
def __init__(self, task_man: TaskManager, arch_config: dict, i18n: I18n, logger: logging.Logger, controller: "ArchManager", internet_available: bool):
|
||||||
super(ArchDiskCacheUpdater, self).__init__(daemon=True)
|
super(ArchDiskCacheUpdater, self).__init__(daemon=True)
|
||||||
self.logger = logger
|
self.logger = logger
|
||||||
self.task_man = task_man
|
self.task_man = task_man
|
||||||
@@ -74,6 +73,8 @@ class ArchDiskCacheUpdater(Thread):
|
|||||||
self.progress = 0 # progress is defined by the number of packages prepared and indexed
|
self.progress = 0 # progress is defined by the number of packages prepared and indexed
|
||||||
self.repositories = arch_config['repositories']
|
self.repositories = arch_config['repositories']
|
||||||
self.aur = bool(arch_config['aur'])
|
self.aur = bool(arch_config['aur'])
|
||||||
|
self.controller = controller
|
||||||
|
self.internet_available = internet_available
|
||||||
|
|
||||||
def update_prepared(self, pkgname: str, add: bool = True):
|
def update_prepared(self, pkgname: str, add: bool = True):
|
||||||
if add:
|
if add:
|
||||||
@@ -97,24 +98,20 @@ class ArchDiskCacheUpdater(Thread):
|
|||||||
self.task_man.register_task(self.task_id, self.i18n['arch.task.disk_cache'], get_icon_path())
|
self.task_man.register_task(self.task_id, self.i18n['arch.task.disk_cache'], get_icon_path())
|
||||||
|
|
||||||
self.logger.info('Pre-caching installed Arch packages data to disk')
|
self.logger.info('Pre-caching installed Arch packages data to disk')
|
||||||
repo_map = pacman.map_repositories()
|
|
||||||
installed = pacman.map_installed(repositories=self.repositories, aur=self.aur, repo_map=repo_map)
|
installed = self.controller.read_installed(disk_loader=None, internet_available=self.internet_available,
|
||||||
|
only_apps=False, pkg_types=None, limit=-1).installed
|
||||||
|
|
||||||
self.task_man.update_progress(self.task_id, 0, self.i18n['arch.task.disk_cache.reading'])
|
self.task_man.update_progress(self.task_id, 0, self.i18n['arch.task.disk_cache.reading'])
|
||||||
for k in ('signed', 'not_signed'):
|
|
||||||
installed[k] = {p for p in installed[k] if not os.path.exists(ArchPackage.disk_cache_path(p))}
|
|
||||||
|
|
||||||
saved = 0
|
saved = 0
|
||||||
pkgs = {*installed['signed'], *installed['not_signed']}
|
pkgs = {p.name: p for p in installed if not os.path.exists(p.get_disk_cache_path())}
|
||||||
|
|
||||||
if installed['not_signed']:
|
|
||||||
repo_map.update({p: 'aur' for p in installed['not_signed']})
|
|
||||||
|
|
||||||
self.to_index = len(pkgs)
|
self.to_index = len(pkgs)
|
||||||
self.progress = self.to_index * 2
|
self.progress = self.to_index * 2
|
||||||
self.update_prepared(None, add=False)
|
self.update_prepared(None, add=False)
|
||||||
|
|
||||||
saved += disk.save_several(pkgs, repo_map, when_prepared=self.update_prepared, after_written=self.update_indexed)
|
saved += disk.save_several(pkgs, when_prepared=self.update_prepared, after_written=self.update_indexed)
|
||||||
self.task_man.update_progress(self.task_id, 100, None)
|
self.task_man.update_progress(self.task_id, 100, None)
|
||||||
self.task_man.finish_task(self.task_id)
|
self.task_man.finish_task(self.task_id)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user