summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-10-28 19:57:35 -0700
committerTim Smith <tsmith@chef.io>2018-10-31 12:37:31 -0700
commit3d09465449092c2cfe68cec0800c5d5a2a949a55 (patch)
tree12ffe2adc08772725b830409885508a2f54f22b7
parent70c0f211b7e3268b6f17674d6505ef2d30752a28 (diff)
downloadchef-3d09465449092c2cfe68cec0800c5d5a2a949a55.tar.gz
Move dmg attached check out to a helper method
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/resource/dmg_package.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/chef/resource/dmg_package.rb b/lib/chef/resource/dmg_package.rb
index 678e251795..a5c7a3923f 100644
--- a/lib/chef/resource/dmg_package.rb
+++ b/lib/chef/resource/dmg_package.rb
@@ -107,7 +107,7 @@ class Chef
accept_eula_cmd = new_resource.accept_eula ? "echo Y | echo Y | PAGER=true " : ""
shell_out!("#{accept_eula_cmd} /usr/bin/hdiutil attach #{passphrase_cmd} '#{dmg_file}' -nobrowse -mountpoint '/Volumes/#{new_resource.volumes_dir}' -quiet", env: { "PAGER" => "true" })
end
- not_if "/usr/bin/hdiutil info #{passphrase_cmd} | grep -q 'image-path.*#{dmg_file}'"
+ not_if { dmg_attached? }
end
case new_resource.type
@@ -156,6 +156,12 @@ class Chef
# example hdiutil imageinfo output: http://rubular.com/r/0xvOaA6d8B
/Software License Agreement: true/.match?(shell_out!("/usr/bin/hdiutil imageinfo #{passphrase_cmd} '#{dmg_file}'").stdout)
end
+
+ # @return [Boolean] is the dmg file currently attached?
+ def dmg_attached?
+ # example hdiutil imageinfo output: http://rubular.com/r/CDcqenkixg
+ /image-path.*#{dmg_file}/.match?(shell_out!("/usr/bin/hdiutil info #{passphrase_cmd}").stdout)
+ end
end
end
end