Merge pull request #4543 from reitermarkus/verbose-system_command
Pass `verbose` to unpack strategies.
This commit is contained in:
commit
28fd59672a
@ -357,7 +357,8 @@ end
|
|||||||
class NoUnzipCurlDownloadStrategy < CurlDownloadStrategy
|
class NoUnzipCurlDownloadStrategy < CurlDownloadStrategy
|
||||||
def stage
|
def stage
|
||||||
UnpackStrategy::Uncompressed.new(cached_location)
|
UnpackStrategy::Uncompressed.new(cached_location)
|
||||||
.extract(basename: basename_without_params)
|
.extract(basename: basename_without_params,
|
||||||
|
verbose: ARGV.verbose? && !shutup)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -28,8 +28,9 @@ class SystemCommand
|
|||||||
end
|
end
|
||||||
|
|
||||||
def run!
|
def run!
|
||||||
|
puts command.shelljoin.gsub(/\\=/, "=") if verbose? || ARGV.debug?
|
||||||
|
|
||||||
@merged_output = []
|
@merged_output = []
|
||||||
odebug command.shelljoin
|
|
||||||
|
|
||||||
each_output_line do |type, line|
|
each_output_line do |type, line|
|
||||||
case type
|
case type
|
||||||
@ -46,13 +47,16 @@ class SystemCommand
|
|||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(executable, args: [], sudo: false, input: [], print_stdout: false, print_stderr: true, must_succeed: false, env: {}, **options)
|
def initialize(executable, args: [], sudo: false, env: {}, input: [], must_succeed: false,
|
||||||
|
print_stdout: false, print_stderr: true, verbose: false, **options)
|
||||||
|
|
||||||
@executable = executable
|
@executable = executable
|
||||||
@args = args
|
@args = args
|
||||||
@sudo = sudo
|
@sudo = sudo
|
||||||
@input = [*input]
|
@input = [*input]
|
||||||
@print_stdout = print_stdout
|
@print_stdout = print_stdout
|
||||||
@print_stderr = print_stderr
|
@print_stderr = print_stderr
|
||||||
|
@verbose = verbose
|
||||||
@must_succeed = must_succeed
|
@must_succeed = must_succeed
|
||||||
options.assert_valid_keys!(:chdir)
|
options.assert_valid_keys!(:chdir)
|
||||||
@options = options
|
@options = options
|
||||||
@ -71,7 +75,7 @@ class SystemCommand
|
|||||||
|
|
||||||
attr_reader :executable, :args, :input, :options, :env
|
attr_reader :executable, :args, :input, :options, :env
|
||||||
|
|
||||||
attr_predicate :sudo?, :print_stdout?, :print_stderr?, :must_succeed?
|
attr_predicate :sudo?, :print_stdout?, :print_stderr?, :verbose?, :must_succeed?
|
||||||
|
|
||||||
def env_args
|
def env_args
|
||||||
set_variables = env.reject { |_, value| value.nil? }
|
set_variables = env.reject { |_, value| value.nil? }
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module UnpackStrategy
|
module UnpackStrategy
|
||||||
class Air
|
class Air
|
||||||
include UnpackStrategy
|
include UnpackStrategy
|
||||||
@ -17,13 +19,17 @@ module UnpackStrategy
|
|||||||
@dependencies ||= [Hbc::CaskLoader.load("adobe-air")]
|
@dependencies ||= [Hbc::CaskLoader.load("adobe-air")]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
AIR_APPLICATION_INSTALLER =
|
||||||
|
"/Applications/Utilities/Adobe AIR Application Installer.app/Contents/MacOS/Adobe AIR Application Installer"
|
||||||
|
|
||||||
|
private_constant :AIR_APPLICATION_INSTALLER
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def extract_to_dir(unpack_dir, basename:, verbose:)
|
def extract_to_dir(unpack_dir, basename:, verbose:)
|
||||||
system_command!(
|
system_command! AIR_APPLICATION_INSTALLER,
|
||||||
"/Applications/Utilities/Adobe AIR Application Installer.app/Contents/MacOS/Adobe AIR Application Installer",
|
args: ["-silent", "-location", unpack_dir, path],
|
||||||
args: ["-silent", "-location", unpack_dir, path],
|
verbose: verbose
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -17,7 +17,9 @@ module UnpackStrategy
|
|||||||
def extract_to_dir(unpack_dir, basename:, verbose:)
|
def extract_to_dir(unpack_dir, basename:, verbose:)
|
||||||
FileUtils.cp path, unpack_dir/basename, preserve: true
|
FileUtils.cp path, unpack_dir/basename, preserve: true
|
||||||
quiet_flags = verbose ? [] : ["-q"]
|
quiet_flags = verbose ? [] : ["-q"]
|
||||||
system_command! "bunzip2", args: [*quiet_flags, unpack_dir/basename]
|
system_command! "bunzip2",
|
||||||
|
args: [*quiet_flags, unpack_dir/basename],
|
||||||
|
verbose: verbose
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -15,7 +15,8 @@ module UnpackStrategy
|
|||||||
def extract_to_dir(unpack_dir, basename:, verbose:)
|
def extract_to_dir(unpack_dir, basename:, verbose:)
|
||||||
system_command! "cabextract",
|
system_command! "cabextract",
|
||||||
args: ["-d", unpack_dir, "--", path],
|
args: ["-d", unpack_dir, "--", path],
|
||||||
env: { "PATH" => PATH.new(Formula["cabextract"].opt_bin, ENV["PATH"]) }
|
env: { "PATH" => PATH.new(Formula["cabextract"].opt_bin, ENV["PATH"]) },
|
||||||
|
verbose: verbose
|
||||||
end
|
end
|
||||||
|
|
||||||
def dependencies
|
def dependencies
|
||||||
|
|||||||
@ -4,8 +4,6 @@ module UnpackStrategy
|
|||||||
class Dmg
|
class Dmg
|
||||||
include UnpackStrategy
|
include UnpackStrategy
|
||||||
|
|
||||||
using Magic
|
|
||||||
|
|
||||||
module Bom
|
module Bom
|
||||||
DMG_METADATA = Set.new %w[
|
DMG_METADATA = Set.new %w[
|
||||||
.background
|
.background
|
||||||
@ -51,7 +49,7 @@ module UnpackStrategy
|
|||||||
class Mount
|
class Mount
|
||||||
include UnpackStrategy
|
include UnpackStrategy
|
||||||
|
|
||||||
def eject
|
def eject(verbose: false)
|
||||||
tries ||= 3
|
tries ||= 3
|
||||||
|
|
||||||
return unless path.exist?
|
return unless path.exist?
|
||||||
@ -59,11 +57,13 @@ module UnpackStrategy
|
|||||||
if tries > 1
|
if tries > 1
|
||||||
system_command! "diskutil",
|
system_command! "diskutil",
|
||||||
args: ["eject", path],
|
args: ["eject", path],
|
||||||
print_stderr: false
|
print_stderr: false,
|
||||||
|
verbose: verbose
|
||||||
else
|
else
|
||||||
system_command! "diskutil",
|
system_command! "diskutil",
|
||||||
args: ["unmount", "force", path],
|
args: ["unmount", "force", path],
|
||||||
print_stderr: false
|
print_stderr: false,
|
||||||
|
verbose: verbose
|
||||||
end
|
end
|
||||||
rescue ErrorDuringExecution => e
|
rescue ErrorDuringExecution => e
|
||||||
raise e if (tries -= 1).zero?
|
raise e if (tries -= 1).zero?
|
||||||
@ -81,10 +81,14 @@ module UnpackStrategy
|
|||||||
filelist.puts(path.bom)
|
filelist.puts(path.bom)
|
||||||
filelist.close
|
filelist.close
|
||||||
|
|
||||||
system_command! "mkbom", args: ["-s", "-i", filelist.path, "--", bomfile.path]
|
system_command! "mkbom",
|
||||||
|
args: ["-s", "-i", filelist.path, "--", bomfile.path],
|
||||||
|
verbose: verbose
|
||||||
end
|
end
|
||||||
|
|
||||||
system_command! "ditto", args: ["--bom", bomfile.path, "--", path, unpack_dir]
|
system_command! "ditto",
|
||||||
|
args: ["--bom", bomfile.path, "--", path, unpack_dir],
|
||||||
|
verbose: verbose
|
||||||
|
|
||||||
FileUtils.chmod "u+w", Pathname.glob(unpack_dir/"**/*").reject(&:symlink?)
|
FileUtils.chmod "u+w", Pathname.glob(unpack_dir/"**/*").reject(&:symlink?)
|
||||||
end
|
end
|
||||||
@ -111,7 +115,7 @@ module UnpackStrategy
|
|||||||
raise "No mounts found in '#{path}'; perhaps it is a bad disk image?" if mounts.empty?
|
raise "No mounts found in '#{path}'; perhaps it is a bad disk image?" if mounts.empty?
|
||||||
|
|
||||||
mounts.each do |mount|
|
mounts.each do |mount|
|
||||||
mount.extract(to: unpack_dir)
|
mount.extract(to: unpack_dir, verbose: verbose)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -120,10 +124,11 @@ module UnpackStrategy
|
|||||||
Dir.mktmpdir do |mount_dir|
|
Dir.mktmpdir do |mount_dir|
|
||||||
mount_dir = Pathname(mount_dir)
|
mount_dir = Pathname(mount_dir)
|
||||||
|
|
||||||
without_eula = system_command("hdiutil",
|
without_eula = system_command "hdiutil",
|
||||||
args: ["attach", "-plist", "-nobrowse", "-readonly", "-noidme", "-mountrandom", mount_dir, path],
|
args: ["attach", "-plist", "-nobrowse", "-readonly", "-noidme", "-mountrandom", mount_dir, path],
|
||||||
input: "qn\n",
|
input: "qn\n",
|
||||||
print_stderr: false)
|
print_stderr: false,
|
||||||
|
verbose: verbose
|
||||||
|
|
||||||
# If mounting without agreeing to EULA succeeded, there is none.
|
# If mounting without agreeing to EULA succeeded, there is none.
|
||||||
plist = if without_eula.success?
|
plist = if without_eula.success?
|
||||||
@ -131,12 +136,13 @@ module UnpackStrategy
|
|||||||
else
|
else
|
||||||
cdr_path = mount_dir/path.basename.sub_ext(".cdr")
|
cdr_path = mount_dir/path.basename.sub_ext(".cdr")
|
||||||
|
|
||||||
system_command!("hdiutil", args: ["convert", "-quiet", "-format", "UDTO", "-o", cdr_path, path])
|
system_command! "hdiutil",
|
||||||
|
args: ["convert", "-quiet", "-format", "UDTO", "-o", cdr_path, path],
|
||||||
|
verbose: verbose
|
||||||
|
|
||||||
with_eula = system_command!(
|
with_eula = system_command! "hdiutil",
|
||||||
"/usr/bin/hdiutil",
|
args: ["attach", "-plist", "-nobrowse", "-readonly", "-noidme", "-mountrandom", mount_dir, cdr_path],
|
||||||
args: ["attach", "-plist", "-nobrowse", "-readonly", "-noidme", "-mountrandom", mount_dir, cdr_path],
|
verbose: verbose
|
||||||
)
|
|
||||||
|
|
||||||
if verbose && !(eula_text = without_eula.stdout).empty?
|
if verbose && !(eula_text = without_eula.stdout).empty?
|
||||||
ohai "Software License Agreement for '#{path}':"
|
ohai "Software License Agreement for '#{path}':"
|
||||||
@ -158,7 +164,9 @@ module UnpackStrategy
|
|||||||
begin
|
begin
|
||||||
yield mounts
|
yield mounts
|
||||||
ensure
|
ensure
|
||||||
mounts.each(&:eject)
|
mounts.each do |mount|
|
||||||
|
mount.eject(verbose: verbose)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -28,7 +28,8 @@ module UnpackStrategy
|
|||||||
system_command! "fossil",
|
system_command! "fossil",
|
||||||
args: ["open", path, *args],
|
args: ["open", path, *args],
|
||||||
chdir: unpack_dir,
|
chdir: unpack_dir,
|
||||||
env: { "PATH" => PATH.new(Formula["fossil"].opt_bin, ENV["PATH"]) }
|
env: { "PATH" => PATH.new(Formula["fossil"].opt_bin, ENV["PATH"]) },
|
||||||
|
verbose: verbose
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -21,7 +21,8 @@ module UnpackStrategy
|
|||||||
def extract_to_dir(unpack_dir, basename:, verbose:)
|
def extract_to_dir(unpack_dir, basename:, verbose:)
|
||||||
system_command! "unar",
|
system_command! "unar",
|
||||||
args: ["-force-overwrite", "-quiet", "-no-directory", "-output-directory", unpack_dir, "--", path],
|
args: ["-force-overwrite", "-quiet", "-no-directory", "-output-directory", unpack_dir, "--", path],
|
||||||
env: { "PATH" => PATH.new(Formula["unar"].opt_bin, ENV["PATH"]) }
|
env: { "PATH" => PATH.new(Formula["unar"].opt_bin, ENV["PATH"]) },
|
||||||
|
verbose: verbose
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -18,7 +18,8 @@ module UnpackStrategy
|
|||||||
FileUtils.cp path, unpack_dir/basename, preserve: true
|
FileUtils.cp path, unpack_dir/basename, preserve: true
|
||||||
quiet_flags = verbose ? [] : ["-q"]
|
quiet_flags = verbose ? [] : ["-q"]
|
||||||
system_command! "gunzip",
|
system_command! "gunzip",
|
||||||
args: [*quiet_flags, "-N", "--", unpack_dir/basename]
|
args: [*quiet_flags, "-N", "--", unpack_dir/basename],
|
||||||
|
verbose: verbose
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -21,7 +21,8 @@ module UnpackStrategy
|
|||||||
def extract_to_dir(unpack_dir, basename:, verbose:)
|
def extract_to_dir(unpack_dir, basename:, verbose:)
|
||||||
system_command! "lha",
|
system_command! "lha",
|
||||||
args: ["xq2w=#{unpack_dir}", path],
|
args: ["xq2w=#{unpack_dir}", path],
|
||||||
env: { "PATH" => PATH.new(Formula["lha"].opt_bin, ENV["PATH"]) }
|
env: { "PATH" => PATH.new(Formula["lha"].opt_bin, ENV["PATH"]) },
|
||||||
|
verbose: verbose
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -23,7 +23,8 @@ module UnpackStrategy
|
|||||||
quiet_flags = verbose ? [] : ["-q"]
|
quiet_flags = verbose ? [] : ["-q"]
|
||||||
system_command! "lzip",
|
system_command! "lzip",
|
||||||
args: ["-d", *quiet_flags, unpack_dir/basename],
|
args: ["-d", *quiet_flags, unpack_dir/basename],
|
||||||
env: { "PATH" => PATH.new(Formula["lzip"].opt_bin, ENV["PATH"]) }
|
env: { "PATH" => PATH.new(Formula["lzip"].opt_bin, ENV["PATH"]) },
|
||||||
|
verbose: verbose
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -17,7 +17,8 @@ module UnpackStrategy
|
|||||||
quiet_flags = verbose ? [] : ["-q"]
|
quiet_flags = verbose ? [] : ["-q"]
|
||||||
system_command! "unlzma",
|
system_command! "unlzma",
|
||||||
args: [*quiet_flags, "--", unpack_dir/basename],
|
args: [*quiet_flags, "--", unpack_dir/basename],
|
||||||
env: { "PATH" => PATH.new(Formula["xz"].opt_bin, ENV["PATH"]) }
|
env: { "PATH" => PATH.new(Formula["xz"].opt_bin, ENV["PATH"]) },
|
||||||
|
verbose: verbose
|
||||||
end
|
end
|
||||||
|
|
||||||
def dependencies
|
def dependencies
|
||||||
|
|||||||
@ -13,7 +13,8 @@ module UnpackStrategy
|
|||||||
def extract_to_dir(unpack_dir, basename:, verbose:)
|
def extract_to_dir(unpack_dir, basename:, verbose:)
|
||||||
system_command! "hg",
|
system_command! "hg",
|
||||||
args: ["--cwd", path, "archive", "--subrepos", "-y", "-t", "files", unpack_dir],
|
args: ["--cwd", path, "archive", "--subrepos", "-y", "-t", "files", unpack_dir],
|
||||||
env: { "PATH" => PATH.new(Formula["mercurial"].opt_bin, ENV["PATH"]) }
|
env: { "PATH" => PATH.new(Formula["mercurial"].opt_bin, ENV["PATH"]) },
|
||||||
|
verbose: verbose
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -21,7 +21,8 @@ module UnpackStrategy
|
|||||||
def extract_to_dir(unpack_dir, basename:, verbose:)
|
def extract_to_dir(unpack_dir, basename:, verbose:)
|
||||||
system_command! "7zr",
|
system_command! "7zr",
|
||||||
args: ["x", "-y", "-bd", "-bso0", path, "-o#{unpack_dir}"],
|
args: ["x", "-y", "-bd", "-bso0", path, "-o#{unpack_dir}"],
|
||||||
env: { "PATH" => PATH.new(Formula["p7zip"].opt_bin, ENV["PATH"]) }
|
env: { "PATH" => PATH.new(Formula["p7zip"].opt_bin, ENV["PATH"]) },
|
||||||
|
verbose: verbose
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -21,7 +21,8 @@ module UnpackStrategy
|
|||||||
def extract_to_dir(unpack_dir, basename:, verbose:)
|
def extract_to_dir(unpack_dir, basename:, verbose:)
|
||||||
system_command! "unrar",
|
system_command! "unrar",
|
||||||
args: ["x", "-inul", path, unpack_dir],
|
args: ["x", "-inul", path, unpack_dir],
|
||||||
env: { "PATH" => PATH.new(Formula["unrar"].opt_bin, ENV["PATH"]) }
|
env: { "PATH" => PATH.new(Formula["unrar"].opt_bin, ENV["PATH"]) },
|
||||||
|
verbose: verbose
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -13,7 +13,8 @@ module UnpackStrategy
|
|||||||
def extract_to_dir(unpack_dir, basename:, verbose:)
|
def extract_to_dir(unpack_dir, basename:, verbose:)
|
||||||
system_command! "svn",
|
system_command! "svn",
|
||||||
args: ["export", "--force", ".", unpack_dir],
|
args: ["export", "--force", ".", unpack_dir],
|
||||||
chdir: path.to_s
|
chdir: path.to_s,
|
||||||
|
verbose: verbose
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -35,11 +35,13 @@ module UnpackStrategy
|
|||||||
|
|
||||||
if DependencyCollector.tar_needs_xz_dependency? && Xz.can_extract?(path)
|
if DependencyCollector.tar_needs_xz_dependency? && Xz.can_extract?(path)
|
||||||
tmpdir = Pathname(tmpdir)
|
tmpdir = Pathname(tmpdir)
|
||||||
Xz.new(path).extract(to: tmpdir)
|
Xz.new(path).extract(to: tmpdir, verbose: verbose)
|
||||||
tar_path = tmpdir.children.first
|
tar_path = tmpdir.children.first
|
||||||
end
|
end
|
||||||
|
|
||||||
system_command! "tar", args: ["xf", tar_path, "-C", unpack_dir]
|
system_command! "tar",
|
||||||
|
args: ["xf", tar_path, "-C", unpack_dir],
|
||||||
|
verbose: verbose
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -15,7 +15,9 @@ module UnpackStrategy
|
|||||||
private
|
private
|
||||||
|
|
||||||
def extract_to_dir(unpack_dir, basename:, verbose:)
|
def extract_to_dir(unpack_dir, basename:, verbose:)
|
||||||
system_command! "xar", args: ["-x", "-f", path, "-C", unpack_dir]
|
system_command! "xar",
|
||||||
|
args: ["-x", "-f", path, "-C", unpack_dir],
|
||||||
|
verbose: verbose
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -23,7 +23,8 @@ module UnpackStrategy
|
|||||||
quiet_flags = verbose ? [] : ["-q"]
|
quiet_flags = verbose ? [] : ["-q"]
|
||||||
system_command! "unxz",
|
system_command! "unxz",
|
||||||
args: [*quiet_flags, "-T0", "--", unpack_dir/basename],
|
args: [*quiet_flags, "-T0", "--", unpack_dir/basename],
|
||||||
env: { "PATH" => PATH.new(Formula["xz"].opt_bin, ENV["PATH"]) }
|
env: { "PATH" => PATH.new(Formula["xz"].opt_bin, ENV["PATH"]) },
|
||||||
|
verbose: verbose
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -16,7 +16,9 @@ module UnpackStrategy
|
|||||||
|
|
||||||
def extract_to_dir(unpack_dir, basename:, verbose:)
|
def extract_to_dir(unpack_dir, basename:, verbose:)
|
||||||
quiet_flags = verbose ? [] : ["-qq"]
|
quiet_flags = verbose ? [] : ["-qq"]
|
||||||
system_command! "unzip", args: [*quiet_flags, path, "-d", unpack_dir]
|
system_command! "unzip",
|
||||||
|
args: [*quiet_flags, path, "-d", unpack_dir],
|
||||||
|
verbose: verbose
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user