From d292dbdc2be91d7b1e6a9989ea9d9e24c22fe71e Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 20 Feb 2023 17:20:57 +0000 Subject: [PATCH] Revert "Fix permissions before moving extracted files." --- Library/Homebrew/cask/audit.rb | 2 +- Library/Homebrew/download_strategy.rb | 4 +-- Library/Homebrew/unpack_strategy.rb | 30 ++++++------------- .../Homebrew/unpack_strategy/uncompressed.rb | 14 ++------- 4 files changed, 15 insertions(+), 35 deletions(-) diff --git a/Library/Homebrew/cask/audit.rb b/Library/Homebrew/cask/audit.rb index 20bb834248..3b128a07a3 100644 --- a/Library/Homebrew/cask/audit.rb +++ b/Library/Homebrew/cask/audit.rb @@ -491,7 +491,6 @@ module Cask Dir.mktmpdir do |tmpdir| tmpdir = Pathname(tmpdir) primary_container.extract_nestedly(to: tmpdir, basename: downloaded_path.basename, verbose: false) - artifacts.each do |artifact| path = case artifact when Artifact::Moved @@ -502,6 +501,7 @@ module Cask next unless path.exist? result = system_command("codesign", args: ["--verify", path], print_stderr: false) + next if result.success? message = "Signature verification failed:\n#{result.merged_output}\nmacOS on ARM requires applications " \ diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index a70285ec56..29a04553da 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -95,10 +95,10 @@ class AbstractDownloadStrategy # @api public def stage(&block) UnpackStrategy.detect(cached_location, - prioritize_extension: true, + prioritise_extension: true, ref_type: @ref_type, ref: @ref) .extract_nestedly(basename: basename, - prioritize_extension: true, + prioritise_extension: true, verbose: verbose? && !quiet?) chdir(&block) if block end diff --git a/Library/Homebrew/unpack_strategy.rb b/Library/Homebrew/unpack_strategy.rb index 210717e7b8..587b5f32bc 100644 --- a/Library/Homebrew/unpack_strategy.rb +++ b/Library/Homebrew/unpack_strategy.rb @@ -104,10 +104,10 @@ module UnpackStrategy strategies.find { |s| s.can_extract?(path) } 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 - if prioritize_extension && path.extname.present? + if prioritise_extension && path.extname.present? strategy ||= from_extension(path.extname) strategy ||= strategies.select { |s| s < Directory || s == Fossil } .find { |s| s.can_extract?(path) } @@ -135,27 +135,14 @@ module UnpackStrategy def extract_to_dir(unpack_dir, basename:, verbose:); end private :extract_to_dir - sig { - 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) + def extract(to: nil, basename: nil, verbose: nil) basename ||= path.basename unpack_dir = Pathname(to || Dir.pwd).expand_path 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 - sig { - 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) + def extract_nestedly(to: nil, basename: nil, verbose: false, prioritise_extension: false) Dir.mktmpdir do |tmp_unpack_dir| tmp_unpack_dir = Pathname(tmp_unpack_dir) @@ -166,14 +153,15 @@ module UnpackStrategy if children.count == 1 && !children.first.directory? 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 end - FileUtils.chmod_R "+w", tmp_unpack_dir, force: true, 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 diff --git a/Library/Homebrew/unpack_strategy/uncompressed.rb b/Library/Homebrew/unpack_strategy/uncompressed.rb index 08b72eeb83..732cde1b4a 100644 --- a/Library/Homebrew/unpack_strategy/uncompressed.rb +++ b/Library/Homebrew/unpack_strategy/uncompressed.rb @@ -8,22 +8,14 @@ module UnpackStrategy include UnpackStrategy - sig { - 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) - extract(to: to, basename: basename, verbose: verbose) + def extract_nestedly(prioritise_extension: false, **options) + extract(**options) end private 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 end end