help-cfengine
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: method to check for package installation


From: Ed Brown
Subject: Re: method to check for package installation
Date: Wed, 28 Apr 2004 12:59:16 -0600

Yes, the special characters limitations in class names added a wrinkle. 
Our solution was to substitute variable numbers of underscores, eg:

packages:
        cyrus-sasl              elsedefine=needs_cyrus__sasl
        perl-Net_SSLeay.pm      elsedefine=needs_perl__Net_SSLeay___pm
        #(yes, that was the name of the rpm)
        compat-libstdc++        elsedefine=needs_compat__libstdc____

Hyphens in rpm names are common, other problem characters are rare, and
handling for them was added as needed.  The wrapper script does the
unconversion, before handing the rpm names to install to yum, by looking
for ____ first, then ___, then __.  

By the way, cmp= and version= can be used of course to define the class
if the package is installed but not up to date.  Yum takes care of
installing the most recent.  

And we can make sure an rpm is not installed by changing elsedefine to
define, and the class prefix to needs_NOT_, (handled in the wrapper
script).

-Ed


On Wed, 2004-04-28 at 12:14, Chip Seraphine wrote:
> I do something similar (and posted about it on the Faq-o-matic, if you can 
> decipher my broken linefeeds).  The wrinkle is that the RPM often has 
> non-class-friendly characters in it (dots, dashes, and plusses in 
> particular).  This led me to map the packagenames to classnames that have all 
> the illegals converted to underscores. 
> 
> The problem then becomes unconverting it.  It's easy to see that libsigc++ 
> becomes libsigc__, but the reverse is not at all clear :-)   My solution was 
> to create an http-accessible directory on my RPM server that has symbolic 
> links to the appropriate versions of  all the various packages by their 
> 'converted' name.  My perlscript then simply does:
> 
> rpm <options> -U http://kickstart/path/to/rpmlinkdir/libsigc__
> 
> ...and we're good.  This arrangement is also useful because "rpmlinkdir"  
> gives me one nice place to get all RPMs, so I don't have to remember if it is 
> actually in contrib/ or RPM2/ or i686/ or whatever.
> 
> If anybody is interested, I'll tidy up the scripts and post 'em.
> 
> On Wednesday 28 April 2004 10:43, Ed Brown wrote:
> > Instead of a long list of conditional shellcommands, we pass the
> > ALLCLASSES variable to a short perl script.  The classes we define if an
> > rpm isn't installed begin with 'needs_', the rpm names that follow are
> > gathered and passed to yum.  It's working well, but should, and will be
> > soon, rewritten as a module.
> > 
> > -Ed
> > 
> > 
> > 
> > On Wed, 2004-04-28 at 08:53, Graham Allan wrote:
> > > On Wed, Apr 28, 2004 at 11:23:06AM +1000, Tim Nelson wrote:
> > > > On Tue, 27 Apr 2004, Graham Allan wrote:
> > > > 
> > > > > I'm trying to write a method file to check if a particular RPM package
> > > > > is installed, and if not, install it.
> > > > 
> > > >         Is there some particular reason you aren't using RPM's built-in 
> > > > functionality?  rpm -i and rpm -U both do this.  
> > > 
> > > Mainly because we use yum to perform the actual installations (rpm by
> > > itself doesn't handle dependencies well enough).
> > > 
> > > 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.
> > > 
> > > G.
> > 
> > 
> > 
> > _______________________________________________
> > Help-cfengine mailing list
> > address@hidden
> > http://mail.gnu.org/mailman/listinfo/help-cfengine
> > 
> 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]