diff options
author | Kapil Chouhan <kapil.chouhan@msystechnologies.com> | 2018-11-19 10:00:25 +0000 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2018-11-27 17:10:06 -0800 |
commit | a268a84e05e2510291c74f0e86f738c502ff3a56 (patch) | |
tree | 7009be40f8c9cef75aa56685cc000ab8ccad7f55 | |
parent | 852b6eb69e9d11acd32c6d756dfbb9473d97a4ac (diff) | |
download | chef-cab.tar.gz |
Chef client should be fail appropriately when specified package is not applicable to imagecab
Signed-off-by: Kapil Chouhan <kapil.chouhan@msystechnologies.com>
-rw-r--r-- | lib/chef/provider/package/cab.rb | 8 | ||||
-rw-r--r-- | spec/functional/resource/msu_package_spec.rb | 14 |
2 files changed, 20 insertions, 2 deletions
diff --git a/lib/chef/provider/package/cab.rb b/lib/chef/provider/package/cab.rb index 79292293d2..cfc629b9ef 100644 --- a/lib/chef/provider/package/cab.rb +++ b/lib/chef/provider/package/cab.rb @@ -74,9 +74,13 @@ class Chef end def dism_command(command) - shellout = Mixlib::ShellOut.new("dism.exe /Online /English #{command} /NoRestart", timeout: new_resource.timeout) with_os_architecture(nil) do - shellout.run_command + result = shell_out("dism.exe /Online /English #{command} /NoRestart", { timeout: new_resource.timeout }) + if result.exitstatus == -2146498530 + raise Chef::Exceptions::Package, "The specified package is not applicable to this image." if result.stdout.include?("0x800f081e") + result.error! + end + result end end diff --git a/spec/functional/resource/msu_package_spec.rb b/spec/functional/resource/msu_package_spec.rb index 23342be6ae..d6811d99e7 100644 --- a/spec/functional/resource/msu_package_spec.rb +++ b/spec/functional/resource/msu_package_spec.rb @@ -76,6 +76,20 @@ describe Chef::Resource::MsuPackage, :win2012r2_only do end end + context "when an msu package is not applicable to the image." do + def package_name + "Package_for_KB4019990" + end + + def package_source + "http://download.windowsupdate.com/c/msdownload/update/software/updt/2017/05/windows8-rt-kb4019990-x64_a77f4e3e1f2d47205824763e7121bb11979c2716.msu" + end + + it "raises error while installing" do + expect { subject.run_action(:install) }.to raise_error(Chef::Exceptions::Package, /The specified package is not applicable to this image./) + end + end + def remove_package pkg_to_remove = Chef::Resource::MsuPackage.new(package_name, run_context) pkg_to_remove.source = package_source |