From 95a8c3f6384bce8211f6675ca7b03b52149aa6ab Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 23 Mar 2023 15:22:27 +0000 Subject: [PATCH] Add `brew install --skip-post-install` Will be needed by `brew test-bot`. --- Library/Homebrew/cmd/install.rb | 3 +++ Library/Homebrew/formula_installer.rb | 15 +++++++++++++-- completions/bash/brew | 2 ++ completions/fish/brew.fish | 2 ++ completions/zsh/_brew | 6 ++++-- docs/Manpage.md | 2 ++ manpages/brew.1 | 4 ++++ 7 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index 7481ddb3d0..28174a3c21 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -98,6 +98,9 @@ module Homebrew description: "Prepare the formula for eventual bottling during installation, skipping any " \ "post-install steps.", }], + [:switch, "--skip-post-install", { + description: "Install but skip any post-install steps.", + }], [:flag, "--bottle-arch=", { depends_on: "--build-bottle", description: "Optimise bottles for the specified architecture rather than the oldest " \ diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 1cbec1c9ca..0edde1f5fe 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -49,6 +49,7 @@ class FormulaInstaller installed_on_request: true, show_header: false, build_bottle: false, + skip_post_install: false, force_bottle: false, bottle_arch: nil, ignore_deps: false, @@ -80,6 +81,7 @@ class FormulaInstaller @only_deps = only_deps @build_from_source_formulae = build_from_source_formulae @build_bottle = build_bottle + @skip_post_install = skip_post_install @bottle_arch = bottle_arch @formula.force_bottle ||= force_bottle @force_bottle = @formula.force_bottle @@ -140,6 +142,11 @@ class FormulaInstaller @build_bottle.present? end + sig { returns(T::Boolean) } + def skip_post_install? + @skip_post_install.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 @@ -782,8 +789,12 @@ on_request: installed_on_request?, options: options) Homebrew::Install.global_post_install - if build_bottle? - ohai "Not running 'post_install' as we're building a bottle" + if build_bottle? || skip_post_install? + if build_bottle? + ohai "Not running 'post_install' as we're building a bottle" + elsif skip_post_install? + ohai "Skipping 'post_install' on request" + end puts "You can run it manually using:" puts " brew postinstall #{formula.full_name}" else diff --git a/completions/bash/brew b/completions/bash/brew index cad55301f8..37a56a5802 100644 --- a/completions/bash/brew +++ b/completions/bash/brew @@ -1178,6 +1178,7 @@ _brew_instal() { --screen-saverdir --servicedir --skip-cask-deps + --skip-post-install --verbose --vst-plugindir --vst3-plugindir @@ -1239,6 +1240,7 @@ _brew_install() { --screen-saverdir --servicedir --skip-cask-deps + --skip-post-install --verbose --vst-plugindir --vst3-plugindir diff --git a/completions/fish/brew.fish b/completions/fish/brew.fish index d2f9c719b2..ec01daf737 100644 --- a/completions/fish/brew.fish +++ b/completions/fish/brew.fish @@ -848,6 +848,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-post-install -d 'Install but skip any post-install steps' __fish_brew_complete_arg 'instal' -l verbose -d 'Print the verification and postinstall steps' __fish_brew_complete_arg 'instal' -l vst-plugindir -d 'Target location for VST Plugins (default: `~/Library/Audio/Plug-Ins/VST`)' __fish_brew_complete_arg 'instal' -l vst3-plugindir -d 'Target location for VST3 Plugins (default: `~/Library/Audio/Plug-Ins/VST3`)' @@ -900,6 +901,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-post-install -d 'Install but skip any post-install steps' __fish_brew_complete_arg 'install' -l verbose -d 'Print the verification and postinstall steps' __fish_brew_complete_arg 'install' -l vst-plugindir -d 'Target location for VST Plugins (default: `~/Library/Audio/Plug-Ins/VST`)' __fish_brew_complete_arg 'install' -l vst3-plugindir -d 'Target location for VST3 Plugins (default: `~/Library/Audio/Plug-Ins/VST3`)' diff --git a/completions/zsh/_brew b/completions/zsh/_brew index a0df052392..0297bb23c3 100644 --- a/completions/zsh/_brew +++ b/completions/zsh/_brew @@ -1041,6 +1041,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-post-install[Install but skip any post-install steps]' \ '--verbose[Print the verification and postinstall steps]' \ '(--formula)--vst-plugindir[Target location for VST Plugins (default: `~/Library/Audio/Plug-Ins/VST`)]' \ '(--formula)--vst3-plugindir[Target location for VST3 Plugins (default: `~/Library/Audio/Plug-Ins/VST3`)]' \ @@ -1049,7 +1050,7 @@ _brew_instal() { '(--casks --binaries --require-sha --quarantine --adopt --skip-cask-deps --zap --appdir --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 --bottle-arch --display-times --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 --bottle-arch --display-times --interactive --git --overwrite)--cask[Treat all named arguments as casks]' \ '*::cask:__brew_casks' } @@ -1097,6 +1098,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-post-install[Install but skip any post-install steps]' \ '--verbose[Print the verification and postinstall steps]' \ '(--formula)--vst-plugindir[Target location for VST Plugins (default: `~/Library/Audio/Plug-Ins/VST`)]' \ '(--formula)--vst3-plugindir[Target location for VST3 Plugins (default: `~/Library/Audio/Plug-Ins/VST3`)]' \ @@ -1105,7 +1107,7 @@ _brew_install() { '(--casks --binaries --require-sha --quarantine --adopt --skip-cask-deps --zap --appdir --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 --bottle-arch --display-times --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 --bottle-arch --display-times --interactive --git --overwrite)--cask[Treat all named arguments as casks]' \ '*::cask:__brew_casks' } diff --git a/docs/Manpage.md b/docs/Manpage.md index 6da9b531f4..9ee1e3dbfc 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -352,6 +352,8 @@ is already installed but outdated. Generate debug symbols on build. Source will be retained in a cache directory. * `--build-bottle`: Prepare the formula for eventual bottling during installation, skipping any post-install steps. +* `--skip-post-install`: + Install but skip any post-install steps. * `--bottle-arch`: Optimise bottles for the specified architecture rather than the oldest architecture supported by the version of macOS the bottles are built on. * `--display-times`: diff --git a/manpages/brew.1 b/manpages/brew.1 index ae9803b988..63a81a403f 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -480,6 +480,10 @@ Generate debug symbols on build\. Source will be retained in a cache directory\. Prepare the formula for eventual bottling during installation, skipping any post\-install steps\. . .TP +\fB\-\-skip\-post\-install\fR +Install but skip any post\-install steps\. +. +.TP \fB\-\-bottle\-arch\fR Optimise bottles for the specified architecture rather than the oldest architecture supported by the version of macOS the bottles are built on\. .