summaryrefslogtreecommitdiff
path: root/lib/chef/provider/package/apt.rb
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2013-08-01 16:49:16 -0700
committerdanielsdeleo <dan@opscode.com>2013-08-02 09:49:10 -0700
commit4228e9b64d9bd8a1f6171c26db1372b1f056bd4d (patch)
treea9a7c0ae235e32b2e13e9f2e4f28f5af548a4026 /lib/chef/provider/package/apt.rb
parentdf324cb4815ce09d8b0bb5a1544099441c220cf0 (diff)
downloadchef-4228e9b64d9bd8a1f6171c26db1372b1f056bd4d.tar.gz
Convert apt package provider to shellout
- Convert apt package provider to shellout. Improves content of error messages when apt fails. - Refactor tests to avoid stubbing value objects
Diffstat (limited to 'lib/chef/provider/package/apt.rb')
-rw-r--r--lib/chef/provider/package/apt.rb41
1 files changed, 11 insertions, 30 deletions
diff --git a/lib/chef/provider/package/apt.rb b/lib/chef/provider/package/apt.rb
index e8939b494e..6dcc0acad7 100644
--- a/lib/chef/provider/package/apt.rb
+++ b/lib/chef/provider/package/apt.rb
@@ -90,12 +90,7 @@ class Chef
def install_package(name, version)
package_name = "#{name}=#{version}"
package_name = name if @is_virtual_package
- run_command_with_systems_locale(
- :command => "apt-get -q -y#{expand_options(default_release_options)}#{expand_options(@new_resource.options)} install #{package_name}",
- :environment => {
- "DEBIAN_FRONTEND" => "noninteractive"
- }
- )
+ run_noninteractive("apt-get -q -y#{expand_options(default_release_options)}#{expand_options(@new_resource.options)} install #{package_name}")
end
def upgrade_package(name, version)
@@ -104,41 +99,27 @@ class Chef
def remove_package(name, version)
package_name = "#{name}"
- run_command_with_systems_locale(
- :command => "apt-get -q -y#{expand_options(@new_resource.options)} remove #{package_name}",
- :environment => {
- "DEBIAN_FRONTEND" => "noninteractive"
- }
- )
+ run_noninteractive("apt-get -q -y#{expand_options(@new_resource.options)} remove #{package_name}")
end
def purge_package(name, version)
- run_command_with_systems_locale(
- :command => "apt-get -q -y#{expand_options(@new_resource.options)} purge #{@new_resource.package_name}",
- :environment => {
- "DEBIAN_FRONTEND" => "noninteractive"
- }
- )
+ run_noninteractive("apt-get -q -y#{expand_options(@new_resource.options)} purge #{@new_resource.package_name}")
end
def preseed_package(preseed_file)
Chef::Log.info("#{@new_resource} pre-seeding package installation instructions")
- run_command_with_systems_locale(
- :command => "debconf-set-selections #{preseed_file}",
- :environment => {
- "DEBIAN_FRONTEND" => "noninteractive"
- }
- )
+ run_noninteractive("debconf-set-selections #{preseed_file}")
end
def reconfig_package(name, version)
Chef::Log.info("#{@new_resource} reconfiguring")
- run_command_with_systems_locale(
- :command => "dpkg-reconfigure #{name}",
- :environment => {
- "DEBIAN_FRONTEND" => "noninteractive"
- }
- )
+ run_noninteractive("dpkg-reconfigure #{name}")
+ end
+
+ private
+
+ def run_noninteractive(command)
+ shell_out!(command, :env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil })
end
end