Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to JSON bottle handling #11715

Merged
merged 7 commits into from
Jul 16, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions Library/Homebrew/bottle_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ def fetch_bottles(name)
download_bottle(hash, bottle_tag)

hash["dependencies"].each do |dep_hash|
existing_formula = begin
Formulary.factory dep_hash["name"]
rescue FormulaUnavailableError
nil
Rylan12 marked this conversation as resolved.
Show resolved Hide resolved
end

next if existing_formula.present? && existing_formula.latest_version_installed?

download_bottle(dep_hash, bottle_tag)
end
end
Expand Down
8 changes: 7 additions & 1 deletion Library/Homebrew/cmd/info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,13 @@ def info_formula(f, args:)
specs = []

if (stable = f.stable)
s = "stable #{stable.version}"
latest_version = if ENV["HOMEBREW_JSON_CORE"].present?
BottleAPI.latest_pkg_version(f.name).version || stable.version
else
stable.version
end
Rylan12 marked this conversation as resolved.
Show resolved Hide resolved

s = "stable #{latest_version}"
s += " (bottled)" if stable.bottled? && f.pour_bottle?
Rylan12 marked this conversation as resolved.
Show resolved Hide resolved
specs << s
end
Expand Down
16 changes: 15 additions & 1 deletion Library/Homebrew/cmd/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Rylan12 marked this conversation as resolved.
Show resolved Hide resolved
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
Expand All @@ -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

Expand Down Expand Up @@ -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

Expand Down
8 changes: 7 additions & 1 deletion Library/Homebrew/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,13 @@ def aliases
# 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.
Expand Down