summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2009-05-15 03:21:34 +0000
committerNarayan Desai <desai@mcs.anl.gov>2009-05-15 03:21:34 +0000
commit60a2643d4e7bd0a0964180ebbfd8e31d12cbbf98 (patch)
tree10ebcdf531b7ded118ed941543a252044370fbf9 /src/lib
parent4c05d2e4db46e319890f0052790eebaf1d2c029b (diff)
downloadbcfg2-60a2643d4e7bd0a0964180ebbfd8e31d12cbbf98.tar.gz
bcfg2-60a2643d4e7bd0a0964180ebbfd8e31d12cbbf98.tar.bz2
bcfg2-60a2643d4e7bd0a0964180ebbfd8e31d12cbbf98.zip
Remove deprecated RPM and Yum drivers
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5237 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Client/Tools/RPM.py109
-rw-r--r--src/lib/Client/Tools/Yum.py47
-rw-r--r--src/lib/Client/Tools/__init__.py3
3 files changed, 1 insertions, 158 deletions
diff --git a/src/lib/Client/Tools/RPM.py b/src/lib/Client/Tools/RPM.py
deleted file mode 100644
index 1ccffb4a8..000000000
--- a/src/lib/Client/Tools/RPM.py
+++ /dev/null
@@ -1,109 +0,0 @@
-'''Bcfg2 Support for RPMS'''
-
-__revision__ = '$Revision$'
-
-import Bcfg2.Client.Tools, time
-
-class RPM(Bcfg2.Client.Tools.PkgTool):
- '''Support for RPM packages'''
- name = 'RPM'
- __execs__ = ['/bin/rpm', '/var/lib/rpm']
- __handles__ = [('Package', 'rpm')]
- __req__ = {'Package': ['name', 'version']}
- __ireq__ = {'Package': ['name', 'version', 'url']}
- pkgtype = 'rpm'
- pkgtool = ("rpm --oldpackage --replacepkgs --quiet -U %s", ("%s", ["url"]))
-
- def RefreshPackages(self, level=0):
- '''Cache package states'''
- self.installed = {}
- if level > 5:
- return
- for line in self.cmd.run("rpm -qa --qf '%{NAME} %{VERSION}-%{RELEASE}\n'")[1]:
- try:
- (name, version) = line.split()
- self.installed[name] = version
- except ValueError:
- if line == '':
- continue
- self.logger.error("Failed to access RPM db; retrying after 30s")
- time.sleep(30)
- return self.RefreshPackages(level + 1)
-
- def VerifyPackage(self, entry, modlist):
- '''Verify Package status for entry'''
- if not entry.get('version'):
- self.logger.error("Can't install package %s, not enough data." % (entry.get('name')))
- return False
- rpm_options = []
- if entry.get('verify', 'false') == 'nomtime':
- self.logger.debug("Skipping mtime verification for package %s" % \
- (entry.get('name')))
- rpm_options.append("--nomtime")
- if entry.get('name') in self.installed:
- if entry.get('version') == self.installed[entry.get('name')]:
- if entry.get('multiarch'):
- archs = entry.get('multiarch').split()
- info = self.cmd.run(
- 'rpm -q %s --qf "%%{NAME} %%{VERSION}-%%{RELEASE} %%{ARCH}\n"' \
- % (entry.get('name')))[1]
- while info:
- arch = info.pop().split()[2]
- if arch in archs:
- archs.remove(arch)
- else:
- self.logger.error("Got pkg install for Package %s: arch %s" % \
- (entry.get('name'), arch))
- return False
- if archs:
- self.logger.error("Package %s not installed for arch: %s" % \
- (entry.get('name'), archs))
- return False
- if (self.setup['quick'] or (entry.get('verify', 'true') == 'false')) \
- or entry.get('multiarch'):
- if entry.get('verify', 'true') == 'false':
- self.logger.debug("Skipping checksum verification for package %s" % \
- (entry.get('name')))
- return True
- else:
- self.logger.debug("Package %s: wrong version installed. want %s have %s" %
- (entry.get('name'), entry.get('version'),
- self.installed[entry.get('name')]))
- entry.set('current_version', self.installed[entry.get('name')])
- entry.set('qtext', 'Upgrade/downgrade Package %s (%s -> %s)? (y/N) ' % \
- (entry.get('name'), entry.get('current_version'),
- entry.get('version')))
- return False
- else:
- self.logger.debug("Package %s: not installed" % (entry.get('name')))
- entry.set('current_exists', 'false')
- entry.set('qtext', "Install Package %s-%s? (y/N) " % \
- (entry.get('name'), entry.get('version')))
- return False
-
- (vstat, output) = self.cmd.run("rpm --verify %s %s-%s" % \
- (" ".join(rpm_options),
- entry.get('name'),
- entry.get('version')))
- if vstat != 0:
- if [name for name in output if name.split()[-1] not in modlist]:
- self.logger.debug("Package %s content verification failed" % \
- entry.get('name'))
- return False
- return True
-
- def RemovePackages(self, packages):
- '''Remove specified entries'''
- pkgnames = [pkg.get('name') for pkg in packages]
- if len(pkgnames) > 0:
- self.logger.info("Removing packages: %s" % pkgnames)
- if self.cmd.run("rpm --quiet -e --allmatches %s" % " ".join(pkgnames))[0] == 0:
- self.modified += packages
- else:
- for pkg in packages:
- if self.cmd.run("rpm --quiet -e --allmatches %s" % \
- pkg.get('name'))[0] == 0:
- self.modified += pkg
-
- self.RefreshPackages()
- self.extra = self.FindExtraPackages()
diff --git a/src/lib/Client/Tools/Yum.py b/src/lib/Client/Tools/Yum.py
deleted file mode 100644
index 73506af14..000000000
--- a/src/lib/Client/Tools/Yum.py
+++ /dev/null
@@ -1,47 +0,0 @@
-# This is the bcfg2 support for yum
-'''This provides bcfg2 support for yum'''
-__revision__ = '$Revision$'
-
-import Bcfg2.Client.Tools.RPM, ConfigParser, sys
-
-YAD = True
-CP = ConfigParser.ConfigParser()
-try:
- if '-C' in sys.argv:
- CP.read([sys.argv[sys.argv.index('-C') + 1]])
- else:
- CP.read(['/etc/bcfg2.conf'])
- if CP.get('Yum', 'autodep') == 'false':
- YAD = False
-except:
- pass
-
-class Yum(Bcfg2.Client.Tools.RPM.RPM):
- '''Support for Yum packages'''
- pkgtype = 'yum'
- if YAD:
- pkgtool = ("/usr/bin/yum -d0 -y install %s", ("%s-%s", ["name", "version"]))
- else:
- pkgtool = ("/usr/bin/yum -d0 install %s", ("%s-%s", ["name", "version"]))
- name = 'Yum'
- __execs__ = ['/usr/bin/yum', '/var/lib/rpm']
- __handles__ = [('Package', 'yum'), ('Package', 'rpm')]
- __req__ = {'Package': ['name', 'version']}
- __ireq__ = {'Package': ['name', 'version']}
- conflicts = ['RPM']
-
- def RemovePackages(self, packages):
- '''Remove specified entries'''
- pkgnames = [pkg.get('name') for pkg in packages]
- rmcmd = "yum -d0 -y remove %s" % " ".join(pkgnames)
- if len(pkgnames) > 0:
- self.logger.info("Removing packages: %s" % pkgnames)
- if self.cmd.run(rmcmd)[0] == 0:
- self.modified += packages
- self.RefreshPackages()
- self.extra = self.FindExtraPackages()
-
- def VerifyPackage(self, entry, modlist):
- if entry.get('version') == 'noverify':
- return entry.get('name') in self.installed
- return Bcfg2.Client.Tools.RPM.RPM.VerifyPackage(self, entry, modlist)
diff --git a/src/lib/Client/Tools/__init__.py b/src/lib/Client/Tools/__init__.py
index e03ceab3a..f0ae01a0a 100644
--- a/src/lib/Client/Tools/__init__.py
+++ b/src/lib/Client/Tools/__init__.py
@@ -3,8 +3,7 @@ __revision__ = '$Revision$'
__all__ = ["Action", "APT", "Blast", "Chkconfig", "DebInit", "Encap", "IPS",
"FreeBSDInit", "FreeBSDPackage", "launchd", "Portage", "POSIX",
- "RPM", "RPMng", 'rpmtools', "RcUpdate", "SMF", "SYSV", "Yum",
- "YUMng"]
+ "RPMng", 'rpmtools', "RcUpdate", "SMF", "SYSV", "YUMng"]
drivers = [item for item in __all__ if item not in ['rpmtools']]
default = [item for item in drivers if item not in ['RPM', 'Yum']]