Merge pull request #10085 from reitermarkus/cask-download-basename

Fix basename for extracting cask downloads.
This commit is contained in:
Markus Reiter 2020-12-21 22:30:14 +01:00 committed by GitHub
commit 9c1bdfe229
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 4 deletions

View File

@ -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 = [

View File

@ -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."

View File

@ -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|