Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert a_to_s to shell_out_compact in DNF/yum #7313

Merged
merged 3 commits into from May 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/chef/provider/package/dnf.rb
@@ -1,5 +1,5 @@
#
# Copyright:: Copyright 2016-2017, Chef Software Inc.
# Copyright:: Copyright 2016-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -95,10 +95,10 @@ def get_current_versions

def install_package(names, versions)
if new_resource.source
dnf(options, "-y install", new_resource.source)
dnf(options, "-y", "install", new_resource.source)
else
resolved_names = names.each_with_index.map { |name, i| available_version(i).to_s unless name.nil? }
dnf(options, "-y install", resolved_names)
dnf(options, "-y", "install", resolved_names)
end
flushcache
end
Expand All @@ -108,7 +108,7 @@ def install_package(names, versions)

def remove_package(names, versions)
resolved_names = names.each_with_index.map { |name, i| installed_version(i).to_s unless name.nil? }
dnf(options, "-y remove", resolved_names)
dnf(options, "-y", "remove", resolved_names)
flushcache
end

Expand Down Expand Up @@ -167,7 +167,7 @@ def flushcache
end

def dnf(*args)
shell_out_with_timeout!(a_to_s("dnf", *args))
shell_out_compact_timeout!("dnf", *args)
end

def safe_version_array
Expand Down
14 changes: 7 additions & 7 deletions lib/chef/provider/package/yum.rb
Expand Up @@ -117,10 +117,10 @@ def install_package(names, versions)
end

if new_resource.source
yum(options, "-y #{method}", new_resource.source)
yum(options, "-y", method, new_resource.source)
else
resolved_names = names.each_with_index.map { |name, i| available_version(i).to_s unless name.nil? }
yum(options, "-y #{method}", resolved_names)
yum(options, "-y", method, resolved_names)
end
flushcache
end
Expand All @@ -130,7 +130,7 @@ def install_package(names, versions)

def remove_package(names, versions)
resolved_names = names.each_with_index.map { |name, i| installed_version(i).to_s unless name.nil? }
yum(options, "-y remove", resolved_names)
yum(options, "-y", "remove", resolved_names)
flushcache
end

Expand All @@ -143,14 +143,14 @@ def remove_package(names, versions)
# NB: the yum_package provider manages individual single packages, please do not submit issues or PRs to try to add wildcard
# support to lock / unlock. The best solution is to write an execute resource which does a not_if `yum versionlock | grep '^pattern`` kind of approach
def lock_package(names, versions)
yum("-d0 -e0 -y", options, "versionlock add", resolved_package_lock_names(names))
yum("-d0", "-e0", "-y", options, "versionlock", "add", resolved_package_lock_names(names))
end

# NB: the yum_package provider manages individual single packages, please do not submit issues or PRs to try to add wildcard
# support to lock / unlock. The best solution is to write an execute resource which does a only_if `yum versionlock | grep '^pattern`` kind of approach
def unlock_package(names, versions)
# yum versionlock delete on rhel6 needs the glob nonsense in the following command
yum("-d0 -e0 -y", options, "versionlock delete", resolved_package_lock_names(names).map { |n| "'*:#{n}-*'" })
yum("-d0", "-e0", "-y", options, "versionlock", "delete", resolved_package_lock_names(names).map { |n| "'*:#{n}-*'" })
end

private
Expand All @@ -171,7 +171,7 @@ def resolved_package_lock_names(names)
def locked_packages
@locked_packages ||=
begin
locked = shell_out_with_timeout!("yum versionlock list")
locked = yum("versionlock", "list")
locked.stdout.each_line.map do |line|
line.sub(/-[^-]*-[^-]*$/, "").split(":").last.strip
end
Expand Down Expand Up @@ -260,7 +260,7 @@ def yum_binary
end

def yum(*args)
shell_out_with_timeout!(a_to_s(yum_binary, *args))
shell_out_compact_timeout!(yum_binary, *args)
end

def safe_version_array
Expand Down