formula: pinned keg is not eligible for cleanup

If formula is pinned it shouldn't be eligible for cleanup.
Otherwise we can encounter the following behaviour:

1. Install <formula>
2. Pin <formula>
3. <formula> gets outdated
4. Install <other_formula> that depends on <formula>, which requires
up-to-date installation of <formula>. Thus, <formula> gets updated.
5. Now, if we cleanup <formula> we don't remove pin, so it points to
the keg which doesn't exist any longer. The right behaviour is not
to cleanup pinned kegs, which is done in this commit.

Also see #831 for further info.
This commit is contained in:
Vlad Shablinsky 2016-09-01 17:31:28 +03:00
parent 6622b565ee
commit 6cff426b4f

View File

@ -1611,6 +1611,8 @@ class Formula
eligible_kegs.each do |keg|
if keg.linked?
opoo "Skipping (old) #{keg} due to it being linked"
elsif pinned? && keg == Keg.new(@pin.path.resolved_path)
opoo "Skipping (old) #{keg} due to it being pinned"
else
eligible_for_cleanup << keg
end