[fix][aur] not finding some dependencies declared as files instead of the package names

This commit is contained in:
Vinicius Moreira
2019-12-02 11:36:05 -03:00
parent a6de4caa51
commit ef5210b468
12 changed files with 54 additions and 24 deletions

View File

@@ -1,6 +1,6 @@
import re
from threading import Thread
from typing import List, Set
from typing import List, Set, Tuple
from bauh.commons.system import run_cmd, new_subprocess, new_root_subprocess, SystemProcess
@@ -13,6 +13,17 @@ def is_enabled() -> bool:
return res and not res.strip().startswith('which ')
def get_mirror(pkg: str) -> Tuple[str, str]:
res = run_cmd('pacman -Ss {}'.format(pkg))
if res:
lines = res.split('\n')
if lines:
data = lines[0].split('/')
return data[1].split(' ')[0], data[0]
def get_mirrors(pkgs: Set[str]) -> dict:
pkgre = '|'.join(pkgs).replace('+', r'\+').replace('.', r'\.')
@@ -26,6 +37,15 @@ def get_mirrors(pkgs: Set[str]) -> dict:
if p in match:
mirrors[p] = match.split('/')[0]
not_found = {pkg for pkg in pkgs if pkg not in mirrors}
if not_found: # if there are any not found, try to find via the single method:
for dep in not_found:
mirror_data = get_mirror(dep)
if mirror_data:
mirrors[mirror_data[0]] = mirror_data[1]
return mirrors