diff options
Diffstat (limited to 'src/lib/Client/Tools')
-rw-r--r-- | src/lib/Client/Tools/FreeBSDPackage.py | 42 | ||||
-rw-r--r-- | src/lib/Client/Tools/__init__.py | 5 |
2 files changed, 45 insertions, 2 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 diff --git a/src/lib/Client/Tools/__init__.py b/src/lib/Client/Tools/__init__.py index a4a2dc08c..1ab656481 100644 --- a/src/lib/Client/Tools/__init__.py +++ b/src/lib/Client/Tools/__init__.py @@ -2,8 +2,9 @@ __revision__ = '$Revision$' __all__ = ["Action", "APT", "Blast", "Chkconfig", "DebInit", "Encap", - "launchd", "Portage", "POSIX", "RPM", "RPMng", 'rpmtools', - "RcUpdate", "SMF", "SYSV", "Yum", "YUMng"] + "FreeBSDPackage", "launchd", "Portage", "POSIX", "RPM", + "RPMng", 'rpmtools', "RcUpdate", "SMF", "SYSV", "Yum", + "YUMng"] drivers = [item for item in __all__ if item not in ['rpmtools']] default = [item for item in drivers if item not in ['RPMng', 'YUMng']] |