Add deprecate! and disable! methods to the Cask DSL
This commit is contained in:
parent
a60c58c798
commit
036723a668
@ -331,6 +331,12 @@ module Cask
|
|||||||
"conflicts_with" => conflicts_with,
|
"conflicts_with" => conflicts_with,
|
||||||
"container" => container&.pairs,
|
"container" => container&.pairs,
|
||||||
"auto_updates" => auto_updates,
|
"auto_updates" => auto_updates,
|
||||||
|
"deprecated" => deprecated?,
|
||||||
|
"deprecation_date" => deprecation_date,
|
||||||
|
"deprecation_reason" => deprecation_reason,
|
||||||
|
"disabled" => disabled?,
|
||||||
|
"disable_date" => disable_date,
|
||||||
|
"disable_reason" => disable_reason,
|
||||||
"tap_git_head" => tap_git_head,
|
"tap_git_head" => tap_git_head,
|
||||||
"languages" => languages,
|
"languages" => languages,
|
||||||
"ruby_source_path" => ruby_source_path,
|
"ruby_source_path" => ruby_source_path,
|
||||||
|
|||||||
@ -84,6 +84,14 @@ module Cask
|
|||||||
:url,
|
:url,
|
||||||
:version,
|
:version,
|
||||||
:appdir,
|
:appdir,
|
||||||
|
:deprecate!,
|
||||||
|
:deprecated?,
|
||||||
|
:deprecation_date,
|
||||||
|
:deprecation_reason,
|
||||||
|
:disable!,
|
||||||
|
:disabled?,
|
||||||
|
:disable_date,
|
||||||
|
:disable_reason,
|
||||||
:discontinued?,
|
:discontinued?,
|
||||||
:livecheck,
|
:livecheck,
|
||||||
:livecheckable?,
|
:livecheckable?,
|
||||||
@ -96,9 +104,9 @@ module Cask
|
|||||||
extend Predicable
|
extend Predicable
|
||||||
include OnSystem::MacOSOnly
|
include OnSystem::MacOSOnly
|
||||||
|
|
||||||
attr_reader :cask, :token
|
attr_reader :cask, :token, :deprecation_date, :deprecation_reason, :disable_date, :disable_reason
|
||||||
|
|
||||||
attr_predicate :on_system_blocks_exist?
|
attr_predicate :on_system_blocks_exist?, :disabled?, :livecheckable?
|
||||||
|
|
||||||
def initialize(cask)
|
def initialize(cask)
|
||||||
@cask = cask
|
@cask = cask
|
||||||
@ -316,9 +324,15 @@ module Cask
|
|||||||
end
|
end
|
||||||
|
|
||||||
def discontinued?
|
def discontinued?
|
||||||
|
# odeprecated "`discontinued?`", "`deprecated?` or `disabled?`"
|
||||||
@caveats&.discontinued? == true
|
@caveats&.discontinued? == true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# TODO: replace with with attr_predicate once discontinued? is disabled
|
||||||
|
def deprecated?
|
||||||
|
@deprecated == true || @caveats&.discontinued? == true
|
||||||
|
end
|
||||||
|
|
||||||
# @api public
|
# @api public
|
||||||
def auto_updates(auto_updates = nil)
|
def auto_updates(auto_updates = nil)
|
||||||
set_unique_stanza(:auto_updates, auto_updates.nil?) { auto_updates }
|
set_unique_stanza(:auto_updates, auto_updates.nil?) { auto_updates }
|
||||||
@ -337,8 +351,27 @@ module Cask
|
|||||||
@livecheck.instance_eval(&block)
|
@livecheck.instance_eval(&block)
|
||||||
end
|
end
|
||||||
|
|
||||||
def livecheckable?
|
# @api public
|
||||||
@livecheckable == true
|
def deprecate!(date:, because:)
|
||||||
|
@deprecation_date = Date.parse(date)
|
||||||
|
return if @deprecation_date > Date.today
|
||||||
|
|
||||||
|
@deprecation_reason = because
|
||||||
|
@deprecated = true
|
||||||
|
end
|
||||||
|
|
||||||
|
# @api public
|
||||||
|
def disable!(date:, because:)
|
||||||
|
@disable_date = Date.parse(date)
|
||||||
|
|
||||||
|
if @disable_date > Date.today
|
||||||
|
@deprecation_reason = because
|
||||||
|
@deprecated = true
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
@disable_reason = because
|
||||||
|
@disabled = true
|
||||||
end
|
end
|
||||||
|
|
||||||
ORDINARY_ARTIFACT_CLASSES.each do |klass|
|
ORDINARY_ARTIFACT_CLASSES.each do |klass|
|
||||||
|
|||||||
@ -7,7 +7,12 @@
|
|||||||
module DeprecateDisable
|
module DeprecateDisable
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
DEPRECATE_DISABLE_REASONS = {
|
SHARED_DEPRECATE_DISABLE_REASONS = {
|
||||||
|
repo_archived: "has an archived upstream repository",
|
||||||
|
repo_removed: "has a removed upstream repository",
|
||||||
|
}.freeze
|
||||||
|
|
||||||
|
FORMULA_DEPRECATE_DISABLE_REASONS = {
|
||||||
does_not_build: "does not build",
|
does_not_build: "does not build",
|
||||||
no_license: "has no license",
|
no_license: "has no license",
|
||||||
repo_archived: "has an archived upstream repository",
|
repo_archived: "has an archived upstream repository",
|
||||||
@ -20,20 +25,32 @@ module DeprecateDisable
|
|||||||
"a different checksum than the current one. " \
|
"a different checksum than the current one. " \
|
||||||
"Upstream's repository might have been compromised. " \
|
"Upstream's repository might have been compromised. " \
|
||||||
"We can re-package this once upstream has confirmed that they retagged their release",
|
"We can re-package this once upstream has confirmed that they retagged their release",
|
||||||
|
**SHARED_DEPRECATE_DISABLE_REASONS,
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
def deprecate_disable_info(formula)
|
CASK_DEPRECATE_DISABLE_REASONS = {
|
||||||
if formula.deprecated?
|
discontinued: "is discontinued upstream",
|
||||||
|
unsigned_artifact: "has an unsigned binary which prevents it from running on Apple Silicon devices " \
|
||||||
|
"under standard macOS security policy",
|
||||||
|
**SHARED_DEPRECATE_DISABLE_REASONS,
|
||||||
|
}.freeze
|
||||||
|
|
||||||
|
def deprecate_disable_info(formula_or_cask)
|
||||||
|
if formula_or_cask.deprecated?
|
||||||
type = :deprecated
|
type = :deprecated
|
||||||
reason = formula.deprecation_reason
|
reason = formula_or_cask.deprecation_reason
|
||||||
elsif formula.disabled?
|
elsif formula_or_cask.disabled?
|
||||||
type = :disabled
|
type = :disabled
|
||||||
reason = formula.disable_reason
|
reason = formula_or_cask.disable_reason
|
||||||
else
|
else
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
reason = DEPRECATE_DISABLE_REASONS[reason] if DEPRECATE_DISABLE_REASONS.key? reason
|
reason = if formula_or_cask.is_a?(Formula) && FORMULA_DEPRECATE_DISABLE_REASONS.key?(reason)
|
||||||
|
FORMULA_DEPRECATE_DISABLE_REASONS[reason]
|
||||||
|
elsif formula_or_cask.is_a?(Cask::Cask) && CASK_DEPRECATE_DISABLE_REASONS.key?(reason)
|
||||||
|
CASK_DEPRECATE_DISABLE_REASONS[reason]
|
||||||
|
end
|
||||||
|
|
||||||
[type, reason]
|
[type, reason]
|
||||||
end
|
end
|
||||||
|
|||||||
@ -3550,7 +3550,7 @@ class Formula
|
|||||||
# <pre>deprecate! date: "2020-08-27", because: :unmaintained</pre>
|
# <pre>deprecate! date: "2020-08-27", because: :unmaintained</pre>
|
||||||
# <pre>deprecate! date: "2020-08-27", because: "has been replaced by foo"</pre>
|
# <pre>deprecate! date: "2020-08-27", because: "has been replaced by foo"</pre>
|
||||||
# @see https://docs.brew.sh/Deprecating-Disabling-and-Removing-Formulae
|
# @see https://docs.brew.sh/Deprecating-Disabling-and-Removing-Formulae
|
||||||
# @see DeprecateDisable::DEPRECATE_DISABLE_REASONS
|
# @see DeprecateDisable::FORMULA_DEPRECATE_DISABLE_REASONS
|
||||||
def deprecate!(date:, because:)
|
def deprecate!(date:, because:)
|
||||||
@deprecation_date = Date.parse(date)
|
@deprecation_date = Date.parse(date)
|
||||||
return if @deprecation_date > Date.today
|
return if @deprecation_date > Date.today
|
||||||
@ -3585,7 +3585,7 @@ class Formula
|
|||||||
# <pre>disable! date: "2020-08-27", because: :does_not_build</pre>
|
# <pre>disable! date: "2020-08-27", because: :does_not_build</pre>
|
||||||
# <pre>disable! date: "2020-08-27", because: "has been replaced by foo"</pre>
|
# <pre>disable! date: "2020-08-27", because: "has been replaced by foo"</pre>
|
||||||
# @see https://docs.brew.sh/Deprecating-Disabling-and-Removing-Formulae
|
# @see https://docs.brew.sh/Deprecating-Disabling-and-Removing-Formulae
|
||||||
# @see DeprecateDisable::DEPRECATE_DISABLE_REASONS
|
# @see DeprecateDisable::FORMULA_DEPRECATE_DISABLE_REASONS
|
||||||
def disable!(date:, because:)
|
def disable!(date:, because:)
|
||||||
@disable_date = Date.parse(date)
|
@disable_date = Date.parse(date)
|
||||||
|
|
||||||
|
|||||||
@ -412,7 +412,7 @@ module Homebrew
|
|||||||
return if formula.disabled?
|
return if formula.disabled?
|
||||||
|
|
||||||
return if formula.deprecated? &&
|
return if formula.deprecated? &&
|
||||||
formula.deprecation_reason != DeprecateDisable::DEPRECATE_DISABLE_REASONS[:versioned_formula]
|
formula.deprecation_reason != DeprecateDisable::FORMULA_DEPRECATE_DISABLE_REASONS[:versioned_formula]
|
||||||
|
|
||||||
problem <<~EOS
|
problem <<~EOS
|
||||||
#{formula.full_name} contains conflicting version recursive dependencies:
|
#{formula.full_name} contains conflicting version recursive dependencies:
|
||||||
|
|||||||
@ -464,7 +464,7 @@ module Formulary
|
|||||||
|
|
||||||
def self.convert_to_deprecate_disable_reason_string_or_symbol(string)
|
def self.convert_to_deprecate_disable_reason_string_or_symbol(string)
|
||||||
require "deprecate_disable"
|
require "deprecate_disable"
|
||||||
return string unless DeprecateDisable::DEPRECATE_DISABLE_REASONS.keys.map(&:to_s).include?(string)
|
return string unless DeprecateDisable::FORMULARY_DEPRECATE_DISABLE_REASONS.keys.map(&:to_s).include?(string)
|
||||||
|
|
||||||
string.to_sym
|
string.to_sym
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user