Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 0.7.16
-
Fix Version/s: None
-
Component/s: Chef Client, Chef Solo
-
Labels:None
-
Environment:
freebsd 7.2
Description
2. package version parsing is just plain wrong.
a version is detected by prefix and - so any package name with a
dash in it similiar to another will fail to
install. ie, protobuf and protobuf-c
--- recipe --- package "protobuf" --- chef run --- [Tue, 21 Sep 2010 07:56:43 -0700] DEBUG: Processing package[protobuf] [Tue, 21 Sep 2010 07:56:43 -0700] DEBUG: package[protobuf] using Chef::Provider::Package::Freebsd [Tue, 21 Sep 2010 07:56:43 -0700] DEBUG: Current version is c-0.14 [Tue, 21 Sep 2010 07:56:43 -0700] DEBUG: Ports candidate version is 2.1.0 --- debug --- $ pkg_info |grep protobuf protobuf-c-0.14 C bindings for Google's Protocol Buffers py25-protobuf-2.1.0 Google protobuf Python Client Library
Well obviously c-0.14 is not a version for protbuf. The regular
expression is greedy when it should not be.
In /usr/local/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/provider/package/freebsd.rb
Chef does this to determine candidate version:
$ make -V PORTVERSION -C /usr/ports/devel/protobuf 2.1.0
And does this to determine current version:
$ pkg_info -E protobuf\* protobuf-c-0.14
It does not bother to parse the package properly and get the
package_name and assert it
matches before returning the version.
line ~34
WRONG:
when /^#{package_name}-(.+)/
Something like this has worked for me:
when /^#{package_name}-([^-]+)$/
Activity
- All
- Comments
- History
- Activity
- Transitions Summary
For a hot fix save this file to cookbooks/freebsd/libraries/package_bug.rb
class Chef class Provider class Package class Freebsd < Chef::Provider::Package def current_installed_version command = "pkg_info -E \"#{package_name}*\"" status = popen4(command) do |pid, stdin, stdout, stderr| stdout.each do |line| case line # when /^#{package_name}-(.+)/ when /^#{package_name}-([^-]+)$/ return $1 end end end unless status.exitstatus == 0 || status.exitstatus == 1 raise Chef::Exceptions::Package, "#{command} failed - #{status.inspect}!" end nil end end # Freebsd end # Package end # Provider end # Chef