Great, thanks -- this explanation helped a lot.  But more questions,  
sorry ;-)

What does the = and > bring to the table?  Are they part of the  
package name, or...?

FYI, FreeBSD has almost exactly the same issue.  So if you want a  
specific version (not the very latest) then you supply the specific  
version in the configuration and it is removed from the package name  
before checking versions.  For instance, if I want to install 2.1.2.9  
but only if no 2.x version is installed then:

   =sys-apps/portage-2.1.2.9 cmp=gt version=2.0 action=install

You might want to check out what I did for FreeBSD and see if you can  
make it work.

> I run into an interesting problem trying to strip the version off,  
> because some Portage packages have hyphens in the names, like =sys- 
> process/vixie-cron-4.1-r10 (doh!).

FreeBSD has the same issue, but they have explicit package naming  
structure and I used the same code copied right out of the OS package  
tools.  This can fail if the package is named wrong, but it will fail  
for every provided package tool :-)

FYI, the quick version is that hyphens aren't allowed after the  
version begins, so in freebsd-land your example package would be  
named  =sys-process/vixie-cron-4.1_r10

If you can't control/prevent this, then try to look for the last  
hyphen which is followed by a digit and see if that works in all cases.

On Jul 24, 2007, at 12:09 PM, Eric Searcy wrote:
> On Jul 24, 2007, at 11:39 AM, Jo Rhett wrote:
>
>> Just to help me understand, can you provide a review of the input  
>> available (example config?) and what options you need to give the  
>> package manager?   I could reply more usefully if I understood  
>> fully the desired output...
>
> Example config:
>
> control:
>   DefaultPkgMgr         = ( portage )
>   PortageInstallCommand = ( "/usr/bin/emerge %s" )
>
> packages:
>   sys-apps/portage cmp=eq version=2.1.2.9 action=install
>   sys-libs/ncurses cmp=gt version=5.5-r3 action=install
>   app-admin/pwgen action=install
>
>
> Desired commandline (assuming all package checks return false):
>
> /usr/bin/emerge =sys-apps/portage-2.1.2.9 >sys-libs/ncurses-5.5-r3  
> app-admin/pwgen
>
>
> Without package-name mangling, the command would be
>
> /usr/bin/emerge sys-apps/portage sys-libs/ncurses app-admin/pwgen
>
> Which installs the latest stable version of each package.  However,  
> since the whole point of doing a comparison is that you care about  
> the specific version that is installed, the command directly above  
> is useless.
>
> Why didn't this show up before?  The original portage code I wrote  
> let me do the following:
>
> packages:
>   =sys-apps/portage-2.1.2.9 action=install
>   >sys-libs/ncurses-5.5-r3 action=install
>   app-admin/pwgen action=install
>
> The entire package string was then used both for checks and in the  
> install line, instead of using the cfengine comparison operator.   
> Unfortunately, the new way I'm doing package checks, which is 100  
> times faster, uses a tool that only takes the package name for  
> checking what's installed.  I can't mangle the name in my search  
> code, either.  If I had this:
>
> packages:
>   =sys-apps/portage-2.1.2.9 cmp=eq version=2.1.2.9 action=install
>   >sys-libs/ncurses-5.5-r3 cmp=gt version=5.5-r3 action=install
>   app-admin/pwgen action=install
>
> And stripped the version and = off the package, ran the tool, did  
> the check against cmp and version, then let the whole name be added  
> to pending_pkgs, I run into an interesting problem trying to strip  
> the version off, because some Portage packages have hyphens in the  
> names, like =sys-process/vixie-cron-4.1-r10 (doh!).
>
> Does that help?
>
> -- 
> Eric Searcy
> OSU Open Source Lab
>
>

-- 
Jo Rhett
senior geek

Silicon Valley Colocation
Support Phone: 408-400-0550




_______________________________________________
Bug-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/bug-cfengine

Reply via email to