Skip to content
Open
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
30 changes: 29 additions & 1 deletion repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,15 +830,43 @@ def installFromYum(targets, mounts, progress_callback, cachedir):
rv = p.wait()
stderr.seek(0)
stderr = stderr.read()
gpg_error_message = None
if stderr:
logger.log("YUM stderr: %s" % stderr.strip())

if ' in import_key_to_pubring' in stderr:
gpg_error_message = "Signature key import failed"
# add any other instance of uncaught GpgmeError before this like
elif 'gpgme.GpgmeError: ' in stderr:
gpg_error_message = "Cryptography-related yum crash"

elif re.search("Couldn't open file [^ ]*/repodata/repomd.xml.asc", stderr):
# would otherwise be mistaken for "pubring import" !?
gpg_error_message = "No signature on repository metadata"
elif 'repomd.xml signature could not be verified' in stderr:
gpg_error_message = "Repository signature verification failure"

else:
match = re.search("Public key for ([^ ]*.rpm) is not installed", stderr)
if match:
gpg_error_message = "Missing key for %s" % (match.group(1),)
match = re.search("Package ([^ ]*.rpm) is not signed", stderr)
if match:
gpg_error_message = "Package not signed: %s" % (match.group(1),)
match = re.search(r" ([^ ]*): \[Errno [0-9]*\] No more mirrors to try", stderr)
if match:
# rpm not found or corrupted/re-signed/etc
gpg_error_rpm_not_found = match.group(1)
gpg_error_message = "Cannot find valid rpm for %s" % (match.group(1),)

if rv:
if rv > 0:
logger.log("Yum exited with %d" % rv)
else:
logger.log("Yum killed by signal %d" % -rv)
raise ErrorInstallingPackage("Error installing packages")
if gpg_error_message is None:
gpg_error_message = "Error installing packages"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: You could just set gpg_error_message to this value on line 833 and remove lines 867 & 878 (then if any matches occur it would just replace it with a more detailed error message

raise ErrorInstallingPackage(gpg_error_message)

shutil.rmtree(os.path.join(mounts['root'], cachedir))

Expand Down