Hello, I don't believe that the package_list_command is executed inside a shell. Piping will not work in such a case. You may write a bash or perl script instead and use it from cfengine. I am not a gentoo user, but is there no emerge --list command?
Best regards, Boleslaw Tokarski On 21/06/11 13:44, no-re...@cfengine.com wrote: > Forum: Cfengine Help > Subject: Creating package_method for gentoo's portage > Author: doychin > Link to topic: https://cfengine.com/forum/read.php?3,22533,22533#msg-22533 > > I was little surprised when found out that there's no package_method using > emerge in the COPBL - http://source.cfengine.com/browse/copbl . The next > shock was "emerge cfengine package_method" generated no search results! > Well... I had to write one myself, right? It shouldn't be that hard. Here's > what I've came up with: > > > body package_method emerge { > > package_changes => "individual"; > package_list_command => "/bin/ls -d /var/db/pkg/*/* | > /bin/sed 's/\/var\/db\/pkg\///'"; > package_list_name_regex => ".*/([^\s]+)-\d.*"; > package_list_version_regex => ".*/[^\s]+-(\d.*)"; > package_installed_regex => ".*"; # all reported > are installed > package_name_convention => "$(name)"; > package_list_update_command => "/usr/bin/emerge --sync"; > package_list_update_ifelapsed => "2000"; > > > package_add_command => "/usr/bin/emerge -q --quiet-build"; > #package_add_command => "/bin/echo Installing"; > package_delete_command => "/usr/bin/emerge --depclean"; > package_update_command => "/usr/bin/emerge --update"; > package_verify_command => "/usr/bin/emerge -s"; > package_noverify_regex => ".*(Not Installed|Applications found : > 0).*"; > } > > > BUT there's the catch. It doesn't seem to match the installed packages. It > tries to install all packages every time even though they are already > installed. To save some time in debugging I've changed package_add_command > => "/usr/bin/emerge -q --quiet-build"; with package_add_command > => "/bin/echo Installing"; to produce the output below. It is the verbose > output for nagios-nrpe package. > > > cf3> -> This promise has already been verified > cf3> -> Cache file exists and is sufficiently fresh according to > (package_list_update_ifelapsed) > cf3> ??????????????????????????????????????????????????????????????? > cf3> Reading package list from /bin/ls > cf3> ??????????????????????????????????????????????????????????????? > cf3> # Patch reporting feature is only available in version Nova and above > cf3> ??????????????????????????????????????????????????????????????? > cf3> Done checking packages and patches > cf3> ??????????????????????????????????????????????????????????????? > cf3> -> Package version was not specified > cf3> -> Looking for (nagios-nrpe,*,*) > cf3> No installed packages matched (nagios-nrpe,*,*) > cf3> -> Looking for (nagios-nrpe,*,*) > cf3> No installed packages matched (nagios-nrpe,*,*) > cf3> Checking if package (nagios-nrpe,*,*) is at the desired state > (installed=0,matched=0) > cf3> -> Package promises to refer to itself as "nagios-nrpe" to the manager > cf3> -> Package version seems to match criteria > cf3> -> Schedule package for addition > cf3> -> Package (nagios-nrpe,any,any) found > cf3> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > cf3> Offering these package-promise suggestions to the managers > cf3> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > cf3> -> Deletion schedule... > cf3> -> Addition schedule... > cf3> Execute scheduled package addition > cf3> Command prefix: /bin/echo Installing > cf3> Executing /bin/echo Installing nagios-nrpe... > cf3> Q:echo Installing nagi ...:Installing nagios-nrpe > cf3> Q:echo Installing nagi ...: > cf3> -> Finished command related to promiser "nagios-nrpe" -- succeeded > cf3> Package schedule execution ok for nagios-nrpe (outcome cannot be > promised by cf-agent) > > > The bundle agent I use for debugging is simple > > > bundle agent nagios_scripts { > packages: > > gentoo:: > > "nagions-nrpe" > package_policy => "add", > package_method => emerge, > comment => "making sure nagions installed through > emerge"; > } > > > Any help? I don't find the verbose output enough to debug my problem? How can > I find more information about what's going on and why it says the package is > not installed. > > _______________________________________________ > Help-cfengine mailing list > Help-cfengine@cfengine.org > https://cfengine.org/mailman/listinfo/help-cfengine > _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine