Merge branch 'master' into undeclared_runtime_dependencies

This commit is contained in:
Mike McQuaid 2018-04-25 10:41:43 +01:00 committed by GitHub
commit 598bbd4c72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
255 changed files with 2897 additions and 3719 deletions

View File

@ -88,3 +88,7 @@ Style/HashSyntax:
# so many of these in formulae but none in here # so many of these in formulae but none in here
Style/TrailingBodyOnMethodDefinition: Style/TrailingBodyOnMethodDefinition:
Enabled: true Enabled: true
Rspec/ExpectActual:
Exclude:
- 'test/missing_formula_spec.rb'

View File

@ -32,7 +32,7 @@ class PATH
end end
def to_ary def to_ary
@paths @paths.dup.to_ary
end end
alias to_a to_ary alias to_a to_ary

View File

@ -14,12 +14,13 @@ end
require "pathname" require "pathname"
HOMEBREW_LIBRARY_PATH = Pathname.new(__FILE__).realpath.parent HOMEBREW_LIBRARY_PATH = Pathname.new(__FILE__).realpath.parent
require "English" require "English"
unless $LOAD_PATH.include?(HOMEBREW_LIBRARY_PATH.to_s) unless $LOAD_PATH.include?(HOMEBREW_LIBRARY_PATH.to_s)
$LOAD_PATH.unshift(HOMEBREW_LIBRARY_PATH.to_s) $LOAD_PATH.unshift(HOMEBREW_LIBRARY_PATH.to_s)
end end
require "global" require "global"
require "tap"
if ARGV == %w[--version] || ARGV == %w[-v] if ARGV == %w[--version] || ARGV == %w[-v]
puts "Homebrew #{HOMEBREW_VERSION}" puts "Homebrew #{HOMEBREW_VERSION}"

View File

@ -1,4 +1,3 @@
require "set"
class BuildEnvironment class BuildEnvironment
def initialize(*settings) def initialize(*settings)

View File

@ -1,5 +1,4 @@
require "hardware" require "hardware"
require "utils"
require "hbc/artifact" require "hbc/artifact"
require "hbc/audit" require "hbc/audit"
@ -20,8 +19,6 @@ require "hbc/locations"
require "hbc/config" require "hbc/config"
require "hbc/macos" require "hbc/macos"
require "hbc/pkg" require "hbc/pkg"
require "hbc/qualified_token"
require "hbc/scopes"
require "hbc/staged" require "hbc/staged"
require "hbc/system_command" require "hbc/system_command"
require "hbc/topological_hash" require "hbc/topological_hash"
@ -32,7 +29,6 @@ require "hbc/version"
module Hbc module Hbc
include Locations include Locations
include Scopes
include Utils include Utils
def self.init def self.init

View File

@ -1,4 +1,3 @@
require "pathname"
require "timeout" require "timeout"
require "hbc/artifact/abstract_artifact" require "hbc/artifact/abstract_artifact"

View File

@ -3,11 +3,20 @@ require "hbc/metadata"
module Hbc module Hbc
class Cask class Cask
extend Enumerable
extend Forwardable extend Forwardable
include Metadata include Metadata
attr_reader :token, :sourcefile_path, :config attr_reader :token, :sourcefile_path, :config
def self.each
return to_enum unless block_given?
Tap.flat_map(&:cask_files).each do |f|
yield CaskLoader::FromTapPathLoader.new(f).load
end
end
def tap def tap
return super if block_given? # Object#tap return super if block_given? # Object#tap
@tap @tap
@ -43,11 +52,13 @@ module Hbc
end end
def full_name def full_name
if @tap.nil? || @tap == Hbc.default_tap return token if tap == Hbc.default_tap
token qualified_token
else end
"#{@tap}/#{token}"
end def qualified_token
return token if tap.nil?
"#{tap.name}/#{token}"
end end
def installed? def installed?

View File

@ -15,5 +15,17 @@ module Hbc
SystemCommand.run("/usr/sbin/chown", args: [Utils.current_user, Hbc.caskroom], sudo: sudo) SystemCommand.run("/usr/sbin/chown", args: [Utils.current_user, Hbc.caskroom], sudo: sudo)
SystemCommand.run("/usr/bin/chgrp", args: ["admin", Hbc.caskroom], sudo: sudo) SystemCommand.run("/usr/bin/chgrp", args: ["admin", Hbc.caskroom], sudo: sudo)
end end
def casks
Pathname.glob(Hbc.caskroom.join("*")).sort.select(&:directory?).map do |path|
token = path.basename.to_s
if tap_path = CaskLoader.tap_paths(token).first
next CaskLoader::FromTapPathLoader.new(tap_path).load
end
CaskLoader::FromPathLoader.new(Pathname.glob(path.join(".metadata/*/*/*/*.rb")).first).load
end
end
end end
end end

View File

@ -9,7 +9,7 @@ module Hbc
end end
def run def run
failed_casks = casks(alternative: -> { Hbc.all }) failed_casks = casks(alternative: -> { Cask.to_a })
.reject { |cask| audit(cask) } .reject { |cask| audit(cask) }
return if failed_casks.empty? return if failed_casks.empty?

View File

@ -60,16 +60,12 @@ module Hbc
end end
def self.repo_info(cask) def self.repo_info(cask)
user, repo, token = QualifiedToken.parse(Hbc.all_tokens.detect { |t| t.split("/").last == cask.token }) return if cask.tap.nil?
return if user.nil? || repo.nil? url = if cask.tap.custom_remote? && !cask.tap.remote.nil?
cask.tap.remote
remote_tap = Tap.fetch(user, repo)
url = if remote_tap.custom_remote? && !remote_tap.remote.nil?
remote_tap.remote
else else
"#{remote_tap.default_remote}/blob/master/Casks/#{token}.rb" "#{cask.tap.default_remote}/blob/master/Casks/#{cask.token}.rb"
end end
puts "From: #{Formatter.url(url)}" puts "From: #{Formatter.url(url)}"

View File

@ -58,7 +58,7 @@ module Hbc
@stanza = :artifacts @stanza = :artifacts
end end
casks(alternative: -> { Hbc.all }).each do |cask| casks(alternative: -> { Cask.to_a }).each do |cask|
print "#{cask}\t" if table? print "#{cask}\t" if table?
begin begin

View File

@ -37,7 +37,7 @@ module Hbc
end end
def list_installed def list_installed
installed_casks = Hbc.installed installed_casks = Caskroom.casks
if one? if one?
puts installed_casks.map(&:to_s) puts installed_casks.map(&:to_s)

View File

@ -10,7 +10,7 @@ module Hbc
end end
def run def run
casks(alternative: -> { Hbc.installed }).each do |cask| casks(alternative: -> { Caskroom.casks }).each do |cask|
odebug "Checking update info of Cask #{cask}" odebug "Checking update info of Cask #{cask}"
self.class.list_if_outdated(cask, greedy?, verbose?) self.class.list_if_outdated(cask, greedy?, verbose?)
end end

View File

