diff options
29 files changed, 243 insertions, 165 deletions
diff --git a/.travis.yml b/.travis.yml index b9549eb16..48e13983b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ cache: - $HOME/Library/Caches/Homebrew/tests matrix: + fast_finish: true include: - os: osx osx_image: xcode8.3 diff --git a/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb b/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb index 695b5a950..d92644150 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb @@ -247,8 +247,11 @@ module Hbc set output to "" repeat with i from 1 to (count trashedItems) - set item i of trashedItems to POSIX path of (item i of trashedItems as string) - set output to output & (item i of trashedItems) & (do shell script "printf \"\\0\"") + set trashedItem to POSIX path of (item i of trashedItems as string) + set output to output & trashedItem + if i < count trashedItems then + set output to output & (do shell script "printf \"\\0\"") + end if end repeat return output diff --git a/Library/Homebrew/cask/lib/hbc/cli/zap.rb b/Library/Homebrew/cask/lib/hbc/cli/zap.rb index d12943106..e709f4191 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/zap.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/zap.rb @@ -1,6 +1,8 @@ module Hbc class CLI class Zap < AbstractCommand + option "--force", :force, false + def initialize(*) super raise CaskUnspecifiedError if args.empty? @@ -13,7 +15,7 @@ module Hbc def zap_casks casks.each do |cask| odebug "Zapping Cask #{cask}" - Installer.new(cask, verbose: verbose?).zap + Installer.new(cask, verbose: verbose?, force: force?).zap end end diff --git a/Library/Homebrew/cask/lib/hbc/dsl.rb b/Library/Homebrew/cask/lib/hbc/dsl.rb index 112ceb943..8ad206c2f 100644 --- a/Library/Homebrew/cask/lib/hbc/dsl.rb +++ b/Library/Homebrew/cask/lib/hbc/dsl.rb @@ -89,14 +89,20 @@ module Hbc @name.concat(args.flatten) end - def assert_only_one_stanza_allowed(stanza, arg_given) - return unless instance_variable_defined?("@#{stanza}") && arg_given - raise CaskInvalidError.new(token, "'#{stanza}' stanza may only appear once") + def set_unique_stanza(stanza, should_return) + return instance_variable_get("@#{stanza}") if should_return + + if instance_variable_defined?("@#{stanza}") + raise CaskInvalidError.new(token, "'#{stanza}' stanza may only appear once") + end + + instance_variable_set("@#{stanza}", yield) + rescue StandardError => e + raise CaskInvalidError.new(token, "'#{stanza}' stanza failed with: #{e}") end def homepage(homepage = nil) - assert_only_one_stanza_allowed :homepage, !homepage.nil? - @homepage ||= homepage + set_unique_stanza(:homepage, homepage.nil?) { homepage } end def language(*args, default: false, &block) @@ -135,78 +141,51 @@ module Hbc end def url(*args, &block) - url_given = !args.empty? || block_given? - return @url unless url_given - assert_only_one_stanza_allowed :url, url_given - @url ||= begin - URL.from(*args, &block) - rescue StandardError => e - raise CaskInvalidError.new(token, "'url' stanza failed with: #{e}") + set_unique_stanza(:url, args.empty? && !block_given?) do + begin + URL.from(*args, &block) + end end end def appcast(*args) - return @appcast if args.empty? - assert_only_one_stanza_allowed :appcast, !args.empty? - @appcast ||= begin - DSL::Appcast.new(*args) unless args.empty? - rescue StandardError => e - raise CaskInvalidError.new(token, e) - end + set_unique_stanza(:appcast, args.empty?) { DSL::Appcast.new(*args) } end def gpg(*args) - return @gpg if args.empty? - assert_only_one_stanza_allowed :gpg, !args.empty? - @gpg ||= begin - DSL::Gpg.new(*args) unless args.empty? - rescue StandardError => e - raise CaskInvalidError.new(token, e) - end + set_unique_stanza(:gpg, args.empty?) { DSL::Gpg.new(*args) } end def container(*args) - return @container if args.empty? # TODO: remove this constraint, and instead merge multiple container stanzas - assert_only_one_stanza_allowed :container, !args.empty? - @container ||= begin - DSL::Container.new(*args) unless args.empty? - rescue StandardError => e - raise CaskInvalidError.new(token, e) - end - # TODO: remove this backward-compatibility section after removing nested_container - if @container && @container.nested - artifacts[:nested_container] << @container.nested + set_unique_stanza(:container, args.empty?) do + begin + DSL::Container.new(*args).tap do |container| + # TODO: remove this backward-compatibility section after removing nested_container + if container && container.nested + artifacts[:nested_container] << container.nested + end + end + end end - @container end - SYMBOLIC_VERSIONS = Set.new [ - :latest, - ] - def version(arg = nil) - return @version if arg.nil? - assert_only_one_stanza_allowed :version, !arg.nil? - raise CaskInvalidError.new(token, "invalid 'version' value: '#{arg.inspect}'") if !arg.is_a?(String) && !SYMBOLIC_VERSIONS.include?(arg) - @version ||= DSL::Version.new(arg) + set_unique_stanza(:version, arg.nil?) do + if !arg.is_a?(String) && arg != :latest + raise CaskInvalidError.new(token, "invalid 'version' value: '#{arg.inspect}'") + end + DSL::Version.new(arg) + end end - SYMBOLIC_SHA256S = Set.new [ - :no_check, - ] - def sha256(arg = nil) - return @sha256 if arg.nil? - assert_only_one_stanza_allowed :sha256, !arg.nil? - raise CaskInvalidError.new(token, "invalid 'sha256' value: '#{arg.inspect}'") if !arg.is_a?(String) && !SYMBOLIC_SHA256S.include?(arg) - @sha256 ||= arg - end - - def license(*) - # TODO: Uncomment after `license` has been - # removed from all official taps. - # odeprecated "Hbc::DSL#license" + set_unique_stanza(:sha256, arg.nil?) do + if !arg.is_a?(String) && arg != :no_check + raise CaskInvalidError.new(token, "invalid 'sha256' value: '#{arg.inspect}'") + end + arg + end end # depends_on uses a load method so that multiple stanzas can be merged @@ -222,14 +201,8 @@ module Hbc end def conflicts_with(*args) - return @conflicts_with if args.empty? # TODO: remove this constraint, and instead merge multiple conflicts_with stanzas - assert_only_one_stanza_allowed :conflicts_with, !args.empty? - @conflicts_with ||= begin - DSL::ConflictsWith.new(*args) unless args.empty? - rescue StandardError => e - raise CaskInvalidError.new(token, e) - end + set_unique_stanza(:conflicts_with, args.empty?) { DSL::ConflictsWith.new(*args) } end def artifacts @@ -257,13 +230,11 @@ module Hbc end def accessibility_access(accessibility_access = nil) - assert_only_one_stanza_allowed :accessibility_access, !accessibility_access.nil? - @accessibility_access ||= accessibility_access + set_unique_stanza(:accessibility_access, accessibility_access.nil?) { accessibility_access } end def auto_updates(auto_updates = nil) - assert_only_one_stanza_allowed :auto_updates, !auto_updates.nil? - @auto_updates ||= auto_updates + set_unique_stanza(:auto_updates, auto_updates.nil?) { auto_updates } end ORDINARY_ARTIFACT_TYPES.each do |type| diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index da48582d2..c00087705 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -330,13 +330,8 @@ module Homebrew fi.ignore_deps = ARGV.ignore_deps? fi.only_deps = ARGV.only_deps? fi.build_bottle = ARGV.build_bottle? - fi.build_from_source = ARGV.build_from_source? || ARGV.build_all_from_source? - fi.force_bottle = ARGV.force_bottle? fi.interactive = ARGV.interactive? fi.git = ARGV.git? - fi.verbose = ARGV.verbose? - fi.quieter = ARGV.quieter? - fi.debug = ARGV.debug? fi.prelude fi.install fi.finish diff --git a/Library/Homebrew/cmd/reinstall.rb b/Library/Homebrew/cmd/reinstall.rb index f5d6437bd..94096d2dd 100644 --- a/Library/Homebrew/cmd/reinstall.rb +++ b/Library/Homebrew/cmd/reinstall.rb @@ -23,6 +23,8 @@ module Homebrew def reinstall_formula(f) if f.opt_prefix.directory? keg = Keg.new(f.opt_prefix.resolved_path) + keg_had_linked_opt = true + keg_was_linked = keg.linked? backup keg end @@ -35,12 +37,9 @@ module Homebrew fi.options = options fi.invalid_option_names = build_options.invalid_option_names fi.build_bottle = ARGV.build_bottle? || (!f.bottled? && f.build.bottle?) - fi.build_from_source = ARGV.build_from_source? || ARGV.build_all_from_source? - fi.force_bottle = ARGV.force_bottle? fi.interactive = ARGV.interactive? fi.git = ARGV.git? - fi.verbose = ARGV.verbose? - fi.debug = ARGV.debug? + fi.link_keg = keg_was_linked if keg_had_linked_opt fi.prelude oh1 "Reinstalling #{f.full_name} #{options.to_a.join " "}" @@ -50,7 +49,7 @@ module Homebrew rescue FormulaInstallationAlreadyAttemptedError # next rescue Exception - ignore_interrupts { restore_backup(keg, f) } + ignore_interrupts { restore_backup(keg, keg_was_linked) } raise else backup_path(keg).rmtree if backup_path(keg).exist? @@ -61,7 +60,7 @@ module Homebrew keg.rename backup_path(keg) end - def restore_backup(keg, formula) + def restore_backup(keg, keg_was_linked) path = backup_path(keg) return unless path.directory? @@ -69,7 +68,7 @@ module Homebrew Pathname.new(keg).rmtree if keg.exist? path.rename keg - keg.link unless formula.keg_only? + keg.link if keg_was_linked end def backup_path(path) diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb index d007ff8c8..1cdb497cf 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -101,11 +101,18 @@ module Homebrew end def upgrade_formula(f) + if f.opt_prefix.directory? + keg = Keg.new(f.opt_prefix.resolved_path) + keg_had_linked_opt = true + keg_was_linked = keg.linked? + end + formulae_maybe_with_kegs = [f] + f.old_installed_formulae outdated_kegs = formulae_maybe_with_kegs .map(&:linked_keg) .select(&:directory?) .map { |k| Keg.new(k.resolved_path) } + linked_kegs = outdated_kegs.select(&:linked?) if f.opt_prefix.directory? keg = Keg.new(f.opt_prefix.resolved_path) @@ -116,11 +123,8 @@ module Homebrew fi.options = f.build.used_options fi.options &= f.options fi.build_bottle = ARGV.build_bottle? || (!f.bottled? && f.build.build_bottle?) - fi.build_from_source = ARGV.build_from_source? || ARGV.build_all_from_source? - fi.verbose = ARGV.verbose? - fi.quieter = ARGV.quieter? - fi.debug = ARGV.debug? fi.installed_on_request = !ARGV.named.empty? + fi.link_keg = keg_was_linked if keg_had_linked_opt if tab fi.installed_as_dependency = tab.installed_as_dependency fi.installed_on_request ||= tab.installed_on_request @@ -157,7 +161,7 @@ module Homebrew ensure # restore previous installation state if build failed begin - outdated_kegs.each(&:link) unless f.installed? + linked_kegs.each(&:link) unless f.installed? rescue nil end diff --git a/Library/Homebrew/compat/hbc.rb b/Library/Homebrew/compat/hbc.rb index 3ff8fccb7..608d46e37 100644 --- a/Library/Homebrew/compat/hbc.rb +++ b/Library/Homebrew/compat/hbc.rb @@ -3,6 +3,7 @@ require "compat/hbc/cli/update" require "compat/hbc/cache" require "compat/hbc/caskroom" require "compat/hbc/cli" +require "compat/hbc/dsl" module Hbc class << self diff --git a/Library/Homebrew/compat/hbc/dsl.rb b/Library/Homebrew/compat/hbc/dsl.rb new file mode 100644 index 000000000..b550501ed --- /dev/null +++ b/Library/Homebrew/compat/hbc/dsl.rb @@ -0,0 +1,7 @@ +module Hbc + class DSL + def license(*) + odeprecated "Hbc::DSL#license" + end + end +end diff --git a/Library/Homebrew/compat/software_spec.rb b/Library/Homebrew/compat/software_spec.rb index 5efd2aeb4..8b0408d02 100644 --- a/Library/Homebrew/compat/software_spec.rb +++ b/Library/Homebrew/compat/software_spec.rb @@ -1,6 +1,6 @@ class BottleSpecification def revision(*args) - # odeprecated "BottleSpecification.revision", "BottleSpecification.rebuild" + odeprecated "BottleSpecification.revision", "BottleSpecification.rebuild" rebuild(*args) end end diff --git a/Library/Homebrew/compat/utils.rb b/Library/Homebrew/compat/utils.rb index f2cca4726..8904f0f2b 100644 --- a/Library/Homebrew/compat/utils.rb +++ b/Library/Homebrew/compat/utils.rb @@ -1,8 +1,3 @@ -def shell_profile - # odeprecated "shell_profile", "Utils::Shell.profile" - Utils::Shell.profile -end - module Tty module_function diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index c707dfa0f..7b5befaa0 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -94,7 +94,7 @@ module Homebrew elsif !except_cops.empty? options[:except_cops] = except_cops elsif !strict - options[:except_cops] = [:FormulaAuditStrict, :NewFormulaAudit] + options[:only_cops] = [:FormulaAudit] end # Check style in a single batch run up front for performance @@ -909,16 +909,6 @@ class FormulaAuditor problem "\"#{Regexp.last_match(1)}\" should be \"\#{#{Regexp.last_match(2)}}\"" end - if line =~ /depends_on :(automake|autoconf|libtool)/ - problem ":#{Regexp.last_match(1)} is deprecated. Usage should be \"#{Regexp.last_match(1)}\"" - end - - if line =~ /depends_on :apr/ - problem ":apr is deprecated. Usage should be \"apr-util\"" - end - - problem ":tex is deprecated" if line =~ /depends_on :tex/ - if line =~ /depends_on\s+['"](.+)['"]\s+=>\s+:(lua|perl|python|ruby)(\d*)/ problem "#{Regexp.last_match(2)} modules should be vendored rather than use deprecated `depends_on \"#{Regexp.last_match(1)}\" => :#{Regexp.last_match(2)}#{Regexp.last_match(3)}`" end diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 9a31c9e5e..5673a433f 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -383,7 +383,9 @@ class Formula # All of aliases for the formula def aliases @aliases ||= if tap - tap.alias_reverse_table[full_name] || [] + tap.alias_reverse_table[full_name].to_a.map do |a| + a.split("/")[-1] + end else [] end @@ -2070,8 +2072,8 @@ class Formula # # If you maintain your own repository, you can add your own bottle links. # https://docs.brew.sh/Bottles.html - # You can ignore this block entirely if submitting to Homebrew/Homebrew, It'll be - # handled for you by the Brew Test Bot. + # You can ignore this block entirely if submitting to Homebrew/homebrew-core. + # It'll be handled for you by the Brew Test Bot. # # <pre>bottle do # root_url "https://example.com" # Optional root to calculate bottle URLs @@ -2368,7 +2370,7 @@ class Formula # version '4.8.1' # end</pre> def fails_with(compiler, &block) - # odeprecated "fails_with :llvm" if compiler == :llvm + odeprecated "fails_with :llvm" if compiler == :llvm specs.each { |spec| spec.fails_with(compiler, &block) } end diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index a0c091e7f..4e4a59972 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -37,21 +37,22 @@ class FormulaInstaller mode_attr_accessor :show_summary_heading, :show_header mode_attr_accessor :build_from_source, :force_bottle mode_attr_accessor :ignore_deps, :only_deps, :interactive, :git - mode_attr_accessor :verbose, :debug, :quieter + mode_attr_accessor :verbose, :debug, :quieter, :link_keg def initialize(formula) @formula = formula + @link_keg = !formula.keg_only? @show_header = false @ignore_deps = false @only_deps = false - @build_from_source = false - @build_bottle = false - @force_bottle = false + @build_from_source = ARGV.build_from_source? || ARGV.build_all_from_source? + @build_bottle = ARGV.build_bottle? + @force_bottle = ARGV.force_bottle? @interactive = false @git = false - @verbose = false - @quieter = false - @debug = false + @verbose = ARGV.verbose? + @quieter = ARGV.quieter? + @debug = ARGV.debug? @installed_as_dependency = false @installed_on_request = true @options = Options.new @@ -402,14 +403,13 @@ class FormulaInstaller raise UnsatisfiedRequirements, fatals end - def install_requirement_formula?(req, dependent, build) - req_dependency = req.to_dependency + def install_requirement_formula?(req_dependency, req, install_bottle_for_dependent) return false unless req_dependency return true unless req.satisfied? return false if req.run? return true if build_bottle? return true if req.satisfied_by_formula? - install_bottle_for?(dependent, build) + install_bottle_for_dependent end def runtime_requirements(formula) @@ -429,19 +429,21 @@ class FormulaInstaller runtime_requirements = runtime_requirements(f) f.recursive_requirements do |dependent, req| build = effective_build_options_for(dependent) + install_bottle_for_dependent = install_bottle_for?(dependent, build) + use_default_formula = install_bottle_for_dependent || build_bottle? + req_dependency = req.to_dependency(use_default_formula: use_default_formula) if (req.optional? || req.recommended?) && build.without?(req) Requirement.prune - elsif req.build? && install_bottle_for?(dependent, build) + elsif req.build? && install_bottle_for_dependent Requirement.prune - elsif install_requirement_formula?(req, dependent, build) - dep = req.to_dependency - deps.unshift(dep) - formulae.unshift(dep.to_formula) + elsif install_requirement_formula?(req_dependency, req, install_bottle_for_dependent) + deps.unshift(req_dependency) + formulae.unshift(req_dependency.to_formula) Requirement.prune elsif req.satisfied? Requirement.prune - elsif !runtime_requirements.include?(req) && install_bottle_for?(dependent, build) + elsif !runtime_requirements.include?(req) && install_bottle_for_dependent Requirement.prune else unsatisfied_reqs[dependent] << req @@ -524,6 +526,8 @@ class FormulaInstaller if df.linked_keg.directory? linked_keg = Keg.new(df.linked_keg.resolved_path) + keg_had_linked_keg = true + keg_was_linked = linked_keg.linked? linked_keg.unlink end @@ -539,8 +543,12 @@ class FormulaInstaller fi.options |= inherited_options fi.options &= df.options fi.build_from_source = ARGV.build_formula_from_source?(df) - fi.verbose = verbose? && !quieter? + fi.build_bottle = false + fi.force_bottle = false + fi.verbose = verbose? + fi.quieter = quieter? fi.debug = debug? + fi.link_keg = keg_was_linked if keg_had_linked_keg fi.installed_as_dependency = true fi.installed_on_request = false fi.prelude @@ -550,7 +558,7 @@ class FormulaInstaller rescue Exception ignore_interrupts do tmp_keg.rename(installed_keg) if tmp_keg && !installed_keg.directory? - linked_keg.link if linked_keg + linked_keg.link if keg_was_linked end raise else @@ -711,7 +719,7 @@ class FormulaInstaller end def link(keg) - if formula.keg_only? + unless link_keg begin keg.optlink rescue Keg::LinkError => e @@ -865,6 +873,7 @@ class FormulaInstaller tab.source["path"] = formula.specified_path.to_s tab.installed_as_dependency = installed_as_dependency tab.installed_on_request = installed_on_request + tab.aliases = formula.aliases tab.write end diff --git a/Library/Homebrew/formula_support.rb b/Library/Homebrew/formula_support.rb index a4534291a..2c9c19187 100644 --- a/Library/Homebrew/formula_support.rb +++ b/Library/Homebrew/formula_support.rb @@ -19,6 +19,8 @@ class KegOnlyReason MacOS.version < :mavericks when :provided_pre_el_capitan MacOS.version < :el_capitan + when :provided_pre_high_sierra + MacOS.version < :high_sierra when :provided_until_xcode43 MacOS::Xcode.installed? && MacOS::Xcode.version < "4.3" when :provided_until_xcode5 @@ -51,6 +53,9 @@ class KegOnlyReason when :provided_pre_el_capitan then <<-EOS.undent macOS already provides this software in versions before El Capitan EOS + when :provided_pre_high_sierra then <<-EOS.undent + macOS already provides this software in versions before High Sierra + EOS when :provided_until_xcode43 then <<-EOS.undent Xcode provides this software prior to version 4.3 EOS diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index b52269e30..8fcbecfbd 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -237,13 +237,37 @@ class Keg opt_record.symlink? && path == opt_record.resolved_path end - def remove_opt_record - opt_record.unlink - aliases.each do |a| - alias_symlink = opt_record.parent/a - next if !alias_symlink.symlink? && !alias_symlink.exist? + def remove_old_aliases + opt = opt_record.parent + + tap = begin + to_formula.tap + rescue FormulaUnavailableError, TapFormulaAmbiguityError, + TapFormulaWithOldnameAmbiguityError + # If the formula can't be found, just ignore aliases for now. + nil + end + + if tap + bad_tap_opt = opt/tap.user + FileUtils.rm_rf bad_tap_opt if bad_tap_opt.directory? + end + + Pathname.glob("#{opt_record}@*").each do |a| + a = a.basename + next if aliases.include?(a) + + alias_symlink = opt/a + if alias_symlink.symlink? && alias_symlink.exist? + next if rack != alias_symlink.realpath.parent + end + alias_symlink.delete end + end + + def remove_opt_record + opt_record.unlink opt_record.parent.rmdir_if_possible end @@ -251,6 +275,7 @@ class Keg path.rmtree path.parent.rmdir_if_possible remove_opt_record if optlinked? + remove_old_aliases remove_oldname_opt_record end @@ -277,6 +302,7 @@ class Keg dst.uninstall_info if dst.to_s =~ INFOFILE_RX dst.unlink + remove_old_aliases Find.prune if src.directory? end end @@ -468,12 +494,7 @@ class Keg end def aliases - formula = Formulary.from_rack(rack) - aliases = formula.aliases - return aliases if formula.stable? - aliases.reject { |a| a.include?("@") } - rescue FormulaUnavailableError - [] + Tab.for_keg(self).aliases || [] end def optlink(mode = OpenStruct.new) diff --git a/Library/Homebrew/requirement.rb b/Library/Homebrew/requirement.rb index cfb925b49..1ec8580c4 100644 --- a/Library/Homebrew/requirement.rb +++ b/Library/Homebrew/requirement.rb @@ -129,8 +129,10 @@ class Requirement !@formula.nil? end - def to_dependency - if formula =~ HOMEBREW_TAP_FORMULA_REGEX + def to_dependency(use_default_formula: false) + if use_default_formula && default_formula? + Dependency.new(self.class.default_formula, tags, method(:modify_build_environment), name) + elsif formula =~ HOMEBREW_TAP_FORMULA_REGEX TapDependency.new(formula, tags, method(:modify_build_environment), name) elsif formula Dependency.new(formula, tags, method(:modify_build_environment), name) diff --git a/Library/Homebrew/rubocops.rb b/Library/Homebrew/rubocops.rb index 7d104ad9e..4323e044c 100644 --- a/Library/Homebrew/rubocops.rb +++ b/Library/Homebrew/rubocops.rb @@ -10,3 +10,4 @@ require_relative "./rubocops/legacy_patches_cop" require_relative "./rubocops/conflicts_cop" require_relative "./rubocops/options_cop" require_relative "./rubocops/urls_cop" +require_relative "./rubocops/lines_cop" diff --git a/Library/Homebrew/rubocops/extend/formula_cop.rb b/Library/Homebrew/rubocops/extend/formula_cop.rb index 169b1c34a..4be0c0fe3 100644 --- a/Library/Homebrew/rubocops/extend/formula_cop.rb +++ b/Library/Homebrew/rubocops/extend/formula_cop.rb @@ -138,7 +138,8 @@ module RuboCop case type when :required - type_match = !node.method_args.nil? && node.method_args.first.str_type? + type_match = !node.method_args.nil? && + (node.method_args.first.str_type? || node.method_args.first.sym_type?) if type_match && !name_match name_match = node_equals?(node.method_args.first, name) end diff --git a/Library/Homebrew/rubocops/lines_cop.rb b/Library/Homebrew/rubocops/lines_cop.rb new file mode 100644 index 000000000..22039869b --- /dev/null +++ b/Library/Homebrew/rubocops/lines_cop.rb @@ -0,0 +1,20 @@ +require_relative "./extend/formula_cop" + +module RuboCop + module Cop + module FormulaAudit + # This cop checks for various miscellaneous Homebrew coding styles + class Lines < FormulaCop + def audit_formula(_node, _class_node, _parent_class_node, _body_node) + [:automake, :autoconf, :libtool].each do |dependency| + next unless depends_on?(dependency) + problem ":#{dependency} is deprecated. Usage should be \"#{dependency}\"" + end + + problem ':apr is deprecated. Usage should be "apr-util"' if depends_on?(:apr) + problem ":tex is deprecated" if depends_on?(:tex) + end + end + end + end +end diff --git a/Library/Homebrew/sandbox.rb b/Library/Homebrew/sandbox.rb index e72ecb950..0de970773 100644 --- a/Library/Homebrew/sandbox.rb +++ b/Library/Homebrew/sandbox.rb @@ -3,18 +3,14 @@ require "tempfile" class Sandbox SANDBOX_EXEC = "/usr/bin/sandbox-exec".freeze - SANDBOXED_TAPS = %w[ - homebrew/core - ].freeze def self.available? OS.mac? && OS::Mac.version >= "10.6" && File.executable?(SANDBOX_EXEC) end - def self.formula?(formula) + def self.formula?(_formula) return false unless available? - return false if ARGV.no_sandbox? - ARGV.sandbox? || SANDBOXED_TAPS.include?(formula.tap.to_s) + !ARGV.no_sandbox? end def self.test? diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb index 0d2b48acc..c6e704350 100644 --- a/Library/Homebrew/software_spec.rb +++ b/Library/Homebrew/software_spec.rb @@ -194,7 +194,7 @@ class SoftwareSpec end def fails_with(compiler, &block) - # odeprecated "fails_with :llvm" if compiler == :llvm + odeprecated "fails_with :llvm" if compiler == :llvm compiler_failures << CompilerFailure.create(compiler, &block) end diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index 6d0a3d6d1..e7df88356 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -33,6 +33,7 @@ class Tab < OpenStruct "HEAD" => HOMEBREW_REPOSITORY.git_head, "compiler" => compiler, "stdlib" => stdlib, + "aliases" => formula.aliases, "runtime_dependencies" => formula.runtime_dependencies.map do |dep| f = dep.to_formula { "full_name" => f.full_name, "version" => f.version.to_s } @@ -185,6 +186,7 @@ class Tab < OpenStruct "HEAD" => nil, "stdlib" => nil, "compiler" => DevelopmentTools.default_compiler, + "aliases" => [], "runtime_dependencies" => [], "source" => { "path" => nil, @@ -328,6 +330,7 @@ class Tab < OpenStruct "HEAD" => self.HEAD, "stdlib" => (stdlib.to_s if stdlib), "compiler" => (compiler.to_s if compiler), + "aliases" => aliases, "runtime_dependencies" => runtime_dependencies, "source" => source, } diff --git a/Library/Homebrew/test/bottle_hooks_spec.rb b/Library/Homebrew/test/bottle_hooks_spec.rb index 913e3ffba..e70b558a1 100644 --- a/Library/Homebrew/test/bottle_hooks_spec.rb +++ b/Library/Homebrew/test/bottle_hooks_spec.rb @@ -12,6 +12,7 @@ describe Homebrew::Hooks::Bottles do local_bottle_path: nil, bottle_disabled?: false, some_random_method: true, + keg_only?: false, ) end diff --git a/Library/Homebrew/test/formula_installer_spec.rb b/Library/Homebrew/test/formula_installer_spec.rb index 49bb5d564..c3573ae94 100644 --- a/Library/Homebrew/test/formula_installer_spec.rb +++ b/Library/Homebrew/test/formula_installer_spec.rb @@ -133,22 +133,22 @@ describe FormulaInstaller do }.to raise_error(CannotInstallFormulaError) end - describe "#install_requirement_formula?" do + describe "#install_requirement_formula?", :focus do before do @requirement = Python3Requirement.new + @requirement_dependency = @requirement.to_dependency + @install_bottle_for_dependent = false allow(@requirement).to receive(:satisfied?).and_return(satisfied?) allow(@requirement).to receive(:satisfied_by_formula?).and_return(satisfied_by_formula?) - allow_any_instance_of(Dependency).to receive(:installed?).and_return(installed?) @dependent = formula do url "foo" version "0.1" depends_on :python3 end - @build = BuildOptions.new [], [] @fi = FormulaInstaller.new(@dependent) end - subject { @fi.install_requirement_formula?(@requirement, @dependent, @build) } + subject { @fi.install_requirement_formula?(@requirement_dependency, @requirement, @install_bottle_for_dependent) } context "it returns false when requirement is satisfied" do let(:satisfied?) { true } diff --git a/Library/Homebrew/test/rubocops/lines_cop_spec.rb b/Library/Homebrew/test/rubocops/lines_cop_spec.rb new file mode 100644 index 000000000..c865e1480 --- /dev/null +++ b/Library/Homebrew/test/rubocops/lines_cop_spec.rb @@ -0,0 +1,53 @@ +require "rubocop" +require "rubocop/rspec/support" +require_relative "../../extend/string" +require_relative "../../rubocops/lines_cop" + +describe RuboCop::Cop::FormulaAudit::Lines do + subject(:cop) { described_class.new } + + context "When auditing lines" do + it "with correctable deprecated dependencies" do + formulae = [{ + "dependency" => :automake, + "correct" => "automake", + }, { + "dependency" => :autoconf, + "correct" => "autoconf", + }, { + "dependency" => :libtool, + "correct" => "libtool", + }, { + "dependency" => :apr, + "correct" => "apr-util", + }, { + "dependency" => :tex, + }] + + formulae.each do |formula| + source = <<-EOS.undent + class Foo < Formula + url 'http://example.com/foo-1.0.tgz' + depends_on :#{formula["dependency"]} + end + EOS + if formula.key?("correct") + offense = ":#{formula["dependency"]} is deprecated. Usage should be \"#{formula["correct"]}\"" + else + offense = ":#{formula["dependency"]} is deprecated" + end + expected_offenses = [{ message: offense, + severity: :convention, + line: 3, + column: 2, + source: source }] + + inspect_source(cop, source) + + expected_offenses.zip(cop.offenses.reverse).each do |expected, actual| + expect_offense(expected, actual) + end + end + end + end +end diff --git a/Library/Homebrew/test/sandbox_spec.rb b/Library/Homebrew/test/sandbox_spec.rb index 10414f75b..38ff4da75 100644 --- a/Library/Homebrew/test/sandbox_spec.rb +++ b/Library/Homebrew/test/sandbox_spec.rb @@ -12,15 +12,7 @@ describe Sandbox do specify "#formula?" do f = formula { url "foo-1.0" } - f2 = formula { url "bar-1.0" } - allow(f2).to receive(:tap).and_return(Tap.fetch("test/tap")) - - ENV["HOMEBREW_SANDBOX"] = "1" - expect(described_class).to be_formula(f), "Formulae should be sandboxed if --sandbox was passed." - - ENV.delete("HOMEBREW_SANDBOX") - expect(described_class).to be_formula(f), "Formulae should be sandboxed if in a sandboxed tap." - expect(described_class).not_to be_formula(f2), "Formulae should not be sandboxed if not in a sandboxed tap." + expect(described_class).to be_formula(f), "Formulae should be sandboxed." end specify "#test?" do diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 5a6295394..e3137ac49 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -556,3 +556,7 @@ def with_env(hash) ENV.update(old_values) end end + +def shell_profile + Utils::Shell.profile +end diff --git a/docs/brew-tap.md b/docs/brew-tap.md index 126ee11c2..59825a0c9 100644 --- a/docs/brew-tap.md +++ b/docs/brew-tap.md @@ -13,7 +13,7 @@ but the command isn't limited to any one location. $ brew tap homebrew/core mistydemeo/tigerbrew -edavis/emacs +dunn/emacs ``` * `brew tap <user/repo>` makes a shallow clone of the repository at |
