summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Bonds <scott@ggr.com>2014-11-03 14:28:36 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2014-11-13 13:09:16 -0800
commitd5fc01256de335ab3d29d850ed3cbf16d40191de (patch)
treebf6180082009af733c89123f166d8ad9e24f1e41
parent01da76c90f63de1012a1799e9a2921f042539ac9 (diff)
downloadchef-d5fc01256de335ab3d29d850ed3cbf16d40191de.tar.gz
use PKG_PATH instead of PACKAGEROOT/SITE
-rw-r--r--lib/chef/provider/package/openbsd.rb12
-rw-r--r--spec/unit/provider/package/openbsd_spec.rb6
2 files changed, 6 insertions, 12 deletions
diff --git a/lib/chef/provider/package/openbsd.rb b/lib/chef/provider/package/openbsd.rb
index 476a9689f6..611c0e58f3 100644
--- a/lib/chef/provider/package/openbsd.rb
+++ b/lib/chef/provider/package/openbsd.rb
@@ -38,7 +38,7 @@ class Chef
def initialize(*args)
super
@current_resource = Chef::Resource::Package.new(@new_resource.name)
- @new_resource.source("#{mirror}/pub/#{node.kernel.name}/#{node.kernel.release}/packages/#{node.kernel.machine}/") if !@new_resource.source
+ @new_resource.source(pkg_path) if !@new_resource.source
end
def load_current_resource
@@ -54,11 +54,7 @@ class Chef
if parts = name.match(/^(.+?)--(.+)/)
name = parts[1]
end
- if @new_resource.source =~ /\/$/
- shell_out!("pkg_add -r #{name}#{version_string}", :env => { "PACKAGESITE" => @new_resource.source, 'LC_ALL' => nil }).status
- else
- shell_out!("pkg_add -r #{name}#{version_string}", :env => { "PACKAGEROOT" => @new_resource.source, 'LC_ALL' => nil }).status
- end
+ shell_out!("pkg_add -r #{name}#{version_string}", :env => {"PKG_PATH" => @new_resource.source}).status
Chef::Log.debug("#{@new_resource} installed from: #{@new_resource.source}")
end
end
@@ -101,8 +97,8 @@ class Chef
end
end
- def mirror
- 'http://ftp.eu.openbsd.org'
+ def pkg_path
+ ENV['PKG_PATH'] || "http://ftp.OpenBSD.org/pub/#{node.kernel.name}/#{node.kernel.release}/packages/#{node.kernel.machine}/"
end
end
diff --git a/spec/unit/provider/package/openbsd_spec.rb b/spec/unit/provider/package/openbsd_spec.rb
index 37d0d844a9..ee9c9e89fb 100644
--- a/spec/unit/provider/package/openbsd_spec.rb
+++ b/spec/unit/provider/package/openbsd_spec.rb
@@ -26,6 +26,7 @@ describe Chef::Provider::Package::Openbsd do
@node.default['kernel'] = {'name' => 'OpenBSD', 'release' => '5.5', 'machine' => 'amd64'}
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
+ ENV['PKG_PATH'] = nil
end
describe "install a package" do
@@ -39,10 +40,7 @@ describe Chef::Provider::Package::Openbsd do
it "should run the installation command" do
expect(@provider).to receive(:shell_out!).with(
"pkg_add -r #{@name}",
- :env=>{
- "PACKAGESITE" => "http://ftp.eu.openbsd.org/pub/OpenBSD/5.5/packages/amd64/",
- "LC_ALL" => nil
- }
+ {:env => {"PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/"}}
) {OpenStruct.new :status => true}
@provider.install_package(@name, nil)
end