From 5b2e901d2e1b1199c3f1198affaf9b874ef8cb30 Mon Sep 17 00:00:00 2001 From: Patrick Uiterwijk Date: Jan 02 2020 09:45:48 +0000 Subject: Add a sanity check on remotely opened RPMs This should catch issues with downloading RPMs early, so as to not break the build in unknown ways. Fixes: #290 Signed-off-by: Patrick Uiterwijk --- diff --git a/koji/__init__.py b/koji/__init__.py index 69940cb..d9fa549 100644 --- a/koji/__init__.py +++ b/koji/__init__.py @@ -1688,6 +1688,15 @@ def openRemoteFile(relpath, topurl=None, topdir=None, tempdir=None): fo = open(fn) else: raise GenericError("No access method for remote file: %s" % relpath) + if relpath.endswith('.rpm'): + # Do a initial sanity check on any RPM we opened. + # This is basically to detect issues with RPMs before they break builds + # in unknown ways. + # Note that this does not always catch every possible issue, but it + # will at least catch issues like when an RPM is only partly downloaded + # (see issue #290). + rpm.TransactionSet().hdrCheck(fo.read()) + fo.seek(0) return fo