mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 01:14:15 +02:00
[aur] architecture dependencies
This commit is contained in:
@@ -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]])
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user