diff --git a/CHANGELOG.md b/CHANGELOG.md index c251de9f..8b04fae5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - AUR: - info dialog of installed packages displays the latest PKGBUILD file instead of the one used for installation/upgrade/downgrade (the fix will only work for new installed packages) - multi-threaded download: not retrieving correctly some source files URLs (e.g: linux-xanmod-lts) + - importing PGP keys (Generic error). Now the key server is specified: `gpg --keyserver SERVER --recv-key KEYID` (the server is retrieved from [bauh-files](https://github.com/vinifmor/bauh-files/blob/master/arch/gpgservers.txt)) - Flatpak - downgrading crashing with version 1.8.X - history: the top commit is returned as "(null)" in version 1.8.X diff --git a/bauh/gems/arch/__init__.py b/bauh/gems/arch/__init__.py index 6a1cb5c2..8471a7d6 100644 --- a/bauh/gems/arch/__init__.py +++ b/bauh/gems/arch/__init__.py @@ -10,6 +10,7 @@ PACKAGE_CACHE_DIR = '{}/pkg_cache'.format(BUILD_DIR) ARCH_CACHE_PATH = CACHE_PATH + '/arch' CATEGORIES_FILE_PATH = ARCH_CACHE_PATH + '/categories.txt' URL_CATEGORIES_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/arch/categories.txt' +URL_GPG_SERVERS = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/arch/gpgservers.txt' CONFIG_DIR = '{}/.config/bauh/arch'.format(str(Path.home())) CUSTOM_MAKEPKG_FILE = '{}/makepkg.conf'.format(CONFIG_DIR) AUR_INDEX_FILE = '{}/arch.txt'.format(BUILD_DIR) diff --git a/bauh/gems/arch/controller.py b/bauh/gems/arch/controller.py index 06a3fe98..598f0858 100644 --- a/bauh/gems/arch/controller.py +++ b/bauh/gems/arch/controller.py @@ -33,7 +33,7 @@ from bauh.commons.view_utils import new_select from bauh.gems.arch import BUILD_DIR, aur, pacman, makepkg, message, confirmation, disk, git, \ gpg, URL_CATEGORIES_FILE, CATEGORIES_FILE_PATH, CUSTOM_MAKEPKG_FILE, SUGGESTIONS_FILE, \ CONFIG_FILE, get_icon_path, database, mirrors, sorting, cpu_manager, ARCH_CACHE_PATH, UPDATES_IGNORED_FILE, \ - CONFIG_DIR, EDITABLE_PKGBUILDS_FILE + CONFIG_DIR, EDITABLE_PKGBUILDS_FILE, URL_GPG_SERVERS from bauh.gems.arch.aur import AURClient from bauh.gems.arch.config import read_config from bauh.gems.arch.dependencies import DependenciesAnalyser @@ -1789,7 +1789,11 @@ class ArchManager(SoftwareManager): body=self.i18n['arch.install.aur.unknown_key.body'].format(bold(context.name), bold(check_res['gpg_key']))): context.watcher.change_substatus(self.i18n['arch.aur.install.unknown_key.status'].format(bold(check_res['gpg_key']))) self.logger.info("Importing GPG key {}".format(check_res['gpg_key'])) - if not context.handler.handle(gpg.receive_key(check_res['gpg_key'])): + + gpg_res = self.context.http_client.get(URL_GPG_SERVERS) + gpg_server = gpg_res.text.split('\n')[0] if gpg_res else None + + if not context.handler.handle(gpg.receive_key(check_res['gpg_key'], gpg_server)): self.logger.error("An error occurred while importing the GPG key {}".format(check_res['gpg_key'])) context.watcher.show_message(title=self.i18n['error'].capitalize(), body=self.i18n['arch.aur.install.unknown_key.receive_error'].format(bold(check_res['gpg_key']))) diff --git a/bauh/gems/arch/gpg.py b/bauh/gems/arch/gpg.py index 7b9e3378..01c7235c 100644 --- a/bauh/gems/arch/gpg.py +++ b/bauh/gems/arch/gpg.py @@ -1,5 +1,14 @@ +from typing import Optional + from bauh.commons.system import SystemProcess, new_subprocess -def receive_key(key: str) -> SystemProcess: - return SystemProcess(new_subprocess(['gpg', '--recv-key', key]), check_error_output=False) +def receive_key(key: str, server: Optional[str] = None) -> SystemProcess: + cmd = ['gpg'] + + if server: + cmd.extend(['--keyserver', server]) + + cmd.extend(['--recv-key', key]) + + return SystemProcess(new_subprocess(cmd), check_error_output=False)