From 82c1e6fb0ebeb5bb34f03c1ef1b4cd482515f76c Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 21 Dec 2020 15:43:25 +0100 Subject: [PATCH 1/2] Fix basename for extracting cask downloads. --- Library/Homebrew/cask/download.rb | 4 ++++ Library/Homebrew/cask/installer.rb | 10 +++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/cask/download.rb b/Library/Homebrew/cask/download.rb index e2f43bf526..30efff34fe 100644 --- a/Library/Homebrew/cask/download.rb +++ b/Library/Homebrew/cask/download.rb @@ -52,6 +52,10 @@ module Cask downloader.cached_location end + def basename + downloader.basename + end + def verify_download_integrity(fn) if @cask.sha256 == :no_check opoo "No checksum defined for cask '#{@cask}', skipping verification." diff --git a/Library/Homebrew/cask/installer.rb b/Library/Homebrew/cask/installer.rb index a3cf058dec..318cb045ba 100644 --- a/Library/Homebrew/cask/installer.rb +++ b/Library/Homebrew/cask/installer.rb @@ -152,10 +152,14 @@ module Cask s.freeze end + sig { returns(Download) } + def downloader + @downloader ||= Download.new(@cask, quarantine: quarantine?) + end + sig { returns(Pathname) } def download - @download ||= Download.new(@cask, quarantine: quarantine?) - .fetch(verify_download_integrity: @verify_download_integrity) + @download ||= downloader.fetch(verify_download_integrity: @verify_download_integrity) end def verify_has_sha @@ -180,7 +184,7 @@ module Cask odebug "Using container class #{primary_container.class} for #{primary_container.path}" - basename = CGI.unescape(File.basename(@cask.url.path)) + basename = downloader.basename if nested_container = @cask.container&.nested Dir.mktmpdir do |tmpdir| From 8b17017108d5b550562b556c5d407361cea27781 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 21 Dec 2020 15:45:18 +0100 Subject: [PATCH 2/2] Improve error message for missing PKG source. --- Library/Homebrew/cask/artifact/pkg.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cask/artifact/pkg.rb b/Library/Homebrew/cask/artifact/pkg.rb index ae717a3e7e..f6eef1e42c 100644 --- a/Library/Homebrew/cask/artifact/pkg.rb +++ b/Library/Homebrew/cask/artifact/pkg.rb @@ -42,7 +42,14 @@ module Cask ohai "Running installer for #{cask}; your password may be necessary." ohai "Package installers may write to any location; options such as --appdir are ignored." unless path.exist? - raise CaskError, "pkg source file not found: '#{path.relative_path_from(cask.staged_path)}'" + pkg = path.relative_path_from(cask.staged_path) + pkgs = Pathname.glob(cask.staged_path/"**"/"*.pkg").map { |path| path.relative_path_from(cask.staged_path) } + + message = "Could not find PKG source file '#{pkg}'" + message += ", found #{pkgs.map { |path| "'#{path}'" }.to_sentence} instead" if pkgs.any? + message += "." + + raise CaskError, message end args = [