Move verbose from #initialize to #extract.
This commit is contained in:
parent
c5f92bfb8b
commit
8278e9e403
@ -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
|
||||
|
||||
@ -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],
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
@ -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"]) })
|
||||
|
||||
@ -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?
|
||||
|
||||
@ -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"]) })
|
||||
|
||||
@ -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|
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
@ -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)],
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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"]) })
|
||||
|
||||
@ -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"]) })
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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],
|
||||
|
||||
@ -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])
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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).
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user