From e775e56acf394a23f325064a0b767434abe6a065 Mon Sep 17 00:00:00 2001 From: Patrick Uiterwijk Date: May 03 2017 14:08:31 +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 7bafee7..d384854 100644 --- a/koji/__init__.py +++ b/koji/__init__.py @@ -1571,6 +1571,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