add deprecate module
This commit is contained in:
parent
f527f03fb5
commit
7a62973de2
@ -315,6 +315,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
def install_formula(f)
|
||||
opoo "#{f.name} has been deprecated" if f.is_deprecated?
|
||||
f.print_tap_action
|
||||
build_options = f.build
|
||||
|
||||
|
||||
@ -61,6 +61,7 @@ module Homebrew
|
||||
onoe "#{f.full_name} is pinned. You must unpin it to reinstall."
|
||||
next
|
||||
end
|
||||
opoo "#{f.name} has been deprecated" if f.is_deprecated?
|
||||
Migrator.migrate_if_needed(f)
|
||||
reinstall_formula(f)
|
||||
Cleanup.install_formula_clean!(f)
|
||||
|
||||
@ -150,6 +150,8 @@ module Homebrew
|
||||
def upgrade_formula(f)
|
||||
return if args.dry_run?
|
||||
|
||||
opoo "#{f.name} has been deprecated" if f.is_deprecated?
|
||||
|
||||
if f.opt_prefix.directory?
|
||||
keg = Keg.new(f.opt_prefix.resolved_path)
|
||||
keg_had_linked_opt = true
|
||||
|
||||
@ -51,6 +51,7 @@ class Formula
|
||||
include FileUtils
|
||||
include Utils::Inreplace
|
||||
include Utils::Shell
|
||||
include Utils::Deprecate
|
||||
extend Enumerable
|
||||
extend Forwardable
|
||||
extend Cachable
|
||||
@ -175,6 +176,16 @@ class Formula
|
||||
attr_accessor :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
|
||||
def initialize(name, path, spec, alias_path: nil)
|
||||
@name = name
|
||||
@ -211,6 +222,8 @@ class Formula
|
||||
@follow_installed_alias = true
|
||||
@prefix_returns_versioned_prefix = false
|
||||
@oldname_lock = nil
|
||||
@is_deprecated = false
|
||||
@is_disabled = false
|
||||
end
|
||||
|
||||
# @private
|
||||
|
||||
@ -13,6 +13,7 @@ require "utils/link"
|
||||
require "utils/popen"
|
||||
require "utils/svn"
|
||||
require "utils/tty"
|
||||
require "utils/deprecate"
|
||||
require "tap_constants"
|
||||
require "time"
|
||||
|
||||
|
||||
35
Library/Homebrew/utils/deprecate.rb
Normal file
35
Library/Homebrew/utils/deprecate.rb
Normal file
@ -0,0 +1,35 @@
|
||||
# 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