Revert "Improve @-versioned formulae linking."
This commit is contained in:
parent
5c2714f068
commit
099af8cf9c
@ -4,7 +4,6 @@
|
|||||||
require "ostruct"
|
require "ostruct"
|
||||||
require "caveats"
|
require "caveats"
|
||||||
require "cli/parser"
|
require "cli/parser"
|
||||||
require "unlink"
|
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module_function
|
||||||
@ -67,27 +66,26 @@ module Homebrew
|
|||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
formula = keg.to_formula
|
|
||||||
|
|
||||||
if keg_only
|
if keg_only
|
||||||
if Homebrew.default_prefix? && formula.keg_only_reason.by_macos?
|
if Homebrew.default_prefix?
|
||||||
caveats = Caveats.new(formula)
|
f = keg.to_formula
|
||||||
|
if f.keg_only_reason.by_macos?
|
||||||
|
caveats = Caveats.new(f)
|
||||||
opoo <<~EOS
|
opoo <<~EOS
|
||||||
Refusing to link macOS provided/shadowed software: #{keg.name}
|
Refusing to link macOS provided/shadowed software: #{keg.name}
|
||||||
#{caveats.keg_only_text(skip_reason: true).strip}
|
#{caveats.keg_only_text(skip_reason: true).strip}
|
||||||
EOS
|
EOS
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if !formula.keg_only_reason.versioned_formula? && !args.force?
|
unless args.force?
|
||||||
opoo "#{keg.name} is keg-only and must be linked with --force"
|
opoo "#{keg.name} is keg-only and must be linked with --force"
|
||||||
puts_keg_only_path_message(keg)
|
puts_keg_only_path_message(keg)
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Unlink.unlink_versioned_formulae(formula, verbose: args.verbose?)
|
|
||||||
|
|
||||||
keg.lock do
|
keg.lock do
|
||||||
print "Linking #{keg}... "
|
print "Linking #{keg}... "
|
||||||
puts if args.verbose?
|
puts if args.verbose?
|
||||||
|
@ -17,7 +17,6 @@ module Homebrew
|
|||||||
EOS
|
EOS
|
||||||
|
|
||||||
named 2
|
named 2
|
||||||
hide_from_man_page!
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -29,8 +28,6 @@ module Homebrew
|
|||||||
|
|
||||||
odie "#{name} not found in the Cellar." unless rack.directory?
|
odie "#{name} not found in the Cellar." unless rack.directory?
|
||||||
|
|
||||||
# odeprecated "`brew switch`", "`brew link` @-versioned formulae"
|
|
||||||
|
|
||||||
versions = rack.subdirs
|
versions = rack.subdirs
|
||||||
.map { |d| Keg.new(d).version }
|
.map { |d| Keg.new(d).version }
|
||||||
.sort
|
.sort
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
require "ostruct"
|
require "ostruct"
|
||||||
require "cli/parser"
|
require "cli/parser"
|
||||||
require "unlink"
|
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module_function
|
||||||
@ -37,7 +36,11 @@ module Homebrew
|
|||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
Unlink.unlink(keg, dry_run: args.dry_run?, verbose: args.verbose?)
|
keg.lock do
|
||||||
|
print "Unlinking #{keg}... "
|
||||||
|
puts if args.verbose?
|
||||||
|
puts "#{keg.unlink(**options)} symlinks removed"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -414,12 +414,12 @@ class Formula
|
|||||||
name.include?("@")
|
name.include?("@")
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns any `@`-versioned formulae for any formula (including versioned formulae).
|
# Returns any `@`-versioned formulae for an non-`@`-versioned formula.
|
||||||
def versioned_formulae
|
def versioned_formulae
|
||||||
Pathname.glob(path.to_s.gsub(/(@[\d.]+)?\.rb$/, "@*.rb")).map do |versioned_path|
|
return [] if versioned_formula?
|
||||||
next if versioned_path == path
|
|
||||||
|
|
||||||
Formula[versioned_path.basename(".rb").to_s]
|
Pathname.glob(path.to_s.gsub(/\.rb$/, "@*.rb")).map do |path|
|
||||||
|
Formula[path.basename(".rb").to_s]
|
||||||
rescue FormulaUnavailableError
|
rescue FormulaUnavailableError
|
||||||
nil
|
nil
|
||||||
end.compact.sort_by(&:version).reverse
|
end.compact.sort_by(&:version).reverse
|
||||||
|
@ -22,7 +22,6 @@ require "cmd/install"
|
|||||||
require "find"
|
require "find"
|
||||||
require "utils/spdx"
|
require "utils/spdx"
|
||||||
require "deprecate_disable"
|
require "deprecate_disable"
|
||||||
require "unlink"
|
|
||||||
|
|
||||||
# Installer for a formula.
|
# Installer for a formula.
|
||||||
#
|
#
|
||||||
@ -885,8 +884,6 @@ class FormulaInstaller
|
|||||||
keg.remove_linked_keg_record
|
keg.remove_linked_keg_record
|
||||||
end
|
end
|
||||||
|
|
||||||
Homebrew::Unlink.unlink_versioned_formulae(formula, verbose: verbose?)
|
|
||||||
|
|
||||||
link_overwrite_backup = {} # Hash: conflict file -> backup file
|
link_overwrite_backup = {} # Hash: conflict file -> backup file
|
||||||
backup_dir = HOMEBREW_CACHE/"Backup"
|
backup_dir = HOMEBREW_CACHE/"Backup"
|
||||||
|
|
||||||
|
@ -335,7 +335,6 @@ class Keg
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: refactor to use keyword arguments.
|
|
||||||
def unlink(**options)
|
def unlink(**options)
|
||||||
ObserverPathnameExtension.reset_counts!
|
ObserverPathnameExtension.reset_counts!
|
||||||
|
|
||||||
@ -449,7 +448,6 @@ class Keg
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: refactor to use keyword arguments.
|
|
||||||
def link(**options)
|
def link(**options)
|
||||||
raise AlreadyLinkedError, self if linked_keg_record.directory?
|
raise AlreadyLinkedError, self if linked_keg_record.directory?
|
||||||
|
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
# typed: false
|
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
module Homebrew
|
|
||||||
# Provides helper methods for unlinking formulae and kegs with consistent output.
|
|
||||||
module Unlink
|
|
||||||
module_function
|
|
||||||
|
|
||||||
def unlink_versioned_formulae(formula, verbose: false)
|
|
||||||
formula.versioned_formulae
|
|
||||||
.select(&:linked?)
|
|
||||||
.map(&:any_installed_keg)
|
|
||||||
.compact
|
|
||||||
.select(&:directory?)
|
|
||||||
.each do |keg|
|
|
||||||
unlink(keg, verbose: verbose)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def unlink(keg, dry_run: false, verbose: false)
|
|
||||||
options = { dry_run: dry_run, verbose: verbose }
|
|
||||||
|
|
||||||
keg.lock do
|
|
||||||
print "Unlinking #{keg}... "
|
|
||||||
puts if verbose
|
|
||||||
puts "#{keg.unlink(**options)} symlinks removed"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
@ -537,6 +537,10 @@ Print export statements. When run in a shell, this installation of Homebrew will
|
|||||||
The variables `HOMEBREW_PREFIX`, `HOMEBREW_CELLAR` and `HOMEBREW_REPOSITORY` are also exported to avoid querying them multiple times.
|
The variables `HOMEBREW_PREFIX`, `HOMEBREW_CELLAR` and `HOMEBREW_REPOSITORY` are also exported to avoid querying them multiple times.
|
||||||
Consider adding evaluation of this command's output to your dotfiles (e.g. `~/.profile`, `~/.bash_profile`, or `~/.zprofile`) with: `eval $(brew shellenv)`
|
Consider adding evaluation of this command's output to your dotfiles (e.g. `~/.profile`, `~/.bash_profile`, or `~/.zprofile`) with: `eval $(brew shellenv)`
|
||||||
|
|
||||||
|
### `switch` *`formula`* *`version`*
|
||||||
|
|
||||||
|
Symlink all of the specified *`version`* of *`formula`*'s installation into Homebrew's prefix.
|
||||||
|
|
||||||
### `tap` [*`options`*] [*`user`*`/`*`repo`*] [*`URL`*]
|
### `tap` [*`options`*] [*`user`*`/`*`repo`*] [*`URL`*]
|
||||||
|
|
||||||
Tap a formula repository.
|
Tap a formula repository.
|
||||||
|
@ -773,6 +773,9 @@ Print export statements\. When run in a shell, this installation of Homebrew wil
|
|||||||
.P
|
.P
|
||||||
The variables \fBHOMEBREW_PREFIX\fR, \fBHOMEBREW_CELLAR\fR and \fBHOMEBREW_REPOSITORY\fR are also exported to avoid querying them multiple times\. Consider adding evaluation of this command\'s output to your dotfiles (e\.g\. \fB~/\.profile\fR, \fB~/\.bash_profile\fR, or \fB~/\.zprofile\fR) with: \fBeval $(brew shellenv)\fR
|
The variables \fBHOMEBREW_PREFIX\fR, \fBHOMEBREW_CELLAR\fR and \fBHOMEBREW_REPOSITORY\fR are also exported to avoid querying them multiple times\. Consider adding evaluation of this command\'s output to your dotfiles (e\.g\. \fB~/\.profile\fR, \fB~/\.bash_profile\fR, or \fB~/\.zprofile\fR) with: \fBeval $(brew shellenv)\fR
|
||||||
.
|
.
|
||||||
|
.SS "\fBswitch\fR \fIformula\fR \fIversion\fR"
|
||||||
|
Symlink all of the specified \fIversion\fR of \fIformula\fR\'s installation into Homebrew\'s prefix\.
|
||||||
|
.
|
||||||
.SS "\fBtap\fR [\fIoptions\fR] [\fIuser\fR\fB/\fR\fIrepo\fR] [\fIURL\fR]"
|
.SS "\fBtap\fR [\fIoptions\fR] [\fIuser\fR\fB/\fR\fIrepo\fR] [\fIURL\fR]"
|
||||||
Tap a formula repository\.
|
Tap a formula repository\.
|
||||||
.
|
.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user