mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-11 03:04:15 +02:00
fix: AUR installation receiving GPG key
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import re
|
||||
import subprocess
|
||||
from typing import List, Set
|
||||
|
||||
from bauh.commons.system import run_cmd, new_subprocess, new_root_subprocess, SystemProcess
|
||||
from bauh.api.abstract.handler import ProcessWatcher
|
||||
from bauh.commons.system import run_cmd, new_subprocess, new_root_subprocess, SystemProcess, ProcessHandler
|
||||
|
||||
RE_DEPS = re.compile(r'[\w\-_]+:[\s\w_\-\.]+\s+\[\w+\]')
|
||||
|
||||
@@ -51,7 +53,8 @@ def get_info_dict(pkg_name: str) -> dict:
|
||||
info_dict = {}
|
||||
for info_data in info_list:
|
||||
attr = info_data[0].lower().strip()
|
||||
info_dict[attr] = info_data[1] if '\n' not in info_data[1] else ' '.join([l.strip() for l in info_data[1].split('\n')])
|
||||
info_dict[attr] = info_data[1] if '\n' not in info_data[1] else ' '.join(
|
||||
[l.strip() for l in info_data[1].split('\n')])
|
||||
|
||||
if info_dict[attr] == 'None':
|
||||
info_dict[attr] = None
|
||||
@@ -76,7 +79,8 @@ def list_and_map_installed() -> dict: # returns a dict with with package names
|
||||
allinfo = new_subprocess(['pacman', '-Qi'], stdin=installed).stdout # retrieving all installed packages info
|
||||
|
||||
pkgs, current_pkg = {'mirrors': {}, 'not_signed': {}}, {}
|
||||
for out in new_subprocess(['grep', '-E', '(Name|Description|Version|Validated By)'], stdin=allinfo).stdout: # filtering only the Name and Validated By fields:
|
||||
for out in new_subprocess(['grep', '-E', '(Name|Description|Version|Validated By)'],
|
||||
stdin=allinfo).stdout: # filtering only the Name and Validated By fields:
|
||||
if out:
|
||||
line = out.decode()
|
||||
|
||||
@@ -90,7 +94,8 @@ def list_and_map_installed() -> dict: # returns a dict with with package names
|
||||
elif line.startswith('Validated'):
|
||||
|
||||
if line.split(':')[1].strip().lower() == 'none':
|
||||
pkgs['not_signed'][current_pkg['name']] = {'version': current_pkg['version'], 'description': current_pkg['description']}
|
||||
pkgs['not_signed'][current_pkg['name']] = {'version': current_pkg['version'],
|
||||
'description': current_pkg['description']}
|
||||
|
||||
current_pkg = {}
|
||||
|
||||
@@ -98,7 +103,6 @@ def list_and_map_installed() -> dict: # returns a dict with with package names
|
||||
|
||||
|
||||
def install_as_process(pkgpath: str, root_password: str, aur: bool, pkgdir: str = '.') -> SystemProcess:
|
||||
|
||||
if aur:
|
||||
cmd = ['pacman', '-U', pkgpath, '--noconfirm'] # pkgpath = install file path
|
||||
else:
|
||||
@@ -143,3 +147,23 @@ def list_bin_paths(pkgnames: Set[str]) -> List[str]:
|
||||
bin_paths.append(line)
|
||||
|
||||
return bin_paths
|
||||
|
||||
|
||||
def verify_pgp_key(key: str) -> bool:
|
||||
list_key = new_subprocess(['pacman-key', '-l']).stdout
|
||||
|
||||
for out in new_subprocess(['grep', " " + key], stdin=list_key).stdout:
|
||||
if out:
|
||||
line = out.decode().strip()
|
||||
if line and key in line:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def receive_key(key: str, root_password: str) -> SystemProcess:
|
||||
return SystemProcess(new_root_subprocess(['pacman-key', '-r', key], root_password=root_password), check_error_output=False)
|
||||
|
||||
|
||||
def sign_key(key: str, root_password: str) -> SystemProcess:
|
||||
return SystemProcess(new_root_subprocess(['pacman-key', '--lsign-key', key], root_password=root_password), check_error_output=False)
|
||||
|
||||
Reference in New Issue
Block a user