[yum-cvs] yum cli.py,1.182,1.183
Menno Smits
mjs at login.linux.duke.edu
Wed Jun 15 11:49:48 UTC 2005
Update of /home/groups/yum/cvs/yum
In directory login:/tmp/cvs-serv18474
Modified Files:
cli.py
Log Message:
Support for multple GPG keys per repo.
Index: cli.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/cli.py,v
retrieving revision 1.182
retrieving revision 1.183
diff -u -r1.182 -r1.183
--- cli.py 30 May 2005 05:49:22 -0000 1.182
+++ cli.py 15 Jun 2005 11:49:45 -0000 1.183
@@ -743,55 +743,65 @@
'unattended.\nUse "-y" to override.'
repo = self.repos.getRepo(po.repoid)
- keyurl = repo.gpgkey
- self.log(0, 'Retrieving GPG key from %s' % keyurl)
+ keyurls = repo.gpgkey
+ key_installed = False
- # Go get the GPG key from the given URL
- try:
- rawkey = urlgrabber.urlread(keyurl, limit=9999)
- except urlgrabber.grabber.URLGrabError, e:
- raise yum.Errors.YumBaseError(
- 'GPG key retrieval failed: ' + str(e))
+ for keyurl in keyurls:
+ self.log(0, 'Retrieving GPG key from %s' % keyurl)
- # Parse the key
- try:
- keyinfo = yum.misc.getgpgkeyinfo(rawkey)
- keyid = keyinfo['keyid']
- hexkeyid = yum.misc.keyIdToRPMVer(keyid).upper()
- timestamp = keyinfo['timestamp']
- userid = keyinfo['userid']
- except ValueError, e:
- raise yum.Errors.YumBaseError, \
- 'GPG key parsing failed: ' + str(e)
+ # Go get the GPG key from the given URL
+ try:
+ rawkey = urlgrabber.urlread(keyurl, limit=9999)
+ except urlgrabber.grabber.URLGrabError, e:
+ raise yum.Errors.YumBaseError(
+ 'GPG key retrieval failed: ' + str(e))
+
+ # Parse the key
+ try:
+ keyinfo = yum.misc.getgpgkeyinfo(rawkey)
+ keyid = keyinfo['keyid']
+ hexkeyid = yum.misc.keyIdToRPMVer(keyid).upper()
+ timestamp = keyinfo['timestamp']
+ userid = keyinfo['userid']
+ except ValueError, e:
+ raise yum.Errors.YumBaseError, \
+ 'GPG key parsing failed: ' + str(e)
+
+ # Check if key is already installed
+ if yum.misc.keyInstalled(self.read_ts, keyid, timestamp) >= 0:
+ self.log(0, 'GPG key at %s (0x%s) is already installed' % (
+ keyurl,
+ hexkeyid
+ ))
+ continue
- # Check if key is already installed
- if yum.misc.keyInstalled(self.read_ts, keyid, timestamp) >= 0:
- self.log(0, '\n')
- raise yum.Errors.YumBaseError, \
- 'The GPG key at %s (0x%s) \n' \
- 'is already installed but is not the correct '\
- 'key for this package.\nCheck that this is the ' \
- 'correct key for the "%s" repository.' % \
- (keyurl, hexkeyid, repo.name)
-
- # Try installing/updating GPG key
- self.log(0, 'Importing GPG key 0x%s "%s"' % (hexkeyid, userid))
- if not self.conf.getConfigOption('assumeyes'):
- if not self.userconfirm():
- self.log(0, 'Exiting on user command')
- return 1
-
- # Import the key
- result = self.ts.pgpImportPubkey(yum.misc.procgpgkey(rawkey))
- if result != 0:
+ # Try installing/updating GPG key
+ self.log(0, 'Importing GPG key 0x%s "%s"' % (hexkeyid, userid))
+ if not self.conf.getConfigOption('assumeyes'):
+ if not self.userconfirm():
+ self.log(0, 'Exiting on user command')
+ return 1
+
+ # Import the key
+ result = self.ts.pgpImportPubkey(yum.misc.procgpgkey(rawkey))
+ if result != 0:
+ raise yum.Errors.YumBaseError, \
+ 'Key import failed (code %d)' % result
+ self.log(1, 'Key imported successfully')
+ key_installed = True
+
+ if not key_installed:
raise yum.Errors.YumBaseError, \
- 'Key import failed (code %d)' % result
- self.log(1, 'Key imported successfully')
-
- # Check if the key helped
+ 'The GPG keys listed for the "%s" repository are ' \
+ 'already installed but they are not correct for this ' \
+ 'package.\n' \
+ 'Check that the correct key URLs are configured for ' \
+ 'this repository.' % (repo.name)
+
+ # Check if the newly installed keys helped
result, errmsg = self.sigCheckPkg(po)
if result != 0:
- self.log(0, "Key import didn't help, wrong key?")
+ self.log(0, "Import of key(s) didn't help, wrong key(s)?")
raise yum.Errors.YumBaseError, errmsg
else:
More information about the Yum-cvs-commits
mailing list