[PATCH] verify package checksums against metadata (#681224)
Brian C. Lane
bcl at redhat.com
Wed Aug 15 15:27:38 UTC 2012
From: "Brian C. Lane" <bcl at redhat.com>
Anaconda uses yum's getPackage() function to grab packages. It needs to
have a function passed to it in order to verify the package checksum
against the metadata.
Resolves: rhbz#681224
---
yuminstall.py | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/yuminstall.py b/yuminstall.py
index 61a0b65..f30fba0 100644
--- a/yuminstall.py
+++ b/yuminstall.py
@@ -177,7 +177,18 @@ class AnacondaCallback:
while self.openfile is None:
trynumber += 1
try:
- fn = repo.getPackage(po)
+ # checkfunc gets passed to yum's use of URLGrabber which
+ # then calls it with the file being fetched. verifyPkg
+ # makes sure the checksum matches the one in the metadata.
+ #
+ # From the URLGrab documents:
+ # checkfunc=(function, ('arg1', 2), {'kwarg': 3})
+ # results in a callback like:
+ # function(obj, 'arg1', 2, kwarg=3)
+ # obj.filename = '/tmp/stuff'
+ # obj.url = 'http://foo.com/stuff'
+ checkfunc = (self.ayum.verifyPkg, (po, 1), {})
+ fn = repo.getPackage(po, checkfunc=checkfunc)
f = open(fn, 'r')
self.openfile = f
@@ -185,6 +196,9 @@ class AnacondaCallback:
self.ayum._handleFailure(po, trynumber)
except IOError:
self.ayum._handleFailure(po, trynumber)
+ except URLGrabError as e:
+ log.error("URLGrabError: %s" % (e,))
+ self.ayum._handleFailure(po, trynumber)
except yum.Errors.RepoError, e:
continue
self.inProgressPo = po
--
1.7.11.2
More information about the anaconda-patches
mailing list