[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: method to check for package installation
From: |
Brendan Strejcek |
Subject: |
Re: method to check for package installation |
Date: |
Wed, 28 Apr 2004 10:27:24 -0500 |
User-agent: |
Mutt/1.3.28i |
Graham Allan wrote:
> So the desired sequesnce is to determine if a package is installed,
> and if not, run "yum -y install packagename".
>
> This has been working for a while with hard-coded lists of package
> names, but aesthetically, it's not so great - the script has one long
> list of class definitions to test for packages, then another long list
> of conditional shellcommands. The test and the action are too widely
> separated for good readability.
>
> The idea was to try and move the test/shellcommand into a method so
> the main script can simply have a list of one-line "test and install"
> method calls.
Though maybe not as clean, if your goal is unity you could just do it
with shellcommands:
shellcommands:
"/some/test ${package} || yum -y install ${package}"
An m4 macro would make that just as aesthetic as a method call.
You could even use an iterator variable so you would only need one
shellcommand action, with some magic:
control:
split = ( : )
pkgiter = ( pkg1:pkg2:pkg3 )
# other ideas:
#pkgiter = ( ExecResult(/some/db/query) )
shellcommands:
"/bin/sh -c 'PKG=${pkgiter} /some/test ${dollar}PKG ||
yum -y install ${dollar}PKG'"
You might be able to dispense with the /bin/sh -c trick by using the
noabspath=true option to the shell command.
I'm suprised yum can't do the test for you though, actually. My
understanding was that yum was an apt-get clone, and apt-get is
idempotent, so I would expect yum to have the same functionality.
Here is a fragment I use with OpenBSD machines, for yet another
solution:
control:
actionsequence = (
"module:openbsd_pkg_add -c -p pstree-2.17p1"
"module:openbsd_pkg_add -c -p lsof-4.68"
"module:openbsd_pkg_add -c -p wget-1.8.2"
"module:openbsd_pkg_add -c -p fping-2.2b1"
)
# end of openbsd_pkg_add
Okay, I'm done. You all can go back to your coffee now (or whatever it
is you were doing).
-- Brendan
Re: method to check for package installation, Mark . Burgess, 2004/04/28
Re: method to check for package installation, Christian Pearce, 2004/04/28