include_recipe 'dmg'
dmg_package "R" do
source 'https://cran.r-project.org/bin/macosx/R-3.3.0.pkg'
type 'pkg'
end
Here’s the error from running it in test kitchen. It looks from the error that it is treating the pkg file as a dmg and trying to attach it. I just want to run ‘installer’ on it.
================================================================================
Error executing action `run` on resource 'ruby_block[attach /tmp/kitchen/cache/R.dmg]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of hdiutil attach '/tmp/kitchen/cache/R.dmg' -quiet ----
STDOUT:
STDERR:
---- End output of hdiutil attach '/tmp/kitchen/cache/R.dmg' -quiet ----
Ran hdiutil attach '/tmp/kitchen/cache/R.dmg' -quiet returned 1
Cookbook Trace:
---------------
/tmp/kitchen/cache/cookbooks/dmg/providers/package.rb:57:in `block (3 levels) in class_from_file'
Resource Declaration:
---------------------
# In /tmp/kitchen/cache/cookbooks/dmg/providers/package.rb
51: ruby_block "attach #{dmg_file}" do
52: block do
53: cmd = shell_out("hdiutil imageinfo #{passphrase_cmd} '#{dmg_file}' | grep -q 'Software License Agreement: true'")
54: software_license_agreement = (cmd.exitstatus == 0)
55: raise "Requires EULA Acceptance; add 'accept_eula true' to package resource" if software_license_agreement && !new_resource.accept_eula
56: accept_eula_cmd = new_resource.accept_eula ? 'echo Y | PAGER=true' : ''
57: shell_out!("#{accept_eula_cmd} hdiutil attach #{passphrase_cmd} '#{dmg_file}' -quiet")
58: end
59: not_if "hdiutil info #{passphrase_cmd} | grep -q 'image-path.*#{dmg_file}'"
60: end
61:
Compiled Resource:
------------------
# Declared in /tmp/kitchen/cache/cookbooks/dmg/providers/package.rb:51:in `block in class_from_file'
ruby_block("attach /tmp/kitchen/cache/R.dmg") do
action [:run]
retries 0
retry_delay 2
default_guard_interpreter :default
block_name "attach /tmp/kitchen/cache/R.dmg"
declared_type :ruby_block
cookbook_name "BBS-provision-cookbook-mac"
block #<Proc:0x007f8d257692b0@/tmp/kitchen/cache/cookbooks/dmg/providers/package.rb:52>
not_if "hdiutil info | grep -q 'image-path.*/tmp/kitchen/cache/R.dmg'"
end
Platform:
---------
x86_64-darwin13.0
================================================================================
Error executing action `install` on resource 'dmg_package[R]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
ruby_block[attach /tmp/kitchen/cache/R.dmg] (/tmp/kitchen/cache/cookbooks/dmg/providers/package.rb line 51) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of hdiutil attach '/tmp/kitchen/cache/R.dmg' -quiet ----
STDOUT:
STDERR:
---- End output of hdiutil attach '/tmp/kitchen/cache/R.dmg' -quiet ----
Ran hdiutil attach '/tmp/kitchen/cache/R.dmg' -quiet returned 1
Cookbook Trace:
---------------
/tmp/kitchen/cache/cookbooks/dmg/providers/package.rb:57:in `block (3 levels) in class_from_file'
Resource Declaration:
---------------------
# In /tmp/kitchen/cache/cookbooks/BBS-provision-cookbook-mac/recipes/default.rb
3: dmg_package "R" do
4: source 'https://cran.r-project.org/bin/macosx/R-3.3.0.pkg'
5: type 'pkg'
6: end
7:
Compiled Resource:
------------------
# Declared in /tmp/kitchen/cache/cookbooks/BBS-provision-cookbook-mac/recipes/default.rb:3:in `from_file'
dmg_package("R") do
action :install
updated true
updated_by_last_action true
retries 0
retry_delay 2
default_guard_interpreter :default
declared_type :dmg_package
cookbook_name "BBS-provision-cookbook-mac"
recipe_name "default"
source "https://cran.r-project.org/bin/macosx/R-3.3.0.pkg"
type "pkg"
app "R"
destination "/Applications"
end
Platform:
---------
x86_64-darwin13.0
I think the message in the DMG cookbook’s README is confusing in that it refers to the fact that it knows how to install .pkg files off a .dmg, not .pkg's directly.
I use the equivalent of:
execute "install-#{pkgdata['name']}" do
command "installer -pkg #{Chef::Config[:file_cache_path]}/#{pkgdata['name']}.pkg -target /"
action :run
not_if "pkgutil --pkgs=#{pkgdata['package_id']}"
end
Thanks. This seems like such a basic thing to do that I would have thought there was a recipe or LWRP to do it, or a provider for the package resource. Would love to be able to just say: