diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index e033259d55..c92a5e4583 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1148,12 +1148,24 @@ class Formula # @return [Boolean] delegate deprecated?: :"self.class" + # The reason this {Formula} is deprecated. + # Returns `nil` if no reason is specified or the formula is not deprecated. + # @method deprecation_reason + # @return [String] + delegate deprecation_reason: :"self.class" + # Whether this {Formula} is disabled (i.e. cannot be installed). # Defaults to false. # @method disabled? # @return [Boolean] delegate disabled?: :"self.class" + # The reason this {Formula} is disabled. + # Returns `nil` if no reason is specified or the formula is not disabled. + # @method disable_reason + # @return [String] + delegate disable_reason: :"self.class" + def skip_cxxstdlib_check? false end @@ -2766,9 +2778,11 @@ class Formula # Deprecates a {Formula} (on a given date, if provided) so a warning is # shown on each installation. If the date has not yet passed the formula # will not be deprecated. - def deprecate!(date: nil) + #
deprecate! date: "2020-08-27", because: "it is no longer maintained"
+ def deprecate!(date: nil, because: nil) return if date.present? && Date.parse(date) > Date.today + @deprecation_reason = because if because.present? @deprecated = true end @@ -2779,15 +2793,23 @@ class Formula @deprecated == true end + # The reason for deprecation of a {Formula}. + # Returns `nil` if no reason was provided or the formula is not deprecated. + # @return [String] + attr_reader :deprecation_reason + # Disables a {Formula} (on a given date, if provided) so it cannot be # installed. If the date has not yet passed the formula # will be deprecated instead of disabled. - def disable!(date: nil) + #
disable! date: "2020-08-27", because: "it no longer builds"
+ def disable!(date: nil, because: nil) if date.present? && Date.parse(date) > Date.today + @deprecation_reason = because if because.present? @deprecated = true return end + @disable_reason = because if because.present? @disabled = true end @@ -2798,6 +2820,11 @@ class Formula @disabled == true end + # The reason for a {Formula} is disabled. + # Returns `nil` if no reason was provided or the formula is not disabled. + # @return [String] + attr_reader :disable_reason + # @private def link_overwrite(*paths) paths.flatten! diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 0da32495f1..1086373c12 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -203,9 +203,17 @@ class FormulaInstaller raise FormulaInstallationAlreadyAttemptedError, formula if self.class.attempted.include?(formula) if formula.deprecated? - opoo "#{formula.full_name} has been deprecated!" + if formula.deprecation_reason.present? + opoo "#{formula.full_name} has been deprecated because #{formula.deprecation_reason}!" + else + opoo "#{formula.full_name} has been deprecated!" + end elsif formula.disabled? - odie "#{formula.full_name} has been disabled!" + if formula.disable_reason.present? + odie "#{formula.full_name} has been disabled because #{formula.disable_reason}!" + else + odie "#{formula.full_name} has been disabled!" + end end return if ignore_deps?