I'd like to recommend this patch to go into the upcoming 0.25.5 release. It looks like a typo has crept into your github branch, though:
+ commands :rug => "/usr/bin/zypper" And the code below is calling "zypper" as a method - I suspect that doesn't work (and it doesn't match your old mailing-list patch, either) It's unfortunate that the way we use mocks in provider specs can hide this sort of error. ~Jesse On Thu, Feb 4, 2010 at 1:08 PM, Andrew Forgue <[email protected]>wrote: > Tree Updated at: http://github.com/ajf/puppet/tree/feature/0.25.x/zypper > > On Dec 28 2009, 3:26 pm, jb <[email protected]> wrote: > > install options to zypper should include '-l' (aka --auto-agree-with- > > licenses) else install will hang with some packages (java comes to > > mind). > > > > On Nov 27, 4:02 pm, Andrew Forgue <[email protected]> wrote: > > > > > > > > > Zypper is the replacement for `rug' from earlier SuSE releases. Zypper > > > is backward compatible with the rug command and supports the same > > > commands that rug does. > > > > > Technically all that needed to be changed is :rug => "/usr/bin/zypper". > > > However, I'd expect rug to eventually be removed so this just depends > on > > > the RPM provider. > > > > > Signed-off-by: Andrew Forgue <[email protected]> > > > --- > > > lib/puppet/provider/package/zypper.rb | 52 +++++++++++++++++++++ > > > spec/unit/provider/package/zypper.rb | 81 > +++++++++++++++++++++++++++++++++ > > > 2 files changed, 133 insertions(+), 0 deletions(-) > > > create mode 100644 lib/puppet/provider/package/zypper.rb > > > create mode 100644 spec/unit/provider/package/zypper.rb > > > > > diff --git a/lib/puppet/provider/package/zypper.rb > b/lib/puppet/provider/package/zypper.rb > > > new file mode 100644 > > > index 0000000..3a5f49c > > > --- /dev/null > > > +++ b/lib/puppet/provider/package/zypper.rb > > > @@ -0,0 +1,52 @@ > > > +Puppet::Type.type(:package).provide :zypper, :parent => :rpm do > > > + desc "Support for SuSE ``zypper`` package manager. Found in > SLES10sp2+ and SLES11" > > > + > > > + has_feature :versionable > > > + > > > + commands :zypper => "/usr/bin/zypper" > > > + commands :rpm => "rpm" > > > + > > > + confine :operatingsystem => [:suse, :sles] > > > + > > > + # Install a package using 'zypper'. > > > + def install > > > + should = @resource.should(:ensure) > > > + self.debug "Ensuring => #{should}" > > > + wanted = @resource[:name] > > > + > > > + # XXX: We don't actually deal with epochs here. > > > + case should > > > + when true, false, Symbol > > > + # pass > > > + else > > > + # Add the package version > > > + wanted += "-%s" % should > > > + end > > > + output = zypper "--quiet", :install, "-y", wanted > > > + > > > + unless self.query > > > + raise Puppet::ExecutionFailure.new( > > > + "Could not find package %s" % self.name > > > + ) > > > + end > > > + end > > > + > > > + # What's the latest package version available? > > > + def latest > > > + #zypper can only get a list of *all* available packages? > > > + output = zypper "list-updates" > > > + > > > + if output =~ /#{Regexp.escape > @resource[:name]}\s*\|\s*([^\s\|]+)/ > > > + return $1 > > > + else > > > + # rug didn't find updates, pretend the current > > > + # version is the latest > > > + return @property_hash[:ensure] > > > + end > > > + end > > > + > > > + def update > > > + # rug install can be used for update, too > > > + self.install > > > + end > > > +end > > > diff --git a/spec/unit/provider/package/zypper.rb > b/spec/unit/provider/package/zypper.rb > > > new file mode 100644 > > > index 0000000..a611503 > > > --- /dev/null > > > +++ b/spec/unit/provider/package/zypper.rb > > > @@ -0,0 +1,81 @@ > > > +#!/usr/bin/env ruby > > > + > > > +require File.dirname(__FILE__) + '/../../../spec_helper' > > > + > > > +provider_class = Puppet::Type.type(:package).provider(:zypper) > > > + > > > +describe provider_class do > > > + before(:each) do > > > + # Create a mock resource > > > + @resource = stub 'resource' > > > + > > > + # A catch all; no parameters set > > > + @resource.stubs(:[]).returns(nil) > > > + > > > + # But set name and source > > > + @resource.stubs(:[]).with(:name).returns "mypackage" > > > + @resource.stubs(:[]).with(:ensure).returns :installed > > > + @resource.stubs(:command).with(:zypper).returns > "/usr/bin/zypper" > > > + > > > + @provider = provider_class.new(@resource) > > > + end > > > + > > > + it "should have an install method" do > > > + @provider = provider_class.new > > > + @provider.should respond_to(:install) > > > + end > > > + > > > + it "should have a latest method" do > > > + @provider = provider_class.new > > > + @provider.should respond_to(:uninstall) > > > + end > > > + > > > + it "should have an update method" do > > > + @provider = provider_class.new > > > + @provider.should respond_to(:update) > > > + end > > > + > > > + it "should have a latest method" do > > > + @provider = provider_class.new > > > + @provider.should respond_to(:latest) > > > + end > > > + > > > + describe "when installing" do > > > + it "should use a command-line with versioned package'" do > > > + @resource.stubs(:should).with(:ensure).returns > "1.2.3-4.5.6" > > > + @provider.expects(:zypper).with('--quiet', :install, '-y', > 'mypackage-1.2.3-4.5.6') > > > + @provider.expects(:query).returns "mypackage 0 1.2.3 4.5.6 > x86_64" > > > + @provider.install > > > + end > > > + > > > + it "should use a command-line without versioned package" do > > > + @resource.stubs(:should).with(:ensure).returns :latest > > > + @provider.expects(:zypper).with('--quiet', :install, '-y', > 'mypackage') > > > + @provider.expects(:query).returns "mypackage 0 1.2.3 4.5.6 > x86_64" > > > + @provider.install > > > + end > > > + end > > > + > > > + describe "when updating" do > > > + it "should call install method of instance" do > > > + @provider.expects(:install) > > > + @provider.update > > > + end > > > + end > > > + > > > + describe "when getting latest version" do > > > + it "should return a version string" do > > > + > > > + fake_data = "Loading repository data... > > > +Reading installed packages... > > > +S | Repository | Name | Version | Arch > > > +--+----------------+-----------------------+-----------------+------- > > > +v | SLES11-Updates | cups | 1.1.1 | x86_64 > > > +v | SLES11-Updates | mypackage | 1.3.9h-8.20.1 | x86_64" > > > + > > > + @provider.expects(:zypper).with("list-updates").returns > fake_data > > > + @provider.latest.should == "1.3.9h-8.20.1" > > > + end > > > + end > > > + > > > + end > > > -- > > > 1.6.3.3 > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Developers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<puppet-dev%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/puppet-dev?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
