aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorMike McQuaid2017-07-28 11:41:12 +0100
committerMike McQuaid2017-07-28 11:41:12 +0100
commit1651647a3dc9dbc03ed3c5da06090228db4cd1a0 (patch)
treeac8447a3b4636df3365c3ce77e926d8c667aa176 /Library/Homebrew
parentfe35bb32e8f9afdd9dfeea6a657104b6a1d450bb (diff)
downloadbrew-1651647a3dc9dbc03ed3c5da06090228db4cd1a0.tar.bz2
keg: correctly cleanup old aliases.
Cleanup old, versioned aliases and tap aliases folders when unlinking or uninstalling a keg.
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/keg.rb43
1 files changed, 32 insertions, 11 deletions
diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb
index b52269e30..8fcbecfbd 100644
--- a/Library/Homebrew/keg.rb
+++ b/Library/Homebrew/keg.rb
@@ -237,13 +237,37 @@ class Keg
opt_record.symlink? && path == opt_record.resolved_path
end
- def remove_opt_record
- opt_record.unlink
- aliases.each do |a|
- alias_symlink = opt_record.parent/a
- next if !alias_symlink.symlink? && !alias_symlink.exist?
+ def remove_old_aliases
+ opt = opt_record.parent
+
+ tap = begin
+ to_formula.tap
+ rescue FormulaUnavailableError, TapFormulaAmbiguityError,
+ TapFormulaWithOldnameAmbiguityError
+ # If the formula can't be found, just ignore aliases for now.
+ nil
+ end
+
+ if tap
+ bad_tap_opt = opt/tap.user
+ FileUtils.rm_rf bad_tap_opt if bad_tap_opt.directory?
+ end
+
+ Pathname.glob("#{opt_record}@*").each do |a|
+ a = a.basename
+ next if aliases.include?(a)
+
+ alias_symlink = opt/a
+ if alias_symlink.symlink? && alias_symlink.exist?
+ next if rack != alias_symlink.realpath.parent
+ end
+
alias_symlink.delete
end
+ end
+
+ def remove_opt_record
+ opt_record.unlink
opt_record.parent.rmdir_if_possible
end
@@ -251,6 +275,7 @@ class Keg
path.rmtree
path.parent.rmdir_if_possible
remove_opt_record if optlinked?
+ remove_old_aliases
remove_oldname_opt_record
end
@@ -277,6 +302,7 @@ class Keg
dst.uninstall_info if dst.to_s =~ INFOFILE_RX
dst.unlink
+ remove_old_aliases
Find.prune if src.directory?
end
end
@@ -468,12 +494,7 @@ class Keg
end
def aliases
- formula = Formulary.from_rack(rack)
- aliases = formula.aliases
- return aliases if formula.stable?
- aliases.reject { |a| a.include?("@") }
- rescue FormulaUnavailableError
- []
+ Tab.for_keg(self).aliases || []
end
def optlink(mode = OpenStruct.new)