diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2007-06-02 21:00:41 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2007-06-02 21:00:41 +0000 |
commit | 6d5c8583ecf0cafa139d20a7bfb123c843ad77b8 (patch) | |
tree | b5540e59f4b5521e2a48622fa238b7b7361d6dbe /src/lib/Client/Tools/FreeBSDPackage.py | |
parent | f5bb417f750cc4b39d8b6cc6cae31e5c95800c67 (diff) | |
download | bcfg2-6d5c8583ecf0cafa139d20a7bfb123c843ad77b8.tar.gz bcfg2-6d5c8583ecf0cafa139d20a7bfb123c843ad77b8.tar.bz2 bcfg2-6d5c8583ecf0cafa139d20a7bfb123c843ad77b8.zip |
Add preliminary support for FreeBSD Packages (from gogo)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@3223 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Client/Tools/FreeBSDPackage.py')
-rw-r--r-- | src/lib/Client/Tools/FreeBSDPackage.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/lib/Client/Tools/FreeBSDPackage.py b/src/lib/Client/Tools/FreeBSDPackage.py new file mode 100644 index 000000000..0e8747e8b --- /dev/null +++ b/src/lib/Client/Tools/FreeBSDPackage.py @@ -0,0 +1,42 @@ +'''This is the bcfg2 tool for the FreeBSD package system.''' +__revision__ = '$Id$' + +import re +import Bcfg2.Client.Tools + +class FreeBSDPackage(Bcfg2.Client.Tools.PkgTool): + '''The FreeBSD toolset implements package operations and inherits + the rest from Toolset.Toolset''' + __name__ = 'FreeBSDPackage' + __execs__ = ['/usr/sbin/pkg_add', '/usr/sbin/pkg_info'] + __handles__ = [('Package', 'freebsdpkg')] + __req__ = {'Package': ['name', 'version']} + pkgtool = ('/usr/sbin/pkg_add -r %s', ('%s-%s', ['name', 'version'])) + pkgtype = 'freebsdpkg' + + def RefreshPackages(self): + self.installed = {} + packages = self.cmd.run("/usr/sbin/pkg_info -a -E")[1] + pattern = re.compile('(.*)-(\d.*)') + for pkg in packages: + if pattern.match(pkg): + name = pattern.match(pkg).group(1) + version = pattern.match(pkg).group(2) + self.installed[name] = version + + def VerifyPackage(self, entry, modlist): + if not entry.attrib.has_key('version'): + self.logger.info("Cannot verify unversioned package %s" % + (entry.attrib['name'])) + return False + if self.installed.has_key(entry.attrib['name']): + if self.installed[entry.attrib['name']] == entry.attrib['version']: + # TODO: verfification + return True + else: + entry.set('current_version', self.installed[entry.get('name')]) + return False + + self.logger.info("Package %s not installed" % (entry.get('name'))) + entry.set('current_exists', 'false') + return False |