Merge pull request #3748 from MikeMcQuaid/pin-more-robust
Make pinning more robust
This commit is contained in:
commit
af8f8f11e3
@ -1,7 +1,6 @@
|
|||||||
#: * `pin` <formulae>:
|
#: * `pin` <formulae>:
|
||||||
#: Pin the specified <formulae>, preventing them from being upgraded when
|
#: Pin the specified <formulae>, preventing them from being upgraded when
|
||||||
#: issuing the `brew upgrade <formulae>` command (but can still be upgraded
|
#: issuing the `brew upgrade <formulae>` command. See also `unpin`.
|
||||||
#: as dependencies for other formulae). See also `unpin`.
|
|
||||||
|
|
||||||
require "formula"
|
require "formula"
|
||||||
|
|
||||||
|
@ -46,6 +46,16 @@ module Homebrew
|
|||||||
rm_pin rack
|
rm_pin rack
|
||||||
else
|
else
|
||||||
kegs.each do |keg|
|
kegs.each do |keg|
|
||||||
|
begin
|
||||||
|
f = Formulary.from_rack(rack)
|
||||||
|
if f.pinned?
|
||||||
|
onoe "#{f.full_name} is pinned. You must unpin it to uninstall."
|
||||||
|
next
|
||||||
|
end
|
||||||
|
rescue
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
keg.lock do
|
keg.lock do
|
||||||
puts "Uninstalling #{keg}... (#{keg.abv})"
|
puts "Uninstalling #{keg}... (#{keg.abv})"
|
||||||
keg.unlink
|
keg.unlink
|
||||||
|
@ -50,11 +50,8 @@ module Homebrew
|
|||||||
exit 1 if outdated.empty?
|
exit 1 if outdated.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
unless upgrade_pinned?
|
|
||||||
pinned = outdated.select(&:pinned?)
|
pinned = outdated.select(&:pinned?)
|
||||||
outdated -= pinned
|
outdated -= pinned
|
||||||
end
|
|
||||||
|
|
||||||
formulae_to_install = outdated.map(&:latest_formula)
|
formulae_to_install = outdated.map(&:latest_formula)
|
||||||
|
|
||||||
if formulae_to_install.empty?
|
if formulae_to_install.empty?
|
||||||
@ -64,8 +61,8 @@ module Homebrew
|
|||||||
puts formulae_to_install.map { |f| "#{f.full_specified_name} #{f.pkg_version}" } * ", "
|
puts formulae_to_install.map { |f| "#{f.full_specified_name} #{f.pkg_version}" } * ", "
|
||||||
end
|
end
|
||||||
|
|
||||||
unless upgrade_pinned? || pinned.empty?
|
unless pinned.empty?
|
||||||
oh1 "Not upgrading #{Formatter.pluralize(pinned.length, "pinned package")}:"
|
onoe "Not upgrading #{Formatter.pluralize(pinned.length, "pinned package")}:"
|
||||||
puts pinned.map { |f| "#{f.full_specified_name} #{f.pkg_version}" } * ", "
|
puts pinned.map { |f| "#{f.full_specified_name} #{f.pkg_version}" } * ", "
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -95,10 +92,6 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def upgrade_pinned?
|
|
||||||
!ARGV.named.empty?
|
|
||||||
end
|
|
||||||
|
|
||||||
def upgrade_formula(f)
|
def upgrade_formula(f)
|
||||||
if f.opt_prefix.directory?
|
if f.opt_prefix.directory?
|
||||||
keg = Keg.new(f.opt_prefix.resolved_path)
|
keg = Keg.new(f.opt_prefix.resolved_path)
|
||||||
@ -143,13 +136,6 @@ module Homebrew
|
|||||||
|
|
||||||
fi.install
|
fi.install
|
||||||
fi.finish
|
fi.finish
|
||||||
|
|
||||||
# If the formula was pinned, and we were force-upgrading it, unpin and
|
|
||||||
# pin it again to get a symlink pointing to the correct keg.
|
|
||||||
if f.pinned?
|
|
||||||
f.unpin
|
|
||||||
f.pin
|
|
||||||
end
|
|
||||||
rescue FormulaInstallationAlreadyAttemptedError
|
rescue FormulaInstallationAlreadyAttemptedError
|
||||||
# We already attempted to upgrade f as part of the dependency tree of
|
# We already attempted to upgrade f as part of the dependency tree of
|
||||||
# another formula. In that case, don't generate an error, just move on.
|
# another formula. In that case, don't generate an error, just move on.
|
||||||
|
@ -371,8 +371,7 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note
|
|||||||
|
|
||||||
* `pin` `formulae`:
|
* `pin` `formulae`:
|
||||||
Pin the specified `formulae`, preventing them from being upgraded when
|
Pin the specified `formulae`, preventing them from being upgraded when
|
||||||
issuing the `brew upgrade `formulae command (but can still be upgraded
|
issuing the `brew upgrade `formulae command. See also `unpin`.
|
||||||
as dependencies for other formulae). See also `unpin`.
|
|
||||||
|
|
||||||
* `postinstall` `formula`:
|
* `postinstall` `formula`:
|
||||||
Rerun the post-install steps for `formula`.
|
Rerun the post-install steps for `formula`.
|
||||||
|
@ -384,7 +384,7 @@ If \fB\-\-fetch\-HEAD\fR is passed, fetch the upstream repository to detect if t
|
|||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
\fBpin\fR \fIformulae\fR
|
\fBpin\fR \fIformulae\fR
|
||||||
Pin the specified \fIformulae\fR, preventing them from being upgraded when issuing the \fBbrew upgrade <formulae>\fR command (but can still be upgraded as dependencies for other formulae)\. See also \fBunpin\fR\.
|
Pin the specified \fIformulae\fR, preventing them from being upgraded when issuing the \fBbrew upgrade <formulae>\fR command\. See also \fBunpin\fR\.
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
\fBpostinstall\fR \fIformula\fR
|
\fBpostinstall\fR \fIformula\fR
|
||||||
|
Loading…
x
Reference in New Issue
Block a user