From 64659200c00ab083f0cbbe92ea7fb8d212772da7 Mon Sep 17 00:00:00 2001 From: Sol Jerome Date: Sat, 13 Mar 2010 21:18:53 +0000 Subject: APT: Add support for using non-standard tool paths (Resolves Ticket #773 Signed-off-by: Sol Jerome git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5766 ce84e21b-d406-0410-9b95-82705330c041 --- doc/client/tools/apt.txt | 16 ++++++++++++++++ doc/client/tools/index.txt | 3 ++- src/lib/Client/Tools/APT.py | 34 +++++++++++++++++++++++++--------- src/lib/Options.py | 10 ++++++++++ 4 files changed, 53 insertions(+), 10 deletions(-) create mode 100644 doc/client/tools/apt.txt diff --git a/doc/client/tools/apt.txt b/doc/client/tools/apt.txt new file mode 100644 index 000000000..dba359e4a --- /dev/null +++ b/doc/client/tools/apt.txt @@ -0,0 +1,16 @@ +.. -*- mode: rst -*- + +.. _client-tools-apt: + +===================== +Bcfg2 APT Client Tool +===================== + +The APT tool allows you to configure custom options in ``bcfg2.conf`` +for systems where the tools reside in non-standard locations. The +available options (and their corresponding default values) are:: + + [APT] + install_path = '/usr' + var_path = '/var' + etc_path = '/etc' diff --git a/doc/client/tools/index.txt b/doc/client/tools/index.txt index 6ae903c50..37fcdae5c 100644 --- a/doc/client/tools/index.txt +++ b/doc/client/tools/index.txt @@ -38,7 +38,8 @@ APT --- Debian Packages. This tool driver is used to handle packages on dpkg -based systems and employs the "apt" executable. +based systems and employs the "apt" executable. Extra information can be +found at :ref:`client-tools-apt`. Blast ----- diff --git a/src/lib/Client/Tools/APT.py b/src/lib/Client/Tools/APT.py index ed686e400..395b87e77 100644 --- a/src/lib/Client/Tools/APT.py +++ b/src/lib/Client/Tools/APT.py @@ -9,21 +9,37 @@ warnings.filterwarnings("ignore", "Accessed deprecated property Package.installe warnings.filterwarnings("ignore", "Accessed deprecated property Package.candidateVersion, please see the Version class for alternatives.", DeprecationWarning) import apt.cache import os + import Bcfg2.Client.Tools +import Bcfg2.Options + +# Options for tool locations +opts = {'install_path': Bcfg2.Options.CLIENT_APT_TOOLS_INSTALL_PATH, + 'var_path': Bcfg2.Options.CLIENT_APT_TOOLS_VAR_PATH, + 'etc_path': Bcfg2.Options.CLIENT_SYSTEM_ETC_PATH} +setup = Bcfg2.Options.OptionParser(opts) +setup.parse([]) +install_path = setup['install_path'] +var_path = setup['var_path'] +etc_path = setup['etc_path'] +DEBSUMS = '%s/bin/debsums' % install_path +APTGET = '%s/bin/apt-get' % install_path +DPKG = '%s/bin/dpkg' % install_path class APT(Bcfg2.Client.Tools.Tool): '''The Debian toolset implements package and service operations and inherits the rest from Toolset.Toolset''' name = 'APT' - __execs__ = ['/usr/bin/debsums', '/usr/bin/apt-get', '/usr/bin/dpkg'] - __important__ = ["/etc/apt/sources.list", - "/var/cache/debconf/config.dat", - "/var/cache/debconf/templates.dat", + __execs__ = [DEBSUMS, APTGET, DPKG] + __important__ = ["%s/apt/sources.list" % etc_path, + "%s/cache/debconf/config.dat" % var_path, + "%s/cache/debconf/templates.dat" % var_path, '/etc/passwd', '/etc/group', - '/etc/apt/apt.conf', '/etc/dpkg/dpkg.cfg'] + '%s/apt/apt.conf' % etc_path, + '%s/dpkg/dpkg.cfg' % etc_path] __handles__ = [('Package', 'deb')] __req__ = {'Package': ['name', 'version']} - pkgcmd = 'apt-get ' + \ + pkgcmd = '%s ' % APTGET + \ '-o DPkg::Options::=--force-overwrite ' + \ '-o DPkg::Options::=--force-confold ' + \ '--reinstall ' + \ @@ -37,8 +53,8 @@ class APT(Bcfg2.Client.Tools.Tool): os.environ["DEBIAN_FRONTEND"] = 'noninteractive' self.actions = {} if self.setup['kevlar'] and not self.setup['dryrun']: - self.cmd.run("dpkg --force-confold --configure --pending") - self.cmd.run("apt-get clean") + self.cmd.run("%s --force-confold --configure --pending" % DPKG) + self.cmd.run("%s clean" % APTGET) self.pkg_cache = apt.cache.Cache() self.pkg_cache.update() self.pkg_cache = apt.cache.Cache() @@ -53,7 +69,7 @@ class APT(Bcfg2.Client.Tools.Tool): for (name, version) in extras] def VerifyDebsums(self, entry, modlist): - output = self.cmd.run("/usr/bin/debsums -as %s" % entry.get('name'))[1] + output = self.cmd.run("%s -as %s" % (DEBSUMS, entry.get('name')))[1] if len(output) == 1 and "no md5sums for" in output[0]: self.logger.info("Package %s has no md5sums. Cannot verify" % \ entry.get('name')) diff --git a/src/lib/Options.py b/src/lib/Options.py index c2e265b87..879bc3bab 100644 --- a/src/lib/Options.py +++ b/src/lib/Options.py @@ -247,6 +247,16 @@ SERVER_PROTOCOL = Option('Server Protocol', cf=('communication', 'procotol'), SENDMAIL_PATH = Option('Path to sendmail', cf=('reports', 'sendmailpath'), default='/usr/lib/sendmail') +# APT client tool options +CLIENT_APT_TOOLS_INSTALL_PATH = Option('Apt tools install path', + cf=('APT', 'install_path'), + default='/usr') +CLIENT_APT_TOOLS_VAR_PATH = Option('Apt tools var path', + cf=('APT', 'var_path'), default='/var') +CLIENT_SYSTEM_ETC_PATH = Option('System etc path', cf=('APT', 'etc_path'), + default='/etc') + + CLIENT_PROFILE = Option('assert the given profile for the host', default=False, cmd='-p', odesc="") CLIENT_RETRIES = Option('the number of times to retry network communication', -- cgit v1.2.3-1-g7c22