@ -3,7 +3,7 @@ module Hbc
class Search < AbstractCommand class Search < AbstractCommand
def run def run
if args.empty? if args.empty?
puts Formatter.columns(CLI.nice_listing(Hbc.all_tokens)) puts Formatter.columns(CLI.nice_listing(Cask.map(&:qualified_token)))
else else
results = self.class.search(*args) results = self.class.search(*args)
self.class.render_results(*results) self.class.render_results(*results)
@ -30,6 +30,7 @@ module Hbc
opoo "Error searching on GitHub: #{error}\n" opoo "Error searching on GitHub: #{error}\n"
[] []
end end
matches.map do |match| matches.map do |match|
tap = Tap.fetch(match["repository"]["full_name"]) tap = Tap.fetch(match["repository"]["full_name"])
next if tap.installed? next if tap.installed?
@ -42,7 +43,7 @@ module Hbc
partial_matches = [] partial_matches = []
search_term = arguments.join(" ") search_term = arguments.join(" ")
search_regexp = extract_regexp arguments.first search_regexp = extract_regexp arguments.first
all_tokens = CLI.nice_listing(Hbc.all_tokens) all_tokens = CLI.nice_listing(Cask.map(&:qualified_token))
if search_regexp if search_regexp
search_term = arguments.first search_term = arguments.first
partial_matches = all_tokens.grep(/#{search_regexp}/i) partial_matches = all_tokens.grep(/#{search_regexp}/i)
@ -65,7 +66,7 @@ module Hbc
return return
end end
if !exact_match && partial_matches.empty? if !exact_match && partial_matches.empty? && remote_matches.empty?
puts "No Cask found for \"#{search_term}\"." puts "No Cask found for \"#{search_term}\"."
return return
end end

View File

@ -27,7 +27,7 @@ module Hbc
def cask_paths def cask_paths
@cask_paths ||= if args.empty? @cask_paths ||= if args.empty?
Hbc.all_tapped_cask_dirs Tap.map(&:cask_dir).select(&:directory?)
elsif args.any? { |file| File.exist?(file) } elsif args.any? { |file| File.exist?(file) }
args args
else else

View File

@ -13,7 +13,7 @@ module Hbc
def run def run
outdated_casks = casks(alternative: lambda { outdated_casks = casks(alternative: lambda {
Hbc.installed.select do |cask| Caskroom.casks.select do |cask|
cask.outdated?(greedy?) cask.outdated?(greedy?)
end end
}).select { |cask| cask.outdated?(true) } }).select { |cask| cask.outdated?(true) }

View File

@ -1,5 +1,3 @@
require "tmpdir"
require "hbc/container/base" require "hbc/container/base"
module Hbc module Hbc

View File

@ -1,4 +1,3 @@
require "tmpdir"
require "hbc/container/base" require "hbc/container/base"

View File

@ -1,4 +1,3 @@
require "set"
require "tempfile" require "tempfile"
require "hbc/container/base" require "hbc/container/base"

View File

@ -1,4 +1,3 @@
require "tmpdir"
require "hbc/container/base" require "hbc/container/base"

View File

@ -1,4 +1,3 @@
require "tmpdir"
require "hbc/container/base" require "hbc/container/base"

View File

@ -1,4 +1,3 @@
require "tmpdir"
require "hbc/container/base" require "hbc/container/base"

View File

@ -1,4 +1,3 @@
require "tmpdir"
require "hbc/container/base" require "hbc/container/base"

View File

@ -1,4 +1,3 @@
require "tmpdir"
require "hbc/container/base" require "hbc/container/base"

View File

@ -1,4 +1,3 @@
require "tmpdir"
require "hbc/container/base" require "hbc/container/base"

View File

@ -1,4 +1,3 @@
require "tmpdir"
require "hbc/container/base" require "hbc/container/base"

View File

@ -1,4 +1,3 @@
require "set"
require "locale" require "locale"
require "hbc/artifact" require "hbc/artifact"

View File

@ -1,4 +1,3 @@
require "tap"
module Hbc module Hbc
module Locations module Locations

View File

@ -1,4 +1,3 @@
require "set"
require "os/mac/version" require "os/mac/version"
@ -239,26 +238,35 @@ module OS
# TODO: There should be a way to specify a containing # TODO: There should be a way to specify a containing
# directory under which nothing can be deleted. # directory under which nothing can be deleted.
UNDELETABLE_DIRS = [ UNDELETABLE_PATHS = [
"~/", "~/",
"~/Applications", "~/Applications",
"~/Applications/.localized",
"~/Desktop", "~/Desktop",
"~/Desktop/.localized",
"~/Documents", "~/Documents",
"~/Documents/.localized",
"~/Downloads", "~/Downloads",
"~/Downloads/.localized",
"~/Mail", "~/Mail",
"~/Movies", "~/Movies",
"~/Movies/.localized",
"~/Music", "~/Music",
"~/Music/.localized",
"~/Music/iTunes", "~/Music/iTunes",
"~/Music/iTunes/iTunes Music", "~/Music/iTunes/iTunes Music",
"~/Music/iTunes/Album Artwork", "~/Music/iTunes/Album Artwork",
"~/News", "~/News",
"~/Pictures", "~/Pictures",
"~/Pictures/.localized",
"~/Pictures/Desktops", "~/Pictures/Desktops",
"~/Pictures/Photo Booth", "~/Pictures/Photo Booth",
"~/Pictures/iChat Icons", "~/Pictures/iChat Icons",
"~/Pictures/iPhoto Library", "~/Pictures/iPhoto Library",
"~/Public", "~/Public",
"~/Public/.localized",
"~/Sites", "~/Sites",
"~/Sites/.localized",
"~/Library", "~/Library",
"~/Library/.localized", "~/Library/.localized",
"~/Library/Accessibility", "~/Library/Accessibility",
@ -365,17 +373,17 @@ module OS
"~/Library/Widgets", "~/Library/Widgets",
"~/Library/Workflows", "~/Library/Workflows",
] ]
.map { |x| Pathname(x.sub(%r{^~(?=(/|$))}, Dir.home)).expand_path } .map { |path| Pathname(path.sub(%r{^~(?=(/|$))}, Dir.home)).expand_path }
.to_set .to_set
.union(SYSTEM_DIRS) .union(SYSTEM_DIRS)
.freeze .freeze
def system_dir?(dir) def system_dir?(dir)
SYSTEM_DIRS.include?(Pathname.new(dir).expand_path) SYSTEM_DIRS.include?(Pathname.new(dir).expand_path)
end end
def undeletable?(dir) def undeletable?(path)
UNDELETABLE_DIRS.include?(Pathname.new(dir).expand_path) UNDELETABLE_PATHS.include?(Pathname.new(path).expand_path)
end end
end end
end end

View File

@ -22,7 +22,7 @@ module Hbc
end end
path = if timestamp == :latest path = if timestamp == :latest
Pathname.glob(metadata_versioned_path(version: version).join("*")).sort.last Pathname.glob(metadata_versioned_path(version: version).join("*")).max
else else
timestamp = new_timestamp if timestamp == :now timestamp = new_timestamp if timestamp == :now
metadata_versioned_path(version: version).join(timestamp) metadata_versioned_path(version: version).join(timestamp)

View File

@ -1,11 +0,0 @@
module Hbc
module QualifiedToken
def self.parse(arg)
return nil unless arg.is_a?(String)
return nil unless match = arg.downcase.match(HOMEBREW_TAP_CASK_REGEX)
user, repo, token = match.captures
odebug "[user, repo, token] might be [#{user}, #{repo}, #{token}]"
[user, repo, token]
end
end
end

View File

@ -1,47 +0,0 @@
module Hbc
module Scopes
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def all
all_tokens.map(&CaskLoader.public_method(:load))
end
def all_tapped_cask_dirs
Tap.map(&:cask_dir).select(&:directory?)
end
def all_tokens
Tap.flat_map do |t|
t.cask_files.map do |p|
"#{t.name}/#{File.basename(p, ".rb")}"
end
end
end
def installed
# CaskLoader.load has some DWIM which is slow. Optimize here
# by spoon-feeding CaskLoader.load fully-qualified paths.
# TODO: speed up Hbc::Source::Tapped (main perf drag is calling Hbc.all_tokens repeatedly)
# TODO: ability to specify expected source when calling CaskLoader.load (minor perf benefit)
Pathname.glob(caskroom.join("*"))
.sort
.map do |caskroom_path|
token = caskroom_path.basename.to_s
path_to_cask = all_tapped_cask_dirs.find do |tap_dir|
tap_dir.join("#{token}.rb").exist?
end
if path_to_cask
CaskLoader.load(path_to_cask.join("#{token}.rb"))
else
CaskLoader.load(token)
end
end
end
end
end
end

View File

@ -33,6 +33,7 @@ module Hbc
def set_ownership(paths, user: current_user, group: "staff") def set_ownership(paths, user: current_user, group: "staff")
full_paths = remove_nonexistent(paths) full_paths = remove_nonexistent(paths)
return if full_paths.empty? return if full_paths.empty?
ohai "Changing ownership of paths required by #{@cask}; your password may be necessary"
@command.run!("/usr/sbin/chown", args: ["-R", "--", "#{user}:#{group}"] + full_paths, @command.run!("/usr/sbin/chown", args: ["-R", "--", "#{user}:#{group}"] + full_paths,
sudo: true) sudo: true)
end end

View File

@ -4,17 +4,6 @@ require "stringio"
BUG_REPORTS_URL = "https://github.com/caskroom/homebrew-cask#reporting-bugs".freeze BUG_REPORTS_URL = "https://github.com/caskroom/homebrew-cask#reporting-bugs".freeze
class Buffer < StringIO
extend Predicable
attr_predicate :tty?
def initialize(tty = false)
super()
@tty = tty
end
end
# global methods # global methods
def odebug(title, *sput) def odebug(title, *sput)

View File

@ -1,4 +1,3 @@
require "forwardable"
require "language/python" require "language/python"
class Caveats class Caveats

View File

@ -11,16 +11,20 @@ module Homebrew
def initialize(&block) def initialize(&block)
@parser = OptionParser.new @parser = OptionParser.new
@parsed_args = OpenStruct.new @parsed_args = OpenStruct.new
# undefine tap to allow --tap argument
@parsed_args.instance_eval { undef tap }
instance_eval(&block) instance_eval(&block)
end end
def switch(*names, description: nil, env: nil) def switch(*names, description: nil, env: nil)
description = option_to_description(*names) if description.nil? description = option_to_description(*names) if description.nil?
names, env = common_switch(*names) if names.first.is_a?(Symbol) global_switch = names.first.is_a?(Symbol)
names, env = common_switch(*names) if global_switch
@parser.on(*names, description) do @parser.on(*names, description) do
enable_switch(*names) enable_switch(*names, global_switch)
end end
enable_switch(*names) if !env.nil? && !ENV["HOMEBREW_#{env.to_s.upcase}"].nil? enable_switch(*names, global_switch) if !env.nil? &&
!ENV["HOMEBREW_#{env.to_s.upcase}"].nil?
end end
def comma_array(name, description: nil) def comma_array(name, description: nil)
@ -30,14 +34,15 @@ module Homebrew
end end
end end
def flag(name, description: nil, required: false) def flag(name, description: nil)
if required if name.end_with? "="
option_required = OptionParser::REQUIRED_ARGUMENT required = OptionParser::REQUIRED_ARGUMENT
name.chomp! "="
else else
option_required = OptionParser::OPTIONAL_ARGUMENT required = OptionParser::OPTIONAL_ARGUMENT
end end
description = option_to_description(name) if description.nil? description = option_to_description(name) if description.nil?
@parser.on(name, description, option_required) do |option_value| @parser.on(name, description, required) do |option_value|
@parsed_args[option_to_name(name)] = option_value @parsed_args[option_to_name(name)] = option_value
end end
end end
@ -47,27 +52,33 @@ module Homebrew
end end
def option_to_description(*names) def option_to_description(*names)
names.map { |name| name.to_s.sub(/\A--?/, "").tr("-", " ") }.sort.last names.map { |name| name.to_s.sub(/\A--?/, "").tr("-", " ") }.max
end end
def parse(cmdline_args = ARGV) def parse(cmdline_args = ARGV)
@parser.parse!(cmdline_args) @parser.parse(cmdline_args)
@parsed_args @parsed_args
end end
private private
def enable_switch(*names) def enable_switch(*names, global_switch)
names.each do |name| names.each do |name|
if global_switch
Homebrew.args["#{option_to_name(name)}?"] = true
next
end
@parsed_args["#{option_to_name(name)}?"] = true @parsed_args["#{option_to_name(name)}?"] = true
end end
end end
# These are common/global switches accessible throughout Homebrew
def common_switch(name) def common_switch(name)
case name case name
when :quiet then [["-q", "--quiet"], :quiet] when :quiet then [["-q", "--quiet"], :quiet]
when :verbose then [["-v", "--verbose"], :verbose] when :verbose then [["-v", "--verbose"], :verbose]
when :debug then [["-d", "--debug"], :debug] when :debug then [["-d", "--debug"], :debug]
when :force then [["-f", "--force"], :force]
else name else name
end end
end end

View File

@ -4,8 +4,6 @@
#: * `--repository` <user>`/`<repo>: #: * `--repository` <user>`/`<repo>:
#: Display where tap <user>`/`<repo>'s directory is located. #: Display where tap <user>`/`<repo>'s directory is located.
require "tap"
module Homebrew module Homebrew
module_function module_function

View File

@ -12,7 +12,6 @@
#: deleted. If you want to delete those too: `rm -rf $(brew --cache)` #: deleted. If you want to delete those too: `rm -rf $(brew --cache)`
require "cleanup" require "cleanup"
require "utils"
module Homebrew module Homebrew
module_function module_function

View File

@ -28,7 +28,6 @@ module Homebrew
slow_checks = %w[ slow_checks = %w[
check_for_broken_symlinks check_for_broken_symlinks
check_missing_deps check_missing_deps
check_for_linked_keg_only_brews
] ]
methods = (checks.all.sort - slow_checks) + slow_checks methods = (checks.all.sort - slow_checks) + slow_checks
else else

View File

@ -119,7 +119,7 @@ module Homebrew
def create_issue(repo, title, body) def create_issue(repo, title, body)
url = "https://api.github.com/repos/#{repo}/issues" url = "https://api.github.com/repos/#{repo}/issues"
data = { "title" => title, "body" => body } data = { "title" => title, "body" => body }
scopes = GitHub::CREATE_ISSUE_SCOPES scopes = GitHub::CREATE_ISSUE_FORK_OR_PR_SCOPES
GitHub.open_api(url, data: data, scopes: scopes)["html_url"] GitHub.open_api(url, data: data, scopes: scopes)["html_url"]
end end

View File

@ -1,7 +1,7 @@
HOMEBREW_HELP = <<~EOS.freeze HOMEBREW_HELP = <<~EOS.freeze
Example usage: Example usage:
brew search [TEXT|/REGEX/] brew search [TEXT|/REGEX/]
brew (info|home|options) [FORMULA...] brew info [FORMULA...]
brew install FORMULA... brew install FORMULA...
brew update brew update
brew upgrade [FORMULA...] brew upgrade [FORMULA...]
@ -11,17 +11,17 @@ HOMEBREW_HELP = <<~EOS.freeze
Troubleshooting: Troubleshooting:
brew config brew config
brew doctor brew doctor
brew install -vd FORMULA brew install --verbose --debug FORMULA
Developers: Contributing:
brew create [URL [--no-fetch]] brew create [URL [--no-fetch]]
brew edit [FORMULA...] brew edit [FORMULA...]
https://docs.brew.sh/Formula-Cookbook
Further help: Further help:
man brew brew commands
brew help [COMMAND] brew help [COMMAND]
brew home man brew
https://docs.brew.sh
EOS EOS
# NOTE Keep the lenth of vanilla --help less than 25 lines! # NOTE Keep the lenth of vanilla --help less than 25 lines!

View File

@ -60,7 +60,7 @@ module Homebrew
rescue FormulaUnavailableError => e rescue FormulaUnavailableError => e
ofail e.message ofail e.message
# No formula with this name, try a missing formula lookup # No formula with this name, try a missing formula lookup
if (reason = Homebrew::MissingFormula.reason(f)) if (reason = MissingFormula.reason(f))
$stderr.puts reason $stderr.puts reason
end end
end end

View File

@ -71,7 +71,6 @@ require "missing_formula"
require "diagnostic" require "diagnostic"
require "cmd/search" require "cmd/search"
require "formula_installer" require "formula_installer"
require "tap"
require "hardware" require "hardware"
require "development_tools" require "development_tools"
@ -166,7 +165,8 @@ module Homebrew
formulae << f formulae << f
else else
opoo <<~EOS opoo <<~EOS
#{f.full_name} #{f.pkg_version} is already installed #{f.full_name} #{f.pkg_version} is already installed and up-to-date
To reinstall #{f.pkg_version}, run `brew reinstall #{f.name}`
EOS EOS
end end
elsif (ARGV.build_head? && new_head_installed) || prefix_installed elsif (ARGV.build_head? && new_head_installed) || prefix_installed
@ -190,12 +190,17 @@ module Homebrew
EOS EOS
elsif !f.linked? || f.keg_only? elsif !f.linked? || f.keg_only?
msg = <<~EOS msg = <<~EOS
#{msg}, it's just not linked. #{msg}, it's just not linked
You can use `brew link #{f}` to link this version. You can use `brew link #{f}` to link this version.
EOS EOS
elsif ARGV.only_deps? elsif ARGV.only_deps?
msg = nil msg = nil
formulae << f formulae << f
else
msg = <<~EOS
#{msg} and up-to-date
To reinstall #{f.pkg_version}, run `brew reinstall #{f.name}`
EOS
end end
opoo msg if msg opoo msg if msg
elsif !f.any_version_installed? && old_formula = f.old_installed_formulae.first elsif !f.any_version_installed? && old_formula = f.old_installed_formulae.first
@ -252,7 +257,7 @@ module Homebrew
end end
ofail e.message ofail e.message
if (reason = Homebrew::MissingFormula.reason(e.name)) if (reason = MissingFormula.reason(e.name))
$stderr.puts reason $stderr.puts reason
return return
end end

View File

@ -3,7 +3,6 @@
require "formula" require "formula"
require "tab" require "tab"
require "set"
module Homebrew module Homebrew
module_function module_function

View File

@ -1,67 +0,0 @@
#: @hide_from_man_page
#: * `linkapps` [`--local`] [<formulae>]:
#: Find installed formulae that provide `.app`-style macOS apps and symlink them
#: into `/Applications`, allowing for easier access (deprecated).
#:
#: Unfortunately `brew linkapps` cannot behave nicely with e.g. Spotlight using
#: either aliases or symlinks and Homebrew formulae do not build "proper" `.app`
#: bundles that can be relocated. Instead, please consider using `brew cask` and
#: migrate formulae using `.app`s to casks.
require "keg"
require "formula"
module Homebrew
module_function
def linkapps
odeprecated "'brew linkapps'"
target_dir = linkapps_target(local: ARGV.include?("--local"))
unless target_dir.directory?
opoo "#{target_dir} does not exist, stopping."
puts "Run `mkdir #{target_dir}` first."
exit 1
end
if ARGV.named.empty?
kegs = Formula.racks.map do |rack|
keg = rack.subdirs.map { |d| Keg.new(d) }
next if keg.empty?
keg.detect(&:linked?) || keg.max_by(&:version)
end
else
kegs = ARGV.kegs
end
link_count = 0
kegs.each do |keg|
keg.apps.each do |app|
puts "Linking: #{app}"
target_app = target_dir/app.basename
if target_app.exist? && !target_app.symlink?
onoe "#{target_app} already exists, skipping."
next
end
# We prefer system `ln` over `FileUtils.ln_sf` because the latter seems
# to have weird failure conditions (that were observed in the past).
system "ln", "-sf", app, target_dir
link_count += 1
end
end
if link_count.zero?
puts "No apps linked to #{target_dir}" if ARGV.verbose?
else
puts "Linked #{Formatter.pluralize(link_count, "app")} to #{target_dir}"
end
end
def linkapps_target(opts = {})
local = opts.fetch(:local, false)
Pathname.new(local ? "~/Applications" : "/Applications").expand_path
end
end

View File

@ -4,6 +4,8 @@
#: #:
#: If `--hide=`<hidden> is passed, act as if none of <hidden> are installed. #: If `--hide=`<hidden> is passed, act as if none of <hidden> are installed.
#: <hidden> should be a comma-separated list of formulae. #: <hidden> should be a comma-separated list of formulae.
#:
#: `missing` exits with a non-zero status if any formulae are missing dependencies.
require "formula" require "formula"
require "tab" require "tab"
@ -25,6 +27,7 @@ module Homebrew
missing = f.missing_dependencies(hide: ARGV.values("hide")) missing = f.missing_dependencies(hide: ARGV.values("hide"))
next if missing.empty? next if missing.empty?
Homebrew.failed = true
print "#{f}: " if ff.size > 1 print "#{f}: " if ff.size > 1
puts missing.join(" ") puts missing.join(" ")
end end

View File

@ -1,15 +1,12 @@
#: * `prune` [`--dry-run`]: #: * `prune` [`--dry-run`]:
#: Remove dead symlinks from the Homebrew prefix. This is generally not #: Remove dead symlinks from the Homebrew prefix. This is generally not
#: needed, but can be useful when doing DIY installations. Also remove broken #: needed, but can be useful when doing DIY installations.
#: app symlinks from `/Applications` and `~/Applications` that were previously
#: created by `brew linkapps`.
#: #:
#: If `--dry-run` or `-n` is passed, show what would be removed, but do not #: If `--dry-run` or `-n` is passed, show what would be removed, but do not
#: actually remove anything. #: actually remove anything.
require "keg" require "keg"
require "cmd/tap" require "cmd/tap"
require "cmd/unlinkapps"
module Homebrew module Homebrew
module_function module_function
@ -49,17 +46,15 @@ module Homebrew
end end
end end
unless ARGV.dry_run? return if ARGV.dry_run?
if ObserverPathnameExtension.total.zero?
puts "Nothing pruned" if ARGV.verbose?
else
n, d = ObserverPathnameExtension.counts
print "Pruned #{n} symbolic links "
print "and #{d} directories " if d.positive?
puts "from #{HOMEBREW_PREFIX}"
end
end
unlinkapps_prune(dry_run: ARGV.dry_run?, quiet: true) if ObserverPathnameExtension.total.zero?
puts "Nothing pruned" if ARGV.verbose?
else
n, d = ObserverPathnameExtension.counts
print "Pruned #{n} symbolic links "
print "and #{d} directories " if d.positive?
puts "from #{HOMEBREW_PREFIX}"
end
end end
end end

View File

@ -15,8 +15,6 @@
require "formula" require "formula"
require "missing_formula" require "missing_formula"
require "utils"
require "official_taps"
require "descriptions" require "descriptions"
module Homebrew module Homebrew
@ -66,7 +64,7 @@ module Homebrew
count = local_results.length + tap_results.length count = local_results.length + tap_results.length
ohai "Searching blacklisted, migrated and deleted formulae..." ohai "Searching blacklisted, migrated and deleted formulae..."
if reason = Homebrew::MissingFormula.reason(query, silent: true) if reason = MissingFormula.reason(query, silent: true)
if count.positive? if count.positive?
puts puts
puts "If you meant #{query.inspect} specifically:" puts "If you meant #{query.inspect} specifically:"
@ -110,15 +108,22 @@ module Homebrew
$stderr.puts Formatter.headline("Searching taps on GitHub...", color: :blue) $stderr.puts Formatter.headline("Searching taps on GitHub...", color: :blue)
end end
valid_dirnames = ["Formula", "HomebrewFormula", "Casks", "."].freeze matches = begin
matches = GitHub.search_code(user: ["Homebrew", "caskroom"], filename: query, extension: "rb") GitHub.search_code(
user: ["Homebrew", "caskroom"],
path: ["Formula", "HomebrewFormula", "Casks", "."],
filename: query,
extension: "rb",
)
rescue GitHub::Error => error
opoo "Error searching on GitHub: #{error}\n"
[]
end
matches.map do |match| matches.map do |match|
dirname, filename = File.split(match["path"]) filename = File.basename(match["path"], ".rb")
next unless valid_dirnames.include?(dirname)
tap = Tap.fetch(match["repository"]["full_name"]) tap = Tap.fetch(match["repository"]["full_name"])
next if tap.installed? && match["repository"]["owner"]["login"] != "caskroom" next if tap.installed? && match["repository"]["owner"]["login"] != "caskroom"
"#{tap.name}/#{File.basename(filename, ".rb")}" "#{tap.name}/#{filename}"
end.compact end.compact
end end

View File

@ -19,7 +19,6 @@
#: #:
#: Exits with a non-zero status if any style violations are found. #: Exits with a non-zero status if any style violations are found.
require "utils"
require "json" require "json"
require "open3" require "open3"

View File

@ -1,5 +1,5 @@
#: * `switch` <name> <version>: #: * `switch` <formula> <version>:
#: Symlink all of the specific <version> of <name>'s install to Homebrew prefix. #: Symlink all of the specific <version> of <formula>'s install to Homebrew prefix.
require "formula" require "formula"
require "keg" require "keg"
@ -9,14 +9,15 @@ module Homebrew
module_function module_function
def switch def switch
if ARGV.named.length != 2 name = ARGV.first
onoe "Usage: brew switch <name> <version>"
usage = "Usage: brew switch <formula> <version>"
unless name
onoe usage
exit 1 exit 1
end end
name = ARGV.shift
version = ARGV.shift
rack = Formulary.to_rack(name) rack = Formulary.to_rack(name)
unless rack.directory? unless rack.directory?
@ -24,13 +25,21 @@ module Homebrew
exit 2 exit 2
end end
# Does the target version exist? versions = rack.subdirs
.map { |d| Keg.new(d).version }
.sort
.join(", ")
version = ARGV[1]
if !version || ARGV.named.length > 2
onoe usage
puts "#{name} installed versions: #{versions}"
exit 1
end
unless (rack/version).directory? unless (rack/version).directory?
onoe "#{name} does not have a version \"#{version}\" in the Cellar." onoe "#{name} does not have a version \"#{version}\" in the Cellar."
puts "#{name} installed versions: #{versions}"
versions = rack.subdirs.map { |d| Keg.new(d).version }.sort
puts "Versions available: #{versions.join(", ")}"
exit 3 exit 3
end end

View File

@ -15,8 +15,6 @@
#: See the docs for examples of using the JSON output: #: See the docs for examples of using the JSON output:
#: <https://docs.brew.sh/Querying-Brew> #: <https://docs.brew.sh/Querying-Brew>
require "tap"
module Homebrew module Homebrew
module_function module_function

View File

@ -2,8 +2,6 @@
#: Pin <tap>, prioritizing its formulae over core when formula names are supplied #: Pin <tap>, prioritizing its formulae over core when formula names are supplied
#: by the user. See also `tap-unpin`. #: by the user. See also `tap-unpin`.
require "tap"
module Homebrew module Homebrew
module_function module_function

View File

@ -1,8 +1,6 @@
#: * `tap-unpin` <tap>: #: * `tap-unpin` <tap>:
#: Unpin <tap> so its formulae are no longer prioritized. See also `tap-pin`. #: Unpin <tap> so its formulae are no longer prioritized. See also `tap-pin`.
require "tap"
module Homebrew module Homebrew
module_function module_function

View File

@ -1,7 +1,7 @@
#: * `tap`: #: * `tap`:
#: List all installed taps. #: List all installed taps.
#: #:
#: * `tap` [`--full`] <user>`/`<repo> [<URL>]: #: * `tap` [`--full`] [`--force-auto-update`] <user>`/`<repo> [<URL>]:
#: Tap a formula repository. #: Tap a formula repository.
#: #:
#: With <URL> unspecified, taps a formula repository from GitHub using HTTPS. #: With <URL> unspecified, taps a formula repository from GitHub using HTTPS.
@ -18,6 +18,10 @@
#: if `--full` is passed, a full clone will be used. To convert a shallow copy #: if `--full` is passed, a full clone will be used. To convert a shallow copy
#: to a full copy, you can retap passing `--full` without first untapping. #: to a full copy, you can retap passing `--full` without first untapping.
#: #:
#: By default, only taps hosted on GitHub are auto-updated (for performance
#: reasons). If `--force-auto-update` is passed, this tap will be auto-updated
#: even if it is not hosted on GitHub.
#:
#: `tap` is re-runnable and exits successfully if there's nothing to do. #: `tap` is re-runnable and exits successfully if there's nothing to do.
#: However, retapping with a different <URL> will cause an exception, so first #: However, retapping with a different <URL> will cause an exception, so first
#: `untap` if you need to modify the <URL>. #: `untap` if you need to modify the <URL>.
@ -25,14 +29,9 @@
#: * `tap` `--repair`: #: * `tap` `--repair`:
#: Migrate tapped formulae from symlink-based to directory-based structure. #: Migrate tapped formulae from symlink-based to directory-based structure.
#: #:
#: * `tap` `--list-official`:
#: List all official taps.
#:
#: * `tap` `--list-pinned`: #: * `tap` `--list-pinned`:
#: List all pinned taps. #: List all pinned taps.
require "tap"
module Homebrew module Homebrew
module_function module_function
@ -40,8 +39,7 @@ module Homebrew
if ARGV.include? "--repair" if ARGV.include? "--repair"
Tap.each(&:link_completions_and_manpages) Tap.each(&:link_completions_and_manpages)
elsif ARGV.include? "--list-official" elsif ARGV.include? "--list-official"
require "official_taps" odeprecated("brew tap --list-official")
puts OFFICIAL_TAPS.map { |t| "homebrew/#{t}" }
elsif ARGV.include? "--list-pinned" elsif ARGV.include? "--list-pinned"
puts Tap.select(&:pinned?).map(&:name) puts Tap.select(&:pinned?).map(&:name)
elsif ARGV.named.empty? elsif ARGV.named.empty?
@ -50,6 +48,7 @@ module Homebrew
tap = Tap.fetch(ARGV.named[0]) tap = Tap.fetch(ARGV.named[0])
begin begin
tap.install clone_target: ARGV.named[1], tap.install clone_target: ARGV.named[1],
force_auto_update: force_auto_update?,
full_clone: full_clone?, full_clone: full_clone?,
quiet: ARGV.quieter? quiet: ARGV.quieter?
rescue TapRemoteMismatchError => e rescue TapRemoteMismatchError => e
@ -62,4 +61,9 @@ module Homebrew
def full_clone? def full_clone?
ARGV.include?("--full") || ARGV.homebrew_developer? ARGV.include?("--full") || ARGV.homebrew_developer?
end end
def force_auto_update?
# if no relevant flag is present, return nil, meaning "no change"
true if ARGV.include?("--force-auto-update")
end
end end

View File

@ -1,79 +0,0 @@
#: @hide_from_man_page
#: * `unlinkapps` [`--local`] [`--dry-run`] [<formulae>]:
#: Remove symlinks created by `brew linkapps` from `/Applications` (deprecated).
#:
#: Unfortunately `brew linkapps` cannot behave nicely with e.g. Spotlight using
#: either aliases or symlinks and Homebrew formulae do not build "proper" `.app`
#: bundles that can be relocated. Instead, please consider using `brew cask` and
#: migrate formulae using `.app`s to casks.
require "cmd/linkapps"
module Homebrew
module_function
def unlinkapps
odeprecated "'brew unlinkapps'"
target_dir = linkapps_target(local: ARGV.include?("--local"))
unlinkapps_from_dir(target_dir, dry_run: ARGV.dry_run?)
end
def unlinkapps_prune(opts = {})
opts = opts.merge(prune: true)
unlinkapps_from_dir(linkapps_target(local: false), opts)
unlinkapps_from_dir(linkapps_target(local: true), opts)
end
def unlinkapps_from_dir(target_dir, opts = {})
return unless target_dir.directory?
dry_run = opts.fetch(:dry_run, false)
quiet = opts.fetch(:quiet, false)
apps = Pathname.glob("#{target_dir}/*.app").select do |app|
unlinkapps_unlink?(app, opts)
end
ObserverPathnameExtension.reset_counts!
app_kind = opts.fetch(:prune, false) ? " (broken link)" : ""
apps.each do |app|
app.extend(ObserverPathnameExtension)
if dry_run
puts "Would unlink#{app_kind}: #{app}"
else
puts "Unlinking#{app_kind}: #{app}" unless quiet
app.unlink
end
end
return if dry_run
if ObserverPathnameExtension.total.zero?
puts "No apps unlinked from #{target_dir}" if ARGV.verbose?
else
n = ObserverPathnameExtension.total
puts "Unlinked #{Formatter.pluralize(n, "app")} from #{target_dir}"
end
end
UNLINKAPPS_PREFIXES = %W[
#{HOMEBREW_CELLAR}/
#{HOMEBREW_PREFIX}/opt/
].freeze
def unlinkapps_unlink?(target_app, opts = {})
# Skip non-symlinks and symlinks that don't point into the Homebrew prefix.
app = target_app.readlink.to_s if target_app.symlink?
return false unless app&.start_with?(*UNLINKAPPS_PREFIXES)
if opts.fetch(:prune, false)
!File.exist?(app) # Remove only broken symlinks in prune mode.
elsif ARGV.named.empty?
true
else
ARGV.kegs.any? { |keg| app.start_with?("#{keg}/", "#{keg.opt_record}/") }
end
end
end

View File

@ -1,8 +1,6 @@
#: * `untap` <tap>: #: * `untap` <tap>:
#: Remove a tapped repository. #: Remove a tapped repository.
require "tap"
module Homebrew module Homebrew
module_function module_function

View File

@ -7,7 +7,6 @@ require "migrator"
require "formulary" require "formulary"
require "descriptions" require "descriptions"
require "cleanup" require "cleanup"
require "utils"
module Homebrew module Homebrew
module_function module_function

View File

@ -493,8 +493,12 @@ EOS
[[ -z "$HOMEBREW_UPDATE_FORCE" ]] && [[ "$UPSTREAM_SHA_HTTP_CODE" = "304" ]] && exit [[ -z "$HOMEBREW_UPDATE_FORCE" ]] && [[ "$UPSTREAM_SHA_HTTP_CODE" = "304" ]] && exit
elif [[ -n "$HOMEBREW_UPDATE_PREINSTALL" ]] elif [[ -n "$HOMEBREW_UPDATE_PREINSTALL" ]]
then then
# Don't try to do a `git fetch` that may take longer than expected. FORCE_AUTO_UPDATE="$(git config homebrew.forceautoupdate 2>/dev/null || echo "false")"
exit if [[ "$FORCE_AUTO_UPDATE" != "true" ]]
then
# Don't try to do a `git fetch` that may take longer than expected.
exit
fi
fi fi
if [[ -n "$HOMEBREW_VERBOSE" ]] if [[ -n "$HOMEBREW_VERBOSE" ]]

View File

@ -29,7 +29,7 @@ module Homebrew
Homebrew.perform_preinstall_checks Homebrew.perform_preinstall_checks
odeprecated "'brew upgrade --all'", "'brew upgrade'" if ARGV.include?("--all") odisabled "'brew upgrade --all'", "'brew upgrade'" if ARGV.include?("--all")
if ARGV.named.empty? if ARGV.named.empty?
outdated = Formula.installed.select do |f| outdated = Formula.installed.select do |f|
@ -67,7 +67,14 @@ module Homebrew
oh1 "No packages to upgrade" oh1 "No packages to upgrade"
else else
oh1 "Upgrading #{Formatter.pluralize(formulae_to_install.length, "outdated package")}, with result:" oh1 "Upgrading #{Formatter.pluralize(formulae_to_install.length, "outdated package")}, with result:"
puts formulae_to_install.map { |f| "#{f.full_specified_name} #{f.pkg_version}" } * ", " formulae_upgrades = formulae_to_install.map do |f|
if f.optlinked?
"#{f.full_specified_name} #{Keg.new(f.opt_prefix).version} -> #{f.pkg_version}"
else
"#{f.full_specified_name} #{f.pkg_version}"
end
end
puts formulae_upgrades.join(", ")
end end
# Sort keg_only before non-keg_only formulae to avoid any needless conflicts # Sort keg_only before non-keg_only formulae to avoid any needless conflicts

View File

@ -54,48 +54,19 @@ module Homebrew
used_formulae.all? do |ff| used_formulae.all? do |ff|
begin begin
deps = f.runtime_dependencies if only_installed_arg deps = f.runtime_dependencies if only_installed_arg
if recursive deps ||= if recursive
deps ||= recursive_includes(Dependency, f, includes, ignores) recursive_includes(Dependency, f, includes, ignores)
dep_formulae = deps.flat_map do |dep|
begin
dep.to_formula
rescue
[]
end
end
reqs_by_formula = ([f] + dep_formulae).flat_map do |formula|
formula.requirements.map { |req| [formula, req] }
end
reqs_by_formula.reject! do |dependent, req|
if req.recommended?
ignores.include?("recommended?") || dependent.build.without?(req)
elsif req.test?
!includes.include?("test?")
elsif req.optional?
!includes.include?("optional?") && !dependent.build.with?(req)
elsif req.build?
!includes.include?("build?")
end
end
reqs = reqs_by_formula.map(&:last)
else else
deps ||= reject_ignores(f.deps, ignores, includes) reject_ignores(f.deps, ignores, includes)
reqs = reject_ignores(f.requirements, ignores, includes)
end end
next true if deps.any? do |dep| deps.any? do |dep|
begin begin
dep.to_formula.full_name == ff.full_name dep.to_formula.full_name == ff.full_name
rescue rescue
dep.name == ff.name dep.name == ff.name
end end
end end
reqs.any? { |req| req.name == ff.name }
rescue FormulaUnavailableError rescue FormulaUnavailableError
# Silently ignore this case as we don't care about things used in # Silently ignore this case as we don't care about things used in
# taps that aren't currently tapped. # taps that aren't currently tapped.

View File

@ -47,7 +47,15 @@ fetch() {
local sha local sha
local temporary_path local temporary_path
curl_args=( curl_args=()
# do not load .curlrc unless requested (must be the first argument)
if [[ -z "$HOMEBREW_CURLRC" ]]
then
curl_args[${#curl_args[*]}]="-q"
fi
curl_args+=(
--fail --fail
--remote-time --remote-time
--location --location

View File

@ -1,32 +1,11 @@
require "compat/fails_with_llvm"
require "compat/tap"
require "compat/hbc" require "compat/hbc"
require "compat/formula" require "compat/formula"
require "compat/formula_specialties"
require "compat/formula_support" require "compat/formula_support"
require "compat/global"
require "compat/hardware"
require "compat/macos"
require "compat/md5"
require "compat/sha1"
require "compat/requirements" require "compat/requirements"
require "compat/version"
require "compat/download_strategy" require "compat/download_strategy"
require "compat/keg"
require "compat/pathname"
require "compat/dependency_collector" require "compat/dependency_collector"
require "compat/language/haskell"
require "compat/xcode"
require "compat/software_spec"
require "compat/utils"
require "compat/json"
require "compat/ARGV"
require "compat/build_options"
require "compat/tab"
require "compat/ENV/shared" require "compat/ENV/shared"
require "compat/ENV/std"
require "compat/ENV/super"
require "compat/utils/shell"
require "compat/extend/string" require "compat/extend/string"
require "compat/gpg" require "compat/gpg"
require "compat/dependable" require "compat/dependable"
require "compat/os/mac"

View File

@ -1,5 +0,0 @@
module HomebrewArgvExtension
def build_32_bit?
odisabled "ARGV.build_32_bit?"
end
end

View File

@ -1,10 +1,9 @@
module SharedEnvExtension module SharedEnvExtension
def j1 def j1
odeprecated "ENV.j1", "ENV.deparallelize" odisabled "ENV.j1", "ENV.deparallelize"
deparallelize
end end
def java_cache def java_cache
odeprecated "ENV.java_cache" odisabled "ENV.java_cache"
end end
end end

View File

@ -1,25 +0,0 @@
module Stdenv
def fast
odisabled "ENV.fast"
end
def O4
odisabled "ENV.O4"
end
def Og
odisabled "ENV.Og"
end
def gcc_4_0_1
odisabled "ENV.gcc_4_0_1", "ENV.gcc_4_0"
end
def gcc
odisabled "ENV.gcc", "ENV.gcc_4_2"
end
def libpng
odisabled "ENV.libpng", "ENV.x11"
end
end

View File

@ -1,45 +0,0 @@
module Superenv
def fast
odisabled "ENV.fast"
end
def O4
odisabled "ENV.O4"
end
def Og
odisabled "ENV.Og"
end
def gcc_4_0_1
odisabled "ENV.gcc_4_0_1", "ENV.gcc_4_0"
end
def gcc
odisabled "ENV.gcc", "ENV.gcc_4_2"
end
def libxml2
odisabled "ENV.libxml2"
end
def minimal_optimization
odisabled "ENV.minimal_optimization"
end
def no_optimization
odisabled "ENV.no_optimization"
end
def enable_warnings
odisabled "ENV.enable_warnings"
end
def macosxsdk
odisabled "ENV.macosxsdk"
end
def remove_macosxsdk
odisabled "ENV.remove_macosxsdk"
end
end

View File

@ -1,9 +0,0 @@
class BuildOptions
def build_32_bit?
odisabled "build.build_32_bit?"
end
def build_bottle?
odisabled "build.build_bottle?", "build.bottle?"
end
end

View File

@ -1,5 +1,6 @@
module Dependable module Dependable
def run? def run?
odeprecated "Dependable#run?"
tags.include? :run tags.include? :run
end end
end end

View File

@ -9,56 +9,42 @@ class DependencyCollector
def parse_string_spec(spec, tags) def parse_string_spec(spec, tags)
if (tag = tags.first) && LANGUAGE_MODULES.include?(tag) if (tag = tags.first) && LANGUAGE_MODULES.include?(tag)
odeprecated "'depends_on ... => #{tag.inspect}'" odisabled "'depends_on ... => #{tag.inspect}'"
LanguageModuleRequirement.new(tag, spec, tags[1])
else
super
end end
if tags.include?(:run)
odeprecated "'depends_on ... => :run'"
end
super
end end
def parse_symbol_spec(spec, tags) def parse_symbol_spec(spec, tags)
case spec case spec
when :clt when :clt
odeprecated "'depends_on :clt'" odisabled "'depends_on :clt'"
when :tex when :tex
odeprecated "'depends_on :tex'" odisabled "'depends_on :tex'"
TeXRequirement.new(tags)
when :autoconf, :automake, :bsdmake, :libtool
output_deprecation(spec)
autotools_dep(spec, tags)
when :cairo, :fontconfig, :freetype, :libpng, :pixman
output_deprecation(spec)
Dependency.new(spec.to_s, tags)
when :ant, :expat
output_deprecation(spec)
Dependency.new(spec.to_s, tags)
when :libltdl when :libltdl
output_deprecation("libtool") output_disabled(spec, "libtool")
Dependency.new("libtool", tags)
when :apr when :apr
output_deprecation(spec, "apr-util") output_disabled(spec, "apr-util")
Dependency.new("apr-util", tags)
when :fortran when :fortran
output_deprecation(spec, "gcc") output_disabled(spec, "gcc")
Dependency.new("gcc", tags)
when :gpg when :gpg
output_deprecation(spec, "gnupg") output_disabled(spec, "gnupg")
Dependency.new("gnupg", tags)
when :hg when :hg
output_deprecation(spec, "mercurial") output_disabled(spec, "mercurial")
Dependency.new("mercurial", tags)
when :mpi when :mpi
output_deprecation(spec, "open-mpi") output_disabled(spec, "open-mpi")
Dependency.new("open-mpi", tags)
when :python, :python2 when :python, :python2
output_deprecation(spec, "python@2") output_disabled(spec, "python@2")
Dependency.new("python@2", tags)
when :python3 when :python3
output_deprecation(spec, "python") output_disabled(spec, "python")
Dependency.new("python", tags) when :ant, :autoconf, :automake, :bsdmake, :cairo, :emacs, :expat,
when :emacs, :mysql, :perl, :postgresql, :rbenv, :ruby :fontconfig, :freetype, :libtool, :libpng, :mysql, :perl, :pixman,
output_deprecation(spec) :postgresql, :rbenv, :ruby
Dependency.new(spec.to_s, tags) output_disabled(spec)
else else
super super
end end
@ -66,14 +52,9 @@ class DependencyCollector
private private
def autotools_dep(spec, tags) def output_disabled(dependency, new_dependency = dependency)
tags << :build odisabled "'depends_on :#{dependency}'",
Dependency.new(spec.to_s, tags) "'depends_on \"#{new_dependency}\"'"
end
def output_deprecation(dependency, new_dependency = dependency)
odeprecated "'depends_on :#{dependency}'",
"'depends_on \"#{new_dependency}\"'"
end end
end end

View File

@ -1,7 +1,7 @@
class String class String
def undent def undent
odeprecated "<<-EOS.undent", "<<~EOS" odisabled "<<-EOS.undent", "<<~EOS"
gsub(/^[ \t]{#{(slice(/^[ \t]+/) || '').length}}/, "") self
end end
alias unindent undent alias unindent undent

View File

@ -1,9 +0,0 @@
class Formula
def fails_with_llvm(_msg = nil, _data = nil)
odisabled "Formula#fails_with_llvm in install"
end
def self.fails_with_llvm(_msg = nil, _data = {})
odisabled "Formula.fails_with_llvm"
end
end

View File

@ -1,74 +1,5 @@
module FormulaCompat
def x11_installed?
odisabled "Formula#x11_installed?", "MacOS::X11.installed?"
end
def snow_leopard_64?
odisabled "Formula#snow_leopard_64?", "MacOS.prefer_64_bit?"
end
end
class Formula class Formula
include FormulaCompat def rake(*)
extend FormulaCompat odisabled "FileUtils#rake", "system \"rake\""
def std_cmake_parameters
odisabled "Formula#std_cmake_parameters", "Formula#std_cmake_args"
end
def cxxstdlib_check(_)
odisabled "Formula#cxxstdlib_check in install",
"Formula.cxxstdlib_check outside install"
end
def self.bottle_sha1(*)
odisabled "Formula.bottle_sha1"
end
def self.all
odisabled "Formula.all", "Formula.map"
end
def self.canonical_name(_)
odisabled "Formula.canonical_name", "Formulary.canonical_name"
end
def self.class_s(_)
odisabled "Formula.class_s", "Formulary.class_s"
end
def self.factory(_)
odisabled "Formula.factory", "Formulary.factory"
end
def self.require_universal_deps
odisabled "Formula.require_universal_deps"
end
def self.path(_)
odisabled "Formula.path", "Formulary.core_path"
end
DATA = :DATA
def patches
# Don't print deprecation warning because this method is inherited
# when used.
{}
end
def python(_options = {}, &_)
odisabled "Formula#python"
end
alias python2 python
alias python3 python
def startup_plist
odisabled "Formula#startup_plist", "Formula#plist"
end
def rake(*args)
odeprecated "FileUtils#rake", "system \"rake\""
system "rake", *args
end end
end end

View File

@ -1,23 +0,0 @@
class ScriptFileFormula < Formula
def install
odisabled "ScriptFileFormula#install", "Formula#install"
end
end
class GithubGistFormula < ScriptFileFormula
def self.url(_val)
odisabled "GithubGistFormula.url", "Formula.url"
end
end
class AmazonWebServicesFormula < Formula
def install
odisabled "AmazonWebServicesFormula#install", "Formula#install"
end
alias standard_install install
# Use this method to generate standard caveats.
def standard_instructions(_, _)
odisabled "AmazonWebServicesFormula#standard_instructions", "Formula#caveats"
end
end

View File

@ -2,17 +2,80 @@ require "formula_support"
class KegOnlyReason class KegOnlyReason
module Compat module Compat
def valid?
case @reason
when :provided_by_osx
odisabled "keg_only :provided_by_osx", "keg_only :provided_by_macos"
when :shadowed_by_osx
odisabled "keg_only :shadowed_by_osx", "keg_only :shadowed_by_macos"
when :provided_pre_mountain_lion
odeprecated "keg_only :provided_pre_mountain_lion"
MacOS.version < :mountain_lion
when :provided_pre_mavericks
odeprecated "keg_only :provided_pre_mavericks"
MacOS.version < :mavericks
when :provided_pre_el_capitan
odeprecated "keg_only :provided_pre_el_capitan"
MacOS.version < :el_capitan
when :provided_pre_high_sierra
odeprecated "keg_only :provided_pre_high_sierra"
MacOS.version < :high_sierra
when :provided_until_xcode43
odeprecated "keg_only :provided_until_xcode43"
MacOS::Xcode.version < "4.3"
when :provided_until_xcode5
odeprecated "keg_only :provided_until_xcode5"
MacOS::Xcode.version < "5.0"
else
super
end
end
def to_s def to_s
case @reason case @reason
when :provided_by_osx when :provided_by_osx
odeprecated "keg_only :provided_by_osx", "keg_only :provided_by_macos" odisabled "keg_only :provided_by_osx", "keg_only :provided_by_macos"
@reason = :provided_by_macos
when :shadowed_by_osx when :shadowed_by_osx
odeprecated "keg_only :shadowed_by_osx", "keg_only :shadowed_by_macos" odisabled "keg_only :shadowed_by_osx", "keg_only :shadowed_by_macos"
@reason = :shadowed_by_macos when :provided_pre_mountain_lion
end odeprecated "keg_only :provided_pre_mountain_lion"
super <<~EOS
macOS already provides this software in versions before Mountain Lion
EOS
when :provided_pre_mavericks
odeprecated "keg_only :provided_pre_mavericks"
<<~EOS
macOS already provides this software in versions before Mavericks
EOS
when :provided_pre_el_capitan
odeprecated "keg_only :provided_pre_el_capitan"
<<~EOS
macOS already provides this software in versions before El Capitan
EOS
when :provided_pre_high_sierra
odeprecated "keg_only :provided_pre_high_sierra"
<<~EOS
macOS already provides this software in versions before High Sierra
EOS
when :provided_until_xcode43
odeprecated "keg_only :provided_until_xcode43"
<<~EOS
Xcode provides this software prior to version 4.3
EOS
when :provided_until_xcode5
odeprecated "keg_only :provided_until_xcode5"
<<~EOS
Xcode provides this software prior to version 5
EOS
else
super
end.to_s.strip
end end
end end

View File

@ -1,15 +0,0 @@
module Homebrew
module_function
def method_missing(method, *args, &block)
if instance_methods.include?(method)
odisabled "#{self}##{method}", "'module_function' or 'def self.#{method}' to convert it to a class method"
end
super
end
def respond_to_missing?(method, include_private = false)
return true if method_defined?(method)
super(method, include_private)
end
end

View File

@ -1,27 +1,24 @@
require "utils"
module Gpg module Gpg
module_function module_function
def executable def executable
odeprecated "Gpg.executable", 'which "gpg"' odisabled "Gpg.executable", 'which "gpg"'
which "gpg"
end end
def available? def available?
odeprecated "Gpg.available?", 'which "gpg"' odisabled "Gpg.available?", 'which "gpg"'
File.executable?(executable.to_s)
end end
def create_test_key(_) def create_test_key(_)
odeprecated "Gpg.create_test_key" odisabled "Gpg.create_test_key"
end end
def cleanup_test_processes! def cleanup_test_processes!
odeprecated "Gpg.cleanup_test_processes!" odisabled "Gpg.cleanup_test_processes!"
end end
def test(_) def test(_)
odeprecated "Gpg.test" odisabled "Gpg.test"
end end
end end

View File

@ -1,35 +0,0 @@
module Hardware
class << self
def is_32_bit?
odisabled "Hardware.is_32_bit?", "Hardware::CPU.is_32_bit?"
end
def is_64_bit?
odisabled "Hardware.is_64_bit?", "Hardware::CPU.is_64_bit?"
end
def bits
odisabled "Hardware.bits", "Hardware::CPU.bits"
end
def cpu_type
odisabled "Hardware.cpu_type", "Hardware::CPU.type"
end
def cpu_family
odisabled "Hardware.cpu_family", "Hardware::CPU.family"
end
def intel_family
odisabled "Hardware.intel_family", "Hardware::CPU.family"
end
def ppc_family
odisabled "Hardware.ppc_family", "Hardware::CPU.family"
end
def processor_count
odisabled "Hardware.processor_count", "Hardware::CPU.cores"
end
end
end

View File

@ -1,19 +0,0 @@
require "json"
module Utils
module JSON
module_function
def load(_)
odisabled "Utils::JSON.load", "JSON.parse"
end
def dump(_)
odisabled "Utils::JSON.dump", "JSON.generate"
end
def stringify_keys(_)
odisabled "Utils::JSON.stringify_keys"
end
end
end

View File

@ -1,5 +0,0 @@
class Keg
def fname
odisabled "Keg#fname", "Keg#name"
end
end

View File

@ -1,9 +0,0 @@
module Language
module Haskell
module Cabal
def cabal_clean_lib
odisabled "Language::Haskell::Cabal#cabal_clean_lib"
end
end
end
end

View File

@ -1,124 +0,0 @@
require "development_tools"
if OS.mac?
MACOS_FULL_VERSION = OS::Mac.full_version.to_s.freeze
MACOS_VERSION = OS::Mac.version.to_s.freeze
end
module OS
module Mac
module_function
def xcode_folder
odisabled "MacOS.xcode_folder", "MacOS::Xcode.folder"
end
def xcode_prefix
odisabled "MacOS.xcode_prefix", "MacOS::Xcode.prefix"
end
def xcode_installed?
odisabled "MacOS.xcode_installed?", "MacOS::Xcode.installed?"
end
def xcode_version
odisabled "MacOS.xcode_version", "MacOS::Xcode.version"
end
def clt_installed?
odisabled "MacOS.clt_installed?", "MacOS::CLT.installed?"
end
def clt_version?
odisabled "MacOS.clt_version?", "MacOS::CLT.version"
end
def x11_installed?
odisabled "MacOS.x11_installed?", "MacOS::X11.installed?"
end
def x11_prefix
odisabled "MacOS.x11_prefix", "MacOS::X11.prefix"
end
def leopard?
odisabled "MacOS.leopard?", "'MacOS.version == :leopard'"
end
def snow_leopard?
odisabled "MacOS.snow_leopard?", "'MacOS.version >= :snow_leopard'"
end
def snow_leopard_or_newer?
odisabled "MacOS.snow_leopard_or_newer?", "'MacOS.version >= :snow_leopard'"
end
def lion?
odisabled "MacOS.lion?", "'MacOS.version >= :lion'"
end
def lion_or_newer?
odisabled "MacOS.lion_or_newer?", "'MacOS.version >= :lion'"
end
def mountain_lion?
odisabled "MacOS.mountain_lion?", "'MacOS.version >= :mountain_lion'"
end
def mountain_lion_or_newer?
odisabled "MacOS.mountain_lion_or_newer?", "'MacOS.version >= :mountain_lion'"
end
def macports_or_fink_installed?
odisabled "MacOS.macports_or_fink_installed?", "!MacOS.macports_or_fink.empty?"
end
def locate(_)
odisabled "MacOS.locate", "DevelopmentTools.locate"
end
def default_cc
odisabled "MacOS.default_cc", "DevelopmentTools.default_cc"
end
def default_compiler
odisabled "MacOS.default_compiler", "DevelopmentTools.default_compiler"
end
def gcc_40_build_version
odisabled "MacOS.gcc_40_build_version", "DevelopmentTools.gcc_4_0_build_version"
end
def gcc_4_0_build_version
odisabled "MacOS.gcc_4_0_build_version", "DevelopmentTools.gcc_4_0_build_version"
end
def gcc_42_build_version
odisabled "MacOS.gcc_42_build_version", "DevelopmentTools.gcc_4_2_build_version"
end
def gcc_build_version
odisabled "MacOS.gcc_build_version", "DevelopmentTools.gcc_4_2_build_version"
end
def llvm_build_version
odisabled "MacOS.llvm_build_version"
end
def clang_version
odisabled "MacOS.clang_version", "DevelopmentTools.clang_version"
end
def clang_build_version
odisabled "MacOS.clang_build_version", "DevelopmentTools.clang_build_version"
end
def has_apple_developer_tools?
odisabled "MacOS.has_apple_developer_tools?", "DevelopmentTools.installed?"
end
def release
odisabled "MacOS.release", "MacOS.version"
end
end
end

View File

@ -1,23 +0,0 @@
class Formula
def self.md5(_val)
odisabled "Formula.md5", "Formula.sha256"
end
end
class SoftwareSpec
def md5(_val)
odisabled "SoftwareSpec#md5", "SoftwareSpec#sha256"
end
end
class Resource
def md5(_val)
odisabled "Resource#md5", "Resource#sha256"
end
end
class Pathname
def md5
odisabled "Pathname#md5", "Pathname#sha256"
end
end

View File

@ -0,0 +1,10 @@
module OS
module Mac
class << self
def release
odeprecated "MacOS.release", "MacOS.version"
version
end
end
end
end

View File

@ -1,9 +0,0 @@
class Pathname
def cp(_)
odisabled "Pathname#cp", "FileUtils.cp"
end
def chmod_R(_)
odisabled "Pathname#chmod_R", "FileUtils.chmod_R"
end
end

View File

@ -1,123 +1,107 @@
require "requirements" require "requirements"
require "compat/requirements/language_module_requirement"
class CVSRequirement < Requirement class CVSRequirement < Requirement
fatal true fatal true
satisfy do satisfy do
odeprecated("CVSRequirement", "'depends_on \"cvs\"'") odisabled("CVSRequirement", "'depends_on \"cvs\"'")
which "cvs"
end end
end end
class EmacsRequirement < Requirement class EmacsRequirement < Requirement
fatal true fatal true
satisfy do satisfy do
odeprecated("EmacsRequirement", "'depends_on \"emacs\"'") odisabled("EmacsRequirement", "'depends_on \"emacs\"'")
which "emacs"
end end
end end
class FortranRequirement < Requirement class FortranRequirement < Requirement
fatal true fatal true
satisfy do satisfy do
odeprecated("FortranRequirement", "'depends_on \"gcc\"'") odisabled("FortranRequirement", "'depends_on \"gcc\"'")
which "gfortran"
end end
end end
class GitRequirement < Requirement class GitRequirement < Requirement
fatal true fatal true
satisfy do satisfy do
odeprecated("GitRequirement", "'depends_on \"git\"'") odisabled("GitRequirement", "'depends_on \"git\"'")
which "git"
end end
end end
class GPG2Requirement < Requirement class GPG2Requirement < Requirement
fatal true fatal true
satisfy do satisfy do
odeprecated("GPG2Requirement", "'depends_on \"gnupg\"'") odisabled("GPG2Requirement", "'depends_on \"gnupg\"'")
which "gpg"
end end
end end
class MercurialRequirement < Requirement class MercurialRequirement < Requirement
fatal true fatal true
satisfy do satisfy do
odeprecated("MercurialRequirement", "'depends_on \"mercurial\"'") odisabled("MercurialRequirement", "'depends_on \"mercurial\"'")
which "hg"
end end
end end
class MPIRequirement < Requirement class MPIRequirement < Requirement
fatal true fatal true
satisfy do satisfy do
odeprecated("MPIRequirement", "'depends_on \"open-mpi\"'") odisabled("MPIRequirement", "'depends_on \"open-mpi\"'")
which "mpicc"
end end
end end
class MysqlRequirement < Requirement class MysqlRequirement < Requirement
fatal true fatal true
satisfy do satisfy do
odeprecated("MysqlRequirement", "'depends_on \"mysql\"'") odisabled("MysqlRequirement", "'depends_on \"mysql\"'")
which "mysql_config"
end end
end end
class PerlRequirement < Requirement class PerlRequirement < Requirement
fatal true fatal true
satisfy do satisfy do
odeprecated("PerlRequirement", "'depends_on \"perl\"'") odisabled("PerlRequirement", "'depends_on \"perl\"'")
which "perl"
end end
end end
class PostgresqlRequirement < Requirement class PostgresqlRequirement < Requirement
fatal true fatal true
satisfy do satisfy do
odeprecated("PostgresqlRequirement", "'depends_on \"postgresql\"'") odisabled("PostgresqlRequirement", "'depends_on \"postgresql\"'")
which "pg_config"
end end
end end
class PythonRequirement < Requirement class PythonRequirement < Requirement
fatal true fatal true
satisfy do satisfy do
odeprecated("PythonRequirement", "'depends_on \"python@2\"'") odisabled("PythonRequirement", "'depends_on \"python@2\"'")
which "python2"
end end
end end
class Python3Requirement < Requirement class Python3Requirement < Requirement
fatal true fatal true
satisfy do satisfy do
odeprecated("Python3Requirement", "'depends_on \"python\"'") odisabled("Python3Requirement", "'depends_on \"python\"'")
which "python"
end end
end end
class RbenvRequirement < Requirement class RbenvRequirement < Requirement
fatal true fatal true
satisfy do satisfy do
odeprecated("RbenvRequirement", "'depends_on \"rbenv\"'") odisabled("RbenvRequirement", "'depends_on \"rbenv\"'")
which "rbenv"
end end
end end
class RubyRequirement < Requirement class RubyRequirement < Requirement
fatal true fatal true
satisfy do satisfy do
odeprecated("RubyRequirement", "'depends_on \"ruby\"'") odisabled("RubyRequirement", "'depends_on \"ruby\"'")
which "ruby"
end end
end end
class SubversionRequirement < Requirement class SubversionRequirement < Requirement
fatal true fatal true
satisfy do satisfy do
odeprecated("SubversionRequirement", "'depends_on \"subversion\"'") odisabled("SubversionRequirement", "'depends_on \"subversion\"'")
which "svn"
end end
end end
@ -126,8 +110,7 @@ class TeXRequirement < Requirement
cask "mactex" cask "mactex"
download "https://www.tug.org/mactex/" download "https://www.tug.org/mactex/"
satisfy do satisfy do
odeprecated("TeXRequirement") odisabled("TeXRequirement")
which("tex") || which("latex")
end end
end end

View File

@ -1,63 +0,0 @@
require "requirement"
class LanguageModuleRequirement < Requirement
fatal true
def initialize(language, module_name, import_name = nil)
@language = language
@module_name = module_name
@import_name = import_name || module_name
super([language, module_name, import_name])
end
satisfy(build_env: false) { quiet_system(*the_test) }
def message
s = <<~EOS
Unsatisfied dependency: #{@module_name}
Homebrew does not provide special #{@language.to_s.capitalize} dependencies; install with:
`#{command_line} #{@module_name}`
EOS
unless [:python, :perl, :ruby].include? @language
s += <<~EOS
You may need to: `brew install #{@language}`
EOS
end
s
end
def the_test
case @language
when :lua
["/usr/bin/env", "luarocks-5.2", "show", @import_name.to_s]
when :lua51
["/usr/bin/env", "luarocks-5.1", "show", @import_name.to_s]
when :perl
["/usr/bin/env", "perl", "-e", "use #{@import_name}"]
when :python
["/usr/bin/env", "python2", "-c", "import #{@import_name}"]
when :python3
["/usr/bin/env", "python", "-c", "import #{@import_name}"]
when :ruby
["/usr/bin/env", "ruby", "-rubygems", "-e", "require '#{@import_name}'"]
end
end
def command_line
case @language
when :lua then "luarocks-5.2 install"
when :lua51 then "luarocks-5.1 install"
when :perl then "cpan -i"
when :python then "pip3 install"
when :python3 then "pip install"
when :ruby then "gem install"
end
end
def display_s
"#{@module_name} (#{@language} module)"
end
end

View File

@ -1,29 +0,0 @@
class Formula
def self.sha1(_val)
odisabled "Formula.sha1", "Formula.sha256"
end
end
class SoftwareSpec
def sha1(_val)
odisabled "SoftwareSpec#sha1", "SoftwareSpec#sha256"
end
end
class Resource
def sha1(_val)
odisabled "Resource#sha1", "Resource#sha256"
end
end
class BottleSpecification
def sha1(_val)
odisabled "BottleSpecification#sha1", "BottleSpecification#sha256"
end
end
class Pathname
def sha1
odisabled "Pathname#sha1", "Pathname#sha256"
end
end

View File

@ -1,5 +0,0 @@
class BottleSpecification
def revision(*)
odisabled "BottleSpecification.revision", "BottleSpecification.rebuild"
end
end

View File

@ -1,5 +0,0 @@
class Tab < OpenStruct
def build_32_bit?
odisabled "Tab.build_32_bit?"
end
end

View File

@ -1,7 +0,0 @@
require "tap"
class Tap
def core_formula_repository?
odisabled "Tap#core_formula_repository?", "Tap#core_tap?"
end
end

View File

@ -1,15 +0,0 @@
module Tty
module_function
def white
odisabled "Tty.white", "Tty.reset.bold"
end
end
def puts_columns(_)
odisabled "puts_columns", "puts Formatter.columns"
end
def plural(_, _)
odisabled "#plural", "Formatter.pluralize"
end

View File

@ -1,7 +0,0 @@
module Utils
module Shell
def self.shell_profile
odisabled "Utils::Shell.shell_profile", "Utils::Shell.profile"
end
end
end

View File

@ -1,5 +0,0 @@
class Version
def slice(*)
odisabled "Version#slice", "Version#to_s.slice"
end
end

View File

@ -1,11 +0,0 @@
module OS
module Mac
module Xcode
module_function
def provides_autotools?
odisabled "OS::Mac::Xcode.provides_autotools?"
end
end
end
end

View File

@ -2,8 +2,6 @@ unless ENV["HOMEBREW_BREW_FILE"]
raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!" raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!"
end end
require "constants"
# Path to `bin/brew` main executable in HOMEBREW_PREFIX # Path to `bin/brew` main executable in HOMEBREW_PREFIX
HOMEBREW_BREW_FILE = Pathname.new(ENV["HOMEBREW_BREW_FILE"]) HOMEBREW_BREW_FILE = Pathname.new(ENV["HOMEBREW_BREW_FILE"])

View File

@ -1,5 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
# RuboCop version used for `brew style` and `brew cask style` # RuboCop version used for `brew style` and `brew cask style`
HOMEBREW_RUBOCOP_VERSION = "0.54.0" HOMEBREW_RUBOCOP_VERSION = "0.55.0"
HOMEBREW_RUBOCOP_CASK_VERSION = "~> 0.18.0" # has to be updated when RuboCop version changes HOMEBREW_RUBOCOP_CASK_VERSION = "~> 0.19.0" # has to be updated when RuboCop version changes

View File

@ -2,7 +2,6 @@ require "dependency"
require "dependencies" require "dependencies"
require "requirement" require "requirement"
require "requirements" require "requirements"
require "set"
require "extend/cachable" require "extend/cachable"
## A dependency is a formula that another formula needs to install. ## A dependency is a formula that another formula needs to install.

View File

@ -1,4 +1,3 @@
require "set"
require "formula" require "formula"
require "formula_versions" require "formula_versions"

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
#: * `bottle` [`--verbose`] [`--no-rebuild`|`--keep-old`] [`--skip-relocation`] [`--root-url=`<URL>] [`--force-core-tap`] <formulae>: #: * `bottle` [`--verbose`] [`--no-rebuild`|`--keep-old`] [`--skip-relocation`] [`--or-later`] [`--root-url=`<URL>] [`--force-core-tap`] <formulae>:
#: Generate a bottle (binary package) from a formula installed with #: Generate a bottle (binary package) from a formula installed with
#: `--build-bottle`. #: `--build-bottle`.
#: #:
@ -15,6 +15,8 @@
#: If `--root-url` is passed, use the specified <URL> as the root of the #: If `--root-url` is passed, use the specified <URL> as the root of the
#: bottle's URL instead of Homebrew's default. #: bottle's URL instead of Homebrew's default.
#: #:
#: If `--or-later` is passed, append _or_later to the bottle tag.
#:
#: If `--force-core-tap` is passed, build a bottle even if <formula> is not #: If `--force-core-tap` is passed, build a bottle even if <formula> is not
#: in homebrew/core or any installed taps. #: in homebrew/core or any installed taps.
#: #:
@ -37,7 +39,6 @@ require "formula_versions"
require "cli_parser" require "cli_parser"
require "utils/inreplace" require "utils/inreplace"
require "erb" require "erb"
require "extend/pathname"
BOTTLE_ERB = <<-EOS.freeze BOTTLE_ERB = <<-EOS.freeze
bottle do bottle do
@ -58,7 +59,7 @@ BOTTLE_ERB = <<-EOS.freeze
<% checksums.each do |checksum_type, checksum_values| %> <% checksums.each do |checksum_type, checksum_values| %>
<% checksum_values.each do |checksum_value| %> <% checksum_values.each do |checksum_value| %>
<% checksum, macos = checksum_value.shift %> <% checksum, macos = checksum_value.shift %>
<%= checksum_type %> "<%= checksum %>" => :<%= macos %> <%= checksum_type %> "<%= checksum %>" => :<%= macos %><%= "_or_later" if Homebrew.args.or_later? %>
<% end %> <% end %>
<% end %> <% end %>
end end
@ -79,7 +80,9 @@ module Homebrew
switch "--write" switch "--write"
switch "--no-commit" switch "--no-commit"
switch "--json" switch "--json"
switch "--or-later"
switch :verbose switch :verbose
switch :debug
flag "--root-url" flag "--root-url"
end end
@ -114,7 +117,7 @@ module Homebrew
linked_libraries = Keg.file_linked_libraries(file, string) linked_libraries = Keg.file_linked_libraries(file, string)
result ||= !linked_libraries.empty? result ||= !linked_libraries.empty?
if @args.verbose? if Homebrew.args.verbose?
print_filename.call(string, file) unless linked_libraries.empty? print_filename.call(string, file) unless linked_libraries.empty?
linked_libraries.each do |lib| linked_libraries.each do |lib|
puts " #{Tty.bold}-->#{Tty.reset} links to #{lib}" puts " #{Tty.bold}-->#{Tty.reset} links to #{lib}"
@ -137,7 +140,7 @@ module Homebrew
end end
end end
next unless @args.verbose? && !text_matches.empty? next unless Homebrew.args.verbose? && !text_matches.empty?
print_filename.call(string, file) print_filename.call(string, file)
text_matches.first(MAXIMUM_STRING_MATCHES).each do |match, offset| text_matches.first(MAXIMUM_STRING_MATCHES).each do |match, offset|
puts " #{Tty.bold}-->#{Tty.reset} match '#{match}' at offset #{Tty.bold}0x#{offset}#{Tty.reset}" puts " #{Tty.bold}-->#{Tty.reset} match '#{match}' at offset #{Tty.bold}0x#{offset}#{Tty.reset}"
@ -158,7 +161,7 @@ module Homebrew
absolute_symlinks_start_with_string << pn if link.to_s.start_with?(string) absolute_symlinks_start_with_string << pn if link.to_s.start_with?(string)
end end
if @args.verbose? if Homebrew.args.verbose?
unless absolute_symlinks_start_with_string.empty? unless absolute_symlinks_start_with_string.empty?
opoo "Absolute symlink starting with #{string}:" opoo "Absolute symlink starting with #{string}:"
absolute_symlinks_start_with_string.each do |pn| absolute_symlinks_start_with_string.each do |pn|
@ -299,7 +302,7 @@ module Homebrew
end end
skip_relocation = relocatable && !keg.require_relocation? skip_relocation = relocatable && !keg.require_relocation?
end end
puts if !relocatable && @args.verbose? puts if !relocatable && Homebrew.args.verbose?
rescue Interrupt rescue Interrupt
ignore_interrupts { bottle_path.unlink if bottle_path.exist? } ignore_interrupts { bottle_path.unlink if bottle_path.exist? }
raise raise
@ -360,6 +363,8 @@ module Homebrew
puts output puts output
return unless @args.json? return unless @args.json?
tag = Utils::Bottles.tag.to_s
tag += "_or_later" if @args.or_later?
json = { json = {
f.full_name => { f.full_name => {
"formula" => { "formula" => {
@ -372,7 +377,7 @@ module Homebrew
"cellar" => bottle.cellar.to_s, "cellar" => bottle.cellar.to_s,
"rebuild" => bottle.rebuild, "rebuild" => bottle.rebuild,
"tags" => { "tags" => {
Utils::Bottles.tag.to_s => { tag => {
"filename" => filename.to_s, "filename" => filename.to_s,
"sha256" => sha256, "sha256" => sha256,
}, },

Some files were not shown because too many files have changed in this diff Show More