summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2011-08-02 07:32:38 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2011-08-02 07:32:38 -0400
commit6a537a6451233f42ffff70953972c1c04c5eeb29 (patch)
tree42b2aef33578ce0af4a7c57cf128addcb5469073 /src
parent7e6a3015cd61fb794fe299df9783099a4a792ec8 (diff)
downloadbcfg2-6a537a6451233f42ffff70953972c1c04c5eeb29.tar.gz
bcfg2-6a537a6451233f42ffff70953972c1c04c5eeb29.tar.bz2
bcfg2-6a537a6451233f42ffff70953972c1c04c5eeb29.zip
don't add gpg-pubkey package unless there are instances to install
Diffstat (limited to 'src')
-rw-r--r--src/lib/Server/Plugins/Packages.py71
1 files changed, 36 insertions, 35 deletions
diff --git a/src/lib/Server/Plugins/Packages.py b/src/lib/Server/Plugins/Packages.py
index 1c960b212..eab7721a3 100644
--- a/src/lib/Server/Plugins/Packages.py
+++ b/src/lib/Server/Plugins/Packages.py
@@ -1202,47 +1202,48 @@ class Packages(Bcfg2.Server.Plugin.Plugin,
def _build_gpgkeys(self, metadata, independent):
""" build list of gpg keys to be added to the specification by
validate_structures() """
- keypkg = lxml.etree.Element('BoundPackage', name="gpg-pubkey",
- type=self.get_ptype(metadata),
- origin='Packages')
-
needkeys = set()
for source in self.get_matching_sources(metadata):
for key in source.gpgkeys:
needkeys.add(key)
- for key in needkeys:
- # figure out the path of the key on the client
- try:
- keydir = self.config.get("global", "gpg_keypath")
- except ConfigParser.NoOptionError:
- keydir = "/etc/pki/rpm-gpg"
- remotekey = os.path.join(keydir, os.path.basename(key))
- localkey = os.path.join(self.keypath, os.path.basename(key))
- kdata = open(localkey).read()
+ if len(needkeys):
+ keypkg = lxml.etree.Element('BoundPackage', name="gpg-pubkey",
+ type=self.get_ptype(metadata),
+ origin='Packages')
+
+ for key in needkeys:
+ # figure out the path of the key on the client
+ try:
+ keydir = self.config.get("global", "gpg_keypath")
+ except ConfigParser.NoOptionError:
+ keydir = "/etc/pki/rpm-gpg"
+ remotekey = os.path.join(keydir, os.path.basename(key))
+ localkey = os.path.join(self.keypath, os.path.basename(key))
+ kdata = open(localkey).read()
- # copy the key to the client
- keypath = lxml.etree.Element("BoundPath", name=remotekey,
- encoding='ascii',
- owner='root', group='root',
- type='file', perms='0644',
- important='true')
- keypath.text = kdata
- independent.append(keypath)
-
- if has_yum:
- # add the key to the specification to ensure it gets
- # installed
- kinfo = yum.misc.getgpgkeyinfo(kdata)
- version = yum.misc.keyIdToRPMVer(kinfo['keyid'])
- release = yum.misc.keyIdToRPMVer(kinfo['timestamp'])
-
- lxml.etree.SubElement(keypkg, 'Instance', version=version,
- release=release, simplefile=remotekey)
- else:
- self.logger.info("Yum libraries not found; GPG keys will not "
- "be handled automatically")
- independent.append(keypkg)
+ # copy the key to the client
+ keypath = lxml.etree.Element("BoundPath", name=remotekey,
+ encoding='ascii',
+ owner='root', group='root',
+ type='file', perms='0644',
+ important='true')
+ keypath.text = kdata
+ independent.append(keypath)
+
+ if has_yum:
+ # add the key to the specification to ensure it
+ # gets installed
+ kinfo = yum.misc.getgpgkeyinfo(kdata)
+ version = yum.misc.keyIdToRPMVer(kinfo['keyid'])
+ release = yum.misc.keyIdToRPMVer(kinfo['timestamp'])
+
+ lxml.etree.SubElement(keypkg, 'Instance', version=version,
+ release=release, simplefile=remotekey)
+ else:
+ self.logger.info("Yum libraries not found; GPG keys will "
+ "not be handled automatically")
+ independent.append(keypkg)
def Refresh(self):
'''Packages.Refresh() => True|False\nReload configuration