summaryrefslogtreecommitdiff
path: root/chef/lib
diff options
context:
space:
mode:
authorDimitri Aivaliotis <aglarond@gmail.com>2012-03-23 17:36:47 +0100
committerBryan McLellan <btm@opscode.com>2012-04-26 13:15:48 -0700
commitb4920aa5e4693bc008fa75ae8d02675a764b662f (patch)
tree01d07796d84d108ce15183660904553901e9792b /chef/lib
parentb9256c222fbae58b6767794459ac8722e44dc294 (diff)
downloadchef-b4920aa5e4693bc008fa75ae8d02675a764b662f.tar.gz
[CHEF-1251] fixed for the case that the binary package and its dependencies are available locally under the :source
Diffstat (limited to 'chef/lib')
-rw-r--r--chef/lib/chef/provider/package/freebsd.rb28
1 files changed, 22 insertions, 6 deletions
diff --git a/chef/lib/chef/provider/package/freebsd.rb b/chef/lib/chef/provider/package/freebsd.rb
index 436c4b707d..acd470b72c 100644
--- a/chef/lib/chef/provider/package/freebsd.rb
+++ b/chef/lib/chef/provider/package/freebsd.rb
@@ -68,13 +68,25 @@ class Chef
ports_makefile_variable_value("PORTVERSION")
end
+ def file_candidate_version_path
+ Dir["#{@new_resource.source}/#{@current_resource.package_name}*"][0].to_s
+ end
+
+ def file_candidate_version
+ file_candidate_version_path.split(/-/).last.split(/.tbz/).first
+ end
+
def load_current_resource
@current_resource.package_name(@new_resource.package_name)
@current_resource.version(current_installed_version)
Chef::Log.debug("#{@new_resource} current version is #{@current_resource.version}") if @current_resource.version
- @candidate_version = ports_candidate_version
+ begin
+ @candidate_version = ports_candidate_version
+ rescue
+ @candidate_version = file_candidate_version
+ end
Chef::Log.debug("#{@new_resource} ports candidate version is #{@candidate_version}") if @candidate_version
@current_resource
@@ -86,10 +98,14 @@ class Chef
# The name of the package (without the version number) as understood by pkg_add and pkg_info
def package_name
- if ports_makefile_variable_value("PKGNAME") =~ /^(.+)-[^-]+$/
- $1
- else
- raise Chef::Exceptions::Package, "Unexpected form for PKGNAME variable in #{port_path}/Makefile"
+ begin
+ if ports_makefile_variable_value("PKGNAME") =~ /^(.+)-[^-]+$/
+ $1
+ else
+ raise Chef::Exceptions::Package, "Unexpected form for PKGNAME variable in #{port_path}/Makefile"
+ end
+ rescue
+ @new_resource.package_name
end
end
@@ -102,7 +118,7 @@ class Chef
shell_out!("pkg_add -r #{package_name}", :env => { "PACKAGESITE" => @new_resource.source, 'LC_ALL' => nil }).status
Chef::Log.debug("#{@new_resource} installed from: #{@new_resource.source}")
when /^\//
- shell_out!("pkg_add #{@new_resource.name}", :env => { "PKG_PATH" => @new_resource.source , 'LC_ALL'=>nil}).status
+ shell_out!("pkg_add #{file_candidate_version_path}", :env => { "PKG_PATH" => @new_resource.source , 'LC_ALL'=>nil}).status
Chef::Log.debug("#{@new_resource} installed from: #{@new_resource.source}")
else
shell_out!("pkg_add -r #{latest_link_name}", :env => nil).status