diff --git a/dnf/base.py b/dnf/base.py index 698021b1c4..0222c76dae 100644 --- a/dnf/base.py +++ b/dnf/base.py @@ -2640,7 +2640,7 @@ def _prov_key_data(msg): 'package.\n' 'Check that the correct key URLs are configured for ' 'this repository.') % repo.name - raise dnf.exceptions.Error(_prov_key_data(msg)) + raise dnf.exceptions.InvalidInstalledGPGKeyError(_prov_key_data(msg)) # Check if the newly installed keys helped result, errmsg = self._sig_check_pkg(po) diff --git a/dnf/cli/cli.py b/dnf/cli/cli.py index d3844df344..2d20cf425c 100644 --- a/dnf/cli/cli.py +++ b/dnf/cli/cli.py @@ -284,6 +284,7 @@ def gpgsigcheck(self, pkgs): :raises: Will raise :class:`Error` if there's a problem """ error_messages = [] + print_plugin_recommendation = False for po in pkgs: result, errmsg = self._sig_check_pkg(po) @@ -304,6 +305,8 @@ def gpgsigcheck(self, pkgs): self._get_key_for_package(po, fn) except (dnf.exceptions.Error, ValueError) as e: error_messages.append(str(e)) + if isinstance(e, dnf.exceptions.InvalidInstalledGPGKeyError): + print_plugin_recommendation = True else: # Fatal error @@ -312,6 +315,11 @@ def gpgsigcheck(self, pkgs): if error_messages: for msg in error_messages: logger.critical(msg) + if print_plugin_recommendation: + msg = '\n' + _("Try to add '--enableplugin=expired-pgp-keys' to resolve the problem. " + "Note: This plugin might not be installed by default, as it is part of " + "the 'dnf-plugins-core' package.") + '\n' + logger.info(msg) raise dnf.exceptions.Error(_("GPG check FAILED")) def latest_changelogs(self, package): diff --git a/dnf/exceptions.py b/dnf/exceptions.py index 2d009b2ad2..6eaa98ff6d 100644 --- a/dnf/exceptions.py +++ b/dnf/exceptions.py @@ -86,6 +86,10 @@ def __str__(self): return self.errmap2str(self.errmap) +class InvalidInstalledGPGKeyError(Error): + pass + + class LockError(Error): pass