Merge pull request #17695 from reitermarkus/from-bottle-loader-downloadable
This commit is contained in:
commit
ab7e49c462
@ -592,36 +592,23 @@ module Formulary
|
|||||||
def self.try_new(ref, from: T.unsafe(nil), warn: false)
|
def self.try_new(ref, from: T.unsafe(nil), warn: false)
|
||||||
ref = ref.to_s
|
ref = ref.to_s
|
||||||
|
|
||||||
new(ref) if HOMEBREW_BOTTLES_EXTNAME_REGEX.match?(ref)
|
new(ref) if HOMEBREW_BOTTLES_EXTNAME_REGEX.match?(ref) && File.exist?(ref)
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(bottle_name)
|
def initialize(bottle_name, warn: false)
|
||||||
case bottle_name
|
@bottle_path = Pathname(bottle_name).realpath
|
||||||
when URL_START_REGEX
|
name, full_name = Utils::Bottles.resolve_formula_names(@bottle_path)
|
||||||
# The name of the formula is found between the last slash and the last hyphen.
|
|
||||||
formula_name = File.basename(bottle_name)[/(.+)-/, 1]
|
|
||||||
resource = Resource.new(formula_name) { url bottle_name }
|
|
||||||
resource.specs[:bottle] = true
|
|
||||||
downloader = resource.downloader
|
|
||||||
cached = downloader.cached_location.exist?
|
|
||||||
downloader.fetch
|
|
||||||
ohai "Pouring the cached bottle" if cached
|
|
||||||
@bottle_filename = downloader.cached_location
|
|
||||||
else
|
|
||||||
@bottle_filename = Pathname(bottle_name).realpath
|
|
||||||
end
|
|
||||||
name, full_name = Utils::Bottles.resolve_formula_names @bottle_filename
|
|
||||||
super name, Formulary.path(full_name)
|
super name, Formulary.path(full_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_formula(spec, force_bottle: false, flags: [], ignore_errors: false, **)
|
def get_formula(spec, force_bottle: false, flags: [], ignore_errors: false, **)
|
||||||
formula = begin
|
formula = begin
|
||||||
contents = Utils::Bottles.formula_contents(@bottle_filename, name:)
|
contents = Utils::Bottles.formula_contents(@bottle_path, name:)
|
||||||
Formulary.from_contents(name, path, contents, spec, force_bottle:,
|
Formulary.from_contents(name, path, contents, spec, force_bottle:,
|
||||||
flags:, ignore_errors:)
|
flags:, ignore_errors:)
|
||||||
rescue FormulaUnreadableError => e
|
rescue FormulaUnreadableError => e
|
||||||
opoo <<~EOS
|
opoo <<~EOS
|
||||||
Unreadable formula in #{@bottle_filename}:
|
Unreadable formula in #{@bottle_path}:
|
||||||
#{e}
|
#{e}
|
||||||
EOS
|
EOS
|
||||||
super
|
super
|
||||||
@ -632,7 +619,7 @@ module Formulary
|
|||||||
EOS
|
EOS
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
formula.local_bottle_path = @bottle_filename
|
formula.local_bottle_path = @bottle_path
|
||||||
formula
|
formula
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user