Merge pull request #7552 from MikeMcQuaid/fetch-resources-from-source

Fetch (all) resources when building from source
This commit is contained in:
Mike McQuaid 2020-05-12 14:27:52 +01:00 committed by GitHub
commit 10c9d96566
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 23 deletions

View File

@ -114,7 +114,9 @@ class Build
with_env(new_env) do
formula.extend(Debrew::Formula) if ARGV.debug?
formula.brew do |_formula, staging|
formula.update_head_version
formula.brew(fetch: false) do |_formula, staging|
# For head builds, HOMEBREW_FORMULA_PREFIX should include the commit,
# which is not known until after the formula has been staged.
ENV["HOMEBREW_FORMULA_PREFIX"] = formula.prefix

View File

@ -1012,11 +1012,11 @@ class Formula
self.build = Tab.for_formula(self)
new_env = {
"TMPDIR" => HOMEBREW_TEMP,
"TEMP" => HOMEBREW_TEMP,
"TMP" => HOMEBREW_TEMP,
"HOMEBREW_PATH" => nil,
"PATH" => ENV["HOMEBREW_PATH"],
TMPDIR: HOMEBREW_TEMP,
TEMP: HOMEBREW_TEMP,
TMP: HOMEBREW_TEMP,
HOMEBREW_PATH: nil,
PATH: ENV["HOMEBREW_PATH"],
}
with_env(new_env) do
@ -1160,11 +1160,12 @@ class Formula
# yields |self,staging| with current working directory set to the uncompressed tarball
# where staging is a Mktemp staging context
# @private
def brew
def brew(fetch: true)
@prefix_returns_versioned_prefix = true
active_spec.fetch if fetch
stage do |staging|
staging.retain! if Homebrew.args.keep_tmp?
prepare_patches
fetch_patches if fetch
begin
yield self, staging
@ -2078,6 +2079,13 @@ class Formula
ENV.update(removed)
end
def fetch_patches
active_spec.add_legacy_patches(patches) if respond_to?(:patches)
patchlist.grep(DATAPatch) { |p| p.path = path }
patchlist.select(&:external?).each(&:fetch)
end
private
# Returns the prefix for a given formula version number.
@ -2147,13 +2155,6 @@ class Formula
end
end
def prepare_patches
active_spec.add_legacy_patches(patches) if respond_to?(:patches)
patchlist.grep(DATAPatch) { |p| p.path = path }
patchlist.select(&:external?).each(&:fetch)
end
# The methods below define the formula DSL.
class << self
include BuildEnvironment::DSL

View File

@ -977,6 +977,11 @@ class FormulaInstaller
return if only_deps?
unless pour_bottle?
formula.fetch_patches
formula.resources.each(&:fetch)
end
downloader.fetch
end
@ -986,7 +991,7 @@ class FormulaInstaller
elsif pour_bottle?
formula.bottle
else
formula.downloader
formula
end
end

View File

@ -117,8 +117,8 @@ class ExternalPatch
attr_reader :resource, :strip
def_delegators :resource,
:url, :fetch, :patch_files, :verify_download_integrity, :cached_download,
:clear_cache
:url, :fetch, :patch_files, :verify_download_integrity,
:cached_download, :downloaded?, :clear_cache
def initialize(strip, &block)
@strip = strip

View File

@ -55,6 +55,10 @@ class Resource
"#{owner.name}--#{escaped_name}"
end
def downloaded?
cached_download.exist?
end
def cached_download
downloader.cached_location
end
@ -68,17 +72,19 @@ class Resource
# directory. Subclasses that override stage should implement the tmp
# dir using {Mktemp} so that works with all subtypes.
def stage(target = nil, &block)
raise ArgumentError, "target directory or block is required" unless target || block
raise ArgumentError, "target directory or block is required" if target.blank? && block.blank?
fetch
prepare_patches
fetch_patches(skip_downloaded: true)
fetch unless downloaded?
unpack(target, &block)
end
def prepare_patches
def fetch_patches(skip_downloaded: false)
patches.grep(DATAPatch) { |p| p.path = owner.owner.path }
patches.select(&:external?).each(&:fetch)
patches.select!(&:external?)
patches.reject!(&:downloaded?) if skip_downloaded
patches.each(&:fetch)
end
def apply_patches
@ -115,6 +121,8 @@ class Resource
def fetch(verify_download_integrity: true)
HOMEBREW_CACHE.mkpath
fetch_patches
begin
downloader.fetch
rescue ErrorDuringExecution, CurlDownloadStrategyError => e