From 82ae65ebb79994c2498ee882aa287e3d275510d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Moreira?= Date: Tue, 11 Feb 2020 18:41:12 -0300 Subject: [PATCH] [aur] architecture dependencies --- CHANGELOG.md | 4 +++- bauh/gems/arch/aur.py | 32 ++++++++++++++++++++++++++++---- bauh/gems/arch/controller.py | 26 +++++++++++++++----------- bauh/gems/arch/pkgbuild.py | 18 +++++++++++------- 4 files changed, 57 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99773ce5..e8a25e44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,9 +12,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - AUR - allowing the user to bypass checksum errors when installing / upgrading / downgrading packages - improved how missing dependencies are checked when installing a new package ( the old way was not identifying some missing dependencies of **anbox-git** ). It is possible to use the old algorithm by setting **simple_checking** to **true** in **~/.config/bauh/arch.yml**. More information at [README](https://github.com/vinifmor/bauh/#aur--arch-). + - checking architecture dependencies (x86_64, i686) + - architecture dependencies are displayed on the info window as well - UI: - **Settings** available as a tray action as well - - minor improvements + - minor fixes and improvements - handling internet timeout errors ## [0.8.2] - 2020-01-31 diff --git a/bauh/gems/arch/aur.py b/bauh/gems/arch/aur.py index cb07c95a..a4ab0465 100644 --- a/bauh/gems/arch/aur.py +++ b/bauh/gems/arch/aur.py @@ -14,8 +14,26 @@ URL_SRC_INFO = 'https://aur.archlinux.org/cgit/aur.git/plain/.SRCINFO?h=' URL_SEARCH = 'https://aur.archlinux.org/rpc/?v=5&type=search&arg=' RE_SRCINFO_KEYS = re.compile(r'(\w+)\s+=\s+(.+)\n') +RE_SPLIT_DEP = re.compile(r'[<>]?=') -KNOWN_LIST_FIELDS = ('validpgpkeys', 'depends', 'optdepends', 'sha512sums', 'sha512sums_x86_64', 'source', 'source_x86_64', 'makedepends') +KNOWN_LIST_FIELDS = ('validpgpkeys', + 'checkdepends', + 'checkdepends_x86_64', + 'checkdepends_i686', + 'depends', + 'depends_x86_64', + 'depends_i686', + 'optdepends', + 'optdepends_x86_64', + 'optdepends_i686', + 'sha512sums', + 'sha512sums_x86_64', + 'source', + 'source_x86_64', + 'source_i686' + 'makedepends', + 'makedepends_x86_64', + 'makedepends_i686') def map_pkgbuild(pkgbuild: str) -> dict: @@ -31,7 +49,7 @@ def map_srcinfo(string: str, fields: Set[str] = None) -> dict: field_re = RE_SRCINFO_KEYS for match in field_re.finditer(string): - field = match.group(0).split('=') + field = RE_SPLIT_DEP.split(match.group(0)) key = field[0].strip() val = field[1].strip() @@ -48,9 +66,10 @@ def map_srcinfo(string: str, fields: Set[str] = None) -> dict: class AURClient: - def __init__(self, http_client: HttpClient, logger: logging.Logger): + def __init__(self, http_client: HttpClient, logger: logging.Logger, x86_64: bool): self.http_client = http_client self.logger = logger + self.x86_64 = x86_64 def search(self, words: str) -> dict: return self.http_client.get_json(URL_SEARCH + words) @@ -81,7 +100,12 @@ class AURClient: def extract_required_dependencies(self, srcinfo: dict) -> Set[str]: deps = set() - for attr in ('makedepends', 'depends', 'checkdepends'): + for attr in ('makedepends', + 'makedepends_{}'.format('x86_64' if self.x86_64 else 'i686'), + 'depends', + 'depends_{}'.format('x86_64' if self.x86_64 else 'i686'), + 'checkdepends', + 'checkdepends_{}'.format('x86_64' if self.x86_64 else 'i686')): if srcinfo.get(attr): deps.update([pacman.RE_DEP_OPERATORS.split(dep)[0] for dep in srcinfo[attr]]) diff --git a/bauh/gems/arch/controller.py b/bauh/gems/arch/controller.py index af854719..b9e50b16 100644 --- a/bauh/gems/arch/controller.py +++ b/bauh/gems/arch/controller.py @@ -61,7 +61,7 @@ class ArchManager(SoftwareManager): self.mapper = ArchDataMapper(http_client=context.http_client, i18n=context.i18n) self.i18n = context.i18n - self.aur_client = AURClient(context.http_client, context.logger) + self.aur_client = AURClient(http_client=context.http_client, logger=context.logger, x86_64=context.is_system_x86_64()) self.dcache_updater = ArchDiskCacheUpdater(context.logger, context.disk_cache) self.logger = context.logger self.enabled = True @@ -335,17 +335,21 @@ class ArchManager(SoftwareManager): srcinfo = self.aur_client.get_src_info(pkg.name) if srcinfo: - if srcinfo.get('makedepends'): - info['12_makedepends'] = srcinfo['makedepends'] + arch_str = 'x86_64' if self.context.is_system_x86_64() else 'i686' + for info_attr, src_attr in {'12_makedepends': 'makedepends', + '13_dependson': 'depends', + '14_optdepends': 'optdepends', + 'checkdepends': '15_checkdepends'}.items(): + if srcinfo.get(src_attr): + info[info_attr] = [*srcinfo[src_attr]] - if srcinfo.get('depends'): - info['13_dependson'] = srcinfo['depends'] + arch_attr = '{}_{}'.format(src_attr, arch_str) - if srcinfo.get('optdepends'): - info['14_optdepends'] = srcinfo['optdepends'] - - if srcinfo.get('checkdepends'): - info['15_checkdepends'] = srcinfo['checkdepends'] + if srcinfo.get(arch_attr): + if not info.get(info_attr): + info[info_attr] = [*srcinfo[arch_attr]] + else: + info[info_attr].extend(srcinfo[arch_attr]) if pkg.pkgbuild: info['00_pkg_build'] = pkg.pkgbuild @@ -660,7 +664,7 @@ class ArchManager(SoftwareManager): def _install_optdeps(self, pkgname: str, root_password: str, handler: ProcessHandler, pkgdir: str) -> bool: with open('{}/.SRCINFO'.format(pkgdir)) as f: - odeps = pkgbuild.read_optdeps_as_dict(f.read()) + odeps = pkgbuild.read_optdeps_as_dict(f.read(), self.context.is_system_x86_64()) if not odeps: return True diff --git a/bauh/gems/arch/pkgbuild.py b/bauh/gems/arch/pkgbuild.py index 747b336d..fe04a4d6 100644 --- a/bauh/gems/arch/pkgbuild.py +++ b/bauh/gems/arch/pkgbuild.py @@ -2,21 +2,25 @@ import re from typing import Set RE_PKGBUILD_OPTDEPS = re.compile(r"optdepends = (.+)") -RE_PKGBUILD_DEPSON = re.compile(r"\s+depends = (.+)") +RE_PKGBUILD_OPTDEPS_x86_64 = re.compile(r"optdepends_x86_64 = (.+)") +RE_PKGBUILD_OPTDEPS_i686 = re.compile(r"optdepends_i686 = (.+)") -def read_optdeps_as_dict(srcinfo: str) -> dict: +def read_optdeps_as_dict(srcinfo: str, x86_64: bool) -> dict: res = {} - for optdep in read_optdeps(srcinfo): + for optdep in read_optdeps(srcinfo, x86_64): 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]: - return set(RE_PKGBUILD_OPTDEPS.findall(srcinfo)) +def read_optdeps(srcinfo: str, x86_64: bool) -> Set[str]: + optdeps = set(RE_PKGBUILD_OPTDEPS.findall(srcinfo)) + if x86_64: + optdeps.update(set(RE_PKGBUILD_OPTDEPS_x86_64.findall(srcinfo))) + else: + optdeps.update(set(RE_PKGBUILD_OPTDEPS_i686.findall(srcinfo))) -def read_depends_on(srcinfo: str) -> Set[str]: - return set(RE_PKGBUILD_DEPSON.findall(srcinfo)) + return optdeps