mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Revert "Fix permissions before moving extracted files."
This commit is contained in:
parent
ddd328ed7d
commit
d292dbdc2b
@ -491,7 +491,6 @@ module Cask
|
|||||||
Dir.mktmpdir do |tmpdir|
|
Dir.mktmpdir do |tmpdir|
|
||||||
tmpdir = Pathname(tmpdir)
|
tmpdir = Pathname(tmpdir)
|
||||||
primary_container.extract_nestedly(to: tmpdir, basename: downloaded_path.basename, verbose: false)
|
primary_container.extract_nestedly(to: tmpdir, basename: downloaded_path.basename, verbose: false)
|
||||||
|
|
||||||
artifacts.each do |artifact|
|
artifacts.each do |artifact|
|
||||||
path = case artifact
|
path = case artifact
|
||||||
when Artifact::Moved
|
when Artifact::Moved
|
||||||
@ -502,6 +501,7 @@ module Cask
|
|||||||
next unless path.exist?
|
next unless path.exist?
|
||||||
|
|
||||||
result = system_command("codesign", args: ["--verify", path], print_stderr: false)
|
result = system_command("codesign", args: ["--verify", path], print_stderr: false)
|
||||||
|
|
||||||
next if result.success?
|
next if result.success?
|
||||||
|
|
||||||
message = "Signature verification failed:\n#{result.merged_output}\nmacOS on ARM requires applications " \
|
message = "Signature verification failed:\n#{result.merged_output}\nmacOS on ARM requires applications " \
|
||||||
|
@ -95,10 +95,10 @@ class AbstractDownloadStrategy
|
|||||||
# @api public
|
# @api public
|
||||||
def stage(&block)
|
def stage(&block)
|
||||||
UnpackStrategy.detect(cached_location,
|
UnpackStrategy.detect(cached_location,
|
||||||
prioritize_extension: true,
|
prioritise_extension: true,
|
||||||
ref_type: @ref_type, ref: @ref)
|
ref_type: @ref_type, ref: @ref)
|
||||||
.extract_nestedly(basename: basename,
|
.extract_nestedly(basename: basename,
|
||||||
prioritize_extension: true,
|
prioritise_extension: true,
|
||||||
verbose: verbose? && !quiet?)
|
verbose: verbose? && !quiet?)
|
||||||
chdir(&block) if block
|
chdir(&block) if block
|
||||||
end
|
end
|
||||||
|
@ -104,10 +104,10 @@ module UnpackStrategy
|
|||||||
strategies.find { |s| s.can_extract?(path) }
|
strategies.find { |s| s.can_extract?(path) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.detect(path, prioritize_extension: false, type: nil, ref_type: nil, ref: nil, merge_xattrs: nil)
|
def self.detect(path, prioritise_extension: false, type: nil, ref_type: nil, ref: nil, merge_xattrs: nil)
|
||||||
strategy = from_type(type) if type
|
strategy = from_type(type) if type
|
||||||
|
|
||||||
if prioritize_extension && path.extname.present?
|
if prioritise_extension && path.extname.present?
|
||||||
strategy ||= from_extension(path.extname)
|
strategy ||= from_extension(path.extname)
|
||||||
strategy ||= strategies.select { |s| s < Directory || s == Fossil }
|
strategy ||= strategies.select { |s| s < Directory || s == Fossil }
|
||||||
.find { |s| s.can_extract?(path) }
|
.find { |s| s.can_extract?(path) }
|
||||||
@ -135,27 +135,14 @@ module UnpackStrategy
|
|||||||
def extract_to_dir(unpack_dir, basename:, verbose:); end
|
def extract_to_dir(unpack_dir, basename:, verbose:); end
|
||||||
private :extract_to_dir
|
private :extract_to_dir
|
||||||
|
|
||||||
sig {
|
def extract(to: nil, basename: nil, verbose: nil)
|
||||||
params(
|
|
||||||
to: T.nilable(Pathname), basename: T.nilable(T.any(String, Pathname)), verbose: T::Boolean,
|
|
||||||
).returns(T.untyped)
|
|
||||||
}
|
|
||||||
def extract(to: nil, basename: nil, verbose: false)
|
|
||||||
basename ||= path.basename
|
basename ||= path.basename
|
||||||
unpack_dir = Pathname(to || Dir.pwd).expand_path
|
unpack_dir = Pathname(to || Dir.pwd).expand_path
|
||||||
unpack_dir.mkpath
|
unpack_dir.mkpath
|
||||||
extract_to_dir(unpack_dir, basename: Pathname(basename), verbose: verbose)
|
extract_to_dir(unpack_dir, basename: Pathname(basename), verbose: verbose || false)
|
||||||
end
|
end
|
||||||
|
|
||||||
sig {
|
def extract_nestedly(to: nil, basename: nil, verbose: false, prioritise_extension: false)
|
||||||
params(
|
|
||||||
to: T.nilable(Pathname),
|
|
||||||
basename: T.nilable(T.any(String, Pathname)),
|
|
||||||
verbose: T::Boolean,
|
|
||||||
prioritize_extension: T::Boolean,
|
|
||||||
).returns(T.untyped)
|
|
||||||
}
|
|
||||||
def extract_nestedly(to: nil, basename: nil, verbose: false, prioritize_extension: false)
|
|
||||||
Dir.mktmpdir do |tmp_unpack_dir|
|
Dir.mktmpdir do |tmp_unpack_dir|
|
||||||
tmp_unpack_dir = Pathname(tmp_unpack_dir)
|
tmp_unpack_dir = Pathname(tmp_unpack_dir)
|
||||||
|
|
||||||
@ -166,14 +153,15 @@ module UnpackStrategy
|
|||||||
if children.count == 1 && !children.first.directory?
|
if children.count == 1 && !children.first.directory?
|
||||||
FileUtils.chmod "+rw", children.first, verbose: verbose
|
FileUtils.chmod "+rw", children.first, verbose: verbose
|
||||||
|
|
||||||
s = UnpackStrategy.detect(children.first, prioritize_extension: prioritize_extension)
|
s = UnpackStrategy.detect(children.first, prioritise_extension: prioritise_extension)
|
||||||
|
|
||||||
s.extract_nestedly(to: to, verbose: verbose, prioritize_extension: prioritize_extension)
|
s.extract_nestedly(to: to, verbose: verbose, prioritise_extension: prioritise_extension)
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
FileUtils.chmod_R "+w", tmp_unpack_dir, force: true, verbose: verbose
|
|
||||||
Directory.new(tmp_unpack_dir).extract(to: to, verbose: verbose)
|
Directory.new(tmp_unpack_dir).extract(to: to, verbose: verbose)
|
||||||
|
|
||||||
|
FileUtils.chmod_R "+w", tmp_unpack_dir, force: true, verbose: verbose
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -8,22 +8,14 @@ module UnpackStrategy
|
|||||||
|
|
||||||
include UnpackStrategy
|
include UnpackStrategy
|
||||||
|
|
||||||
sig {
|
def extract_nestedly(prioritise_extension: false, **options)
|
||||||
params(
|
extract(**options)
|
||||||
to: T.nilable(Pathname),
|
|
||||||
basename: T.nilable(T.any(String, Pathname)),
|
|
||||||
verbose: T::Boolean,
|
|
||||||
prioritize_extension: T::Boolean,
|
|
||||||
).returns(T.untyped)
|
|
||||||
}
|
|
||||||
def extract_nestedly(to: nil, basename: nil, verbose: false, prioritize_extension: false)
|
|
||||||
extract(to: to, basename: basename, verbose: verbose)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
sig { override.params(unpack_dir: Pathname, basename: Pathname, verbose: T::Boolean).returns(T.untyped) }
|
sig { override.params(unpack_dir: Pathname, basename: Pathname, verbose: T::Boolean).returns(T.untyped) }
|
||||||
def extract_to_dir(unpack_dir, basename:, verbose: false)
|
def extract_to_dir(unpack_dir, basename:, verbose:)
|
||||||
FileUtils.cp path, unpack_dir/basename, preserve: true, verbose: verbose
|
FileUtils.cp path, unpack_dir/basename, preserve: true, verbose: verbose
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user