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)
|
hash = fetch(name)
|
||||||
bottle_tag = Utils::Bottles.tag.to_s
|
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)
|
download_bottle(hash, bottle_tag)
|
||||||
|
|
||||||
hash["dependencies"].each do |dep_hash|
|
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)
|
download_bottle(dep_hash, bottle_tag)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -86,6 +95,7 @@ module BottleAPI
|
|||||||
sig { params(hash: Hash, tag: Symbol).void }
|
sig { params(hash: Hash, tag: Symbol).void }
|
||||||
def download_bottle(hash, tag)
|
def download_bottle(hash, tag)
|
||||||
bottle = hash["bottles"][tag]
|
bottle = hash["bottles"][tag]
|
||||||
|
bottle ||= hash["bottles"]["all"]
|
||||||
return if bottle.blank?
|
return if bottle.blank?
|
||||||
|
|
||||||
sha256 = bottle["sha256"] || checksum_from_url(bottle["url"])
|
sha256 = bottle["sha256"] || checksum_from_url(bottle["url"])
|
||||||
|
|||||||
@ -243,7 +243,16 @@ module Homebrew
|
|||||||
def info_formula(f, args:)
|
def info_formula(f, args:)
|
||||||
specs = []
|
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 = "stable #{stable.version}"
|
||||||
s += " (bottled)" if stable.bottled? && f.pour_bottle?
|
s += " (bottled)" if stable.bottled? && f.pour_bottle?
|
||||||
specs << s
|
specs << s
|
||||||
|
|||||||
@ -471,7 +471,7 @@ EOS
|
|||||||
[[ -d "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core" ]]
|
[[ -d "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core" ]]
|
||||||
then
|
then
|
||||||
safe_cd "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core"
|
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 remote set-url origin "${HOMEBREW_CORE_GIT_REMOTE}"
|
||||||
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
|
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
|
||||||
git fetch --force origin refs/heads/master:refs/remotes/origin/master
|
git fetch --force origin refs/heads/master:refs/remotes/origin/master
|
||||||
@ -498,6 +498,12 @@ EOS
|
|||||||
|
|
||||||
for DIR in "${HOMEBREW_REPOSITORY}" "${HOMEBREW_LIBRARY}"/Taps/*/*
|
for DIR in "${HOMEBREW_REPOSITORY}" "${HOMEBREW_LIBRARY}"/Taps/*/*
|
||||||
do
|
do
|
||||||
|
if [[ -n "${HOMEBREW_JSON_CORE}" ]] && [[ -n "${HOMEBREW_UPDATE_PREINSTALL}" ]] &&
|
||||||
|
[[ "${DIR}" = "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core" ]]
|
||||||
|
then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
[[ -d "${DIR}/.git" ]] || continue
|
[[ -d "${DIR}/.git" ]] || continue
|
||||||
cd "${DIR}" || continue
|
cd "${DIR}" || continue
|
||||||
|
|
||||||
@ -639,6 +645,14 @@ EOS
|
|||||||
|
|
||||||
for DIR in "${HOMEBREW_REPOSITORY}" "${HOMEBREW_LIBRARY}"/Taps/*/*
|
for DIR in "${HOMEBREW_REPOSITORY}" "${HOMEBREW_LIBRARY}"/Taps/*/*
|
||||||
do
|
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
|
[[ -d "${DIR}/.git" ]] || continue
|
||||||
cd "${DIR}" || continue
|
cd "${DIR}" || continue
|
||||||
|
|
||||||
|
|||||||
@ -520,7 +520,13 @@ class Formula
|
|||||||
# exists and is not empty.
|
# exists and is not empty.
|
||||||
# @private
|
# @private
|
||||||
def latest_version_installed?
|
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
|
end
|
||||||
|
|
||||||
# If at least one version of {Formula} is installed.
|
# If at least one version of {Formula} is installed.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user