From 0735eba995a1b35d14fbba8f41553d96b2fa14f7 Mon Sep 17 00:00:00 2001 From: Nanda H Krishna Date: Mon, 31 May 2021 16:48:20 +0530 Subject: [PATCH 1/3] formula_installer: improve support for local bottle installs --- Library/Homebrew/formula_installer.rb | 4 ++-- Library/Homebrew/tab.rb | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index dc7e1bee35..c76bfd1cb0 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -404,7 +404,7 @@ class FormulaInstaller options = display_options(formula).join(" ") oh1 "Installing #{Formatter.identifier(formula.full_name)} #{options}".strip if show_header? - unless formula.tap&.private? + if formula.tap&.installed? && !formula.tap&.private? action = "#{formula.full_name} #{options}".strip Utils::Analytics.report_event("install", action) @@ -1163,7 +1163,7 @@ class FormulaInstaller tab.source["versions"]["stable"] = formula.stable.version.to_s tab.source["versions"]["version_scheme"] = formula.version_scheme tab.source["path"] = formula.specified_path.to_s - tab.source["tap_git_head"] = formula.tap&.git_head + tab.source["tap_git_revision"] = formula.tap&.installed? ? formula.tap&.git_head : nil tab.tap = formula.tap tab.write diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index 7ce6b00c08..4725036189 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -39,11 +39,11 @@ class Tab < OpenStruct "runtime_dependencies" => Tab.runtime_deps_hash(formula, runtime_deps), "arch" => Hardware::CPU.arch, "source" => { - "path" => formula.specified_path.to_s, - "tap" => formula.tap&.name, - "tap_git_head" => formula.tap&.git_head, - "spec" => formula.active_spec_sym.to_s, - "versions" => { + "path" => formula.specified_path.to_s, + "tap" => formula.tap&.name, + "tap_git_revision" => formula.tap&.git_head, + "spec" => formula.active_spec_sym.to_s, + "versions" => { "stable" => formula.stable&.version.to_s, "head" => formula.head&.version.to_s, "version_scheme" => formula.version_scheme, @@ -194,11 +194,11 @@ class Tab < OpenStruct "runtime_dependencies" => nil, "arch" => nil, "source" => { - "path" => nil, - "tap" => nil, - "tap_git_head" => nil, - "spec" => "stable", - "versions" => { + "path" => nil, + "tap" => nil, + "tap_git_revision" => nil, + "spec" => "stable", + "versions" => { "stable" => nil, "head" => nil, "version_scheme" => 0, From e6dd13d04ec16525836bc92fe2037dfbd94cf7b7 Mon Sep 17 00:00:00 2001 From: Nanda H Krishna Date: Mon, 31 May 2021 20:36:36 +0530 Subject: [PATCH 2/3] Revert renaming of `tap_git_head` --- Library/Homebrew/formula_installer.rb | 2 +- Library/Homebrew/tab.rb | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index c76bfd1cb0..eb28baaddc 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -1163,7 +1163,7 @@ class FormulaInstaller tab.source["versions"]["stable"] = formula.stable.version.to_s tab.source["versions"]["version_scheme"] = formula.version_scheme tab.source["path"] = formula.specified_path.to_s - tab.source["tap_git_revision"] = formula.tap&.installed? ? formula.tap&.git_head : nil + tab.source["tap_git_head"] = formula.tap&.installed? ? formula.tap&.git_head : nil tab.tap = formula.tap tab.write diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index 4725036189..7ce6b00c08 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -39,11 +39,11 @@ class Tab < OpenStruct "runtime_dependencies" => Tab.runtime_deps_hash(formula, runtime_deps), "arch" => Hardware::CPU.arch, "source" => { - "path" => formula.specified_path.to_s, - "tap" => formula.tap&.name, - "tap_git_revision" => formula.tap&.git_head, - "spec" => formula.active_spec_sym.to_s, - "versions" => { + "path" => formula.specified_path.to_s, + "tap" => formula.tap&.name, + "tap_git_head" => formula.tap&.git_head, + "spec" => formula.active_spec_sym.to_s, + "versions" => { "stable" => formula.stable&.version.to_s, "head" => formula.head&.version.to_s, "version_scheme" => formula.version_scheme, @@ -194,11 +194,11 @@ class Tab < OpenStruct "runtime_dependencies" => nil, "arch" => nil, "source" => { - "path" => nil, - "tap" => nil, - "tap_git_revision" => nil, - "spec" => "stable", - "versions" => { + "path" => nil, + "tap" => nil, + "tap_git_head" => nil, + "spec" => "stable", + "versions" => { "stable" => nil, "head" => nil, "version_scheme" => 0, From a0dfe4aa180f602af0c4b5ed6d9c0ffd315dbc6d Mon Sep 17 00:00:00 2001 From: Nanda H Krishna Date: Thu, 10 Jun 2021 23:21:26 +0530 Subject: [PATCH 3/3] formula_installer: use formula from Keg for local bottle installs Use the formula file from the Keg if `local_bottle_install` is set, which means that the formula file from the tap is used for `-s`, `--HEAD` and normal installs but the formula file present within formula.prefix/".brew" is used for local bottle installs. --- Library/Homebrew/formula_installer.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index eb28baaddc..f13b557d70 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -1074,9 +1074,14 @@ class FormulaInstaller -I #{$LOAD_PATH.join(File::PATH_SEPARATOR)} -- #{HOMEBREW_LIBRARY_PATH}/postinstall.rb - #{formula.path} ] + args << if formula.local_bottle_path.present? + formula.prefix/".brew/#{formula.name}.rb" + else + formula.path + end + Utils.safe_fork do if Sandbox.available? sandbox = Sandbox.new