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

Add brew install --skip-link #19136

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Library/Homebrew/cmd/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ class InstallCmd < AbstractCommand
[:switch, "--skip-post-install", {
description: "Install but skip any post-install steps.",
}],
[:switch, "--skip-link", {
description: "Install but skip linking the keg into the prefix.",
}],
[:flag, "--bottle-arch=", {
depends_on: "--build-bottle",
description: "Optimise bottles for the specified architecture rather than the oldest " \
Expand Down Expand Up @@ -289,6 +292,7 @@ def run
only_dependencies: args.only_dependencies?,
force: args.force?,
quiet: args.quiet?,
skip_link: args.skip_link?,
overwrite: args.overwrite?,
)
end
Expand Down Expand Up @@ -319,6 +323,7 @@ def run
verbose: args.verbose?,
dry_run: args.dry_run?,
skip_post_install: args.skip_post_install?,
skip_link: args.skip_link?,
)

Upgrade.check_installed_dependents(
Expand Down
18 changes: 17 additions & 1 deletion Library/Homebrew/formula_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
show_header: T::Boolean,
build_bottle: T::Boolean,
skip_post_install: T::Boolean,
skip_link: T::Boolean,
force_bottle: T::Boolean,
bottle_arch: T.nilable(String),
ignore_deps: T::Boolean,
Expand Down Expand Up @@ -88,6 +89,7 @@
show_header: false,
build_bottle: false,
skip_post_install: false,
skip_link: false,
force_bottle: false,
bottle_arch: nil,
ignore_deps: false,
Expand Down Expand Up @@ -120,6 +122,7 @@
@build_from_source_formulae = build_from_source_formulae
@build_bottle = build_bottle
@skip_post_install = skip_post_install
@skip_link = skip_link
@bottle_arch = bottle_arch
@formula.force_bottle ||= force_bottle
@force_bottle = T.let(@formula.force_bottle, T::Boolean)
Expand Down Expand Up @@ -195,6 +198,11 @@
@skip_post_install.present?
end

sig { returns(T::Boolean) }
def skip_link?
@skip_link.present?
end

sig { params(output_warning: T::Boolean).returns(T::Boolean) }
def pour_bottle?(output_warning: false)
return false if !formula.bottle_tag? && !formula.local_bottle_path
Expand Down Expand Up @@ -866,7 +874,15 @@
ohai "Finishing up" if verbose?

keg = Keg.new(formula.prefix)
link(keg)
if skip_link?
unless quiet?
ohai "Skipping 'link' on request"
puts "You can run it manually using:"
puts " brew link #{formula.full_name}"

Check warning on line 881 in Library/Homebrew/formula_installer.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/formula_installer.rb#L880-L881

Added lines #L880 - L881 were not covered by tests
end
else
link(keg)
end

install_service

Expand Down
7 changes: 5 additions & 2 deletions Library/Homebrew/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def install_formula?(
only_dependencies: false,
force: false,
quiet: false,
skip_link: false,
overwrite: false
)
# head-only without --HEAD is an error
Expand Down Expand Up @@ -201,7 +202,7 @@ def install_formula?(
To upgrade to #{formula.pkg_version}, run:
#{unpin_cmd_if_needed}brew upgrade #{formula.full_name}
EOS
elsif only_dependencies
elsif only_dependencies || skip_link
return true
else
onoe <<~EOS
Expand Down Expand Up @@ -250,7 +251,8 @@ def install_formulae(
quiet: false,
verbose: false,
dry_run: false,
skip_post_install: false
skip_post_install: false,
skip_link: false
)
formula_installers = formulae_to_install.filter_map do |formula|
Migrator.migrate_if_needed(formula, force:, dry_run:)
Expand Down Expand Up @@ -279,6 +281,7 @@ def install_formulae(
quiet:,
verbose:,
skip_post_install:,
skip_link:,
)

begin
Expand Down
3 changes: 3 additions & 0 deletions Library/Homebrew/sorbet/rbi/dsl/homebrew/cmd/install_cmd.rbi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions completions/bash/brew
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,7 @@ _brew_instal() {
--screen-saverdir
--servicedir
--skip-cask-deps
--skip-link
--skip-post-install
--verbose
--vst-plugindir
Expand Down Expand Up @@ -1405,6 +1406,7 @@ _brew_install() {
--screen-saverdir
--servicedir
--skip-cask-deps
--skip-link
--skip-post-install
--verbose
--vst-plugindir
Expand Down
2 changes: 2 additions & 0 deletions completions/fish/brew.fish
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,7 @@ __fish_brew_complete_arg 'instal' -l require-sha -d 'Require all casks to have a
__fish_brew_complete_arg 'instal' -l screen-saverdir -d 'Target location for Screen Savers (default: `~/Library/Screen Savers`)'
__fish_brew_complete_arg 'instal' -l servicedir -d 'Target location for Services (default: `~/Library/Services`)'
__fish_brew_complete_arg 'instal' -l skip-cask-deps -d 'Skip installing cask dependencies'
__fish_brew_complete_arg 'instal' -l skip-link -d 'Install but skip linking the keg into the prefix'
__fish_brew_complete_arg 'instal' -l skip-post-install -d 'Install but skip any post-install steps'
__fish_brew_complete_arg 'instal' -l verbose -d 'Print the verification and post-install steps'
__fish_brew_complete_arg 'instal' -l vst-plugindir -d 'Target location for VST Plugins (default: `~/Library/Audio/Plug-Ins/VST`)'
Expand Down Expand Up @@ -966,6 +967,7 @@ __fish_brew_complete_arg 'install' -l require-sha -d 'Require all casks to have
__fish_brew_complete_arg 'install' -l screen-saverdir -d 'Target location for Screen Savers (default: `~/Library/Screen Savers`)'
__fish_brew_complete_arg 'install' -l servicedir -d 'Target location for Services (default: `~/Library/Services`)'
__fish_brew_complete_arg 'install' -l skip-cask-deps -d 'Skip installing cask dependencies'
__fish_brew_complete_arg 'install' -l skip-link -d 'Install but skip linking the keg into the prefix'
__fish_brew_complete_arg 'install' -l skip-post-install -d 'Install but skip any post-install steps'
__fish_brew_complete_arg 'install' -l verbose -d 'Print the verification and post-install steps'
__fish_brew_complete_arg 'install' -l vst-plugindir -d 'Target location for VST Plugins (default: `~/Library/Audio/Plug-Ins/VST`)'
Expand Down
6 changes: 4 additions & 2 deletions completions/zsh/_brew
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,7 @@ _brew_instal() {
'(--formula)--screen-saverdir[Target location for Screen Savers (default: `~/Library/Screen Savers`)]' \
'(--formula)--servicedir[Target location for Services (default: `~/Library/Services`)]' \
'(--formula)--skip-cask-deps[Skip installing cask dependencies]' \
'(--cask)--skip-link[Install but skip linking the keg into the prefix]' \
'(--cask)--skip-post-install[Install but skip any post-install steps]' \
'--verbose[Print the verification and post-install steps]' \
'(--formula)--vst-plugindir[Target location for VST Plugins (default: `~/Library/Audio/Plug-Ins/VST`)]' \
Expand All @@ -1154,7 +1155,7 @@ _brew_instal() {
'(--casks --binaries --require-sha --quarantine --adopt --skip-cask-deps --zap --appdir --keyboard-layoutdir --colorpickerdir --prefpanedir --qlplugindir --mdimporterdir --dictionarydir --fontdir --servicedir --input-methoddir --internet-plugindir --audio-unit-plugindir --vst-plugindir --vst3-plugindir --screen-saverdir --language)--formula[Treat all named arguments as formulae]' \
'*::formula:__brew_formulae' \
- cask \
'(--formulae --env --ignore-dependencies --only-dependencies --cc --build-from-source --force-bottle --include-test --HEAD --fetch-HEAD --keep-tmp --debug-symbols --build-bottle --skip-post-install --bottle-arch --interactive --git --overwrite)--cask[Treat all named arguments as casks]' \
'(--formulae --env --ignore-dependencies --only-dependencies --cc --build-from-source --force-bottle --include-test --HEAD --fetch-HEAD --keep-tmp --debug-symbols --build-bottle --skip-post-install --skip-link --bottle-arch --interactive --git --overwrite)--cask[Treat all named arguments as casks]' \
'*::cask:__brew_casks'
}

Expand Down Expand Up @@ -1203,6 +1204,7 @@ _brew_install() {
'(--formula)--screen-saverdir[Target location for Screen Savers (default: `~/Library/Screen Savers`)]' \
'(--formula)--servicedir[Target location for Services (default: `~/Library/Services`)]' \
'(--formula)--skip-cask-deps[Skip installing cask dependencies]' \
'(--cask)--skip-link[Install but skip linking the keg into the prefix]' \
'(--cask)--skip-post-install[Install but skip any post-install steps]' \
'--verbose[Print the verification and post-install steps]' \
'(--formula)--vst-plugindir[Target location for VST Plugins (default: `~/Library/Audio/Plug-Ins/VST`)]' \
Expand All @@ -1212,7 +1214,7 @@ _brew_install() {
'(--casks --binaries --require-sha --quarantine --adopt --skip-cask-deps --zap --appdir --keyboard-layoutdir --colorpickerdir --prefpanedir --qlplugindir --mdimporterdir --dictionarydir --fontdir --servicedir --input-methoddir --internet-plugindir --audio-unit-plugindir --vst-plugindir --vst3-plugindir --screen-saverdir --language)--formula[Treat all named arguments as formulae]' \
'*::formula:__brew_formulae' \
- cask \
'(--formulae --env --ignore-dependencies --only-dependencies --cc --build-from-source --force-bottle --include-test --HEAD --fetch-HEAD --keep-tmp --debug-symbols --build-bottle --skip-post-install --bottle-arch --interactive --git --overwrite)--cask[Treat all named arguments as casks]' \
'(--formulae --env --ignore-dependencies --only-dependencies --cc --build-from-source --force-bottle --include-test --HEAD --fetch-HEAD --keep-tmp --debug-symbols --build-bottle --skip-post-install --skip-link --bottle-arch --interactive --git --overwrite)--cask[Treat all named arguments as casks]' \
'*::cask:__brew_casks'
}

Expand Down
4 changes: 4 additions & 0 deletions docs/Manpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,10 @@ upgrade *`formula`* if it is already installed but outdated.

: Install but skip any post-install steps.

`--skip-link`

: Install but skip linking the keg into the prefix.

`--bottle-arch`

: Optimise bottles for the specified architecture rather than the oldest
Expand Down
3 changes: 3 additions & 0 deletions manpages/brew.1
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,9 @@ Prepare the formula for eventual bottling during installation, skipping any post
\fB\-\-skip\-post\-install\fP
Install but skip any post\-install steps\.
.TP
\fB\-\-skip\-link\fP
Install but skip linking the keg into the prefix\.
.TP
\fB\-\-bottle\-arch\fP
Optimise bottles for the specified architecture rather than the oldest architecture supported by the version of macOS the bottles are built on\.
.TP
Expand Down
Loading