formula*: add source download support for download queue.

This should allow downloading the formula files from GitHub in
parallel too.
This commit is contained in:
Mike McQuaid 2025-07-29 13:48:43 +01:00
parent b63669c92b
commit 5d01b22d38
No known key found for this signature in database
2 changed files with 22 additions and 6 deletions

View File

@ -28,8 +28,8 @@ module Homebrew
Homebrew::API.fetch "formula/#{name}.json"
end
sig { params(formula: ::Formula).returns(::Formula) }
def self.source_download(formula)
sig { params(formula: ::Formula, download_queue: T.nilable(Homebrew::DownloadQueue)).returns(Homebrew::API::SourceDownload) }
def self.source_download(formula, download_queue: nil)
path = formula.ruby_source_path || "Formula/#{formula.name}.rb"
git_head = formula.tap_git_head || "HEAD"
tap = formula.tap&.full_name || "Homebrew/homebrew-core"
@ -39,7 +39,19 @@ module Homebrew
formula.ruby_source_checksum,
cache: HOMEBREW_CACHE_API_SOURCE/"#{tap}/#{git_head}/Formula",
)
download.fetch
if download_queue
download_queue.enqueue(download)
elsif !download.cache.exist?
download.fetch
end
download
end
sig { params(formula: ::Formula).returns(::Formula) }
def self.source_download_formula(formula)
download = source_download(formula)
with_env(HOMEBREW_FORBID_PACKAGES_FROM_PATHS: nil) do
Formulary.factory(download.symlink_location,

View File

@ -317,8 +317,12 @@ class FormulaInstaller
end
end
# Needs to be done before expand_dependencies for compute_dependencies
fetch_bottle_tab if pour_bottle?
if pour_bottle?
# Needs to be done before expand_dependencies for compute_dependencies
fetch_bottle_tab
elsif formula.loaded_from_api?
Homebrew::API::Formula.source_download(formula, download_queue:)
end
fetch_fetch_deps unless ignore_deps?
@ -1446,7 +1450,7 @@ on_request: installed_on_request?, options:)
!downloadable_object.cached_download.exist?
else
@formula = Homebrew::API::Formula.source_download(formula) if formula.loaded_from_api?
@formula = Homebrew::API::Formula.source_download_formula(formula) if formula.loaded_from_api?
if (download_queue = self.download_queue)
formula.enqueue_resources_and_patches(download_queue:)