On Fri, May 18, 2012 at 7:02 AM, Rich Siegel <
rism...@gmail.com> wrote:
> I am trying to build something around a completely new package manager
> for windows (not msi). Specifically I am trying to find out the goal
> of what def_query is within a puppet provider package ? Is this a
> list of all packages installed? Just a determination for 1 specific
> resource package? I have looked at some examples in here :
>
https://github.com/puppetlabs/puppet/tree/master/lib/puppet/provider/package,
> and it is hard to determine what puppet is expecting.
Puppet will call the query method on the instance of the package
provider resource when checking if the package is installed already or
not.
It's a determination for one specific package, the package modeled by
the resource the method is called on.
A simple (and poor) example of this determination is the pkgdmg
provider for Mac OS X:
def query
if FileTest.exists?("/var/db/.puppet_pkgdmg_installed_#{@resource[:name]}")
...
end
https://github.com/puppetlabs/puppet/blob/master/lib/puppet/provider/package/pkgdmg.rb#L104-111
It's a poor example because this method of determining if a package is
installed or not isn't ideal. Ideally the provider will talk directly
to the packaging system of the OS.
self.instances is a class method of the provider that returns all of
the resources present on the system. Not just a specific resource.
Hope this helps,
-Jeff