Skip to content

Commit

Permalink
(#22529) Handle no package message for different dpkg-query versions
Browse files Browse the repository at this point in the history
dpkg-query changes it's notification of missing package between versions
1.15 and 1.16.  We were testing for the earlier variant 'No packages
found matching'.  This change also handles the later variant of
'dpkg-query: no packages found matching'.

Also, sigh.
  • Loading branch information
jpartlow committed Oct 1, 2013
1 parent 133fd3b commit a912111
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/puppet/provider/package/dpkg.rb
Expand Up @@ -44,7 +44,7 @@ def self.instances
self::DPKG_DESCRIPTION_DELIMITER = ':DESC:'
self::DPKG_QUERY_FORMAT_STRING = %Q{'${Status} ${Package} ${Version} #{self::DPKG_DESCRIPTION_DELIMITER} ${Description}\\n#{self::DPKG_DESCRIPTION_DELIMITER}\\n'}
self::FIELDS_REGEX = %r{^(\S+) +(\S+) +(\S+) (\S+) (\S*) #{self::DPKG_DESCRIPTION_DELIMITER} (.*)$}
self::DPKG_PACKAGE_NOT_FOUND_REGEX = /No packages found matching/
self::DPKG_PACKAGE_NOT_FOUND_REGEX = /no package.*match/i
self::FIELDS= [:desired, :error, :status, :name, :ensure, :description]
self::END_REGEX = %r{^#{self::DPKG_DESCRIPTION_DELIMITER}$}

Expand Down
22 changes: 17 additions & 5 deletions spec/unit/provider/package/dpkg_spec.rb
Expand Up @@ -290,12 +290,24 @@ def parser_test(dpkg_output_string, gold_hash)
parser_test(no_description, package_hash.merge(:description => ''))
end

it "parses dpkg reporting that package does not exist without warning about a failed match (#22529)" do
Puppet.expects(:warning).never
pipe = StringIO.new("No packages found matching non-existent-package")
Puppet::Util::Execution.expects(:execpipe).with(query_args).yields(pipe).raises(Puppet::ExecutionFailure.new('no package found'))
context "dpkg-query versions < 1.16" do
it "parses dpkg-query 1.15 reporting that package does not exist without warning about a failed match (#22529)" do
Puppet.expects(:warning).never
pipe = StringIO.new("No packages found matching non-existent-package")
Puppet::Util::Execution.expects(:execpipe).with(query_args).yields(pipe).raises(Puppet::ExecutionFailure.new('no package found'))

expect(provider.query).to eq({:ensure=>:purged, :status=>"missing", :name=>"name", :error=>"ok"})
end
end

context "dpkg-query versions >= 1.16" do
it "parses dpkg-query 1.16 reporting that package does not exist without warning about a failed match (#22529)" do
Puppet.expects(:warning).never
pipe = StringIO.new("dpkg-query: no packages found matching non-existent-package")
Puppet::Util::Execution.expects(:execpipe).with(query_args).yields(pipe).raises(Puppet::ExecutionFailure.new('no package found'))

expect(provider.query).to eq({:ensure=>:purged, :status=>"missing", :name=>"name", :error=>"ok"})
expect(provider.query).to eq({:ensure=>:purged, :status=>"missing", :name=>"name", :error=>"ok"})
end
end
end

Expand Down

0 comments on commit a912111

Please sign in to comment.