diff --git a/Library/Homebrew/cask/lib/hbc/artifact/nested_container.rb b/Library/Homebrew/cask/lib/hbc/artifact/nested_container.rb index ca669267f5..4aeff588b0 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/nested_container.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/nested_container.rb @@ -28,7 +28,7 @@ module Hbc end ohai "Extracting nested container #{path.relative_path_from(cask.staged_path)}" - container.new(cask, path, command, verbose: verbose).extract(to: cask.staged_path) + container.new(cask, path, command).extract(to: cask.staged_path, verbose: verbose) FileUtils.remove_entry_secure(path) end end diff --git a/Library/Homebrew/cask/lib/hbc/container/air.rb b/Library/Homebrew/cask/lib/hbc/container/air.rb index 6b3ac97923..ed069ee402 100644 --- a/Library/Homebrew/cask/lib/hbc/container/air.rb +++ b/Library/Homebrew/cask/lib/hbc/container/air.rb @@ -7,7 +7,7 @@ module Hbc path.extname == ".air" end - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) @command.run!( "/Applications/Utilities/Adobe AIR Application Installer.app/Contents/MacOS/Adobe AIR Application Installer", args: ["-silent", "-location", unpack_dir, path], diff --git a/Library/Homebrew/cask/lib/hbc/container/base.rb b/Library/Homebrew/cask/lib/hbc/container/base.rb index 9e9d595a97..e8ea103c16 100644 --- a/Library/Homebrew/cask/lib/hbc/container/base.rb +++ b/Library/Homebrew/cask/lib/hbc/container/base.rb @@ -5,23 +5,20 @@ module Hbc attr_reader :path - attr_predicate :verbose? - - def initialize(cask, path, command, nested: false, verbose: false) + def initialize(cask, path, command, nested: false) @cask = cask @path = path @command = command - @verbose = verbose end - def extract(to: nil, basename: nil) + def extract(to: nil, basename: nil, verbose: false) basename ||= path.basename unpack_dir = Pathname(to || Dir.pwd).expand_path unpack_dir.mkpath - extract_to_dir(unpack_dir, basename: basename) + extract_to_dir(unpack_dir, basename: basename, verbose: verbose) end - def extract_nested_inside(dir, to:) + def extract_nested_inside(dir, to:, verbose: false) children = Pathname.new(dir).children nested_container = children[0] @@ -29,7 +26,7 @@ module Hbc unless children.count == 1 && !nested_container.directory? && @cask.artifacts.none? { |a| a.is_a?(Artifact::NestedContainer) } && - extract_nested_container(nested_container, to: to) + extract_nested_container(nested_container, to: to, verbose: verbose) children.each do |src| dest = @cask.staged_path.join(src.basename) @@ -39,13 +36,13 @@ module Hbc end end - def extract_nested_container(source, to:) + def extract_nested_container(source, to:, verbose: false) container = Container.for_path(source) return false unless container ohai "Extracting nested container #{source.basename}" - container.new(@cask, source, @command, verbose: verbose?).extract(to: to) + container.new(@cask, source, @command).extract(to: to, verbose: verbose) true end diff --git a/Library/Homebrew/cask/lib/hbc/container/bzip2.rb b/Library/Homebrew/cask/lib/hbc/container/bzip2.rb index 78c4f096fb..9c9ebf0b5b 100644 --- a/Library/Homebrew/cask/lib/hbc/container/bzip2.rb +++ b/Library/Homebrew/cask/lib/hbc/container/bzip2.rb @@ -7,7 +7,7 @@ module Hbc magic_number.match?(/\ABZh/n) end - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) Dir.mktmpdir do |tmp_unpack_dir| tmp_unpack_dir = Pathname(tmp_unpack_dir) diff --git a/Library/Homebrew/cask/lib/hbc/container/cab.rb b/Library/Homebrew/cask/lib/hbc/container/cab.rb index 28c4a0c665..d104b99f30 100644 --- a/Library/Homebrew/cask/lib/hbc/container/cab.rb +++ b/Library/Homebrew/cask/lib/hbc/container/cab.rb @@ -7,7 +7,7 @@ module Hbc magic_number.match?(/\A(MSCF|MZ)/n) end - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) @command.run!("cabextract", args: ["-d", unpack_dir, "--", path], env: { "PATH" => PATH.new(Formula["cabextract"].opt_bin, ENV["PATH"]) }) diff --git a/Library/Homebrew/cask/lib/hbc/container/dmg.rb b/Library/Homebrew/cask/lib/hbc/container/dmg.rb index a3ca9754e3..39e3a840a1 100644 --- a/Library/Homebrew/cask/lib/hbc/container/dmg.rb +++ b/Library/Homebrew/cask/lib/hbc/container/dmg.rb @@ -14,7 +14,7 @@ module Hbc !imageinfo.empty? end - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) mount do |mounts| begin raise CaskError, "No mounts found in '#{@path}'; perhaps it is a bad disk image?" if mounts.empty? diff --git a/Library/Homebrew/cask/lib/hbc/container/generic_unar.rb b/Library/Homebrew/cask/lib/hbc/container/generic_unar.rb index 0b3f2f8ea5..0713e54063 100644 --- a/Library/Homebrew/cask/lib/hbc/container/generic_unar.rb +++ b/Library/Homebrew/cask/lib/hbc/container/generic_unar.rb @@ -7,7 +7,7 @@ module Hbc false end - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) @command.run!("unar", args: ["-force-overwrite", "-quiet", "-no-directory", "-output-directory", unpack_dir, "--", path], env: { "PATH" => PATH.new(Formula["unar"].opt_bin, ENV["PATH"]) }) diff --git a/Library/Homebrew/cask/lib/hbc/container/gpg.rb b/Library/Homebrew/cask/lib/hbc/container/gpg.rb index 10ca691338..af99d69e63 100644 --- a/Library/Homebrew/cask/lib/hbc/container/gpg.rb +++ b/Library/Homebrew/cask/lib/hbc/container/gpg.rb @@ -23,7 +23,7 @@ module Hbc env: { "PATH" => PATH.new(Formula["gnupg"].opt_bin, ENV["PATH"]) }) end - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) import_key Dir.mktmpdir do |tmp_unpack_dir| diff --git a/Library/Homebrew/cask/lib/hbc/container/gzip.rb b/Library/Homebrew/cask/lib/hbc/container/gzip.rb index bc67c64bb5..9a9405bcb0 100644 --- a/Library/Homebrew/cask/lib/hbc/container/gzip.rb +++ b/Library/Homebrew/cask/lib/hbc/container/gzip.rb @@ -7,7 +7,7 @@ module Hbc magic_number.match?(/\A\037\213/n) end - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) Dir.mktmpdir do |tmp_unpack_dir| tmp_unpack_dir = Pathname(tmp_unpack_dir) diff --git a/Library/Homebrew/cask/lib/hbc/container/lzma.rb b/Library/Homebrew/cask/lib/hbc/container/lzma.rb index 79be731bf4..d4da3ee500 100644 --- a/Library/Homebrew/cask/lib/hbc/container/lzma.rb +++ b/Library/Homebrew/cask/lib/hbc/container/lzma.rb @@ -7,7 +7,7 @@ module Hbc magic_number.match?(/\A\]\000\000\200\000/n) end - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) @command.run!("/usr/bin/ditto", args: ["--", path, unpack_dir]) @command.run!("unlzma", args: ["-q", "--", Pathname(unpack_dir).join(basename)], diff --git a/Library/Homebrew/cask/lib/hbc/container/naked.rb b/Library/Homebrew/cask/lib/hbc/container/naked.rb index 4b32a222b5..03ce00ea9a 100644 --- a/Library/Homebrew/cask/lib/hbc/container/naked.rb +++ b/Library/Homebrew/cask/lib/hbc/container/naked.rb @@ -7,7 +7,7 @@ module Hbc false end - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) @command.run!("/usr/bin/ditto", args: ["--", path, unpack_dir/basename]) end end diff --git a/Library/Homebrew/cask/lib/hbc/container/rar.rb b/Library/Homebrew/cask/lib/hbc/container/rar.rb index 0d614af8e9..6d9c799d29 100644 --- a/Library/Homebrew/cask/lib/hbc/container/rar.rb +++ b/Library/Homebrew/cask/lib/hbc/container/rar.rb @@ -7,7 +7,7 @@ module Hbc magic_number.match?(/\ARar!/n) end - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) @command.run!("unrar", args: ["x", "-inul", path, unpack_dir], env: { "PATH" => PATH.new(Formula["unrar"].opt_bin, ENV["PATH"]) }) diff --git a/Library/Homebrew/cask/lib/hbc/container/seven_zip.rb b/Library/Homebrew/cask/lib/hbc/container/seven_zip.rb index 0e860e96ef..61a6711d14 100644 --- a/Library/Homebrew/cask/lib/hbc/container/seven_zip.rb +++ b/Library/Homebrew/cask/lib/hbc/container/seven_zip.rb @@ -7,7 +7,7 @@ module Hbc magic_number.match?(/\A7z\xBC\xAF\x27\x1C/n) end - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) @command.run!("7zr", args: ["x", "-y", "-bd", "-bso0", path, "-o#{unpack_dir}"], env: { "PATH" => PATH.new(Formula["p7zip"].opt_bin, ENV["PATH"]) }) diff --git a/Library/Homebrew/cask/lib/hbc/container/svn_repository.rb b/Library/Homebrew/cask/lib/hbc/container/svn_repository.rb index eaa5a8f213..b5294577ee 100644 --- a/Library/Homebrew/cask/lib/hbc/container/svn_repository.rb +++ b/Library/Homebrew/cask/lib/hbc/container/svn_repository.rb @@ -5,7 +5,7 @@ module Hbc (path/".svn").directory? end - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) @command.run!("svn", args: ["export", "--force", path, unpack_dir]) end end diff --git a/Library/Homebrew/cask/lib/hbc/container/tar.rb b/Library/Homebrew/cask/lib/hbc/container/tar.rb index 5f7f401458..4dba394528 100644 --- a/Library/Homebrew/cask/lib/hbc/container/tar.rb +++ b/Library/Homebrew/cask/lib/hbc/container/tar.rb @@ -12,7 +12,7 @@ module Hbc end end - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) @command.run!("tar", args: ["xf", path, "-C", unpack_dir]) end end diff --git a/Library/Homebrew/cask/lib/hbc/container/xar.rb b/Library/Homebrew/cask/lib/hbc/container/xar.rb index 7b653a787c..87195accbd 100644 --- a/Library/Homebrew/cask/lib/hbc/container/xar.rb +++ b/Library/Homebrew/cask/lib/hbc/container/xar.rb @@ -7,7 +7,7 @@ module Hbc magic_number.match?(/\Axar!/n) end - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) @command.run!("xar", args: ["-x", "-f", @path, "-C", unpack_dir]) end end diff --git a/Library/Homebrew/cask/lib/hbc/container/xz.rb b/Library/Homebrew/cask/lib/hbc/container/xz.rb index 043bf50152..35a2ba82cc 100644 --- a/Library/Homebrew/cask/lib/hbc/container/xz.rb +++ b/Library/Homebrew/cask/lib/hbc/container/xz.rb @@ -7,7 +7,7 @@ module Hbc magic_number.match?(/\A\xFD7zXZ\x00/n) end - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) @command.run!("/usr/bin/ditto", args: ["--", path, unpack_dir]) @command.run!("unxz", args: ["-q", "--", unpack_dir/basename], diff --git a/Library/Homebrew/cask/lib/hbc/container/zip.rb b/Library/Homebrew/cask/lib/hbc/container/zip.rb index 390ee48421..dacbfd7fd4 100644 --- a/Library/Homebrew/cask/lib/hbc/container/zip.rb +++ b/Library/Homebrew/cask/lib/hbc/container/zip.rb @@ -7,7 +7,7 @@ module Hbc magic_number.match?(/\APK(\003\004|\005\006)/n) end - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) Dir.mktmpdir do |tmp_unpack_dir| @command.run!("/usr/bin/ditto", args: ["-x", "-k", "--", path, tmp_unpack_dir]) diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb index 73041f3a96..8b85e4f922 100644 --- a/Library/Homebrew/cask/lib/hbc/installer.rb +++ b/Library/Homebrew/cask/lib/hbc/installer.rb @@ -158,7 +158,7 @@ module Hbc raise CaskError, "Uh oh, could not figure out how to unpack '#{@downloaded_path}'." end - container.new(@cask, @downloaded_path, @command, verbose: verbose?) + container.new(@cask, @downloaded_path, @command) end end @@ -168,7 +168,7 @@ module Hbc odebug "Using container class #{primary_container.class} for #{@downloaded_path}" basename = CGI.unescape(File.basename(@cask.url.path)) - primary_container.extract(to: @cask.staged_path, basename: basename) + primary_container.extract(to: @cask.staged_path, basename: basename, verbose: verbose?) end def install_artifacts diff --git a/Library/Homebrew/unpack_strategy.rb b/Library/Homebrew/unpack_strategy.rb index dbb5ddf27a..4ae1472d11 100644 --- a/Library/Homebrew/unpack_strategy.rb +++ b/Library/Homebrew/unpack_strategy.rb @@ -61,29 +61,29 @@ class UnpackStrategy @ref = ref end - def extract(to: nil, basename: nil) + def extract(to: nil, basename: nil, verbose: false) basename ||= path.basename unpack_dir = Pathname(to || Dir.pwd).expand_path unpack_dir.mkpath - extract_to_dir(unpack_dir, basename: basename) + extract_to_dir(unpack_dir, basename: basename, verbose: verbose) end - def extract_nestedly(to: nil, basename: nil) + def extract_nestedly(to: nil, basename: nil, verbose: false) Dir.mktmpdir do |tmp_unpack_dir| tmp_unpack_dir = Pathname(tmp_unpack_dir) - extract(to: tmp_unpack_dir, basename: basename) + extract(to: tmp_unpack_dir, basename: basename, verbose: verbose) children = tmp_unpack_dir.children if children.count == 1 && !children.first.directory? s = self.class.detect(children.first) - s.extract_nestedly(to: to) + s.extract_nestedly(to: to, verbose: verbose) next end - DirectoryUnpackStrategy.new(tmp_unpack_dir).extract(to: to) + DirectoryUnpackStrategy.new(tmp_unpack_dir).extract(to: to, verbose: verbose) end end end @@ -95,7 +95,7 @@ class DirectoryUnpackStrategy < UnpackStrategy private - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) FileUtils.cp_r File.join(path, "."), unpack_dir, preserve: true end end @@ -105,7 +105,7 @@ class UncompressedUnpackStrategy < UnpackStrategy private - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) FileUtils.cp path, unpack_dir/basename, preserve: true end end @@ -151,7 +151,7 @@ class P7ZipUnpackStrategy < UnpackStrategy private - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) safe_system "7zr", "x", "-y", "-bd", "-bso0", path, "-o#{unpack_dir}" end end @@ -163,7 +163,7 @@ class ZipUnpackStrategy < UnpackStrategy private - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) safe_system "unzip", "-qq", path, "-d", unpack_dir end end @@ -180,7 +180,7 @@ class TarUnpackStrategy < UnpackStrategy private - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) safe_system "tar", "xf", path, "-C", unpack_dir end end @@ -198,7 +198,7 @@ class XzUnpackStrategy < UnpackStrategy private - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) FileUtils.cp path, unpack_dir/basename, preserve: true safe_system Formula["xz"].opt_bin/"unxz", "-q", "-T0", unpack_dir/basename extract_nested_tar(unpack_dir) @@ -224,7 +224,7 @@ class Bzip2UnpackStrategy < UnpackStrategy private - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) FileUtils.cp path, unpack_dir/basename, preserve: true safe_system "bunzip2", "-q", unpack_dir/basename end @@ -237,7 +237,7 @@ class GzipUnpackStrategy < UnpackStrategy private - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) FileUtils.cp path, unpack_dir/basename, preserve: true safe_system "gunzip", "-q", "-N", unpack_dir/basename end @@ -250,7 +250,7 @@ class LzipUnpackStrategy < UnpackStrategy private - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) FileUtils.cp path, unpack_dir/basename, preserve: true safe_system Formula["lzip"].opt_bin/"lzip", "-d", "-q", unpack_dir/basename end @@ -263,7 +263,7 @@ class XarUnpackStrategy < UnpackStrategy private - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) safe_system "xar", "-x", "-f", path, "-C", unpack_dir end end @@ -275,7 +275,7 @@ class RarUnpackStrategy < UnpackStrategy private - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) safe_system Formula["unrar"].opt_bin/"unrar", "x", "-inul", path, unpack_dir end end @@ -287,7 +287,7 @@ class LhaUnpackStrategy < UnpackStrategy private - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) safe_system Formula["lha"].opt_bin/"lha", "xq2w=#{unpack_dir}", path end end @@ -305,7 +305,7 @@ class SubversionUnpackStrategy < DirectoryUnpackStrategy private - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) safe_system "svn", "export", "--force", path, unpack_dir end end @@ -323,7 +323,7 @@ class MercurialUnpackStrategy < DirectoryUnpackStrategy private - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) with_env "PATH" => PATH.new(Formula["mercurial"].opt_bin, ENV["PATH"]) do safe_system "hg", "--cwd", path, "archive", "--subrepos", "-y", "-t", "files", unpack_dir end @@ -341,7 +341,7 @@ class FossilUnpackStrategy < UnpackStrategy private - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) args = if @ref_type && @ref [@ref] else @@ -361,7 +361,7 @@ class BazaarUnpackStrategy < DirectoryUnpackStrategy private - def extract_to_dir(unpack_dir, basename:) + def extract_to_dir(unpack_dir, basename:, verbose:) super # The export command doesn't work on checkouts (see https://bugs.launchpad.net/bzr/+bug/897511).