Merge pull request #19136 from Homebrew/skip_link
Add `brew install --skip-link`
This commit is contained in:
		
						commit
						9f319bc4a7
					
				@ -101,6 +101,9 @@ module Homebrew
 | 
			
		||||
          [: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 " \
 | 
			
		||||
@ -289,6 +292,7 @@ module Homebrew
 | 
			
		||||
            only_dependencies: args.only_dependencies?,
 | 
			
		||||
            force:             args.force?,
 | 
			
		||||
            quiet:             args.quiet?,
 | 
			
		||||
            skip_link:         args.skip_link?,
 | 
			
		||||
            overwrite:         args.overwrite?,
 | 
			
		||||
          )
 | 
			
		||||
        end
 | 
			
		||||
@ -319,6 +323,7 @@ module Homebrew
 | 
			
		||||
          verbose:                    args.verbose?,
 | 
			
		||||
          dry_run:                    args.dry_run?,
 | 
			
		||||
          skip_post_install:          args.skip_post_install?,
 | 
			
		||||
          skip_link:                  args.skip_link?,
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
        Upgrade.check_installed_dependents(
 | 
			
		||||
 | 
			
		||||
@ -60,6 +60,7 @@ class FormulaInstaller
 | 
			
		||||
      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,
 | 
			
		||||
@ -88,6 +89,7 @@ class FormulaInstaller
 | 
			
		||||
    show_header: false,
 | 
			
		||||
    build_bottle: false,
 | 
			
		||||
    skip_post_install: false,
 | 
			
		||||
    skip_link: false,
 | 
			
		||||
    force_bottle: false,
 | 
			
		||||
    bottle_arch: nil,
 | 
			
		||||
    ignore_deps: false,
 | 
			
		||||
@ -120,6 +122,7 @@ class FormulaInstaller
 | 
			
		||||
    @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)
 | 
			
		||||
@ -195,6 +198,11 @@ class FormulaInstaller
 | 
			
		||||
    @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
 | 
			
		||||
@ -866,7 +874,15 @@ on_request: installed_on_request?, options:)
 | 
			
		||||
    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}"
 | 
			
		||||
      end
 | 
			
		||||
    else
 | 
			
		||||
      link(keg)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    install_service
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -70,6 +70,7 @@ module Homebrew
 | 
			
		||||
        only_dependencies: false,
 | 
			
		||||
        force: false,
 | 
			
		||||
        quiet: false,
 | 
			
		||||
        skip_link: false,
 | 
			
		||||
        overwrite: false
 | 
			
		||||
      )
 | 
			
		||||
        # head-only without --HEAD is an error
 | 
			
		||||
@ -201,7 +202,7 @@ module Homebrew
 | 
			
		||||
              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
 | 
			
		||||
@ -250,7 +251,8 @@ module Homebrew
 | 
			
		||||
        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:)
 | 
			
		||||
@ -279,6 +281,7 @@ module Homebrew
 | 
			
		||||
            quiet:,
 | 
			
		||||
            verbose:,
 | 
			
		||||
            skip_post_install:,
 | 
			
		||||
            skip_link:,
 | 
			
		||||
          )
 | 
			
		||||
 | 
			
		||||
          begin
 | 
			
		||||
 | 
			
		||||
@ -152,6 +152,9 @@ class Homebrew::Cmd::InstallCmd::Args < Homebrew::CLI::Args
 | 
			
		||||
  sig { returns(T::Boolean) }
 | 
			
		||||
  def skip_cask_deps?; end
 | 
			
		||||
 | 
			
		||||
  sig { returns(T::Boolean) }
 | 
			
		||||
  def skip_link?; end
 | 
			
		||||
 | 
			
		||||
  sig { returns(T::Boolean) }
 | 
			
		||||
  def skip_post_install?; end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1342,6 +1342,7 @@ _brew_instal() {
 | 
			
		||||
      --screen-saverdir
 | 
			
		||||
      --servicedir
 | 
			
		||||
      --skip-cask-deps
 | 
			
		||||
      --skip-link
 | 
			
		||||
      --skip-post-install
 | 
			
		||||
      --verbose
 | 
			
		||||
      --vst-plugindir
 | 
			
		||||
@ -1405,6 +1406,7 @@ _brew_install() {
 | 
			
		||||
      --screen-saverdir
 | 
			
		||||
      --servicedir
 | 
			
		||||
      --skip-cask-deps
 | 
			
		||||
      --skip-link
 | 
			
		||||
      --skip-post-install
 | 
			
		||||
      --verbose
 | 
			
		||||
      --vst-plugindir
 | 
			
		||||
 | 
			
		||||
@ -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`)'
 | 
			
		||||
@ -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`)'
 | 
			
		||||
 | 
			
		||||
@ -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`)]' \
 | 
			
		||||
@ -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'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -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`)]' \
 | 
			
		||||
@ -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'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user