Tweak formula deprecation/disabling.
This commit is contained in:
parent
4121659413
commit
3effcc4dff
@ -315,7 +315,6 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def install_formula(f)
|
def install_formula(f)
|
||||||
opoo "#{f.name} has been deprecated" if f.is_deprecated?
|
|
||||||
f.print_tap_action
|
f.print_tap_action
|
||||||
build_options = f.build
|
build_options = f.build
|
||||||
|
|
||||||
|
|||||||
@ -61,7 +61,6 @@ module Homebrew
|
|||||||
onoe "#{f.full_name} is pinned. You must unpin it to reinstall."
|
onoe "#{f.full_name} is pinned. You must unpin it to reinstall."
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
opoo "#{f.name} has been deprecated" if f.is_deprecated?
|
|
||||||
Migrator.migrate_if_needed(f)
|
Migrator.migrate_if_needed(f)
|
||||||
reinstall_formula(f)
|
reinstall_formula(f)
|
||||||
Cleanup.install_formula_clean!(f)
|
Cleanup.install_formula_clean!(f)
|
||||||
|
|||||||
@ -150,8 +150,6 @@ module Homebrew
|
|||||||
def upgrade_formula(f)
|
def upgrade_formula(f)
|
||||||
return if args.dry_run?
|
return if args.dry_run?
|
||||||
|
|
||||||
opoo "#{f.name} has been deprecated" if f.is_deprecated?
|
|
||||||
|
|
||||||
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)
|
||||||
keg_had_linked_opt = true
|
keg_had_linked_opt = true
|
||||||
|
|||||||
@ -53,7 +53,6 @@ class Formula
|
|||||||
include Utils::Inreplace
|
include Utils::Inreplace
|
||||||
include Utils::Shebang
|
include Utils::Shebang
|
||||||
include Utils::Shell
|
include Utils::Shell
|
||||||
include Utils::Deprecate
|
|
||||||
extend Enumerable
|
extend Enumerable
|
||||||
extend Forwardable
|
extend Forwardable
|
||||||
extend Cachable
|
extend Cachable
|
||||||
@ -178,16 +177,6 @@ class Formula
|
|||||||
attr_accessor :follow_installed_alias
|
attr_accessor :follow_installed_alias
|
||||||
alias follow_installed_alias? follow_installed_alias
|
alias follow_installed_alias? follow_installed_alias
|
||||||
|
|
||||||
# A Boolean indicating whether this formula is deprecated or not
|
|
||||||
# Defaults to false
|
|
||||||
attr_accessor :is_deprecated
|
|
||||||
alias is_deprecated? is_deprecated
|
|
||||||
|
|
||||||
# A Boolean indicating whether this formula is disabled
|
|
||||||
# Defaults to false
|
|
||||||
attr_accessor :is_disabled
|
|
||||||
alias is_disabled? is_disabled
|
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def initialize(name, path, spec, alias_path: nil)
|
def initialize(name, path, spec, alias_path: nil)
|
||||||
@name = name
|
@name = name
|
||||||
@ -224,8 +213,6 @@ class Formula
|
|||||||
@follow_installed_alias = true
|
@follow_installed_alias = true
|
||||||
@prefix_returns_versioned_prefix = false
|
@prefix_returns_versioned_prefix = false
|
||||||
@oldname_lock = nil
|
@oldname_lock = nil
|
||||||
@is_deprecated = false
|
|
||||||
@is_disabled = false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
@ -1118,6 +1105,20 @@ class Formula
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Whether this {Formula} is deprecated (i.e. warns on installation).
|
||||||
|
# Defaults to false.
|
||||||
|
# @return [Boolean]
|
||||||
|
def deprecated?
|
||||||
|
self.class.deprecated?
|
||||||
|
end
|
||||||
|
|
||||||
|
# Whether this {Formula} is disabled (i.e. cannot be installed).
|
||||||
|
# Defaults to false.
|
||||||
|
# @return [Boolean]
|
||||||
|
def disabled?
|
||||||
|
self.class.disabled?
|
||||||
|
end
|
||||||
|
|
||||||
def skip_cxxstdlib_check?
|
def skip_cxxstdlib_check?
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
@ -2618,6 +2619,34 @@ class Formula
|
|||||||
@pour_bottle_check.instance_eval(&block)
|
@pour_bottle_check.instance_eval(&block)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Deprecates a {Formula} so a warning is shown on each installation.
|
||||||
|
def deprecate!(date: nil)
|
||||||
|
return if date.present? && Date.parse(date) > Date.today
|
||||||
|
|
||||||
|
@deprecated = true
|
||||||
|
end
|
||||||
|
|
||||||
|
# Whether this {Formula} is deprecated (i.e. warns on installation).
|
||||||
|
# Defaults to false.
|
||||||
|
# @return [Boolean]
|
||||||
|
def deprecated?
|
||||||
|
@deprecated == true
|
||||||
|
end
|
||||||
|
|
||||||
|
# Disables a {Formula} so it cannot be installed.
|
||||||
|
def disable!(date: nil)
|
||||||
|
return if date.present? && Date.parse(date) > Date.today
|
||||||
|
|
||||||
|
@disabled = true
|
||||||
|
end
|
||||||
|
|
||||||
|
# Whether this {Formula} is disabled (i.e. cannot be installed).
|
||||||
|
# Defaults to false.
|
||||||
|
# @return [Boolean]
|
||||||
|
def disabled?
|
||||||
|
@disabled == true
|
||||||
|
end
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def link_overwrite(*paths)
|
def link_overwrite(*paths)
|
||||||
paths.flatten!
|
paths.flatten!
|
||||||
|
|||||||
@ -161,6 +161,12 @@ class FormulaInstaller
|
|||||||
def check_install_sanity
|
def check_install_sanity
|
||||||
raise FormulaInstallationAlreadyAttemptedError, formula if self.class.attempted.include?(formula)
|
raise FormulaInstallationAlreadyAttemptedError, formula if self.class.attempted.include?(formula)
|
||||||
|
|
||||||
|
if formula.deprecated?
|
||||||
|
opoo "#{formula.full_name} has been deprecated!"
|
||||||
|
elsif formula.disabled?
|
||||||
|
odie "#{formula.full_name} has been disabled!"
|
||||||
|
end
|
||||||
|
|
||||||
return if ignore_deps?
|
return if ignore_deps?
|
||||||
|
|
||||||
recursive_deps = formula.recursive_dependencies
|
recursive_deps = formula.recursive_dependencies
|
||||||
|
|||||||
@ -13,7 +13,6 @@ require "utils/link"
|
|||||||
require "utils/popen"
|
require "utils/popen"
|
||||||
require "utils/svn"
|
require "utils/svn"
|
||||||
require "utils/tty"
|
require "utils/tty"
|
||||||
require "utils/deprecate"
|
|
||||||
require "tap_constants"
|
require "tap_constants"
|
||||||
require "time"
|
require "time"
|
||||||
|
|
||||||
|
|||||||
@ -1,35 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
module Utils
|
|
||||||
module Deprecate
|
|
||||||
# This module is common for both formulae and casks.
|
|
||||||
# To-do : Add support for casks + add disable method
|
|
||||||
|
|
||||||
def deprecate
|
|
||||||
self.is_deprecated = true
|
|
||||||
|
|
||||||
# deprecate all formulae dependent on this deprecated formula
|
|
||||||
all_formulae = ObjectSpace.each_object(Class).select { |klass| klass < Formula }
|
|
||||||
all_formulae.each do |f|
|
|
||||||
dependencies = f.recursive_dependencies.map(&:name)
|
|
||||||
f.is_deprecated = true if (dependencies.include? self.name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Deprecation can be revoked if the underlying problem is fixed
|
|
||||||
def revoke_deprecation
|
|
||||||
self.is_deprecated = false
|
|
||||||
|
|
||||||
# revoke deprecation from dependents as well
|
|
||||||
all_formulae = ObjectSpace.each_object(Class).select { |klass| klass < Formula }
|
|
||||||
all_formulae.each do |f|
|
|
||||||
dependencies = f.recursive_dependencies.map(&:name)
|
|
||||||
revoke = true
|
|
||||||
dependencies.each do |d|
|
|
||||||
revoke = !(d != self && d.is_deprecated?)
|
|
||||||
end
|
|
||||||
f.is_deprecated = false if revoke && (dependencies.include? self.name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Loading…
x
Reference in New Issue
Block a user