[aur] architecture dependencies

This commit is contained in:
Vinícius Moreira
2020-02-11 18:41:12 -03:00
parent 2b9f4bf69f
commit 82ae65ebb7
4 changed files with 57 additions and 23 deletions

View File

@@ -12,9 +12,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- AUR - AUR
- allowing the user to bypass checksum errors when installing / upgrading / downgrading packages - 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-). - 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: - UI:
- **Settings** available as a tray action as well - **Settings** available as a tray action as well
- minor improvements - minor fixes and improvements
- handling internet timeout errors - handling internet timeout errors
## [0.8.2] - 2020-01-31 ## [0.8.2] - 2020-01-31

View File

@@ -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=' URL_SEARCH = 'https://aur.archlinux.org/rpc/?v=5&type=search&arg='
RE_SRCINFO_KEYS = re.compile(r'(\w+)\s+=\s+(.+)\n') 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: 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 field_re = RE_SRCINFO_KEYS
for match in field_re.finditer(string): for match in field_re.finditer(string):
field = match.group(0).split('=') field = RE_SPLIT_DEP.split(match.group(0))
key = field[0].strip() key = field[0].strip()
val = field[1].strip() val = field[1].strip()
@@ -48,9 +66,10 @@ def map_srcinfo(string: str, fields: Set[str] = None) -> dict:
class AURClient: 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.http_client = http_client
self.logger = logger self.logger = logger
self.x86_64 = x86_64
def search(self, words: str) -> dict: def search(self, words: str) -> dict:
return self.http_client.get_json(URL_SEARCH + words) return self.http_client.get_json(URL_SEARCH + words)
@@ -81,7 +100,12 @@ class AURClient:
def extract_required_dependencies(self, srcinfo: dict) -> Set[str]: def extract_required_dependencies(self, srcinfo: dict) -> Set[str]:
deps = set() 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): if srcinfo.get(attr):
deps.update([pacman.RE_DEP_OPERATORS.split(dep)[0] for dep in srcinfo[attr]]) deps.update([pacman.RE_DEP_OPERATORS.split(dep)[0] for dep in srcinfo[attr]])

View File

@@ -61,7 +61,7 @@ class ArchManager(SoftwareManager):
self.mapper = ArchDataMapper(http_client=context.http_client, i18n=context.i18n) self.mapper = ArchDataMapper(http_client=context.http_client, i18n=context.i18n)
self.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.dcache_updater = ArchDiskCacheUpdater(context.logger, context.disk_cache)
self.logger = context.logger self.logger = context.logger
self.enabled = True self.enabled = True
@@ -335,17 +335,21 @@ class ArchManager(SoftwareManager):
srcinfo = self.aur_client.get_src_info(pkg.name) srcinfo = self.aur_client.get_src_info(pkg.name)
if srcinfo: if srcinfo:
if srcinfo.get('makedepends'): arch_str = 'x86_64' if self.context.is_system_x86_64() else 'i686'
info['12_makedepends'] = srcinfo['makedepends'] 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'): arch_attr = '{}_{}'.format(src_attr, arch_str)
info['13_dependson'] = srcinfo['depends']
if srcinfo.get('optdepends'): if srcinfo.get(arch_attr):
info['14_optdepends'] = srcinfo['optdepends'] if not info.get(info_attr):
info[info_attr] = [*srcinfo[arch_attr]]
if srcinfo.get('checkdepends'): else:
info['15_checkdepends'] = srcinfo['checkdepends'] info[info_attr].extend(srcinfo[arch_attr])
if pkg.pkgbuild: if pkg.pkgbuild:
info['00_pkg_build'] = 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: def _install_optdeps(self, pkgname: str, root_password: str, handler: ProcessHandler, pkgdir: str) -> bool:
with open('{}/.SRCINFO'.format(pkgdir)) as f: 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: if not odeps:
return True return True

View File

@@ -2,21 +2,25 @@ import re
from typing import Set from typing import Set
RE_PKGBUILD_OPTDEPS = re.compile(r"optdepends = (.+)") 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 = {} res = {}
for optdep in read_optdeps(srcinfo): for optdep in read_optdeps(srcinfo, x86_64):
split_dep = optdep.split(':') split_dep = optdep.split(':')
res[split_dep[0].strip()] = split_dep[1].strip() if len(split_dep) > 1 else None res[split_dep[0].strip()] = split_dep[1].strip() if len(split_dep) > 1 else None
return res return res
def read_optdeps(srcinfo: str) -> Set[str]: def read_optdeps(srcinfo: str, x86_64: bool) -> Set[str]:
return set(RE_PKGBUILD_OPTDEPS.findall(srcinfo)) 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 optdeps
return set(RE_PKGBUILD_DEPSON.findall(srcinfo))