summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2018-05-31 22:05:03 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2018-05-31 22:05:03 -0700
commitb22da295fda4545d0e72e0edb6ae1f400b3d5c33 (patch)
treeb27b5d3045ed319454b1318ff4bc92ac3354c3a6 /lib/chef
parentb458142bc388fe0c62018a749f89e650c8f8ae6d (diff)
downloadchef-b22da295fda4545d0e72e0edb6ae1f400b3d5c33.tar.gz
remove uses of shell_out_compact_timeout
just use shell_out_compact now. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef')
-rw-r--r--lib/chef/mixin/shell_out.rb6
-rw-r--r--lib/chef/provider/package.rb4
-rw-r--r--lib/chef/provider/package/apt.rb8
-rw-r--r--lib/chef/provider/package/bff.rb14
-rw-r--r--lib/chef/provider/package/dnf.rb2
-rw-r--r--lib/chef/provider/package/dpkg.rb10
-rw-r--r--lib/chef/provider/package/freebsd/base.rb4
-rw-r--r--lib/chef/provider/package/freebsd/pkg.rb12
-rw-r--r--lib/chef/provider/package/freebsd/pkgng.rb10
-rw-r--r--lib/chef/provider/package/freebsd/port.rb8
-rw-r--r--lib/chef/provider/package/homebrew.rb2
-rw-r--r--lib/chef/provider/package/ips.rb8
-rw-r--r--lib/chef/provider/package/macports.rb10
-rw-r--r--lib/chef/provider/package/openbsd.rb8
-rw-r--r--lib/chef/provider/package/pacman.rb8
-rw-r--r--lib/chef/provider/package/paludis.rb2
-rw-r--r--lib/chef/provider/package/portage.rb4
-rw-r--r--lib/chef/provider/package/rpm.rb14
-rw-r--r--lib/chef/provider/package/smartos.rb8
-rw-r--r--lib/chef/provider/package/solaris.rb14
-rw-r--r--lib/chef/provider/package/yum.rb2
-rw-r--r--lib/chef/provider/package/zypper.rb8
-rw-r--r--lib/chef/resource/paludis_package.rb2
-rw-r--r--lib/chef/resource/portage_package.rb2
24 files changed, 86 insertions, 84 deletions
diff --git a/lib/chef/mixin/shell_out.rb b/lib/chef/mixin/shell_out.rb
index ae83035b4f..870bdcdbf5 100644
--- a/lib/chef/mixin/shell_out.rb
+++ b/lib/chef/mixin/shell_out.rb
@@ -80,10 +80,10 @@ class Chef
end
def maybe_add_timeout(options)
- if is_a?(Chef::Provider) && !new_resource.is_a?(Chef::Resource::LWRPBase) && new_resource.respond_to?(:timeout)
+ if is_a?(Chef::Provider) && !new_resource.is_a?(Chef::Resource::LWRPBase) && new_resource.respond_to?(:timeout) && !options.key?(:timeout)
options = options.dup
- options[:timeout] = new_resource.timeout if new_resource.timeout
- options[:timeout] = 900 unless options.key?(:timeout)
+ # historically resources have not properly declared defaults on their timeouts, so a default default of 900s was enforced here
+ options[:timeout] = new_resource.timeout ? new_resource.timeout.to_f : 900
end
options
end
diff --git a/lib/chef/provider/package.rb b/lib/chef/provider/package.rb
index 133f87dad9..408c54dc3d 100644
--- a/lib/chef/provider/package.rb
+++ b/lib/chef/provider/package.rb
@@ -307,7 +307,7 @@ class Chef
# used by subclasses. deprecated. use #a_to_s instead.
def expand_options(options)
# its deprecated but still work to do to deprecate it fully
- #Chef.deprecated(:package_misc, "expand_options is deprecated, use shell_out_compact or shell_out_compact_timeout instead")
+ #Chef.deprecated(:package_misc, "expand_options is deprecated, use shell_out_compact or shell_out_compact instead")
if options
" #{options.is_a?(Array) ? Shellwords.join(options) : options}"
else
@@ -678,7 +678,7 @@ class Chef
def add_timeout_option(command_args)
# this is deprecated but its not quite done yet
- #Chef.deprecated(:package_misc, "shell_out_with_timeout and add_timeout_option are deprecated methods, use shell_out_compact_timeout instead")
+ #Chef.deprecated(:package_misc, "shell_out_with_timeout and add_timeout_option are deprecated methods, use shell_out_compact instead")
args = command_args.dup
if args.last.is_a?(Hash)
options = args.pop.dup
diff --git a/lib/chef/provider/package/apt.rb b/lib/chef/provider/package/apt.rb
index 798abf4680..b644848442 100644
--- a/lib/chef/provider/package/apt.rb
+++ b/lib/chef/provider/package/apt.rb
@@ -81,7 +81,7 @@ class Chef
def locked_packages
@locked_packages ||=
begin
- locked = shell_out_compact_timeout!("apt-mark", "showhold")
+ locked = shell_out_compact!("apt-mark", "showhold")
locked.stdout.each_line.map do |line|
line.strip
end
@@ -140,9 +140,9 @@ class Chef
#
# @return [Integer] 1 if v1 > v2. 0 if they're equal. -1 if v1 < v2
def version_compare(v1, v2)
- if !shell_out_compact_timeout("dpkg", "--compare-versions", v1.to_s, "gt", v2.to_s).error?
+ if !shell_out_compact("dpkg", "--compare-versions", v1.to_s, "gt", v2.to_s).error?
1
- elsif !shell_out_compact_timeout("dpkg", "--compare-versions", v1.to_s, "eq", v2.to_s).error?
+ elsif !shell_out_compact("dpkg", "--compare-versions", v1.to_s, "eq", v2.to_s).error?
0
else
-1
@@ -153,7 +153,7 @@ class Chef
# interactive prompts. Command is run with default localization rather
# than forcing locale to "C", so command output may not be stable.
def run_noninteractive(*args)
- shell_out_compact_timeout!(*args, env: { "DEBIAN_FRONTEND" => "noninteractive" })
+ shell_out_compact!(*args, env: { "DEBIAN_FRONTEND" => "noninteractive" })
end
def default_release_options
diff --git a/lib/chef/provider/package/bff.rb b/lib/chef/provider/package/bff.rb
index 44fadd92df..6f103c63ac 100644
--- a/lib/chef/provider/package/bff.rb
+++ b/lib/chef/provider/package/bff.rb
@@ -49,7 +49,7 @@ class Chef
if package_source_found?
logger.trace("#{new_resource} checking pkg status")
- ret = shell_out_compact_timeout("installp", "-L", "-d", new_resource.source)
+ ret = shell_out_compact("installp", "-L", "-d", new_resource.source)
ret.stdout.each_line do |line|
case line
when /:#{new_resource.package_name}:/
@@ -65,7 +65,7 @@ class Chef
end
logger.trace("#{new_resource} checking install state")
- ret = shell_out_compact_timeout("lslpp", "-lcq", current_resource.package_name)
+ ret = shell_out_compact("lslpp", "-lcq", current_resource.package_name)
ret.stdout.each_line do |line|
case line
when /#{current_resource.package_name}/
@@ -85,7 +85,7 @@ class Chef
def candidate_version
return @candidate_version if @candidate_version
if package_source_found?
- ret = shell_out_compact_timeout("installp", "-L", "-d", new_resource.source)
+ ret = shell_out_compact("installp", "-L", "-d", new_resource.source)
ret.stdout.each_line do |line|
case line
when /\w:#{Regexp.escape(new_resource.package_name)}:(.*)/
@@ -112,10 +112,10 @@ class Chef
def install_package(name, version)
logger.trace("#{new_resource} package install options: #{options}")
if options.nil?
- shell_out_compact_timeout!("installp", "-aYF", "-d", new_resource.source, new_resource.package_name)
+ shell_out_compact!("installp", "-aYF", "-d", new_resource.source, new_resource.package_name)
logger.trace("#{new_resource} installed version #{new_resource.version} from: #{new_resource.source}")
else
- shell_out_compact_timeout!("installp", "-aYF", options, "-d", new_resource.source, new_resource.package_name)
+ shell_out_compact!("installp", "-aYF", options, "-d", new_resource.source, new_resource.package_name)
logger.trace("#{new_resource} installed version #{new_resource.version} from: #{new_resource.source}")
end
end
@@ -124,10 +124,10 @@ class Chef
def remove_package(name, version)
if options.nil?
- shell_out_compact_timeout!("installp", "-u", name)
+ shell_out_compact!("installp", "-u", name)
logger.trace("#{new_resource} removed version #{new_resource.version}")
else
- shell_out_compact_timeout!("installp", "-u", options, name)
+ shell_out_compact!("installp", "-u", options, name)
logger.trace("#{new_resource} removed version #{new_resource.version}")
end
end
diff --git a/lib/chef/provider/package/dnf.rb b/lib/chef/provider/package/dnf.rb
index b18a284116..0233c0a838 100644
--- a/lib/chef/provider/package/dnf.rb
+++ b/lib/chef/provider/package/dnf.rb
@@ -167,7 +167,7 @@ class Chef
end
def dnf(*args)
- shell_out_compact_timeout!("dnf", *args)
+ shell_out_compact!("dnf", *args)
end
def safe_version_array
diff --git a/lib/chef/provider/package/dpkg.rb b/lib/chef/provider/package/dpkg.rb
index aa53f6145f..0b6a9c8ba2 100644
--- a/lib/chef/provider/package/dpkg.rb
+++ b/lib/chef/provider/package/dpkg.rb
@@ -113,9 +113,9 @@ class Chef
#
# @return [Integer] 1 if v1 > v2. 0 if they're equal. -1 if v1 < v2
def version_compare(v1, v2)
- if !shell_out_compact_timeout("dpkg", "--compare-versions", v1.to_s, "gt", v2.to_s).error?
+ if !shell_out_compact("dpkg", "--compare-versions", v1.to_s, "gt", v2.to_s).error?
1
- elsif !shell_out_compact_timeout("dpkg", "--compare-versions", v1.to_s, "eq", v2.to_s).error?
+ elsif !shell_out_compact("dpkg", "--compare-versions", v1.to_s, "eq", v2.to_s).error?
0
else
-1
@@ -124,7 +124,7 @@ class Chef
def read_current_version_of_package(package_name)
logger.trace("#{new_resource} checking install state of #{package_name}")
- status = shell_out_compact_timeout!("dpkg", "-s", package_name, returns: [0, 1])
+ status = shell_out_compact!("dpkg", "-s", package_name, returns: [0, 1])
package_installed = false
status.stdout.each_line do |line|
case line
@@ -152,7 +152,7 @@ class Chef
# Runs command via shell_out_with_timeout with magic environment to disable
# interactive prompts.
def run_noninteractive(*command)
- shell_out_compact_timeout!(*command, env: { "DEBIAN_FRONTEND" => "noninteractive" })
+ shell_out_compact!(*command, env: { "DEBIAN_FRONTEND" => "noninteractive" })
end
# Returns true if all sources exist. Returns false if any do not, or if no
@@ -192,7 +192,7 @@ class Chef
begin
pkginfos = resolved_source_array.map do |src|
logger.trace("#{new_resource} checking #{src} dpkg status")
- status = shell_out_compact_timeout!("dpkg-deb", "-W", src)
+ status = shell_out_compact!("dpkg-deb", "-W", src)
status.stdout
end
Hash[*package_name_array.zip(pkginfos).flatten]
diff --git a/lib/chef/provider/package/freebsd/base.rb b/lib/chef/provider/package/freebsd/base.rb
index fc62fa7cc0..c9b3bf222b 100644
--- a/lib/chef/provider/package/freebsd/base.rb
+++ b/lib/chef/provider/package/freebsd/base.rb
@@ -47,7 +47,7 @@ class Chef
# Otherwise look up the path to the ports directory using 'whereis'
else
- whereis = shell_out_compact_timeout!("whereis", "-s", port, env: nil)
+ whereis = shell_out_compact!("whereis", "-s", port, env: nil)
unless path = whereis.stdout[/^#{Regexp.escape(port)}:\s+(.+)$/, 1]
raise Chef::Exceptions::Package, "Could not find port with the name #{port}"
end
@@ -57,7 +57,7 @@ class Chef
def makefile_variable_value(variable, dir = nil)
options = dir ? { cwd: dir } : {}
- make_v = shell_out_compact_timeout!("make", "-V", variable, options.merge!(env: nil, returns: [0, 1]))
+ make_v = shell_out_compact!("make", "-V", variable, options.merge!(env: nil, returns: [0, 1]))
make_v.exitstatus == 0 ? make_v.stdout.strip.split($OUTPUT_RECORD_SEPARATOR).first : nil # $\ is the line separator, i.e. newline.
end
end
diff --git a/lib/chef/provider/package/freebsd/pkg.rb b/lib/chef/provider/package/freebsd/pkg.rb
index 04e6e5c427..800bca681c 100644
--- a/lib/chef/provider/package/freebsd/pkg.rb
+++ b/lib/chef/provider/package/freebsd/pkg.rb
@@ -34,24 +34,24 @@ class Chef
case new_resource.source
when /^http/, /^ftp/
if new_resource.source =~ /\/$/
- shell_out_compact_timeout!("pkg_add", "-r", package_name, env: { "PACKAGESITE" => new_resource.source, "LC_ALL" => nil }).status
+ shell_out_compact!("pkg_add", "-r", package_name, env: { "PACKAGESITE" => new_resource.source, "LC_ALL" => nil }).status
else
- shell_out_compact_timeout!("pkg_add", "-r", package_name, env: { "PACKAGEROOT" => new_resource.source, "LC_ALL" => nil }).status
+ shell_out_compact!("pkg_add", "-r", package_name, env: { "PACKAGEROOT" => new_resource.source, "LC_ALL" => nil }).status
end
logger.trace("#{new_resource} installed from: #{new_resource.source}")
when /^\//
- shell_out_compact_timeout!("pkg_add", file_candidate_version_path, env: { "PKG_PATH" => new_resource.source, "LC_ALL" => nil }).status
+ shell_out_compact!("pkg_add", file_candidate_version_path, env: { "PKG_PATH" => new_resource.source, "LC_ALL" => nil }).status
logger.trace("#{new_resource} installed from: #{new_resource.source}")
else
- shell_out_compact_timeout!("pkg_add", "-r", latest_link_name, env: nil).status
+ shell_out_compact!("pkg_add", "-r", latest_link_name, env: nil).status
end
end
end
def remove_package(name, version)
- shell_out_compact_timeout!("pkg_delete", "#{package_name}-#{version || current_resource.version}", env: nil).status
+ shell_out_compact!("pkg_delete", "#{package_name}-#{version || current_resource.version}", env: nil).status
end
# The name of the package (without the version number) as understood by pkg_add and pkg_info.
@@ -72,7 +72,7 @@ class Chef
end
def current_installed_version
- pkg_info = shell_out_compact_timeout!("pkg_info", "-E", "#{package_name}*", env: nil, returns: [0, 1])
+ pkg_info = shell_out_compact!("pkg_info", "-E", "#{package_name}*", env: nil, returns: [0, 1])
pkg_info.stdout[/^#{Regexp.escape(package_name)}-(.+)/, 1]
end
diff --git a/lib/chef/provider/package/freebsd/pkgng.rb b/lib/chef/provider/package/freebsd/pkgng.rb
index c9c0947f9b..ab64753e88 100644
--- a/lib/chef/provider/package/freebsd/pkgng.rb
+++ b/lib/chef/provider/package/freebsd/pkgng.rb
@@ -28,21 +28,21 @@ class Chef
unless current_resource.version
case new_resource.source
when /^(http|ftp|\/)/
- shell_out_compact_timeout!("pkg", "add", options, new_resource.source, env: { "LC_ALL" => nil }).status
+ shell_out_compact!("pkg", "add", options, new_resource.source, env: { "LC_ALL" => nil }).status
logger.trace("#{new_resource} installed from: #{new_resource.source}")
else
- shell_out_compact_timeout!("pkg", "install", "-y", options, name, env: { "LC_ALL" => nil }).status
+ shell_out_compact!("pkg", "install", "-y", options, name, env: { "LC_ALL" => nil }).status
end
end
end
def remove_package(name, version)
options_dup = options && options.map { |str| str.sub(repo_regex, "") }.reject!(&:empty?)
- shell_out_compact_timeout!("pkg", "delete", "-y", options_dup, "#{name}#{version ? '-' + version : ''}", env: nil).status
+ shell_out_compact!("pkg", "delete", "-y", options_dup, "#{name}#{version ? '-' + version : ''}", env: nil).status
end
def current_installed_version
- pkg_info = shell_out_compact_timeout!("pkg", "info", new_resource.package_name, env: nil, returns: [0, 70])
+ pkg_info = shell_out_compact!("pkg", "info", new_resource.package_name, env: nil, returns: [0, 70])
pkg_info.stdout[/^Version +: (.+)$/, 1]
end
@@ -61,7 +61,7 @@ class Chef
options = $1.split(" ")
end
- pkg_query = shell_out_compact_timeout!("pkg", "rquery", options, "%v", new_resource.package_name, env: nil)
+ pkg_query = shell_out_compact!("pkg", "rquery", options, "%v", new_resource.package_name, env: nil)
pkg_query.exitstatus == 0 ? pkg_query.stdout.strip.split(/\n/).last : nil
end
diff --git a/lib/chef/provider/package/freebsd/port.rb b/lib/chef/provider/package/freebsd/port.rb
index e87be4d304..96a96ad030 100644
--- a/lib/chef/provider/package/freebsd/port.rb
+++ b/lib/chef/provider/package/freebsd/port.rb
@@ -26,18 +26,18 @@ class Chef
include PortsHelper
def install_package(name, version)
- shell_out_compact_timeout!("make", "-DBATCH", "install", "clean", timeout: 1800, env: nil, cwd: port_dir).status
+ shell_out_compact!("make", "-DBATCH", "install", "clean", timeout: 1800, env: nil, cwd: port_dir).status
end
def remove_package(name, version)
- shell_out_compact_timeout!("make", "deinstall", timeout: 300, env: nil, cwd: port_dir).status
+ shell_out_compact!("make", "deinstall", timeout: 300, env: nil, cwd: port_dir).status
end
def current_installed_version
pkg_info = if new_resource.supports_pkgng?
- shell_out_compact_timeout!("pkg", "info", new_resource.package_name, env: nil, returns: [0, 70])
+ shell_out_compact!("pkg", "info", new_resource.package_name, env: nil, returns: [0, 70])
else
- shell_out_compact_timeout!("pkg_info", "-E", "#{new_resource.package_name}*", env: nil, returns: [0, 1])
+ shell_out_compact!("pkg_info", "-E", "#{new_resource.package_name}*", env: nil, returns: [0, 1])
end
pkg_info.stdout[/^#{Regexp.escape(new_resource.package_name)}-(.+)/, 1]
end
diff --git a/lib/chef/provider/package/homebrew.rb b/lib/chef/provider/package/homebrew.rb
index 643faf23c6..319ce992f7 100644
--- a/lib/chef/provider/package/homebrew.rb
+++ b/lib/chef/provider/package/homebrew.rb
@@ -128,7 +128,7 @@ class Chef
logger.trace "Executing '#{command.join(' ')}' as user '#{homebrew_user.name}'"
# FIXME: this 1800 second default timeout should be deprecated
- output = shell_out_compact_timeout!(*command, timeout: 1800, user: homebrew_uid, environment: { "HOME" => homebrew_user.dir, "RUBYOPT" => nil, "TMPDIR" => nil })
+ output = shell_out_compact!(*command, timeout: 1800, user: homebrew_uid, environment: { "HOME" => homebrew_user.dir, "RUBYOPT" => nil, "TMPDIR" => nil })
output.stdout.chomp
end
diff --git a/lib/chef/provider/package/ips.rb b/lib/chef/provider/package/ips.rb
index cabc7fc68b..3cd00084f0 100644
--- a/lib/chef/provider/package/ips.rb
+++ b/lib/chef/provider/package/ips.rb
@@ -42,14 +42,14 @@ class Chef
end
def get_current_version
- shell_out_compact_timeout("pkg", "info", new_resource.package_name).stdout.each_line do |line|
+ shell_out_compact("pkg", "info", new_resource.package_name).stdout.each_line do |line|
return $1.split[0] if line =~ /^\s+Version: (.*)/
end
nil
end
def get_candidate_version
- shell_out_compact_timeout!("pkg", "info", "-r", new_resource.package_name).stdout.each_line do |line|
+ shell_out_compact!("pkg", "info", "-r", new_resource.package_name).stdout.each_line do |line|
return $1.split[0] if line =~ /Version: (.*)/
end
nil
@@ -68,7 +68,7 @@ class Chef
command = [ "pkg", options, "install", "-q" ]
command << "--accept" if new_resource.accept_license
command << "#{name}@#{version}"
- shell_out_compact_timeout!(command)
+ shell_out_compact!(command)
end
def upgrade_package(name, version)
@@ -77,7 +77,7 @@ class Chef
def remove_package(name, version)
package_name = "#{name}@#{version}"
- shell_out_compact_timeout!( "pkg", options, "uninstall", "-q", package_name )
+ shell_out_compact!( "pkg", options, "uninstall", "-q", package_name )
end
end
end
diff --git a/lib/chef/provider/package/macports.rb b/lib/chef/provider/package/macports.rb
index ddaf19a76f..50a04991a1 100644
--- a/lib/chef/provider/package/macports.rb
+++ b/lib/chef/provider/package/macports.rb
@@ -49,21 +49,21 @@ class Chef
unless current_resource.version == version
command = [ "port", options, "install", name ]
command << "@#{version}" if version && !version.empty?
- shell_out_compact_timeout!(command)
+ shell_out_compact!(command)
end
end
def purge_package(name, version)
command = [ "port", options, "uninstall", name ]
command << "@#{version}" if version && !version.empty?
- shell_out_compact_timeout!(command)
+ shell_out_compact!(command)
end
def remove_package(name, version)
command = [ "port", options, "deactivate", name ]
command << "@#{version}" if version && !version.empty?
- shell_out_compact_timeout!(command)
+ shell_out_compact!(command)
end
def upgrade_package(name, version)
@@ -76,7 +76,7 @@ class Chef
# that hasn't been installed.
install_package(name, version)
elsif current_version != version
- shell_out_compact_timeout!( "port", options, "upgrade", name, "@#{version}" )
+ shell_out_compact!( "port", options, "upgrade", name, "@#{version}" )
end
end
@@ -84,7 +84,7 @@ class Chef
def get_response_from_command(command)
output = nil
- status = shell_out_compact_timeout(command)
+ status = shell_out_compact(command)
begin
output = status.stdout
rescue Exception
diff --git a/lib/chef/provider/package/openbsd.rb b/lib/chef/provider/package/openbsd.rb
index f528c48f08..0bbe7abb60 100644
--- a/lib/chef/provider/package/openbsd.rb
+++ b/lib/chef/provider/package/openbsd.rb
@@ -72,7 +72,7 @@ class Chef
if parts = name.match(/^(.+?)--(.+)/) # use double-dash for stems with flavors, see man page for pkg_add
name = parts[1]
end
- shell_out_compact_timeout!("pkg_add", "-r", package_string(name, version), env: { "PKG_PATH" => pkg_path }).status
+ shell_out_compact!("pkg_add", "-r", package_string(name, version), env: { "PKG_PATH" => pkg_path }).status
logger.trace("#{new_resource.package_name} installed")
end
end
@@ -81,7 +81,7 @@ class Chef
if parts = name.match(/^(.+?)--(.+)/)
name = parts[1]
end
- shell_out_compact_timeout!("pkg_delete", package_string(name, version), env: nil).status
+ shell_out_compact!("pkg_delete", package_string(name, version), env: nil).status
end
private
@@ -92,7 +92,7 @@ class Chef
else
new_resource.package_name
end
- pkg_info = shell_out_compact_timeout!("pkg_info", "-e", "#{name}->0", env: nil, returns: [0, 1])
+ pkg_info = shell_out_compact!("pkg_info", "-e", "#{name}->0", env: nil, returns: [0, 1])
result = pkg_info.stdout[/^inst:#{Regexp.escape(name)}-(.+?)\s/, 1]
logger.trace("installed_version of '#{new_resource.package_name}' is '#{result}'")
result
@@ -101,7 +101,7 @@ class Chef
def candidate_version
@candidate_version ||= begin
results = []
- shell_out_compact_timeout!("pkg_info", "-I", package_string(new_resource.package_name, new_resource.version), env: nil, returns: [0, 1]).stdout.each_line do |line|
+ shell_out_compact!("pkg_info", "-I", package_string(new_resource.package_name, new_resource.version), env: nil, returns: [0, 1]).stdout.each_line do |line|
results << if parts = new_resource.package_name.match(/^(.+?)--(.+)/)
line[/^#{Regexp.escape(parts[1])}-(.+?)\s/, 1]
else
diff --git a/lib/chef/provider/package/pacman.rb b/lib/chef/provider/package/pacman.rb
index f6dde66219..2f08ee7d28 100644
--- a/lib/chef/provider/package/pacman.rb
+++ b/lib/chef/provider/package/pacman.rb
@@ -32,7 +32,7 @@ class Chef
current_resource.package_name(new_resource.package_name)
logger.trace("#{new_resource} checking pacman for #{new_resource.package_name}")
- status = shell_out_compact_timeout("pacman", "-Qi", new_resource.package_name)
+ status = shell_out_compact("pacman", "-Qi", new_resource.package_name)
status.stdout.each_line do |line|
case line
when /^Version(\s?)*: (.+)$/
@@ -60,7 +60,7 @@ class Chef
package_repos = repos.map { |r| Regexp.escape(r) }.join("|")
- status = shell_out_compact_timeout("pacman", "-Sl")
+ status = shell_out_compact("pacman", "-Sl")
status.stdout.each_line do |line|
case line
when /^(#{package_repos}) #{Regexp.escape(new_resource.package_name)} (.+)$/
@@ -82,7 +82,7 @@ class Chef
end
def install_package(name, version)
- shell_out_compact_timeout!( "pacman", "--sync", "--noconfirm", "--noprogressbar", options, name)
+ shell_out_compact!( "pacman", "--sync", "--noconfirm", "--noprogressbar", options, name)
end
def upgrade_package(name, version)
@@ -90,7 +90,7 @@ class Chef
end
def remove_package(name, version)
- shell_out_compact_timeout!( "pacman", "--remove", "--noconfirm", "--noprogressbar", options, name )
+ shell_out_compact!( "pacman", "--remove", "--noconfirm", "--noprogressbar", options, name )
end
def purge_package(name, version)
diff --git a/lib/chef/provider/package/paludis.rb b/lib/chef/provider/package/paludis.rb
index f6274d7553..50267610c2 100644
--- a/lib/chef/provider/package/paludis.rb
+++ b/lib/chef/provider/package/paludis.rb
@@ -58,7 +58,7 @@ class Chef
else
new_resource.package_name.to_s
end
- shell_out_compact_timeout!("cave", "-L", "warning", "resolve", "-x", options, pkg)
+ shell_out_compact!("cave", "-L", "warning", "resolve", "-x", options, pkg)
end
def upgrade_package(name, version)
diff --git a/lib/chef/provider/package/portage.rb b/lib/chef/provider/package/portage.rb
index fecbba9dc9..4676f0ace4 100644
--- a/lib/chef/provider/package/portage.rb
+++ b/lib/chef/provider/package/portage.rb
@@ -1,6 +1,6 @@
#
# Author:: Ezra Zygmuntowicz (<ezra@engineyard.com>)
-# Copyright:: Copyright 2008-2016, Chef Software Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -31,7 +31,7 @@ class Chef
PACKAGE_NAME_PATTERN = %r{(?:([^/]+)/)?([^/]+)}
def load_current_resource
- @current_resource = Chef::Resource::Package.new(new_resource.name)
+ @current_resource = Chef::Resource::PortagePackage.new(new_resource.name)
current_resource.package_name(new_resource.package_name)
category, pkg = /^#{PACKAGE_NAME_PATTERN}$/.match(new_resource.package_name)[1, 2]
diff --git a/lib/chef/provider/package/rpm.rb b/lib/chef/provider/package/rpm.rb
index 9d4f2f3c23..9388e18860 100644
--- a/lib/chef/provider/package/rpm.rb
+++ b/lib/chef/provider/package/rpm.rb
@@ -57,7 +57,7 @@ class Chef
end
logger.trace("#{new_resource} checking rpm status")
- shell_out_compact_timeout!("rpm", "-qp", "--queryformat", "%{NAME} %{VERSION}-%{RELEASE}\n", new_resource.source).stdout.each_line do |line|
+ shell_out_compact!("rpm", "-qp", "--queryformat", "%{NAME} %{VERSION}-%{RELEASE}\n", new_resource.source).stdout.each_line do |line|
case line
when /^(\S+)\s(\S+)$/
current_resource.package_name($1)
@@ -73,7 +73,7 @@ class Chef
end
logger.trace("#{new_resource} checking install state")
- @rpm_status = shell_out_compact_timeout("rpm", "-q", "--queryformat", "%{NAME} %{VERSION}-%{RELEASE}\n", current_resource.package_name)
+ @rpm_status = shell_out_compact("rpm", "-q", "--queryformat", "%{NAME} %{VERSION}-%{RELEASE}\n", current_resource.package_name)
@rpm_status.stdout.each_line do |line|
case line
when /^(\S+)\s(\S+)$/
@@ -88,12 +88,12 @@ class Chef
def install_package(name, version)
if current_resource.version
if allow_downgrade
- shell_out_compact_timeout!("rpm", options, "-U", "--oldpackage", new_resource.source)
+ shell_out_compact!("rpm", options, "-U", "--oldpackage", new_resource.source)
else
- shell_out_compact_timeout!("rpm", options, "-U", new_resource.source)
+ shell_out_compact!("rpm", options, "-U", new_resource.source)
end
else
- shell_out_compact_timeout!("rpm", options, "-i", new_resource.source)
+ shell_out_compact!("rpm", options, "-i", new_resource.source)
end
end
@@ -101,9 +101,9 @@ class Chef
def remove_package(name, version)
if version
- shell_out_compact_timeout!("rpm", options, "-e", "#{name}-#{version}")
+ shell_out_compact!("rpm", options, "-e", "#{name}-#{version}")
else
- shell_out_compact_timeout!("rpm", options, "-e", name)
+ shell_out_compact!("rpm", options, "-e", name)
end
end
diff --git a/lib/chef/provider/package/smartos.rb b/lib/chef/provider/package/smartos.rb
index 5c637814a6..e78fcec580 100644
--- a/lib/chef/provider/package/smartos.rb
+++ b/lib/chef/provider/package/smartos.rb
@@ -43,7 +43,7 @@ class Chef
def check_package_state(name)
logger.trace("#{new_resource} checking package #{name}")
version = nil
- info = shell_out_compact_timeout!("/opt/local/sbin/pkg_info", "-E", "#{name}*", env: nil, returns: [0, 1])
+ info = shell_out_compact!("/opt/local/sbin/pkg_info", "-E", "#{name}*", env: nil, returns: [0, 1])
if info.stdout
version = info.stdout[/^#{new_resource.package_name}-(.+)/, 1]
@@ -58,7 +58,7 @@ class Chef
return @candidate_version if @candidate_version
name = nil
version = nil
- pkg = shell_out_compact_timeout!("/opt/local/bin/pkgin", "se", new_resource.package_name, env: nil, returns: [0, 1])
+ pkg = shell_out_compact!("/opt/local/bin/pkgin", "se", new_resource.package_name, env: nil, returns: [0, 1])
pkg.stdout.each_line do |line|
case line
when /^#{new_resource.package_name}/
@@ -72,7 +72,7 @@ class Chef
def install_package(name, version)
logger.trace("#{new_resource} installing package #{name} version #{version}")
package = "#{name}-#{version}"
- out = shell_out_compact_timeout!("/opt/local/bin/pkgin", "-y", "install", package, env: nil)
+ out = shell_out_compact!("/opt/local/bin/pkgin", "-y", "install", package, env: nil)
end
def upgrade_package(name, version)
@@ -83,7 +83,7 @@ class Chef
def remove_package(name, version)
logger.trace("#{new_resource} removing package #{name} version #{version}")
package = name.to_s
- out = shell_out_compact_timeout!("/opt/local/bin/pkgin", "-y", "remove", package, env: nil)
+ out = shell_out_compact!("/opt/local/bin/pkgin", "-y", "remove", package, env: nil)
end
end
diff --git a/lib/chef/provider/package/solaris.rb b/lib/chef/provider/package/solaris.rb
index 9c75c76929..9f7cd3cd5d 100644
--- a/lib/chef/provider/package/solaris.rb
+++ b/lib/chef/provider/package/solaris.rb
@@ -55,7 +55,7 @@ class Chef
@package_source_found = ::File.exist?(new_resource.source)
if @package_source_found
logger.trace("#{new_resource} checking pkg status")
- shell_out_compact_timeout("pkginfo", "-l", "-d", new_resource.source, new_resource.package_name).stdout.each_line do |line|
+ shell_out_compact("pkginfo", "-l", "-d", new_resource.source, new_resource.package_name).stdout.each_line do |line|
case line
when /VERSION:\s+(.+)/
new_resource.version($1)
@@ -65,7 +65,7 @@ class Chef
end
logger.trace("#{new_resource} checking install state")
- status = shell_out_compact_timeout("pkginfo", "-l", current_resource.package_name)
+ status = shell_out_compact("pkginfo", "-l", current_resource.package_name)
status.stdout.each_line do |line|
case line
when /VERSION:\s+(.+)/
@@ -83,7 +83,7 @@ class Chef
def candidate_version
return @candidate_version if @candidate_version
- status = shell_out_compact_timeout("pkginfo", "-l", "-d", new_resource.source, new_resource.package_name)
+ status = shell_out_compact("pkginfo", "-l", "-d", new_resource.source, new_resource.package_name)
status.stdout.each_line do |line|
case line
when /VERSION:\s+(.+)/
@@ -106,7 +106,7 @@ class Chef
else
[ "pkgadd", "-n", "-d", new_resource.source, "all" ]
end
- shell_out_compact_timeout!(command)
+ shell_out_compact!(command)
logger.trace("#{new_resource} installed version #{new_resource.version} from: #{new_resource.source}")
else
command = if ::File.directory?(new_resource.source) # CHEF-4469
@@ -114,7 +114,7 @@ class Chef
else
[ "pkgadd", "-n", options, "-d", new_resource.source, "all" ]
end
- shell_out_compact_timeout!(*command)
+ shell_out_compact!(*command)
logger.trace("#{new_resource} installed version #{new_resource.version} from: #{new_resource.source}")
end
end
@@ -123,10 +123,10 @@ class Chef
def remove_package(name, version)
if options.nil?
- shell_out_compact_timeout!( "pkgrm", "-n", name )
+ shell_out_compact!( "pkgrm", "-n", name )
logger.trace("#{new_resource} removed version #{new_resource.version}")
else
- shell_out_compact_timeout!( "pkgrm", "-n", options, name )
+ shell_out_compact!( "pkgrm", "-n", options, name )
logger.trace("#{new_resource} removed version #{new_resource.version}")
end
end
diff --git a/lib/chef/provider/package/yum.rb b/lib/chef/provider/package/yum.rb
index 1c18e4bfc4..325ffc9584 100644
--- a/lib/chef/provider/package/yum.rb
+++ b/lib/chef/provider/package/yum.rb
@@ -260,7 +260,7 @@ class Chef
end
def yum(*args)
- shell_out_compact_timeout!(yum_binary, *args)
+ shell_out_compact!(yum_binary, *args)
end
def safe_version_array
diff --git a/lib/chef/provider/package/zypper.rb b/lib/chef/provider/package/zypper.rb
index c2638fbfc1..5aa4ec7762 100644
--- a/lib/chef/provider/package/zypper.rb
+++ b/lib/chef/provider/package/zypper.rb
@@ -35,7 +35,7 @@ class Chef
candidate_version = current_version = nil
is_installed = false
logger.trace("#{new_resource} checking zypper")
- status = shell_out_compact_timeout!("zypper", "--non-interactive", "info", package_name)
+ status = shell_out_compact!("zypper", "--non-interactive", "info", package_name)
status.stdout.each_line do |line|
case line
when /^Version *: (.+) *$/
@@ -86,7 +86,7 @@ class Chef
def locked_packages
@locked_packages ||=
begin
- locked = shell_out_compact_timeout!("zypper", "locks")
+ locked = shell_out_compact!("zypper", "locks")
locked.stdout.each_line.map do |line|
line.split("|").shift(2).last.strip
end
@@ -144,9 +144,9 @@ class Chef
def zypper_package(command, *options, names, versions)
zipped_names = zip(names, versions)
if zypper_version < 1.0
- shell_out_compact_timeout!("zypper", gpg_checks, command, *options, "-y", names)
+ shell_out_compact!("zypper", gpg_checks, command, *options, "-y", names)
else
- shell_out_compact_timeout!("zypper", "--non-interactive", gpg_checks, command, *options, zipped_names)
+ shell_out_compact!("zypper", "--non-interactive", gpg_checks, command, *options, zipped_names)
end
end
diff --git a/lib/chef/resource/paludis_package.rb b/lib/chef/resource/paludis_package.rb
index 15378cd2e5..722163254f 100644
--- a/lib/chef/resource/paludis_package.rb
+++ b/lib/chef/resource/paludis_package.rb
@@ -1,6 +1,6 @@
#
# Author:: Vasiliy Tolstov (<v.tolstov@selfip.ru>)
-# Copyright:: Copyright 2014-2016, Chef Software Inc.
+# Copyright:: Copyright 2014-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/lib/chef/resource/portage_package.rb b/lib/chef/resource/portage_package.rb
index 6936f5129f..43b0cfc74d 100644
--- a/lib/chef/resource/portage_package.rb
+++ b/lib/chef/resource/portage_package.rb
@@ -25,6 +25,8 @@ class Chef
provides :portage_package
description "Use the portage_package resource to manage packages for the Gentoo platform."
+
+ property :timeout, default: 3600
end
end
end