Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recommend a plugin to resolve expired GPG keys #2166

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dnf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions dnf/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand All @@ -312,6 +315,9 @@ 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.") + '\n'
logger.info(msg)
raise dnf.exceptions.Error(_("GPG check FAILED"))

def latest_changelogs(self, package):
Expand Down
4 changes: 4 additions & 0 deletions dnf/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ def __str__(self):
return self.errmap2str(self.errmap)


class InvalidInstalledGPGKeyError(Error):
pass


class LockError(Error):
pass

Expand Down
Loading