diff options
author | asaf <asaf@home.localdomain> | 2010-10-15 14:27:25 +0200 |
---|---|---|
committer | Sol Jerome <sol.jerome@gmail.com> | 2010-11-02 20:35:17 -0500 |
commit | ab15eceee650081c4a7c2a4803a210c42f73edd8 (patch) | |
tree | 143bd9b565e20646301dab75ee6484675b482629 /src/lib/Client | |
parent | 27ab33cbf8c68ef47416db3998b6df6408f1889e (diff) | |
download | bcfg2-ab15eceee650081c4a7c2a4803a210c42f73edd8.tar.gz bcfg2-ab15eceee650081c4a7c2a4803a210c42f73edd8.tar.bz2 bcfg2-ab15eceee650081c4a7c2a4803a210c42f73edd8.zip |
Packages plugin / Client tools : add support for pacman based distros(arch, parabola), needs some more work
Diffstat (limited to 'src/lib/Client')
-rw-r--r-- | src/lib/Client/Tools/Pacman.py | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/lib/Client/Tools/Pacman.py b/src/lib/Client/Tools/Pacman.py new file mode 100644 index 000000000..f155adfd4 --- /dev/null +++ b/src/lib/Client/Tools/Pacman.py @@ -0,0 +1,81 @@ +"""This is the bcfg2 support for pacman""" + +import Bcfg2.Client.Tools +import Bcfg2.Options +import Bcfg2.Client.Tools + +class Pacman(Bcfg2.Client.Tools.PkgTool): + '''Archlinux package support''' + name = 'Pacman' + __execs__ = ["/usr/bin/pacman"] + __handles__ = [('Package', 'txz')] + __req__ = {'Package': ['name', 'version']} + pkgtype = 'pacman' + pkgtool = ("/usr/bin/pacman --needed --noconfirm --noprogressbar -S %s") + + def __init__(self, logger, setup, config): + Bcfg2.Client.Tools.PkgTool.__init__(self, logger, setup, config) + self.installed = {} + self.RefreshPackages() + + def RefreshPackages(self): + '''Refresh memory hashes of packages''' + pkgcache = self.cmd.run("/usr/bin/pacman -Q")[1] + self.installed = {} + for pkg in pkgcache: + pkgname = pkg.split(' ')[0].strip() + version = pkg.split(' ')[1].strip() + #self.logger.info(" pkgname: %s, version: %s" % (pkgname, version)) + self.installed[pkgname] = version + + def VerifyPackage(self, entry, modlist): + '''Verify Package status for entry''' + if not 'version' in entry.attrib: + self.logger.info("Cannot verify unversioned package %s" % + (entry.attrib['name'])) + return False + + if entry.attrib['name'] in self.installed: + if self.installed[entry.attrib['name']] == entry.attrib['version']: + #if not self.setup['quick'] and \ + # entry.get('verify', 'true') == 'true': + #FIXME: We should be able to check this once + # http://trac.macports.org/ticket/15709 is implemented + return True + else: + entry.set('current_version', self.installed[entry.get('name')]) + self.logger.info("attribname: %s" % (entry.attrib['name'])) + self.logger.info("attribname: %s" % (entry.attrib['name'])) + return False + entry.set('current_exists', 'false') + self.logger.info("attribname: %s" % (entry.attrib['name'])) + return False + + def RemovePackages(self, packages): + '''Remove extra packages''' + names = [pkg.get('name') for pkg in packages] + self.logger.info("Removing packages: %s" % " ".join(names)) + self.cmd.run("/usr/bin/pacman --noconfirm --noprogressbar -R %s" % \ + " ".join(names)) + self.RefreshPackages() + self.extra = self.FindExtraPackages() + + def Install(self, packages, states): + ''' + Pacman Install + ''' + pkgline = "" + for pkg in packages: + pkgline += " " + pkg.get('name') + + print "packages : " + pkgline + + try: + self.logger.debug('Running Pacman.Install()') + print "AAAAA" + s = self.cmd.run("%s install" % self.pkgtool) + print "BBB: " + str(s) + except Exception as ex: + print "error in cmd.run ", ex + + self.logger.debug('Running Pacman.Install()') |