diff --git a/Library/Homebrew/formula_auditor.rb b/Library/Homebrew/formula_auditor.rb index 66b6fc60f8..da49d50314 100644 --- a/Library/Homebrew/formula_auditor.rb +++ b/Library/Homebrew/formula_auditor.rb @@ -590,6 +590,33 @@ module Homebrew new_formula_problem "New formulae in homebrew/core should not have a `bottle do` block" end + def audit_eol + return unless @online + + return if formula.deprecated? || formula.disabled? + + name = if formula.versioned_formula? + formula.name.split("@").first + else + formula.name + end + + return if formula.tap&.audit_exception :eol_date_blocklist, name + + metadata = SharedAudits.eol_data(name, formula.version.major) + metadata ||= SharedAudits.eol_data(name, formula.version.major_minor) + + return if metadata.blank? || metadata["eol"] == false + + see_url = "see #{Formatter.url("https://endoflife.date/#{name}")}" + if metadata["eol"] == true + problem "Product is EOL, #{see_url}" + return + end + + problem "Product is EOL since #{metadata["eol"]}, #{see_url}" if Date.parse(metadata["eol"]) <= Date.today + end + def audit_github_repository_archived return if formula.deprecated? || formula.disabled? diff --git a/Library/Homebrew/utils/shared_audits.rb b/Library/Homebrew/utils/shared_audits.rb index f09156ee7e..6675022cdc 100644 --- a/Library/Homebrew/utils/shared_audits.rb +++ b/Library/Homebrew/utils/shared_audits.rb @@ -12,6 +12,16 @@ module SharedAudits module_function + def eol_data(product, cycle) + @eol_data ||= {} + @eol_data["#{product}/#{cycle}"] ||= begin + out, _, status = Utils::Curl.curl_output("--location", "https://endoflife.date/api/#{product}/#{cycle}.json") + json = JSON.parse(out) if status.success? + json = nil if json&.dig("message")&.include?("Product not found") + json + end + end + def github_repo_data(user, repo) @github_repo_data ||= {} @github_repo_data["#{user}/#{repo}"] ||= GitHub.repository(user, repo)