fix: AUR installation | showing optdeps comments

This commit is contained in:
Vinicius Moreira
2019-09-18 19:15:53 -03:00
parent 65f313cbd8
commit 299be33d9f
3 changed files with 21 additions and 10 deletions

View File

@@ -8,8 +8,8 @@ from bauh.commons.html import bold
def request_optional_deps(pkgname: str, pkg_mirrors: dict, watcher: ProcessWatcher, i18n: dict) -> Set[str]: def request_optional_deps(pkgname: str, pkg_mirrors: dict, watcher: ProcessWatcher, i18n: dict) -> Set[str]:
view_opts = MultipleSelectComponent(label='', view_opts = MultipleSelectComponent(label='',
options=[InputOption('{} ( {} )'.format(p, m.upper()), p) for p, m in options=[InputOption('{}{} ( {} )'.format(p, ': ' + d['desc'] if d['desc'] else '', d['mirror'].upper()), p)
pkg_mirrors.items()]) for p, d in pkg_mirrors.items()])
install = watcher.request_confirmation(title=i18n['arch.install.optdeps.request.title'], install = watcher.request_confirmation(title=i18n['arch.install.optdeps.request.title'],
body='<p>{}</p>'.format(i18n['arch.install.optdeps.request.body'].format(bold(pkgname)) + ':'), body='<p>{}</p>'.format(i18n['arch.install.optdeps.request.body'].format(bold(pkgname)) + ':'),
components=[view_opts], components=[view_opts],

View File

@@ -247,8 +247,8 @@ class ArchManager(SoftwareManager):
res_srcinfo = self.context.http_client.get(URL_SRC_INFO + pkg.name) res_srcinfo = self.context.http_client.get(URL_SRC_INFO + pkg.name)
if res_srcinfo and res_srcinfo.text: if res_srcinfo and res_srcinfo.text:
info['11_dependson'] = ' '.join(pkgbuild.read_depends_on(res_srcinfo.text)) info['11_dependson'] = '\n'.join(pkgbuild.read_depends_on(res_srcinfo.text))
info['12_optdepends'] = ' '.join(pkgbuild.read_optdeps(res_srcinfo.text)) info['12_optdepends'] = '\n'.join(pkgbuild.read_optdeps(res_srcinfo.text))
if pkg.pkgbuild: if pkg.pkgbuild:
info['13_pkg_build'] = pkg.pkgbuild info['13_pkg_build'] = pkg.pkgbuild
@@ -339,7 +339,7 @@ class ArchManager(SoftwareManager):
# building main package # building main package
handler.watcher.change_substatus(self.i18n['arch.building.package'].format(bold(pkgname))) handler.watcher.change_substatus(self.i18n['arch.building.package'].format(bold(pkgname)))
pkgbuilt = handler.handle(SystemProcess(new_subprocess(['makepkg', '-ALcsmf'], cwd=project_dir))) pkgbuilt = handler.handle(SystemProcess(new_subprocess(['makepkg', '-ALcsmf'], cwd=project_dir), check_error_output=False))
self._update_progress(handler.watcher, 65, change_progress) self._update_progress(handler.watcher, 65, change_progress)
if pkgbuilt: if pkgbuilt:
@@ -392,7 +392,7 @@ class ArchManager(SoftwareManager):
def _install_optdeps(self, pkgname: str, root_password: str, handler: ProcessHandler, pkgdir: str, change_progress: bool = True) -> bool: def _install_optdeps(self, pkgname: str, root_password: str, handler: ProcessHandler, pkgdir: str, change_progress: bool = True) -> bool:
with open('{}/.SRCINFO'.format(pkgdir)) as f: with open('{}/.SRCINFO'.format(pkgdir)) as f:
odeps = pkgbuild.read_optdeps(f.read()) odeps = pkgbuild.read_optdeps_as_dict(f.read())
if not odeps: if not odeps:
return True return True
@@ -406,7 +406,9 @@ class ArchManager(SoftwareManager):
pkg_mirrors = self._map_mirrors(to_install) pkg_mirrors = self._map_mirrors(to_install)
if pkg_mirrors: if pkg_mirrors:
deps_to_install = confirmation.request_optional_deps(pkgname, pkg_mirrors, handler.watcher, self.i18n) final_optdeps = {dep: {'desc': odeps[dep], 'mirror': pkg_mirrors[dep]} for dep in to_install}
deps_to_install = confirmation.request_optional_deps(pkgname, final_optdeps, handler.watcher, self.i18n)
if not deps_to_install: if not deps_to_install:
return True return True
@@ -477,7 +479,7 @@ class ArchManager(SoftwareManager):
file_url = URL_PKG_DOWNLOAD.format(pkgname) file_url = URL_PKG_DOWNLOAD.format(pkgname)
file_name = file_url.split('/')[-1] file_name = file_url.split('/')[-1]
handler.watcher.change_substatus('{} {}'.format(self.i18n['arch.downloading.package'], bold(file_name))) handler.watcher.change_substatus('{} {}'.format(self.i18n['arch.downloading.package'], bold(file_name)))
download = handler.handle(SystemProcess(new_subprocess(['wget', file_url], cwd=app_build_dir))) download = handler.handle(SystemProcess(new_subprocess(['wget', file_url], cwd=app_build_dir), check_error_output=False))
if download: if download:
self._update_progress(handler.watcher, 30, change_progress) self._update_progress(handler.watcher, 30, change_progress)

View File

@@ -1,8 +1,17 @@
import re import re
from typing import Set from typing import Set
RE_PKGBUILD_OPTDEPS = re.compile(r"optdepends = ([^:\s]+)") RE_PKGBUILD_OPTDEPS = re.compile(r"optdepends = (.+)")
RE_PKGBUILD_DEPSON = re.compile(r"depends = ([^:\s]+)") RE_PKGBUILD_DEPSON = re.compile(r"\s+depends = (.+)")
def read_optdeps_as_dict(srcinfo: str) -> dict:
res = {}
for optdep in read_opts_deps(srcinfo):
split_dep = optdep.split(':')
res[split_dep[0].strip()] = split_dep[1].strip() if len(split_dep) > 1 else None
return res
def read_optdeps(srcinfo: str) -> Set[str]: def read_optdeps(srcinfo: str) -> Set[str]: