diff options
author | Mark Harrison <mark@mivok.net> | 2017-02-23 14:30:33 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-23 14:30:33 -0500 |
commit | 67b64b7a36c3e2884d8d644579df443ace2e0fb9 (patch) | |
tree | 7d6d0aa20694fbd6198046e7287302a86dc0a599 | |
parent | 42445a55fe97a4c8c1b5b88b91b38e3f15babc61 (diff) | |
parent | 2f675c2849f5f385df7828619aeaff22f201bc52 (diff) | |
download | chef-67b64b7a36c3e2884d8d644579df443ace2e0fb9.tar.gz |
Merge pull request #5838 from chef/mh/apt_package_fix
Use shellsplit for apt_package options
-rw-r--r-- | lib/chef/provider/package.rb | 6 | ||||
-rw-r--r-- | spec/unit/provider/package/apt_spec.rb | 10 |
2 files changed, 12 insertions, 4 deletions
diff --git a/lib/chef/provider/package.rb b/lib/chef/provider/package.rb index 8f504939fc..97aefbd559 100644 --- a/lib/chef/provider/package.rb +++ b/lib/chef/provider/package.rb @@ -23,6 +23,7 @@ require "chef/log" require "chef/file_cache" require "chef/platform" require "chef/decorator/lazy_array" +require "shellwords" class Chef class Provider @@ -54,10 +55,7 @@ class Chef def options if new_resource.options.is_a?(String) - # XXX: needs to handle double quotes, single quotes, nested quotes, etc and probably act - # more like a space-separated "C"SV file -- although users can fix this just by passing in - # a correctly pre-split Array. - new_resource.options.split(" ") + new_resource.options.shellsplit else new_resource.options end diff --git a/spec/unit/provider/package/apt_spec.rb b/spec/unit/provider/package/apt_spec.rb index e14af488ac..a077b2a2a3 100644 --- a/spec/unit/provider/package/apt_spec.rb +++ b/spec/unit/provider/package/apt_spec.rb @@ -291,6 +291,16 @@ mpg123 1.12.1-0ubuntu1 @provider.install_package(["irssi"], ["0.8.12-7"]) end + + it "should run apt-get install with the package name and quotes options if specified" do + expect(@provider).to receive(:shell_out!).with( + "apt-get", "-q", "-y", "--force-yes", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confnew", "install", "irssi=0.8.12-7", + :env => { "DEBIAN_FRONTEND" => "noninteractive" }, + :timeout => @timeout + ) + @new_resource.options('--force-yes -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew"') + @provider.install_package(["irssi"], ["0.8.12-7"]) + end end describe resource_klass, "upgrade_package" do |