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 | |
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')
-rw-r--r-- | src/lib/Client/Frame.py | 3 | ||||
-rw-r--r-- | src/lib/Client/Tools/FreeBSDPackage.py | 42 | ||||
-rw-r--r-- | src/lib/Client/Tools/__init__.py | 5 |
3 files changed, 47 insertions, 3 deletions
diff --git a/src/lib/Client/Frame.py b/src/lib/Client/Frame.py index b069978a8..f685e7491 100644 --- a/src/lib/Client/Frame.py +++ b/src/lib/Client/Frame.py @@ -31,7 +31,8 @@ toolset_defs = {'rh': {'Service':'chkconfig', 'Package':'rpm'}, 'debian': {'Service':'deb', 'Package':'deb'}, 'nexenta': {'Service':'smf', 'Package':'deb'}, 'solaris': {'Service':'smf', 'Package':'sysv'}, - 'gentoo': {'Service':'rc-update', 'Package':'ebuild'}} + 'gentoo': {'Service':'rc-update', 'Package':'ebuild'}, + 'freebsd': {'Package':'freebsdpkg'}} class Frame: '''Frame is the container for all Tool objects and state information''' 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']] |