diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-08-08 13:03:28 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-08 13:03:28 -0700 |
commit | fc5f3f49e161141d9b696ff5cfbe3af8f86f5f1e (patch) | |
tree | a2b86683751a3fc6fa101ae3da1062ca0a5949c6 /lib | |
parent | 247486f81b879e37dc297f3001b07232bb372743 (diff) | |
parent | 332e3f62f3840b838c54bbca03343680781fdb96 (diff) | |
download | chef-fc5f3f49e161141d9b696ff5cfbe3af8f86f5f1e.tar.gz |
Merge pull request #5173 from chef/lcg/apt-update-noop
noop apt_update similar to apt_repository
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/provider/apt_repository.rb | 2 | ||||
-rw-r--r-- | lib/chef/provider/apt_update.rb | 15 |
2 files changed, 13 insertions, 4 deletions
diff --git a/lib/chef/provider/apt_repository.rb b/lib/chef/provider/apt_repository.rb index 1e7db80620..3a1b247d17 100644 --- a/lib/chef/provider/apt_repository.rb +++ b/lib/chef/provider/apt_repository.rb @@ -254,4 +254,4 @@ class Chef end end -Chef::Provider::Noop.provides :apt_resource +Chef::Provider::Noop.provides :apt_repository diff --git a/lib/chef/provider/apt_update.rb b/lib/chef/provider/apt_update.rb index d2dd5cfb14..03598280c8 100644 --- a/lib/chef/provider/apt_update.rb +++ b/lib/chef/provider/apt_update.rb @@ -16,15 +16,17 @@ # limitations under the License. # -require "chef/resource" -require "chef/dsl/declare_resource" +require "chef/provider" +require "chef/provider/noop" class Chef class Provider class AptUpdate < Chef::Provider use_inline_resources - provides :apt_update, os: "linux" + provides :apt_update do + uses_apt? + end APT_CONF_DIR = "/etc/apt/apt.conf.d" STAMP_DIR = "/var/lib/apt/periodic" @@ -75,6 +77,13 @@ class Chef declare_resource(:execute, "apt-get -q update") end + def self.uses_apt? + ENV["PATH"] ||= "" + paths = %w{ /bin /usr/bin /sbin /usr/sbin } + ENV["PATH"].split(::File::PATH_SEPARATOR) + paths.any? { |path| ::File.executable?(::File.join(path, "apt-get")) } + end end end end + +Chef::Provider::Noop.provides :apt_update |