aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMarkus Reiter2017-06-11 04:41:43 +0200
committerMarkus Reiter2017-06-14 02:06:25 +0200
commit80f827e926a35ee8c4555cd14e4a23948dc6bff1 (patch)
tree060aae1086e56e21af19ff09ed02d2db1b4fb881 /Library
parent2f0aad5d88d7e495f0a85581bc7f448ddb844152 (diff)
downloadbrew-80f827e926a35ee8c4555cd14e4a23948dc6bff1.tar.bz2
Print DMG EULA when `--verbose`.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cask/lib/hbc/artifact/nested_container.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/container/base.rb9
-rw-r--r--Library/Homebrew/cask/lib/hbc/container/dmg.rb24
-rw-r--r--Library/Homebrew/cask/lib/hbc/installer.rb2
4 files changed, 29 insertions, 8 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/artifact/nested_container.rb b/Library/Homebrew/cask/lib/hbc/artifact/nested_container.rb
index 45f23fe37..84253ea30 100644
--- a/Library/Homebrew/cask/lib/hbc/artifact/nested_container.rb
+++ b/Library/Homebrew/cask/lib/hbc/artifact/nested_container.rb
@@ -16,7 +16,7 @@ module Hbc
end
ohai "Extracting nested container #{source.basename}"
- container.new(@cask, source, @command).extract
+ container.new(@cask, source, @command, verbose: verbose?).extract
FileUtils.remove_entry_secure(source)
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/container/base.rb b/Library/Homebrew/cask/lib/hbc/container/base.rb
index 1f1c9ad9b..52eb5aab1 100644
--- a/Library/Homebrew/cask/lib/hbc/container/base.rb
+++ b/Library/Homebrew/cask/lib/hbc/container/base.rb
@@ -1,11 +1,16 @@
module Hbc
class Container
class Base
- def initialize(cask, path, command, nested: false)
+ def initialize(cask, path, command, nested: false, verbose: false)
@cask = cask
@path = path
@command = command
@nested = nested
+ @verbose = verbose
+ end
+
+ def verbose?
+ @verbose
end
def extract_nested_inside(dir)
@@ -32,7 +37,7 @@ module Hbc
return false unless container
ohai "Extracting nested container #{source.basename}"
- container.new(@cask, source, @command, nested: true).extract
+ container.new(@cask, source, @command, nested: true, verbose: verbose?).extract
true
end
diff --git a/Library/Homebrew/cask/lib/hbc/container/dmg.rb b/Library/Homebrew/cask/lib/hbc/container/dmg.rb
index 2990195d9..1d172a4b7 100644
--- a/Library/Homebrew/cask/lib/hbc/container/dmg.rb
+++ b/Library/Homebrew/cask/lib/hbc/container/dmg.rb
@@ -31,11 +31,27 @@ module Hbc
Dir.mktmpdir do |unpack_dir|
cdr_path = Pathname.new(unpack_dir).join("#{path.basename(".dmg")}.cdr")
- @command.run!("/usr/bin/hdiutil", args: ["convert", "-quiet", "-format", "UDTO", "-o", cdr_path, path])
+ without_eula = @command.run("/usr/bin/hdiutil",
+ args: ["attach", "-plist", "-nobrowse", "-readonly", "-noidme", "-mountrandom", unpack_dir, path],
+ input: "qn\n",
+ print_stderr: false)
+
+ # If mounting without agreeing to EULA succeeded, there is none.
+ plist = if without_eula.success?
+ without_eula.plist
+ else
+ @command.run!("/usr/bin/hdiutil", args: ["convert", "-quiet", "-format", "UDTO", "-o", cdr_path, path])
+
+ with_eula = @command.run!("/usr/bin/hdiutil",
+ args: ["attach", "-plist", "-nobrowse", "-readonly", "-noidme", "-mountrandom", unpack_dir, cdr_path])
- plist = @command.run!("/usr/bin/hdiutil",
- args: ["attach", "-plist", "-nobrowse", "-readonly", "-noidme", "-mountrandom", unpack_dir, cdr_path],
- input: "qy\n").plist
+ if verbose? && !(eula_text = without_eula.stdout).empty?
+ ohai "Software License Agreement for '#{path}':"
+ puts eula_text
+ end
+
+ with_eula.plist
+ end
yield mounts_from_plist(plist)
end
diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb
index 7da9731e5..dcc813941 100644
--- a/Library/Homebrew/cask/lib/hbc/installer.rb
+++ b/Library/Homebrew/cask/lib/hbc/installer.rb
@@ -165,7 +165,7 @@ module Hbc
end
odebug "Using container class #{container} for #{@downloaded_path}"
- container.new(@cask, @downloaded_path, @command).extract
+ container.new(@cask, @downloaded_path, @command, verbose: verbose?).extract
end
def install_artifacts