summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-10-28 19:57:35 -0700
committerTim Smith <tsmith@chef.io>2018-10-28 19:57:35 -0700
commitde55858248a59e2d20374b9e19c3f21934d4a736 (patch)
treee168f3fc2d6d3b7818b5ff63ff98dad5e27e4119 /lib
parentaef3252a9a9615d9fcd80af9398dadd3a1e06661 (diff)
downloadchef-de55858248a59e2d20374b9e19c3f21934d4a736.tar.gz
Move dmg attached check out to a helper method
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib')
-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