Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chef 3442 #586

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 9 additions & 4 deletions lib/chef/provider/package/portage.rb
Expand Up @@ -58,14 +58,19 @@ def load_current_resource

def parse_emerge(package, txt)
availables = {}
package_without_category = package.split("/").last
found_package_name = nil

txt.each_line do |line|
if line =~ /\*\s+#{PACKAGE_NAME_PATTERN}/
found_package_name = $&.strip
if found_package_name == package || found_package_name.split("/").last == package_without_category
availables[found_package_name] = nil
found_package_name = $&.gsub(/\*/, '').strip
if package =~ /\// #the category is specified
if found_package_name == package
availables[found_package_name] = nil
end
else #the category is not specified
if found_package_name.split("/").last == package
availables[found_package_name] = nil
end
end
end

Expand Down
44 changes: 44 additions & 0 deletions spec/unit/provider/package/portage_spec.rb
Expand Up @@ -230,6 +230,50 @@
lambda { @provider.candidate_version }.should raise_error(Chef::Exceptions::Package)
end

it "should find the candidate_version if a category is specifed and there are category duplicates" do
output = <<EOF
Searching...
[ Results for search key : git ]
[ Applications found : 14 ]

* app-misc/digitemp [ Masked ]
Latest version available: 3.5.0
Latest version installed: [ Not Installed ]
Size of files: 261 kB
Homepage: http://www.digitemp.com/ http://www.ibutton.com/
Description: Temperature logging and reporting using Dallas Semiconductor's iButtons and 1-Wire protocol
License: GPL-2

* app-misc/git
Latest version available: 4.3.20
Latest version installed: [ Not Installed ]
Size of files: 416 kB
Homepage: http://www.gnu.org/software/git/
Description: GNU Interactive Tools - increase speed and efficiency of most daily task
License: GPL-2

* dev-util/git
Latest version available: 1.6.0.6
Latest version installed: ignore
Size of files: 2,725 kB
Homepage: http://git.or.cz/
Description: GIT - the stupid content tracker, the revision control system heavily used by the Linux kernel team
License: GPL-2

* dev-util/gitosis [ Masked ]
Latest version available: 0.2_p20080825
Latest version installed: [ Not Installed ]
Size of files: 31 kB
Homepage: http://eagain.net/gitweb/?p=gitosis.git;a=summary
Description: gitosis -- software for hosting git repositories
License: GPL-2
EOF

@status = mock("Status", :exitstatus => 0)
@provider = Chef::Provider::Package::Portage.new(@new_resource, @run_context)
@provider.should_receive(:popen4).and_yield(nil, nil, StringIO.new(output), nil).and_return(@status)
@provider.candidate_version.should == "1.6.0.6"
end
end

describe Chef::Provider::Package::Portage, "install_package" do
Expand Down