mirror of
https://github.com/Homebrew/brew.git
synced 2026-08-12 22:29:27 +04:00
Merge pull request #23373 from Homebrew/install-step-remove-var-default
Remove the formula install-step var default (29/29)
This commit is contained in:
@@ -4086,9 +4086,6 @@ class Formula
|
|||||||
current_steps.concat(
|
current_steps.concat(
|
||||||
if block
|
if block
|
||||||
Homebrew::InstallSteps::DSL.build(
|
Homebrew::InstallSteps::DSL.build(
|
||||||
# TODO: Remove the undocumented `default_base: :var` compatibility default after official taps use
|
|
||||||
# explicit bases.
|
|
||||||
default_base: :var,
|
|
||||||
default_source_base: :prefix,
|
default_source_base: :prefix,
|
||||||
default_target_base: :prefix,
|
default_target_base: :prefix,
|
||||||
&block
|
&block
|
||||||
|
|||||||
@@ -1354,10 +1354,10 @@ on_request: installed_on_request?, options:)
|
|||||||
@show_summary_heading = true
|
@show_summary_heading = true
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { returns(Pathname) }
|
sig { returns(T.any(String, Pathname)) }
|
||||||
def post_install_formula_path
|
def post_install_formula_path
|
||||||
# Use the formula from the keg when any of the following is true:
|
# Use the formula from the keg when any of the following is true:
|
||||||
# * We're installing from the JSON API
|
# * We're installing from the JSON API and it has a Ruby post-install hook
|
||||||
# * We're installing a local bottle file
|
# * We're installing a local bottle file
|
||||||
# * We're building from source
|
# * We're building from source
|
||||||
# * The formula doesn't exist in the tap (or the tap isn't installed)
|
# * The formula doesn't exist in the tap (or the tap isn't installed)
|
||||||
@@ -1372,7 +1372,11 @@ on_request: installed_on_request?, options:)
|
|||||||
return tap_formula_path if installed_prefix.nil?
|
return tap_formula_path if installed_prefix.nil?
|
||||||
|
|
||||||
keg_formula_path = installed_prefix/".brew/#{formula.name}.rb"
|
keg_formula_path = installed_prefix/".brew/#{formula.name}.rb"
|
||||||
return keg_formula_path if formula.loaded_from_api?
|
if formula.loaded_from_api?
|
||||||
|
return formula.full_name unless formula.post_install_defined?
|
||||||
|
|
||||||
|
return keg_formula_path
|
||||||
|
end
|
||||||
return keg_formula_path if formula.local_bottle_path
|
return keg_formula_path if formula.local_bottle_path
|
||||||
return keg_formula_path if build_from_source?
|
return keg_formula_path if build_from_source?
|
||||||
|
|
||||||
|
|||||||
@@ -181,6 +181,35 @@ RSpec.describe FormulaInstaller do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#post_install_formula_path" do
|
||||||
|
it "uses the API formula for structured-only post-installs" do
|
||||||
|
formula = formula("api-install-steps") do
|
||||||
|
T.bind(self, T.class_of(Formula))
|
||||||
|
url "foo-1.0"
|
||||||
|
end
|
||||||
|
installer = described_class.new(formula)
|
||||||
|
|
||||||
|
allow(formula).to receive_messages(any_installed_prefix: mktmpdir, loaded_from_api?: true,
|
||||||
|
post_install_defined?: false)
|
||||||
|
|
||||||
|
expect(installer.post_install_formula_path).to eq(formula.full_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "uses the keg formula for API post-installs with Ruby hooks" do
|
||||||
|
formula = formula("api-post-install-hook") do
|
||||||
|
T.bind(self, T.class_of(Formula))
|
||||||
|
url "foo-1.0"
|
||||||
|
end
|
||||||
|
installer = described_class.new(formula)
|
||||||
|
installed_prefix = mktmpdir
|
||||||
|
|
||||||
|
allow(formula).to receive_messages(any_installed_prefix: installed_prefix, loaded_from_api?: true,
|
||||||
|
post_install_defined?: true)
|
||||||
|
|
||||||
|
expect(installer.post_install_formula_path).to eq(installed_prefix/".brew/api-post-install-hook.rb")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "#pour" do
|
describe "#pour" do
|
||||||
let(:f) do
|
let(:f) do
|
||||||
formula("missing-bottle-tab") do
|
formula("missing-bottle-tab") do
|
||||||
|
|||||||
@@ -1193,8 +1193,8 @@ RSpec.describe Formula do
|
|||||||
url "foo-1.0"
|
url "foo-1.0"
|
||||||
|
|
||||||
post_install_steps do
|
post_install_steps do
|
||||||
mkdir_p "log/foo"
|
mkdir_p "log/foo", base: :var
|
||||||
touch "foo/marker"
|
touch "foo/marker", base: :var
|
||||||
move "move-source", "move-target"
|
move "move-source", "move-target"
|
||||||
move_contents "children-source", "children-target"
|
move_contents "children-source", "children-target"
|
||||||
symlink "move-target", "linked-target", source_base: :relative, remove_on_uninstall: true
|
symlink "move-target", "linked-target", source_base: :relative, remove_on_uninstall: true
|
||||||
@@ -1226,6 +1226,21 @@ RSpec.describe Formula do
|
|||||||
expect(f.to_hash["post_install_steps"]).to eq(f.post_install_steps)
|
expect(f.to_hash["post_install_steps"]).to eq(f.post_install_steps)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
specify "#post_install_steps does not default paths to var" do
|
||||||
|
f = formula do
|
||||||
|
T.bind(self, T.class_of(Formula))
|
||||||
|
url "foo-1.0"
|
||||||
|
|
||||||
|
post_install_steps do
|
||||||
|
touch "foo/marker"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(f.post_install_steps).to eq([
|
||||||
|
{ "type" => "touch", "path" => { "path" => "foo/marker" } },
|
||||||
|
])
|
||||||
|
end
|
||||||
|
|
||||||
specify "#post_install_steps_defined? with an empty block" do
|
specify "#post_install_steps_defined? with an empty block" do
|
||||||
f = formula do
|
f = formula do
|
||||||
T.bind(self, T.class_of(Formula))
|
T.bind(self, T.class_of(Formula))
|
||||||
|
|||||||
Reference in New Issue
Block a user