Skip to content

Commit fa9f8bd

Browse files
authored
Merge pull request #19570 from Homebrew/install_as_dependency
Add `brew install --as-dependency`
2 parents 7ddc4b0 + e41a1f6 commit fa9f8bd

File tree

8 files changed

+28
-5
lines changed

8 files changed

+28
-5
lines changed

Library/Homebrew/cmd/install.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ class InstallCmd < AbstractCommand
104104
[:switch, "--skip-link", {
105105
description: "Install but skip linking the keg into the prefix.",
106106
}],
107+
[:switch, "--as-dependency", {
108+
description: "Install but mark as installed as a dependency and not installed on request.",
109+
}],
107110
[:flag, "--bottle-arch=", {
108111
depends_on: "--build-bottle",
109112
description: "Optimise bottles for the specified architecture rather than the oldest " \
@@ -311,6 +314,8 @@ def run
311314

312315
Install.install_formulae(
313316
installed_formulae,
317+
installed_on_request: !args.as_dependency?,
318+
installed_as_dependency: args.as_dependency?,
314319
build_bottle: args.build_bottle?,
315320
force_bottle: args.force_bottle?,
316321
bottle_arch: args.bottle_arch,
@@ -336,7 +341,7 @@ def run
336341
Upgrade.check_installed_dependents(
337342
installed_formulae,
338343
flags: args.flags_only,
339-
installed_on_request: args.named.present?,
344+
installed_on_request: !args.as_dependency?,
340345
force_bottle: args.force_bottle?,
341346
build_from_source_formulae: args.build_from_source_formulae,
342347
interactive: args.interactive?,

Library/Homebrew/install.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ def install_formula?(
233233

234234
def install_formulae(
235235
formulae_to_install,
236+
installed_on_request: true,
237+
installed_as_dependency: false,
236238
build_bottle: false,
237239
force_bottle: false,
238240
bottle_arch: nil,
@@ -261,8 +263,8 @@ def install_formulae(
261263
formula_installer = FormulaInstaller.new(
262264
formula,
263265
options: build_options.used_options,
264-
installed_on_request: true,
265-
installed_as_dependency: false,
266+
installed_on_request:,
267+
installed_as_dependency:,
266268
build_bottle:,
267269
force_bottle:,
268270
bottle_arch:,

Library/Homebrew/sorbet/rbi/dsl/homebrew/cmd/install_cmd.rbi

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

completions/bash/brew

+2
Original file line numberDiff line numberDiff line change
@@ -1402,6 +1402,7 @@ _brew_instal() {
14021402
--HEAD
14031403
--adopt
14041404
--appdir
1405+
--as-dependency
14051406
--ask
14061407
--audio-unit-plugindir
14071408
--binaries
@@ -1467,6 +1468,7 @@ _brew_install() {
14671468
--HEAD
14681469
--adopt
14691470
--appdir
1471+
--as-dependency
14701472
--ask
14711473
--audio-unit-plugindir
14721474
--binaries

completions/fish/brew.fish

+2
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,7 @@ __fish_brew_complete_arg 'info; and not __fish_seen_argument -l formula -l formu
944944
__fish_brew_complete_arg 'instal' -l HEAD -d 'If formula defines it, install the HEAD version, aka. main, trunk, unstable, master'
945945
__fish_brew_complete_arg 'instal' -l adopt -d 'Adopt existing artifacts in the destination that are identical to those being installed. Cannot be combined with `--force`'
946946
__fish_brew_complete_arg 'instal' -l appdir -d 'Target location for Applications (default: `/Applications`)'
947+
__fish_brew_complete_arg 'instal' -l as-dependency -d 'Install but mark as installed as a dependency and not installed on request'
947948
__fish_brew_complete_arg 'instal' -l ask -d 'Ask for confirmation before downloading and installing formulae. Print bottles and dependencies download size and install size'
948949
__fish_brew_complete_arg 'instal' -l audio-unit-plugindir -d 'Target location for Audio Unit Plugins (default: `~/Library/Audio/Plug-Ins/Components`)'
949950
__fish_brew_complete_arg 'instal' -l binaries -d 'Disable/enable linking of helper executables (default: enabled)'
@@ -1000,6 +1001,7 @@ __fish_brew_complete_cmd 'install' 'Install a formula or cask'
10001001
__fish_brew_complete_arg 'install' -l HEAD -d 'If formula defines it, install the HEAD version, aka. main, trunk, unstable, master'
10011002
__fish_brew_complete_arg 'install' -l adopt -d 'Adopt existing artifacts in the destination that are identical to those being installed. Cannot be combined with `--force`'
10021003
__fish_brew_complete_arg 'install' -l appdir -d 'Target location for Applications (default: `/Applications`)'
1004+
__fish_brew_complete_arg 'install' -l as-dependency -d 'Install but mark as installed as a dependency and not installed on request'
10031005
__fish_brew_complete_arg 'install' -l ask -d 'Ask for confirmation before downloading and installing formulae. Print bottles and dependencies download size and install size'
10041006
__fish_brew_complete_arg 'install' -l audio-unit-plugindir -d 'Target location for Audio Unit Plugins (default: `~/Library/Audio/Plug-Ins/Components`)'
10051007
__fish_brew_complete_arg 'install' -l binaries -d 'Disable/enable linking of helper executables (default: enabled)'

completions/zsh/_brew

+4-2
Original file line numberDiff line numberDiff line change
@@ -1187,6 +1187,7 @@ _brew_instal() {
11871187
'(--cask)--HEAD[If formula defines it, install the HEAD version, aka. main, trunk, unstable, master]' \
11881188
'(--formula --force)--adopt[Adopt existing artifacts in the destination that are identical to those being installed. Cannot be combined with `--force`]' \
11891189
'(--formula)--appdir[Target location for Applications (default: `/Applications`)]' \
1190+
'(--cask)--as-dependency[Install but mark as installed as a dependency and not installed on request]' \
11901191
'(--cask)--ask[Ask for confirmation before downloading and installing formulae. Print bottles and dependencies download size and install size]' \
11911192
'(--formula)--audio-unit-plugindir[Target location for Audio Unit Plugins (default: `~/Library/Audio/Plug-Ins/Components`)]' \
11921193
'(--formula)--binaries[Disable/enable linking of helper executables (default: enabled)]' \
@@ -1237,7 +1238,7 @@ _brew_instal() {
12371238
'(--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]' \
12381239
'*::formula:__brew_formulae' \
12391240
- cask \
1240-
'(--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 --ask)--cask[Treat all named arguments as casks]' \
1241+
'(--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 --as-dependency --bottle-arch --interactive --git --overwrite --ask)--cask[Treat all named arguments as casks]' \
12411242
'*::cask:__brew_casks'
12421243
}
12431244

@@ -1247,6 +1248,7 @@ _brew_install() {
12471248
'(--cask)--HEAD[If formula defines it, install the HEAD version, aka. main, trunk, unstable, master]' \
12481249
'(--formula --force)--adopt[Adopt existing artifacts in the destination that are identical to those being installed. Cannot be combined with `--force`]' \
12491250
'(--formula)--appdir[Target location for Applications (default: `/Applications`)]' \
1251+
'(--cask)--as-dependency[Install but mark as installed as a dependency and not installed on request]' \
12501252
'(--cask)--ask[Ask for confirmation before downloading and installing formulae. Print bottles and dependencies download size and install size]' \
12511253
'(--formula)--audio-unit-plugindir[Target location for Audio Unit Plugins (default: `~/Library/Audio/Plug-Ins/Components`)]' \
12521254
'(--formula)--binaries[Disable/enable linking of helper executables (default: enabled)]' \
@@ -1297,7 +1299,7 @@ _brew_install() {
12971299
'(--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]' \
12981300
'*::formula:__brew_formulae' \
12991301
- cask \
1300-
'(--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 --ask)--cask[Treat all named arguments as casks]' \
1302+
'(--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 --as-dependency --bottle-arch --interactive --git --overwrite --ask)--cask[Treat all named arguments as casks]' \
13011303
'*::cask:__brew_casks'
13021304
}
13031305

docs/Manpage.md

+4
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,10 @@ upgrade *`formula`* if it is already installed but outdated.
835835

836836
: Install but skip linking the keg into the prefix.
837837

838+
`--as-dependency`
839+
840+
: Install but mark as installed as a dependency and not installed on request.
841+
838842
`--bottle-arch`
839843

840844
: Optimise bottles for the specified architecture rather than the oldest

manpages/brew.1

+3
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,9 @@ Install but skip any post\-install steps\.
520520
\fB\-\-skip\-link\fP
521521
Install but skip linking the keg into the prefix\.
522522
.TP
523+
\fB\-\-as\-dependency\fP
524+
Install but mark as installed as a dependency and not installed on request\.
525+
.TP
523526
\fB\-\-bottle\-arch\fP
524527
Optimise bottles for the specified architecture rather than the oldest architecture supported by the version of macOS the bottles are built on\.
525528
.TP

0 commit comments

Comments
 (0)