Merge pull request #11715 from Rylan12/json-improvements
Improvements to JSON bottle handling
This commit is contained in:
commit
a4e093ded0
@ -66,11 +66,20 @@ module BottleAPI
|
||||
hash = fetch(name)
|
||||
bottle_tag = Utils::Bottles.tag.to_s
|
||||
|
||||
odie "No bottle available for current OS" unless hash["bottles"].key? bottle_tag
|
||||
odie "No bottle available for current OS" if !hash["bottles"].key?(bottle_tag) && !hash["bottles"].key?("all")
|
||||
|
||||
download_bottle(hash, bottle_tag)
|
||||
|
||||
hash["dependencies"].each do |dep_hash|
|
||||
existing_formula = begin
|
||||
Formulary.factory dep_hash["name"]
|
||||
rescue FormulaUnavailableError
|
||||
# The formula might not exist if it's not installed and homebrew/core isn't tapped
|
||||
nil
|
||||
end
|
||||
|
||||
next if existing_formula.present? && existing_formula.latest_version_installed?
|
||||
|
||||
download_bottle(dep_hash, bottle_tag)
|
||||
end
|
||||
end
|
||||
@ -86,6 +95,7 @@ module BottleAPI
|
||||
sig { params(hash: Hash, tag: Symbol).void }
|
||||
def download_bottle(hash, tag)
|
||||
bottle = hash["bottles"][tag]
|
||||
bottle ||= hash["bottles"]["all"]
|
||||
return if bottle.blank?
|
||||
|
||||
sha256 = bottle["sha256"] || checksum_from_url(bottle["url"])
|
||||
|
||||
@ -243,7 +243,16 @@ module Homebrew
|
||||
def info_formula(f, args:)
|
||||
specs = []
|
||||
|
||||
if (stable = f.stable)
|
||||
if ENV["HOMEBREW_JSON_CORE"].present? && BottleAPI.bottle_available?(f.name)
|
||||
info = BottleAPI.fetch(f.name)
|
||||
|
||||
latest_version = info["pkg_version"].split("_").first
|
||||
bottle_exists = info["bottles"].key?(Utils::Bottles.tag.to_s) || info["bottles"].key?("all")
|
||||
|
||||
s = "stable #{latest_version}"
|
||||
s += " (bottled)" if bottle_exists
|
||||
specs << s
|
||||
elsif (stable = f.stable)
|
||||
s = "stable #{stable.version}"
|
||||
s += " (bottled)" if stable.bottled? && f.pour_bottle?
|
||||
specs << s
|
||||
|
||||
@ -471,7 +471,7 @@ EOS
|
||||
[[ -d "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core" ]]
|
||||
then
|
||||
safe_cd "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core"
|
||||
echo "HOMEBREW_CORE_GIT_REMOTE set: using ${HOMEBREW_CORE_GIT_REMOTE} for Homebrew/brew Git remote."
|
||||
echo "HOMEBREW_CORE_GIT_REMOTE set: using ${HOMEBREW_CORE_GIT_REMOTE} for Homebrew/core Git remote."
|
||||
git remote set-url origin "${HOMEBREW_CORE_GIT_REMOTE}"
|
||||
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
|
||||
git fetch --force origin refs/heads/master:refs/remotes/origin/master
|
||||
@ -498,6 +498,12 @@ EOS
|
||||
|
||||
for DIR in "${HOMEBREW_REPOSITORY}" "${HOMEBREW_LIBRARY}"/Taps/*/*
|
||||
do
|
||||
if [[ -n "${HOMEBREW_JSON_CORE}" ]] && [[ -n "${HOMEBREW_UPDATE_PREINSTALL}" ]] &&
|
||||
[[ "${DIR}" = "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core" ]]
|
||||
then
|
||||
continue
|
||||
fi
|
||||
|
||||
[[ -d "${DIR}/.git" ]] || continue
|
||||
cd "${DIR}" || continue
|
||||
|
||||
@ -639,6 +645,14 @@ EOS
|
||||
|
||||
for DIR in "${HOMEBREW_REPOSITORY}" "${HOMEBREW_LIBRARY}"/Taps/*/*
|
||||
do
|
||||
# HOMEBREW_UPDATE_PREINSTALL wasn't modified in subshell.
|
||||
# shellcheck disable=SC2031
|
||||
if [[ -n "${HOMEBREW_JSON_CORE}" ]] && [[ -n "${HOMEBREW_UPDATE_PREINSTALL}" ]] &&
|
||||
[[ "${DIR}" = "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core" ]]
|
||||
then
|
||||
continue
|
||||
fi
|
||||
|
||||
[[ -d "${DIR}/.git" ]] || continue
|
||||
cd "${DIR}" || continue
|
||||
|
||||
|
||||
@ -520,7 +520,13 @@ class Formula
|
||||
# exists and is not empty.
|
||||
# @private
|
||||
def latest_version_installed?
|
||||
(dir = latest_installed_prefix).directory? && !dir.children.empty?
|
||||
latest_prefix = if ENV["HOMEBREW_JSON_CORE"].present?
|
||||
prefix BottleAPI.latest_pkg_version(name)
|
||||
else
|
||||
latest_installed_prefix
|
||||
end
|
||||
|
||||
(dir = latest_prefix).directory? && !dir.children.empty?
|
||||
end
|
||||
|
||||
# If at least one version of {Formula} is installed.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user