language
stringclasses
1 value
owner
stringlengths
2
15
repo
stringlengths
2
21
sha
stringlengths
45
45
message
stringlengths
7
36.3k
path
stringlengths
1
199
patch
stringlengths
15
102k
is_multipart
bool
2 classes
Other
Homebrew
brew
1b688a3a25fa4ca077de88e2177241b6cb76a5f6.json
Relocate bottles on Linux using patchelf Ensure patchelf is installed to pour bottles and build bottles.
Library/Homebrew/extend/os/keg_relocate.rb
@@ -1 +1,5 @@ -require "extend/os/mac/keg_relocate" if OS.mac? +if OS.mac? + require "extend/os/mac/keg_relocate" +elsif OS.linux? + require "extend/os/linux/keg_relocate" +end
true
Other
Homebrew
brew
1b688a3a25fa4ca077de88e2177241b6cb76a5f6.json
Relocate bottles on Linux using patchelf Ensure patchelf is installed to pour bottles and build bottles.
Library/Homebrew/extend/os/linux/keg_relocate.rb
@@ -0,0 +1,81 @@ +class Keg + def relocate_dynamic_linkage(relocation) + # Patching patchelf using itself fails with "Text file busy" or SIGBUS. + return if name == "patchelf" + + elf_files.each do |file| + file.ensure_writable do + change_rpath(file, relocation.old_prefix, relocation.new_prefix) + end + end + end + + def change_rpath(file, old_prefix, new_prefix) + return if !file.elf? || !file.dynamic_elf? + + patchelf = DevelopmentTools.locate "patchelf" + cmd_rpath = [patchelf, "--print-rpath", file] + old_rpath = Utils.popen_read(*cmd_rpath, err: :out).strip + + # patchelf requires that the ELF file have a .dynstr section. + # Skip ELF files that do not have a .dynstr section. + return if ["cannot find section .dynstr", "strange: no string table"].include?(old_rpath) + raise ErrorDuringExecution, "#{cmd_rpath}\n#{old_rpath}" unless $CHILD_STATUS.success? + + rpath = old_rpath + .split(":") + .map { |x| x.sub(old_prefix, new_prefix) } + .select { |x| x.start_with?(new_prefix, "$ORIGIN") } + + lib_path = "#{new_prefix}/lib" + rpath << lib_path unless rpath.include? lib_path + new_rpath = rpath.join(":") + cmd = [patchelf, "--force-rpath", "--set-rpath", new_rpath] + + if file.binary_executable? + old_interpreter = Utils.safe_popen_read(patchelf, "--print-interpreter", file).strip + new_interpreter = if File.readable? "#{new_prefix}/lib/ld.so" + "#{new_prefix}/lib/ld.so" + else + old_interpreter.sub old_prefix, new_prefix + end + cmd << "--set-interpreter" << new_interpreter if old_interpreter != new_interpreter + end + + return if old_rpath == new_rpath && old_interpreter == new_interpreter + safe_system(*cmd, file) + end + + def detect_cxx_stdlibs(options = {}) + skip_executables = options.fetch(:skip_executables, false) + results = Set.new + elf_files.each do |file| + next unless file.dynamic_elf? + next if file.binary_executable? && skip_executables + dylibs = file.dynamically_linked_libraries + results << :libcxx if dylibs.any? { |s| s.include? "libc++.so" } + results << :libstdcxx if dylibs.any? { |s| s.include? "libstdc++.so" } + end + results.to_a + end + + def elf_files + hardlinks = Set.new + elf_files = [] + path.find do |pn| + next if pn.symlink? || pn.directory? + next if !pn.dylib? && !pn.binary_executable? + + # If we've already processed a file, ignore its hardlinks (which have the + # same dev ID and inode). This prevents relocations from being performed + # on a binary more than once. + next unless hardlinks.add? [pn.stat.dev, pn.stat.ino] + elf_files << pn + end + elf_files + end + + def self.relocation_formulae + ["patchelf"] + end +end
true
Other
Homebrew
brew
1b688a3a25fa4ca077de88e2177241b6cb76a5f6.json
Relocate bottles on Linux using patchelf Ensure patchelf is installed to pour bottles and build bottles.
Library/Homebrew/formula_installer.rb
@@ -473,13 +473,15 @@ def expand_requirements def expand_dependencies(deps) inherited_options = Hash.new { |hash, key| hash[key] = Options.new } + pour_bottle = pour_bottle? expanded_deps = Dependency.expand(formula, deps) do |dependent, dep| inherited_options[dep.name] |= inherited_options_for(dep) build = effective_build_options_for( dependent, inherited_options.fetch(dependent.name, []), ) + pour_bottle = true if install_bottle_for?(dep.to_formula, build) if dep.prune_from_option?(build) Dependency.prune @@ -494,6 +496,16 @@ def expand_dependencies(deps) end end + if pour_bottle + bottle_deps = Keg.relocation_formulae + .map { |formula| Dependency.new(formula) } + .reject do |dep| + inherited_options[dep.name] |= inherited_options_for(dep) + dep.satisfied? inherited_options[dep.name] + end + expanded_deps = Dependency.merge_repeats(bottle_deps + expanded_deps) unless bottle_deps.empty? + end + expanded_deps.map { |dep| [dep, inherited_options[dep.name]] } end
true
Other
Homebrew
brew
1b688a3a25fa4ca077de88e2177241b6cb76a5f6.json
Relocate bottles on Linux using patchelf Ensure patchelf is installed to pour bottles and build bottles.
Library/Homebrew/keg_relocate.rb
@@ -175,6 +175,10 @@ def symlink_files def self.file_linked_libraries(_file, _string) [] end + + def self.relocation_formulae + [] + end end require "extend/os/keg_relocate"
true
Other
Homebrew
brew
1b688a3a25fa4ca077de88e2177241b6cb76a5f6.json
Relocate bottles on Linux using patchelf Ensure patchelf is installed to pour bottles and build bottles.
Library/Homebrew/test/dev-cmd/bottle_spec.rb
@@ -4,6 +4,9 @@ expect { brew "install", "--build-bottle", testball } .to be_a_success + setup_test_formula "patchelf" + (HOMEBREW_CELLAR/"patchelf/1.0/bin").mkpath + expect { brew "bottle", "--no-rebuild", testball } .to output(/Formula not from core or any taps/).to_stderr .and not_to_output.to_stdout
true
Other
Homebrew
brew
1b688a3a25fa4ca077de88e2177241b6cb76a5f6.json
Relocate bottles on Linux using patchelf Ensure patchelf is installed to pour bottles and build bottles.
Library/Homebrew/test/formula_installer_bottle_spec.rb
@@ -17,6 +17,9 @@ def temporarily_install_bottle(formula) expect(formula).to be_bottled expect(formula).to pour_bottle + stub_formula_loader formula + stub_formula_loader formula("patchelf") { url "patchelf-1.0" } + allow(Formula["patchelf"]).to receive(:installed?).and_return(true) described_class.new(formula).install keg = Keg.new(formula.prefix)
true
Other
Homebrew
brew
1b688a3a25fa4ca077de88e2177241b6cb76a5f6.json
Relocate bottles on Linux using patchelf Ensure patchelf is installed to pour bottles and build bottles.
Library/Homebrew/test/formulary_spec.rb
@@ -136,20 +136,26 @@ class Wrong#{described_class.class_s(formula_name)} < Formula end context "with installed Formula" do - let(:formula) { described_class.factory(formula_path) } - let(:installer) { FormulaInstaller.new(formula) } + before do + allow(Formulary).to receive(:loader_for).and_call_original + stub_formula_loader formula("patchelf") { url "patchelf-1.0" } + allow(Formula["patchelf"]).to receive(:installed?).and_return(true) + end + + let(:installed_formula) { described_class.factory(formula_path) } + let(:installer) { FormulaInstaller.new(installed_formula) } it "returns a Formula when given a rack" do installer.install - f = described_class.from_rack(formula.rack) + f = described_class.from_rack(installed_formula.rack) expect(f).to be_kind_of(Formula) end it "returns a Formula when given a Keg" do installer.install - keg = Keg.new(formula.prefix) + keg = Keg.new(installed_formula.prefix) f = described_class.from_keg(keg) expect(f).to be_kind_of(Formula) end
true
Other
Homebrew
brew
1b688a3a25fa4ca077de88e2177241b6cb76a5f6.json
Relocate bottles on Linux using patchelf Ensure patchelf is installed to pour bottles and build bottles.
Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb
@@ -157,6 +157,10 @@ def install url "https://example.com/#{name}-1.0" depends_on "foo" RUBY + when "patchelf" + content = <<~RUBY + url "https://example.com/#{name}-1.0" + RUBY end Formulary.core_path(name).tap do |formula_path|
true
Other
Homebrew
brew
1b688a3a25fa4ca077de88e2177241b6cb76a5f6.json
Relocate bottles on Linux using patchelf Ensure patchelf is installed to pour bottles and build bottles.
Library/Homebrew/utils/popen.rb
@@ -3,10 +3,22 @@ def self.popen_read(*args, **options, &block) popen(args, "rb", options, &block) end + def self.safe_popen_read(*args, **options, &block) + output = popen_read(*args, **options, &block) + raise ErrorDuringExecution, args unless $CHILD_STATUS.success? + output + end + def self.popen_write(*args, **options, &block) popen(args, "wb", options, &block) end + def self.safe_popen_write(*args, **options, &block) + output = popen_write(args, **options, &block) + raise ErrorDuringExecution, args unless $CHILD_STATUS.success? + output + end + def self.popen(args, mode, options = {}) IO.popen("-", mode) do |pipe| if pipe
true
Other
Homebrew
brew
bf856117ba9776b3227106ace27493fe3fd9d16f.json
Allow unused keyword arguments.
Library/Homebrew/.rubocop.yml
@@ -31,6 +31,9 @@ Lint/NestedMethodDefinition: Lint/ParenthesesAsGroupedExpression: Enabled: true +Lint/UnusedMethodArgument: + AllowUnusedKeywordArguments: true + # TODO: try to bring down all metrics maximums Metrics/AbcSize: Max: 250
true
Other
Homebrew
brew
bf856117ba9776b3227106ace27493fe3fd9d16f.json
Allow unused keyword arguments.
Library/Homebrew/style.rb
@@ -30,6 +30,10 @@ def check_style_impl(files, output_type, options = {}) args << "--parallel" end + if ARGV.verbose? + args += ["--extra-details", "--display-cop-names"] + end + if ARGV.include?("--rspec") Homebrew.install_gem! "rubocop-rspec" args += %w[--require rubocop-rspec]
true
Other
Homebrew
brew
05cb6cda088d740e2cfa204da2ba36a68f503afc.json
Add `Installer` spec.
Library/Homebrew/test/cask/artifact/installer_spec.rb
@@ -0,0 +1,40 @@ +describe Hbc::Artifact::Installer, :cask do + let(:staged_path) { mktmpdir } + let(:cask) { instance_double("Cask", staged_path: staged_path, config: nil) } + subject(:installer) { described_class.new(cask, **args) } + let(:command) { Hbc::SystemCommand } + + let(:args) { {} } + + describe "#install_phase" do + context "when given a manual installer" do + let(:args) { { manual: "installer" } } + + it "shows a message prompting to run the installer manually" do + expect { + installer.install_phase(command: command) + }.to output(%r{run the installer at\s+'#{staged_path}/installer'}).to_stdout + end + end + + context "when given a script installer" do + let(:executable) { staged_path/"executable" } + let(:args) { { script: { executable: "executable" } } } + + before(:each) do + FileUtils.touch executable + end + + it "looks for the executable in HOMEBREW_PREFIX" do + expect(command).to receive(:run!).with( + executable, + a_hash_including( + env: { "PATH" => PATH.new("#{HOMEBREW_PREFIX}/bin", "#{HOMEBREW_PREFIX}/sbin", ENV["PATH"]) }, + ), + ) + + installer.install_phase(command: command) + end + end + end +end
false
Other
Homebrew
brew
37f3a603cecb24799d3b1087b342c270b78dcc12.json
Use `env` utility instead of `with_env`.
Library/Homebrew/cask/lib/hbc/system_command.rb
@@ -47,15 +47,15 @@ def initialize(executable, args: [], sudo: false, input: [], print_stdout: false @must_succeed = must_succeed options.extend(HashValidator).assert_valid_keys(:chdir) @options = options - @env = { "PATH" => ENV["PATH"] }.merge(env) + @env = env @env.keys.grep_v(/^[\w&&\D]\w*$/) do |name| raise ArgumentError, "Invalid variable name: '#{name}'" end end def command - [*sudo_prefix, executable, *args] + [*sudo_prefix, *env_args, executable, *args] end private @@ -64,18 +64,22 @@ def command attr_predicate :sudo?, :print_stdout?, :print_stderr?, :must_succeed? - def sudo_prefix - return [] unless sudo? - askpass_flags = ENV.key?("SUDO_ASKPASS") ? ["-A"] : [] - prefix = ["/usr/bin/sudo", *askpass_flags, "-E"] + def env_args + return [] if env.empty? - env.each do |name, value| + variables = env.map do |name, value| sanitized_name = Shellwords.escape(name) sanitized_value = Shellwords.escape(value) - prefix << "#{sanitized_name}=#{sanitized_value}" + "#{sanitized_name}=#{sanitized_value}" end - prefix << "--" + ["env", *variables] + end + + def sudo_prefix + return [] unless sudo? + askpass_flags = ENV.key?("SUDO_ASKPASS") ? ["-A"] : [] + ["/usr/bin/sudo", *askpass_flags, "-E", "--"] end def assert_success @@ -97,11 +101,7 @@ def each_output_line(&b) executable, *args = expanded_command raw_stdin, raw_stdout, raw_stderr, raw_wait_thr = - # We need to specifically use `with_env` for `PATH`, otherwise - # Ruby itself will not look for the executable in `PATH`. - with_env "PATH" => env["PATH"] do - Open3.popen3(env, [executable, executable], *args, **options) - end + Open3.popen3([executable, executable], *args, **options) write_input_to(raw_stdin) raw_stdin.close_write
true
Other
Homebrew
brew
37f3a603cecb24799d3b1087b342c270b78dcc12.json
Use `env` utility instead of `with_env`.
Library/Homebrew/test/cask/system_command_spec.rb
@@ -15,10 +15,10 @@ its("run!.stdout") { is_expected.to eq("123") } describe "the resulting command line" do - it "does not include the given variables" do + it "includes the given variables explicitly" do expect(Open3) .to receive(:popen3) - .with(a_hash_including("PATH"), ["env"] * 2, *env_args, {}) + .with(["env", "env"], "A=1", "B=2", "C=3", "env", *env_args, {}) .and_call_original subject.run! @@ -41,9 +41,8 @@ it "includes the given variables explicitly" do expect(Open3) .to receive(:popen3) - .with(an_instance_of(Hash), ["/usr/bin/sudo"] * 2, - "-E", a_string_starting_with("PATH="), - "A=1", "B=2", "C=3", "--", "env", *env_args, {}) + .with(["/usr/bin/sudo", "/usr/bin/sudo"], "-E", "--", + "env", "A=1", "B=2", "C=3", "env", *env_args, {}) .and_wrap_original do |original_popen3, *_, &block| original_popen3.call("/usr/bin/true", &block) end @@ -197,7 +196,7 @@ end end - it "looks for executables in custom PATH" do + it "looks for executables in a custom PATH" do mktmpdir do |path| (path/"tool").write <<~SH #!/bin/sh
true
Other
Homebrew
brew
37f3a603cecb24799d3b1087b342c270b78dcc12.json
Use `env` utility instead of `with_env`.
Library/Homebrew/test/support/helper/cask/fake_system_command.rb
@@ -1,5 +1,5 @@ def sudo(*args) - ["/usr/bin/sudo", "-E", "PATH=#{ENV["PATH"]}", "--"] + args.flatten + ["/usr/bin/sudo", "-E", "--"] + args.flatten end module Hbc
true
Other
Homebrew
brew
37f3a603cecb24799d3b1087b342c270b78dcc12.json
Use `env` utility instead of `with_env`.
Library/Homebrew/test/support/helper/spec/shared_examples/hbc_staged.rb
@@ -80,7 +80,7 @@ allow(staged).to receive(:Pathname).and_return(fake_pathname) Hbc::FakeSystemCommand.expects_command( - ["/usr/bin/sudo", "-E", "PATH=#{ENV["PATH"]}", "--", "/usr/sbin/chown", "-R", "--", "fake_user:staff", fake_pathname], + sudo("/usr/sbin/chown", "-R", "--", "fake_user:staff", fake_pathname), ) staged.set_ownership(fake_pathname.to_s) @@ -93,7 +93,7 @@ allow(staged).to receive(:Pathname).and_return(fake_pathname) Hbc::FakeSystemCommand.expects_command( - ["/usr/bin/sudo", "-E", "PATH=#{ENV["PATH"]}", "--", "/usr/sbin/chown", "-R", "--", "fake_user:staff", fake_pathname, fake_pathname], + sudo("/usr/sbin/chown", "-R", "--", "fake_user:staff", fake_pathname, fake_pathname), ) staged.set_ownership([fake_pathname.to_s, fake_pathname.to_s]) @@ -105,7 +105,7 @@ allow(staged).to receive(:Pathname).and_return(fake_pathname) Hbc::FakeSystemCommand.expects_command( - ["/usr/bin/sudo", "-E", "PATH=#{ENV["PATH"]}", "--", "/usr/sbin/chown", "-R", "--", "other_user:other_group", fake_pathname], + sudo("/usr/sbin/chown", "-R", "--", "other_user:other_group", fake_pathname), ) staged.set_ownership(fake_pathname.to_s, user: "other_user", group: "other_group")
true
Other
Homebrew
brew
1f5311888e59562152d395d25679f22f44205965.json
Add failing spec for `SystemCommand`.
Library/Homebrew/test/cask/system_command_spec.rb
@@ -2,7 +2,7 @@ describe "#initialize" do let(:env_args) { ["bash", "-c", 'printf "%s" "${A?}" "${B?}" "${C?}"'] } - describe "given some environment variables" do + context "when given some environment variables" do subject { described_class.new( "env", @@ -26,7 +26,7 @@ end end - describe "given some environment variables and sudo: true" do + context "when given some environment variables and sudo: true" do subject { described_class.new( "env", @@ -54,7 +54,7 @@ end end - describe "when the exit code is 0" do + context "when the exit code is 0" do describe "its result" do subject { described_class.run("/usr/bin/true") } @@ -63,18 +63,18 @@ end end - describe "when the exit code is 1" do + context "when the exit code is 1" do let(:command) { "/usr/bin/false" } - describe "and the command must succeed" do + context "and the command must succeed" do it "throws an error" do expect { described_class.run!(command) }.to raise_error(Hbc::CaskCommandFailedError) end end - describe "and the command does not have to succeed" do + context "and the command does not have to succeed" do describe "its result" do subject { described_class.run(command) } @@ -84,7 +84,7 @@ end end - describe "given a pathname" do + context "when given a pathname" do let(:command) { "/bin/ls" } let(:path) { Pathname(Dir.mktmpdir) } @@ -100,7 +100,7 @@ end end - describe "with both STDOUT and STDERR output from upstream" do + context "with both STDOUT and STDERR output from upstream" do let(:command) { "/bin/bash" } let(:options) { { args: [ @@ -119,7 +119,7 @@ end end - describe "with default options" do + context "with default options" do it "echoes only STDERR" do expected = [2, 4, 6].map { |i| "#{i}\n" }.join expect { @@ -130,7 +130,7 @@ include_examples("it returns '1 2 3 4 5 6'") end - describe "with print_stdout" do + context "with print_stdout" do before do options.merge!(print_stdout: true) end @@ -144,7 +144,7 @@ include_examples("it returns '1 2 3 4 5 6'") end - describe "without print_stderr" do + context "without print_stderr" do before do options.merge!(print_stderr: false) end @@ -158,7 +158,7 @@ include_examples("it returns '1 2 3 4 5 6'") end - describe "with print_stdout but without print_stderr" do + context "with print_stdout but without print_stderr" do before do options.merge!(print_stdout: true, print_stderr: false) end @@ -174,7 +174,7 @@ end end - describe "with a very long STDERR output" do + context "with a very long STDERR output" do let(:command) { "/bin/bash" } let(:options) { { args: [ @@ -190,10 +190,23 @@ end end - describe "given an invalid variable name" do + context "when given an invalid variable name" do it "raises an ArgumentError" do expect { described_class.run("true", env: { "1ABC" => true }) } .to raise_error(ArgumentError, /variable name/) end end + + it "looks for executables in custom PATH" do + mktmpdir do |path| + (path/"tool").write <<~SH + #!/bin/sh + echo Hello, world! + SH + + FileUtils.chmod "+x", path/"tool" + + expect(described_class.run("tool", env: { "PATH" => path }).stdout).to include "Hello, world!" + end + end end
false
Other
Homebrew
brew
461b61abacbafd523f007e76b39b542f04155994.json
link: fix undefined `dep_f`
Library/Homebrew/cmd/link.rb
@@ -40,7 +40,7 @@ def link elsif (MacOS.version >= :mojave || MacOS::Xcode.version >= "10.0" || MacOS::CLT.version >= "10.0") && - dep_f.keg_only_reason.reason == :provided_by_macos + keg.to_formula.keg_only_reason.reason == :provided_by_macos opoo <<~EOS Refusing to link macOS-provided software: #{keg.name} Instead, pass the full include/library paths to your compiler e.g.:
false
Other
Homebrew
brew
2f181b3f41487c0c2c4459e3dfb5a9e3d256eccb.json
link: stop unneeded force linking on Mojave/CLT 10. People are getting in the habit of force-linking things like `zlib` to fix linking/include issues on Mojave (which doesn't install headers to `/usr/include` by default). This way lies madness so encourage people to instead pass the correct compiler flags instead.
Library/Homebrew/cmd/link.rb
@@ -27,16 +27,27 @@ def link ARGV.kegs.each do |keg| keg_only = Formulary.keg_only?(keg.rack) - if HOMEBREW_PREFIX.to_s == "/usr/local" && keg_only && - keg.name.start_with?("openssl", "libressl") - opoo <<~EOS - Refusing to link: #{keg.name} - Linking keg-only #{keg.name} means you may end up linking against the insecure, - deprecated system OpenSSL while using the headers from Homebrew's #{keg.name}. - Instead, pass the full include/library paths to your compiler e.g.: - -I#{HOMEBREW_PREFIX}/opt/#{keg.name}/include -L#{HOMEBREW_PREFIX}/opt/#{keg.name}/lib - EOS - next + if HOMEBREW_PREFIX.to_s == "/usr/local" && keg_only + if keg.name.start_with?("openssl", "libressl") + opoo <<~EOS + Refusing to link: #{keg.name} + Linking keg-only #{keg.name} means you may end up linking against the insecure, + deprecated system OpenSSL while using the headers from Homebrew's #{keg.name}. + Instead, pass the full include/library paths to your compiler e.g.: + -I#{HOMEBREW_PREFIX}/opt/#{keg.name}/include -L#{HOMEBREW_PREFIX}/opt/#{keg.name}/lib + EOS + next + elsif (MacOS.version >= :mojave || + MacOS::Xcode.version >= "10.0" || + MacOS::CLT.version >= "10.0") && + dep_f.keg_only_reason.reason == :provided_by_macos + opoo <<~EOS + Refusing to link macOS-provided software: #{keg.name} + Instead, pass the full include/library paths to your compiler e.g.: + -I#{HOMEBREW_PREFIX}/opt/#{keg.name}/include -L#{HOMEBREW_PREFIX}/opt/#{keg.name}/lib + EOS + next + end elsif keg.linked? opoo "Already linked: #{keg}" puts "To relink: brew unlink #{keg.name} && brew link #{keg.name}"
false
Other
Homebrew
brew
75d3ca8e6f89aa67dbd5b891295c4bf6d05b6beb.json
Update man pages to reflect prior change Generate new man pages so that the docs and manpages match up
docs/Manpage.md
@@ -239,9 +239,9 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note If `--cc=``compiler` is passed, attempt to compile using `compiler`. `compiler` should be the name of the compiler's executable, for instance - `gcc-8` for gcc 8, `gcc-4.2` for Apple's GCC 4.2, or `gcc-4.9` for a - Homebrew-provided GCC 4.9. In order to use LLVM's clang, use - `llvm_clang`. To specify the Apple-provided clang, use `clang`. This + `gcc-8` for gcc 8, `gcc-4.2` for Apple's GCC 4.2, or `gcc-4.9` for a + Homebrew-provided GCC 4.9. In order to use LLVM's clang, use + `llvm_clang`. To specify the Apple-provided clang, use `clang`. This parameter will only accept compilers that are provided by Homebrew or bundled with MacOS. Please do not file issues if you encounter errors while using this flag.
false
Other
Homebrew
brew
72735aef175bf7ddb74728e75ad3a0dc5961c5f3.json
Update documentation and generate manpage * update references in `--cc` flag, using modern gcc examples * note that issues should not be filed if `--cc` flag is used * remove reference to `HOMEBREW_CC` as it should not be exposed to users * generate manpages using `brew man` with these changes
Library/Homebrew/cmd/install.rb
@@ -21,11 +21,12 @@ #: #: If `--cc=`<compiler> is passed, attempt to compile using <compiler>. #: <compiler> should be the name of the compiler's executable, for instance -#: `gcc-4.2` for Apple's GCC 4.2, or `gcc-4.9` for a Homebrew-provided GCC -#: 4.9. In order to use LLVM's clang, use `llvm_clang`. To specify the -#: Apple-provided clang, use `clang`. This parameter will only accept -#: compilers that are provided by Homebrew. Note that this will override -#: the value set by the `$HOMEBREW_CC` environment variable. +#: `gcc-8` for gcc 8, `gcc-4.2` for Apple's GCC 4.2, or `gcc-4.9` for a +#: Homebrew-provided GCC 4.9. In order to use LLVM's clang, use +#: `llvm_clang`. To specify the Apple-provided clang, use `clang`. This +#: parameter will only accept compilers that are provided by Homebrew or +#: bundled with MacOS. Please do not file issues if you encounter errors +#: while using this flag. #: #: If `--build-from-source` (or `-s`) is passed, compile the specified <formula> from #: source even if a bottle is provided. Dependencies will still be installed
true
Other
Homebrew
brew
72735aef175bf7ddb74728e75ad3a0dc5961c5f3.json
Update documentation and generate manpage * update references in `--cc` flag, using modern gcc examples * note that issues should not be filed if `--cc` flag is used * remove reference to `HOMEBREW_CC` as it should not be exposed to users * generate manpages using `brew man` with these changes
Library/Homebrew/manpages/brew.1.md.erb
@@ -138,15 +138,6 @@ Note that environment variables must have a value set to be detected. For exampl *Default:* `~/Library/Caches/Homebrew`. - * `HOMEBREW_CC`: - If set, instructs Homebrew to used the specified compiler to build a - package from source. In order to specify the Apple-provided clang, - set `clang`. For the clang provided from the LLVM package, use - `llvm_clang`. For versions of gcc, use the names of the executables from - the packages that Homebrew provides, e.g. for gcc 4.9, `gcc-4.9`, or for - gcc 8, `gcc-8`. Note that this variable can only be set to compilers that - are provided by Homebrew. - * `HOMEBREW_CURLRC`: If set, Homebrew will not pass `-q` when invoking `curl`(1) (which disables the use of `curlrc`).
true
Other
Homebrew
brew
72735aef175bf7ddb74728e75ad3a0dc5961c5f3.json
Update documentation and generate manpage * update references in `--cc` flag, using modern gcc examples * note that issues should not be filed if `--cc` flag is used * remove reference to `HOMEBREW_CC` as it should not be exposed to users * generate manpages using `brew man` with these changes
docs/Custom-GCC-and-cross-compilers.md
@@ -14,9 +14,9 @@ Rather than merging in brews for either of these cases at this time, we're listing them on this page. If you come up with a formula for a new version of GCC or cross-compiler suite, please link it in here. -* Homebrew provides a `gcc` formula for use with Xcode 4.2+ or when needing +- Homebrew provides a `gcc` formula for use with Xcode 4.2+ or when needing C++11 support on earlier versions. -* Homebrew provides older GCC formulae, e.g. `gcc@4.8` and `gcc@6`. -* Homebrew provides the LLVM clang, which is bundled with the `llvm` formula. -* [RISC-V](https://github.com/riscv/homebrew-riscv) provides the RISC-V - toolchain including binutils and GCC. \ No newline at end of file +- Homebrew provides older GCC formulae, e.g. `gcc@4.9` and `gcc@6`. +- Homebrew provides the LLVM clang, which is bundled with the `llvm` formula. +- [RISC-V](https://github.com/riscv/homebrew-riscv) provides the RISC-V + toolchain including binutils and GCC.
true
Other
Homebrew
brew
72735aef175bf7ddb74728e75ad3a0dc5961c5f3.json
Update documentation and generate manpage * update references in `--cc` flag, using modern gcc examples * note that issues should not be filed if `--cc` flag is used * remove reference to `HOMEBREW_CC` as it should not be exposed to users * generate manpages using `brew man` with these changes
docs/Manpage.md
@@ -239,11 +239,12 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note If `--cc=``compiler` is passed, attempt to compile using `compiler`. `compiler` should be the name of the compiler's executable, for instance - `gcc-4.2` for Apple's GCC 4.2, or `gcc-4.9` for a Homebrew-provided GCC - 4.9. In order to use LLVM's clang, use `llvm_clang`. To specify the - Apple-provided clang, use `clang`. This parameter will only accept - compilers that are provided by Homebrew. Note that this will override - the value set by the `$HOMEBREW_CC` environment variable. + `gcc-8` for gcc 8, `gcc-4.2` for Apple's GCC 4.2, or `gcc-4.9` for a + Homebrew-provided GCC 4.9. In order to use LLVM's clang, use + `llvm_clang`. To specify the Apple-provided clang, use `clang`. This + parameter will only accept compilers that are provided by Homebrew or + bundled with MacOS. Please do not file issues if you encounter errors + while using this flag. If `--build-from-source` (or `-s`) is passed, compile the specified `formula` from source even if a bottle is provided. Dependencies will still be installed @@ -1125,15 +1126,6 @@ Note that environment variables must have a value set to be detected. For exampl *Default:* `~/Library/Caches/Homebrew`. - * `HOMEBREW_CC`: - If set, instructs Homebrew to used the specified compiler to build a - package from source. In order to specify the Apple-provided clang, - set `clang`. For the clang provided from the LLVM package, use - `llvm_clang`. For versions of gcc, use the names of the executables from - the packages that Homebrew provides, e.g. for gcc 4.9, `gcc-4.9`, or for - gcc 8, `gcc-8`. Note that this variable can only be set to compilers that - are provided by Homebrew. - * `HOMEBREW_CURLRC`: If set, Homebrew will not pass `-q` when invoking `curl`(1) (which disables the use of `curlrc`).
true
Other
Homebrew
brew
72735aef175bf7ddb74728e75ad3a0dc5961c5f3.json
Update documentation and generate manpage * update references in `--cc` flag, using modern gcc examples * note that issues should not be filed if `--cc` flag is used * remove reference to `HOMEBREW_CC` as it should not be exposed to users * generate manpages using `brew man` with these changes
manpages/brew.1
@@ -227,7 +227,7 @@ If \fB\-\-ignore\-dependencies\fR is passed, skip installing any dependencies of If \fB\-\-only\-dependencies\fR is passed, install the dependencies with specified options but do not install the specified formula\. . .IP -If \fB\-\-cc=\fR\fIcompiler\fR is passed, attempt to compile using \fIcompiler\fR\. \fIcompiler\fR should be the name of the compiler\'s executable, for instance \fBgcc\-4\.2\fR for Apple\'s GCC 4\.2, or \fBgcc\-4\.9\fR for a Homebrew\-provided GCC 4\.9\. In order to use LLVM\'s clang, use \fBllvm_clang\fR\. To specify the Apple\-provided clang, use \fBclang\fR\. This parameter will only accept compilers that are provided by Homebrew\. Note that this will override the value set by the \fB$HOMEBREW_CC\fR environment variable\. +If \fB\-\-cc=\fR\fIcompiler\fR is passed, attempt to compile using \fIcompiler\fR\. \fIcompiler\fR should be the name of the compiler\'s executable, for instance \fBgcc\-8\fR for gcc 8, \fBgcc\-4\.2\fR for Apple\'s GCC 4\.2, or \fBgcc\-4\.9\fR for a Homebrew\-provided GCC 4\.9\. In order to use LLVM\'s clang, use \fBllvm_clang\fR\. To specify the Apple\-provided clang, use \fBclang\fR\. This parameter will only accept compilers that are provided by Homebrew or bundled with MacOS\. Please do not file issues if you encounter errors while using this flag\. . .IP If \fB\-\-build\-from\-source\fR (or \fB\-s\fR) is passed, compile the specified \fIformula\fR from source even if a bottle is provided\. Dependencies will still be installed from bottles if they are available\. @@ -1069,10 +1069,6 @@ If set, instructs Homebrew to use the given directory as the download cache\. \fIDefault:\fR \fB~/Library/Caches/Homebrew\fR\. . .TP -\fBHOMEBREW_CC\fR -If set, instructs Homebrew to used the specified compiler to build a package from source\. In order to specify the Apple\-provided clang, set \fBclang\fR\. For the clang provided from the LLVM package, use \fBllvm_clang\fR\. For versions of gcc, use the names of the executables from the packages that Homebrew provides, e\.g\. for gcc 4\.9, \fBgcc\-4\.9\fR, or for gcc 8, \fBgcc\-8\fR\. Note that this variable can only be set to compilers that are provided by Homebrew\. -. -.TP \fBHOMEBREW_CURLRC\fR If set, Homebrew will not pass \fB\-q\fR when invoking \fBcurl\fR(1) (which disables the use of \fBcurlrc\fR)\. .
true
Other
Homebrew
brew
d9f90deb7c7ef8de93b6b4d80ccd5be42745aa33.json
download_strategy: use tar xf. The flags and separate `-` aren't required on 10.5 which is the oldest version of macOS we support (and it looks nicer this way).
Library/Homebrew/download_strategy.rb
@@ -194,15 +194,7 @@ def stage if type == :xz && DependencyCollector.tar_needs_xz_dependency? pipe_to_tar "#{HOMEBREW_PREFIX}/opt/xz/bin/xz", unpack_dir else - flags = if type == :gzip - ["-z"] - elsif type == :bzip2 - ["-j"] - elsif type == :xz - ["-J"] - end - - safe_system "tar", "-x", *flags, "-f", path, "-C", unpack_dir + safe_system "tar", "xf", path, "-C", unpack_dir end chdir when :lzip @@ -239,7 +231,7 @@ def pipe_to_tar(tool, unpack_dir) path = cached_location Utils.popen_read(tool, "-dc", path) do |rd| - Utils.popen_write("tar", "-x", "-f", "-", "-C", unpack_dir) do |wr| + Utils.popen_write("tar", "xf", "-", "-C", unpack_dir) do |wr| buf = "" wr.write(buf) while rd.read(16384, buf) end
false
Other
Homebrew
brew
f5fbb74aaf847c9589af82ceea2f388eae02e0f6.json
linkage: fix output of optional dependencies. Check the runtime dependencies from the tab when outputting the `brew linkage` declared vs. undeclared dependencies.
Library/Homebrew/formula.rb
@@ -1518,7 +1518,7 @@ def opt_or_installed_prefix_keg # Returns a list of Dependency objects that are required at runtime. # @private - def runtime_dependencies(read_from_tab: true) + def runtime_dependencies(read_from_tab: true, undeclared: true) if read_from_tab && (keg = opt_or_installed_prefix_keg) && (tab_deps = keg.runtime_dependencies) @@ -1529,6 +1529,7 @@ def runtime_dependencies(read_from_tab: true) end.compact end + return declared_runtime_dependencies unless undeclared declared_runtime_dependencies | undeclared_runtime_dependencies end
true
Other
Homebrew
brew
f5fbb74aaf847c9589af82ceea2f388eae02e0f6.json
linkage: fix output of optional dependencies. Check the runtime dependencies from the tab when outputting the `brew linkage` declared vs. undeclared dependencies.
Library/Homebrew/linkage_checker.rb
@@ -149,7 +149,8 @@ def check_undeclared_deps declared_deps_names = declared_deps_full_names.map do |dep| dep.split("/").last end - recursive_deps = formula.declared_runtime_dependencies.map do |dep| + recursive_deps = formula.runtime_dependencies(undeclared: false) + .map do |dep| begin dep.to_formula.name rescue FormulaUnavailableError
true
Other
Homebrew
brew
14364bbaee7de213b51abef5ac1f75b9100982f5.json
extend/ENV: support CX11 for LLVM Clang. Fix some checks for `:clang` which should match for either `:clang` or `:llvm_clang`. Note that's not every check.
Library/Homebrew/extend/ENV/shared.rb
@@ -147,7 +147,7 @@ def fcflags # Outputs the current compiler. # @return [Symbol] - # <pre># Do something only for clang + # <pre># Do something only for the system clang # if ENV.compiler == :clang # # modify CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS in one go: # ENV.append_to_cflags "-I ./missing/includes" @@ -301,6 +301,18 @@ def permit_arch_flags; end # A no-op until we enable this by default again (which we may never do). def permit_weak_imports; end + # @private + def compiler_any_clang?(cc = compiler) + %w[clang llvm_clang].include?(cc.to_s) + end + + # @private + def compiler_with_cxx11_support?(cc) + return if compiler_any_clang?(cc) + version = cc[/^gcc-(\d+(?:\.\d+)?)$/, 1] + version && Version.create(version) >= Version.create("4.8") + end + private def cc=(val) @@ -330,11 +342,6 @@ def check_for_compiler_universal_support return unless homebrew_cc =~ GNU_GCC_REGEXP raise "Non-Apple GCC can't build universal binaries" end - - def gcc_with_cxx11_support?(cc) - version = cc[/^gcc-(\d+(?:\.\d+)?)$/, 1] - version && Version.create(version) >= Version.create("4.8") - end end require "extend/os/extend/ENV/shared"
true
Other
Homebrew
brew
14364bbaee7de213b51abef5ac1f75b9100982f5.json
extend/ENV: support CX11 for LLVM Clang. Fix some checks for `:clang` which should match for either `:clang` or `:llvm_clang`. Note that's not every check.
Library/Homebrew/extend/ENV/std.rb
@@ -157,7 +157,7 @@ def universal_binary append_to_cflags Hardware::CPU.universal_archs.as_arch_flags append "LDFLAGS", Hardware::CPU.universal_archs.as_arch_flags - return if compiler == :clang + return if compiler_any_clang? return unless Hardware.is_32_bit? # Can't mix "-march" for a 32-bit CPU with "-arch x86_64" replace_in_cflags(/-march=\S*/, "-Xarch_#{Hardware::CPU.arch_32_bit} \\0") @@ -167,7 +167,7 @@ def cxx11 if compiler == :clang append "CXX", "-std=c++11" append "CXX", "-stdlib=libc++" - elsif gcc_with_cxx11_support?(compiler) + elsif compiler_with_cxx11_support?(compiler) append "CXX", "-std=c++11" else raise "The selected compiler doesn't support C++11: #{compiler}"
true
Other
Homebrew
brew
14364bbaee7de213b51abef5ac1f75b9100982f5.json
extend/ENV: support CX11 for LLVM Clang. Fix some checks for `:clang` which should match for either `:clang` or `:llvm_clang`. Note that's not every check.
Library/Homebrew/extend/ENV/super.rb
@@ -276,7 +276,7 @@ def universal_binary self["HOMEBREW_ARCHFLAGS"] = Hardware::CPU.universal_archs.as_arch_flags # GCC doesn't accept "-march" for a 32-bit CPU with "-arch x86_64" - return if compiler == :clang + return if compiler_any_clang? return unless Hardware::CPU.is_32_bit? self["HOMEBREW_OPTFLAGS"] = self["HOMEBREW_OPTFLAGS"].sub( /-march=\S*/, @@ -300,7 +300,7 @@ def cxx11 if homebrew_cc == "clang" append "HOMEBREW_CCCFG", "x", "" append "HOMEBREW_CCCFG", "g", "" - elsif gcc_with_cxx11_support?(homebrew_cc) + elsif compiler_with_cxx11_support?(homebrew_cc) append "HOMEBREW_CCCFG", "x", "" else raise "The selected compiler doesn't support C++11: #{homebrew_cc}"
true
Other
Homebrew
brew
14364bbaee7de213b51abef5ac1f75b9100982f5.json
extend/ENV: support CX11 for LLVM Clang. Fix some checks for `:clang` which should match for either `:clang` or `:llvm_clang`. Note that's not every check.
Library/Homebrew/test/ENV_spec.rb
@@ -156,6 +156,18 @@ expect(subject["FOO"]).to eq "bar" end end + + describe "#compiler_any_clang?" do + it "returns true for llvm_clang" do + expect(subject.compiler_any_clang?(:llvm_clang)).to be true + end + end + + describe "#compiler_with_cxx11_support?" do + it "returns true for gcc-4.9" do + expect(subject.compiler_with_cxx11_support?("gcc-4.9")).to be true + end + end end describe Stdenv do
true
Other
Homebrew
brew
5e3bc855273d73d2c67704a640d0680afe059ff4.json
Remove unnecessary `Pathname` check.
Library/Homebrew/resource.rb
@@ -118,7 +118,7 @@ def unpack(target = nil) if block_given? yield ResourceStageContext.new(self, staging) elsif target - target = Pathname.new(target) unless target.is_a? Pathname + target = Pathname(target) target.install Pathname.pwd.children end end
false
Other
Homebrew
brew
7e5addfb22661814a10253648719be9f4f8041dd.json
Add version number to cask JSON option `$ brew cask info --json=v1 <formula>` instead of `$ brew cask info --json <formula>`
Library/Homebrew/cask/lib/hbc/cli/info.rb
@@ -3,17 +3,16 @@ module Hbc class CLI class Info < AbstractCommand - option "--json-v1", :json, false + option "--json=VERSION", :json def initialize(*) super raise CaskUnspecifiedError if args.empty? end def run - if json? - json = casks.map(&:to_hash) - puts JSON.generate(json) + if json == "v1" + puts JSON.generate(casks.map(&:to_hash)) else casks.each do |cask| odebug "Getting info for Cask #{cask}"
false
Other
Homebrew
brew
1424b20a3d59f7ba1defa5407e081a6dab55e9fa.json
config: handle HOMEBREW_TEMP being unset. This can happen when updating from a previous version of Homebrew.
Library/Homebrew/config.rb
@@ -40,7 +40,9 @@ # Must use /tmp instead of $TMPDIR because long paths break Unix domain sockets HOMEBREW_TEMP = begin - tmp = Pathname.new(ENV["HOMEBREW_TEMP"]) + # /tmp fallback is here for people auto-updating from a version where + # HOMEBREW_TEMP isn't set. + tmp = Pathname.new(ENV["HOMEBREW_TEMP"] || "/tmp") tmp.mkpath unless tmp.exist? tmp.realpath end
false
Other
Homebrew
brew
a185f3272edf96fc6e65eaf236a61d067270c966.json
audit: disallow unstable specs for versioned formulae
Library/Homebrew/dev-cmd/audit.rb
@@ -571,8 +571,19 @@ def audit_specs end end - if @new_formula && formula.head - new_formula_problem "Formulae should not have a HEAD spec" + if formula.head || formula.devel + unstable_spec_message = "Formulae should not have an unstable spec" + if @new_formula + new_formula_problem unstable_spec_message + elsif formula.versioned_formula? + versioned_unstable_spec = %w[ + bash-completion@2 + imagemagick@6 + openssl@1.1 + python@2 + ] + problem unstable_spec_message unless versioned_unstable_spec.include?(formula.name) + end end throttled = %w[
false
Other
Homebrew
brew
22b3102fbe126be7f58e4d4a70214bf62d07bc09.json
Add version number to cask json option Old: $ brew cask info --json <formula> New: $ brew cask info --json-v1 <formula>
Library/Homebrew/cask/lib/hbc/cli/info.rb
@@ -3,7 +3,7 @@ module Hbc class CLI class Info < AbstractCommand - option "--json", :json, false + option "--json-v1", :json, false def initialize(*) super
false
Other
Homebrew
brew
0bfc6bd490d0ee12624c1c20f7b525bc1939a744.json
Improve format of git cask info --json output
Library/Homebrew/cask/lib/hbc/artifact/abstract_flight_block.rb
@@ -26,6 +26,10 @@ def uninstall_phase(**) abstract_phase(self.class.uninstall_dsl_key) end + def summarize + directives.keys.map(&:to_s).join(", ") + end + private def class_for_dsl_key(dsl_key) @@ -37,10 +41,6 @@ def abstract_phase(dsl_key) return if (block = directives[dsl_key]).nil? class_for_dsl_key(dsl_key).new(cask).instance_eval(&block) end - - def summarize - directives.keys.map(&:to_s).join(", ") - end end end end
true
Other
Homebrew
brew
0bfc6bd490d0ee12624c1c20f7b525bc1939a744.json
Improve format of git cask info --json output
Library/Homebrew/cask/lib/hbc/cask.rb
@@ -138,7 +138,7 @@ def to_hash "appcast" => appcast, "version" => version, "sha256" => sha256, - "artifacts" => artifacts, + "artifacts" => {}, "caveats" => caveats, "depends_on" => depends_on, "conflicts_with" => conflicts_with, @@ -148,6 +148,12 @@ def to_hash "auto_updates" => auto_updates } + artifacts.each do |a| + hsh["artifacts"][a.class.english_name] = a.summarize + end + + hsh["conflicts_with"] = [] if hsh["conflicts_with"] == nil + hsh end end
true
Other
Homebrew
brew
27b58b6955edba830f448f04bda81c1d66105859.json
travis.yml: update xcode to 9.4
.travis.yml
@@ -12,7 +12,7 @@ matrix: include: - os: osx compiler: clang - osx_image: xcode9.2 + osx_image: xcode9.4 - os: linux compiler: gcc sudo: false
false
Other
Homebrew
brew
2d5ae645d9cc46af57aaaabbfe6bfb2db9f9e1bd.json
Add basic JSON option to brew cask $ brew cask info --json <cask>
Library/Homebrew/cask/lib/hbc/cask.rb
@@ -129,5 +129,26 @@ def dumpcask odebug "Cask instance method '#{method}':", send(method).to_yaml end end + + def to_hash + hsh = { + "name" => name, + "homepage" => homepage, + "url" => url, + "appcast" => appcast, + "version" => version, + "sha256" => sha256, + "artifacts" => artifacts, + "caveats" => caveats, + "depends_on" => depends_on, + "conflicts_with" => conflicts_with, + "container" => container, + "gpg" => gpg, + "accessibility_access" => accessibility_access, + "auto_updates" => auto_updates + } + + hsh + end end end
true
Other
Homebrew
brew
2d5ae645d9cc46af57aaaabbfe6bfb2db9f9e1bd.json
Add basic JSON option to brew cask $ brew cask info --json <cask>
Library/Homebrew/cask/lib/hbc/cli/info.rb
@@ -1,15 +1,24 @@ +require "json" + module Hbc class CLI class Info < AbstractCommand + option "--json", :json, false + def initialize(*) super raise CaskUnspecifiedError if args.empty? end def run - casks.each do |cask| - odebug "Getting info for Cask #{cask}" - self.class.info(cask) + if json? + json = casks.map(&:to_hash) + puts JSON.generate(json) + else + casks.each do |cask| + odebug "Getting info for Cask #{cask}" + self.class.info(cask) + end end end
true
Other
Homebrew
brew
bde7c6b82b7794dda797124b26c8593ca034876c.json
brew.sh: Use bashisms for default values
Library/Homebrew/brew.sh
@@ -104,10 +104,7 @@ then HOMEBREW_SYSTEM_GIT_TOO_OLD="1" fi - if [[ -z "$HOMEBREW_CACHE" ]] - then - HOMEBREW_CACHE="$HOME/Library/Caches/Homebrew" - fi + HOMEBREW_CACHE="${HOMEBREW_CACHE:-${HOME}/Library/Caches/Homebrew}" HOMEBREW_TEMP="${HOMEBREW_TEMP:-/private/tmp}" else @@ -117,15 +114,8 @@ else : "${HOMEBREW_OS_VERSION:=$(uname -r)}" HOMEBREW_OS_USER_AGENT_VERSION="$HOMEBREW_OS_VERSION" - if [[ -z "$HOMEBREW_CACHE" ]] - then - if [[ -n "$XDG_CACHE_HOME" ]] - then - HOMEBREW_CACHE="$XDG_CACHE_HOME/Homebrew" - else - HOMEBREW_CACHE="$HOME/.cache/Homebrew" - fi - fi + cache_home="${XDG_CACHE_HOME:-${HOME}/.cache}" + HOMEBREW_CACHE="${HOMEBREW_CACHE:-${cache_home}/Homebrew}" HOMEBREW_TEMP="${HOMEBREW_TEMP:-/tmp}" fi
false
Other
Homebrew
brew
039a4ee4b36ff34ed770af4901696c5e9d086006.json
brew.sh: Move HOMEBREW_TEMP declaration Additionally, assign HOMEBREW_TEMP based on the host system (/tmp for Linux, /private/tmp for macOS).
Library/Homebrew/brew.sh
@@ -108,6 +108,8 @@ then then HOMEBREW_CACHE="$HOME/Library/Caches/Homebrew" fi + + HOMEBREW_TEMP="${HOMEBREW_TEMP:-/private/tmp}" else HOMEBREW_PROCESSOR="$(uname -m)" HOMEBREW_PRODUCT="${HOMEBREW_SYSTEM}brew" @@ -124,6 +126,8 @@ else HOMEBREW_CACHE="$HOME/.cache/Homebrew" fi fi + + HOMEBREW_TEMP="${HOMEBREW_TEMP:-/tmp}" fi if [[ -n "$HOMEBREW_FORCE_BREWED_CURL" &&
true
Other
Homebrew
brew
039a4ee4b36ff34ed770af4901696c5e9d086006.json
brew.sh: Move HOMEBREW_TEMP declaration Additionally, assign HOMEBREW_TEMP based on the host system (/tmp for Linux, /private/tmp for macOS).
bin/brew
@@ -21,7 +21,6 @@ symlink_target_directory() { BREW_FILE_DIRECTORY="$(quiet_cd "${0%/*}/" && pwd -P)" HOMEBREW_BREW_FILE="${BREW_FILE_DIRECTORY%/}/${0##*/}" HOMEBREW_PREFIX="${HOMEBREW_BREW_FILE%/*/*}" -HOMEBREW_TEMP="${HOMEBREW_TEMP:-/private/tmp}" # Default to / prefix if unset or the bin/brew file. if [[ -z "$HOMEBREW_PREFIX" || "$HOMEBREW_PREFIX" = "$HOMEBREW_BREW_FILE" ]]
true
Other
Homebrew
brew
71a79e7e040202c543e54198bc91539c0b7abc01.json
Ignore false RuboCop positive.
Library/Homebrew/utils/formatter.rb
@@ -110,7 +110,7 @@ def pluralize(count, singular, plural = nil, show_count: true) end def comma_and(*items) - *items, last = items.map(&:to_s) + *items, last = items.map(&:to_s) # rubocop:disable Lint/ShadowedArgument, TODO: Remove when RuboCop 0.57.3 is released. return last if items.empty? "#{items.join(", ")} and #{last}"
false
Other
Homebrew
brew
785750ee6364b14e47dfac352372cb51a83ee9c9.json
Add `Tap#contents` methods.
Library/Homebrew/cmd/tap-info.rb
@@ -62,13 +62,11 @@ def print_tap_info(taps) if tap.installed? info += tap.pinned? ? "pinned" : "unpinned" info += ", private" if tap.private? - if (formula_count = tap.formula_files.size).positive? - info += ", #{Formatter.pluralize(formula_count, "formula")}" + if (contents = tap.contents).empty? + info += ", no commands/casks/formulae" + else + info += ", #{contents.join(", ")}" end - if (command_count = tap.command_files.size).positive? - info += ", #{Formatter.pluralize(command_count, "command")}" - end - info += ", no formulae/commands" if (formula_count + command_count).zero? info += "\n#{tap.path} (#{tap.path.abv})" info += "\nFrom: #{tap.remote.nil? ? "N/A" : tap.remote}" else
true
Other
Homebrew
brew
785750ee6364b14e47dfac352372cb51a83ee9c9.json
Add `Tap#contents` methods.
Library/Homebrew/tap.rb
@@ -284,9 +284,8 @@ def install(options = {}) link_completions_and_manpages - casks = Formatter.pluralize(cask_files.count, "cask") - formulae = Formatter.pluralize(formula_files.count, "formula") - puts "Tapped #{formulae} and #{casks} (#{path.abv})." unless quiet + formatted_contents = Formatter.enumeration(*contents)&.prepend(" ") + puts "Tapped#{formatted_contents} (#{path.abv})." unless quiet Descriptions.cache_formulae(formula_names) return if options[:clone_target] @@ -315,16 +314,15 @@ def uninstall puts "Untapping #{name}..." abv = path.abv - casks = Formatter.pluralize(cask_files.count, "cask") - formulae = Formatter.pluralize(formula_files.count, "formula") + formatted_contents = Formatter.enumeration(*contents)&.prepend(" ") unpin if pinned? Descriptions.uncache_formulae(formula_names) Utils::Link.unlink_manpages(path) Utils::Link.unlink_completions(path) path.rmtree path.parent.rmdir_if_possible - puts "Untapped #{formulae} and #{casks} (#{abv})." + puts "Untapped#{formatted_contents} (#{abv})." clear_cache end @@ -348,6 +346,24 @@ def cask_dir @cask_dir ||= path/"Casks" end + def contents + contents = [] + + if (command_count = command_files.count).positive? + contents << Formatter.pluralize(command_count, "command") + end + + if (cask_count = cask_files.count).positive? + contents << Formatter.pluralize(cask_count, "cask") + end + + if (formula_count = formula_files.count).positive? + contents << Formatter.pluralize(formula_count, "formula") + end + + contents + end + # an array of all {Formula} files of this {Tap}. def formula_files @formula_files ||= if formula_dir.directory? @@ -432,7 +448,8 @@ def alias_reverse_table # an array of all commands files of this {Tap}. def command_files - @command_files ||= Pathname.glob("#{path}/cmd/brew-*").select(&:executable?) + @command_files ||= Pathname.glob("#{path}/cmd/brew{,cask}-*") + .select { |file| file.executable? || file.extname == ".rb" } end # path to the pin record for this {Tap}.
true
Other
Homebrew
brew
2aa7597e70d8aa5bd529494884646797ea547cb0.json
Show tapped casks.
Library/Homebrew/tap.rb
@@ -284,8 +284,9 @@ def install(options = {}) link_completions_and_manpages - formula_count = formula_files.size - puts "Tapped #{Formatter.pluralize(formula_count, "formula")} (#{path.abv})" unless quiet + casks = Formatter.pluralize(cask_files.count, "cask") + formulae = Formatter.pluralize(formula_files.count, "formula") + puts "Tapped #{formulae} and #{casks} (#{path.abv})." unless quiet Descriptions.cache_formulae(formula_names) return if options[:clone_target] @@ -311,15 +312,19 @@ def uninstall require "descriptions" raise TapUnavailableError, name unless installed? - puts "Untapping #{name}... (#{path.abv})" + puts "Untapping #{name}..." + + abv = path.abv + casks = Formatter.pluralize(cask_files.count, "cask") + formulae = Formatter.pluralize(formula_files.count, "formula") + unpin if pinned? - formula_count = formula_files.size Descriptions.uncache_formulae(formula_names) Utils::Link.unlink_manpages(path) Utils::Link.unlink_completions(path) path.rmtree path.parent.rmdir_if_possible - puts "Untapped #{Formatter.pluralize(formula_count, "formula")}" + puts "Untapped #{formulae} and #{casks} (#{abv})." clear_cache end
false
Other
Homebrew
brew
ad82cd888e9acf2fdc4c795156b3e0c0e4e88988.json
Remove unneeded RuboCop comment.
Library/Homebrew/debrew.rb
@@ -119,7 +119,7 @@ def self.debug(e) if e.is_a?(Ignorable) menu.choice(:irb) do puts "When you exit this IRB session, execution will continue." - set_trace_func proc { |event, _, _, id, binding, klass| # rubocop:disable Metrics/ParameterLists + set_trace_func proc { |event, _, _, id, binding, klass| if klass == Raise && id == :raise && event == "return" set_trace_func(nil) synchronize { IRB.start_within(binding) }
false
Other
Homebrew
brew
c552e6596ca381cc035128b93013ee2220c728e9.json
brew.sh: Remove trailing / from prefix in message
Library/Homebrew/brew.sh
@@ -300,7 +300,7 @@ check-prefix-is-not-tmpdir() { odie <<EOS Your HOMEBREW_PREFIX is in the system temporary directory, which Homebrew uses to store downloads and builds. You can resolve this by installing Homebrew to -either the standard prefix (/usr/local/) or to a non-standard prefix that is not +either the standard prefix (/usr/local) or to a non-standard prefix that is not in the system temporary directory. EOS fi
false
Other
Homebrew
brew
949c0cc47ee4fe6a3e649a0bd3f51e71d1f39735.json
brew.sh: Use realpath to calculate tmpdir
Library/Homebrew/brew.sh
@@ -295,14 +295,13 @@ EOS check-run-command-as-root check-prefix-is-not-tmpdir() { - if [[ "${HOMEBREW_PREFIX}" = /tmp/* || - "${HOMEBREW_PREFIX}" = /private/tmp/* ]] + if [[ $(realpath "${HOMEBREW_PREFIX}") = /private/tmp/* ]] then odie <<EOS -Your HOMEBREW_PREFIX is in one of the system temporary directories, which Homebrew +Your HOMEBREW_PREFIX is in the system temporary directorie, which Homebrew uses to store downloads and builds. You can resolve this by installing Homebrew to either the standard prefix (/usr/local/) or to a non-standard prefix that is not -a system temporary directory. +the system temporary directory. EOS fi }
false
Other
Homebrew
brew
ec6420229e003e785181c10b9f9ff8e98f1330fd.json
brew.sh: remove unused variable. As of #4377 this is no longer used.
Library/Homebrew/brew.sh
@@ -101,7 +101,6 @@ then # https://github.com/blog/2507-weak-cryptographic-standards-removed if [[ "$HOMEBREW_MACOS_VERSION_NUMERIC" -lt "100900" ]] then - HOMEBREW_SYSTEM_GIT_TOO_OLD="1" HOMEBREW_FORCE_BREWED_GIT="1" fi
false
Other
Homebrew
brew
6f5c8b8509555f8da76967d73665cd84d9af06b5.json
linkage: enable cache by default. This has not been causing any issues in CI or for `master` users so let's now enable it by default for everyone.
Library/Homebrew/brew.sh
@@ -287,11 +287,6 @@ then HOMEBREW_BASH_COMMAND="$HOMEBREW_LIBRARY/Homebrew/dev-cmd/$HOMEBREW_COMMAND.sh" fi -if [[ -n "$HOMEBREW_DEVELOPER" || -n "$HOMEBREW_DEV_CMD_RUN" ]] -then - export HOMEBREW_LINKAGE_CACHE="1" -fi - check-run-command-as-root() { [[ "$(id -u)" = 0 ]] || return
true
Other
Homebrew
brew
6f5c8b8509555f8da76967d73665cd84d9af06b5.json
linkage: enable cache by default. This has not been causing any issues in CI or for `master` users so let's now enable it by default for everyone.
Library/Homebrew/dev-cmd/linkage.rb
@@ -1,4 +1,4 @@ -#: * `linkage` [`--test`] [`--reverse`] [`--cached`] <formula>: +#: * `linkage` [`--test`] [`--reverse`] <formula>: #: Checks the library links of an installed formula. #: #: Only works on installed formulae. An error is raised if it is run on @@ -9,9 +9,6 @@ #: #: If `--reverse` is passed, print the dylib followed by the binaries #: which link to it for each library the keg references. -#: -#: If `--cached` is passed, print the cached linkage values stored in -#: HOMEBREW_CACHE, set from a previous `brew linkage` run require "cache_store" require "linkage_checker" @@ -24,7 +21,6 @@ def linkage Homebrew::CLI::Parser.parse do switch "--test" switch "--reverse" - switch "--cached" switch :verbose switch :debug end @@ -33,8 +29,7 @@ def linkage ARGV.kegs.each do |keg| ohai "Checking #{keg.name} linkage" if ARGV.kegs.size > 1 - use_cache = args.cached? || ENV["HOMEBREW_LINKAGE_CACHE"] - result = LinkageChecker.new(keg, use_cache: use_cache, cache_db: db) + result = LinkageChecker.new(keg, cache_db: db) if args.test? result.display_test_output
true
Other
Homebrew
brew
6f5c8b8509555f8da76967d73665cd84d9af06b5.json
linkage: enable cache by default. This has not been causing any issues in CI or for `master` users so let's now enable it by default for everyone.
Library/Homebrew/linkage_checker.rb
@@ -5,12 +5,10 @@ class LinkageChecker attr_reader :undeclared_deps - def initialize(keg, formula = nil, cache_db:, - use_cache: !ENV["HOMEBREW_LINKAGE_CACHE"].nil?, - rebuild_cache: false) + def initialize(keg, formula = nil, cache_db:, rebuild_cache: false) @keg = keg @formula = formula || resolve_formula(keg) - @store = LinkageCacheStore.new(keg.to_s, cache_db) if use_cache + @store = LinkageCacheStore.new(keg.to_s, cache_db) @system_dylibs = Set.new @broken_dylibs = Set.new
true
Other
Homebrew
brew
6f5c8b8509555f8da76967d73665cd84d9af06b5.json
linkage: enable cache by default. This has not been causing any issues in CI or for `master` users so let's now enable it by default for everyone.
Library/Homebrew/test/dev-cmd/linkage_spec.rb
@@ -4,32 +4,16 @@ (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath end - context "no cache" do - it "works when no arguments are provided" do - expect { brew "linkage" } - .to be_a_success - .and not_to_output.to_stdout - .and not_to_output.to_stderr - end - - it "works when one argument is provided" do - expect { brew "linkage", "testball" } - .to be_a_success - .and not_to_output.to_stderr - end + it "works when no arguments are provided" do + expect { brew "linkage" } + .to be_a_success + .and not_to_output.to_stdout + .and not_to_output.to_stderr end - context "cache" do - it "works when no arguments are provided" do - expect { brew "linkage", "--cached" } - .to be_a_success - .and not_to_output.to_stderr - end - - it "works when one argument is provided" do - expect { brew "linkage", "--cached", "testball" } - .to be_a_success - .and not_to_output.to_stderr - end + it "works when one argument is provided" do + expect { brew "linkage", "testball" } + .to be_a_success + .and not_to_output.to_stderr end end
true
Other
Homebrew
brew
6f5c8b8509555f8da76967d73665cd84d9af06b5.json
linkage: enable cache by default. This has not been causing any issues in CI or for `master` users so let's now enable it by default for everyone.
docs/Manpage.md
@@ -779,7 +779,7 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note If `--pry` is passed or HOMEBREW_PRY is set, pry will be used instead of irb. - * `linkage` [`--test`] [`--reverse`] [`--cached`] `formula`: + * `linkage` [`--test`] [`--reverse`] `formula`: Checks the library links of an installed formula. Only works on installed formulae. An error is raised if it is run on @@ -791,9 +791,6 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note If `--reverse` is passed, print the dylib followed by the binaries which link to it for each library the keg references. - If `--cached` is passed, print the cached linkage values stored in - HOMEBREW_CACHE, set from a previous `brew linkage` run - * `man` [`--fail-if-changed`]: Generate Homebrew's manpages.
true
Other
Homebrew
brew
6f5c8b8509555f8da76967d73665cd84d9af06b5.json
linkage: enable cache by default. This has not been causing any issues in CI or for `master` users so let's now enable it by default for everyone.
manpages/brew.1
@@ -795,7 +795,7 @@ Enter the interactive Homebrew Ruby shell\. If \fB\-\-examples\fR is passed, several examples will be shown\. If \fB\-\-pry\fR is passed or HOMEBREW_PRY is set, pry will be used instead of irb\. . .TP -\fBlinkage\fR [\fB\-\-test\fR] [\fB\-\-reverse\fR] [\fB\-\-cached\fR] \fIformula\fR +\fBlinkage\fR [\fB\-\-test\fR] [\fB\-\-reverse\fR] \fIformula\fR Checks the library links of an installed formula\. . .IP @@ -807,9 +807,6 @@ If \fB\-\-test\fR is passed, only display missing libraries and exit with a non\ .IP If \fB\-\-reverse\fR is passed, print the dylib followed by the binaries which link to it for each library the keg references\. . -.IP -If \fB\-\-cached\fR is passed, print the cached linkage values stored in HOMEBREW_CACHE, set from a previous \fBbrew linkage\fR run -. .TP \fBman\fR [\fB\-\-fail\-if\-changed\fR] Generate Homebrew\'s manpages\.
true
Other
Homebrew
brew
547751d067f2a47afc92a96f97825f8b1238763d.json
Remove infinite loophole
Library/Homebrew/shims/linux/super/make
@@ -7,4 +7,20 @@ else MAKE="make" fi export HOMEBREW_CCCFG="O$HOMEBREW_CCCFG" + +pathremove () { + local IFS=':' + local NEWPATH + local DIR + local PATHVARIABLE=${2:-PATH} + for DIR in ${!PATHVARIABLE} ; do + if [ "$DIR" != "$1" ] ; then + NEWPATH=${NEWPATH:+$NEWPATH:}$DIR + fi + done + export $PATHVARIABLE="$NEWPATH" +} + +pathremove "$HOMEBREW_LIBRARY/Homebrew/shims/linux/super" + exec "$MAKE" "$@"
false
Other
Homebrew
brew
e63feb79f9054c59cccb9ab4ce91a77d078cd349.json
Simplify check before git install No need to check for both variables, because they're always set together. Also, this harmonizes with the CURL equivalent just above.
Library/Homebrew/cmd/update.sh
@@ -384,9 +384,8 @@ EOS fi if ! git --version &>/dev/null || - [[ ( -n "$HOMEBREW_SYSTEM_GIT_TOO_OLD" || - -n "$HOMEBREW_FORCE_BREWED_GIT" ) && - ! -x "$HOMEBREW_PREFIX/opt/git/bin/git" ]] + [[ -n "$HOMEBREW_FORCE_BREWED_GIT" && + ! -x "$HOMEBREW_PREFIX/opt/git/bin/git" ]] then # we cannot install brewed git if homebrew/core is unavailable. [[ -d "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core" ]] && brew install git
false
Other
Homebrew
brew
512073ad388953152ab88802237dd469c799983c.json
cache_store: create HOMEBREW_CACHE when needed. Fixes #4366.
Library/Homebrew/cache_store.rb
@@ -62,7 +62,10 @@ def created? # @return [DBM] db def db # DBM::WRCREAT: Creates the database if it does not already exist - @db ||= DBM.open(dbm_file_path, DATABASE_MODE, DBM::WRCREAT) + @db ||= begin + HOMEBREW_CACHE.mkpath + DBM.open(dbm_file_path, DATABASE_MODE, DBM::WRCREAT) + end end # Creates a CacheStoreDatabase
false
Other
Homebrew
brew
b265d870ed30a97a1c37e9267efe648d661761c0.json
Allow searching Casks by name.
Library/Homebrew/cmd/search.rb
@@ -52,16 +52,17 @@ def search(argv = ARGV) return end - if args.remaining.empty? + if args.remaining.empty? && !args.desc? puts Formatter.columns(Formula.full_names.sort) - elsif args.desc? - query = args.remaining.join(" ") - string_or_regex = query_regexp(query) - Descriptions.search(string_or_regex, :desc).print - else - query = args.remaining.join(" ") - string_or_regex = query_regexp(query) + return + end + query = args.remaining.join(" ") + string_or_regex = query_regexp(query) + + if args.desc? + search_descriptions(string_or_regex) + else remote_results = search_taps(query, silent: true) local_formulae = search_formulae(string_or_regex)
true
Other
Homebrew
brew
b265d870ed30a97a1c37e9267efe648d661761c0.json
Allow searching Casks by name.
Library/Homebrew/extend/os/mac/search.rb
@@ -3,24 +3,41 @@ module Homebrew module Search - def search_casks(string_or_regex) - if string_or_regex.is_a?(String) && string_or_regex.match?(HOMEBREW_TAP_CASK_REGEX) - return begin - [Hbc::CaskLoader.load(string_or_regex).token] - rescue Hbc::CaskUnavailableError - [] + module Extension + def search_descriptions(string_or_regex) + super + + puts + + ohai "Casks" + Hbc::Cask.to_a.extend(Searchable) + .search(string_or_regex, &:name) + .each do |cask| + puts "#{Tty.bold}#{cask.token}:#{Tty.reset} #{cask.name.join(", ")}" end end - results = Hbc::Cask.search(string_or_regex, &:token).sort_by(&:token) + def search_casks(string_or_regex) + if string_or_regex.is_a?(String) && string_or_regex.match?(HOMEBREW_TAP_CASK_REGEX) + return begin + [Hbc::CaskLoader.load(string_or_regex).token] + rescue Hbc::CaskUnavailableError + [] + end + end - results.map do |cask| - if cask.installed? - pretty_installed(cask.token) - else - cask.token + results = Hbc::Cask.search(string_or_regex, &:token).sort_by(&:token) + + results.map do |cask| + if cask.installed? + pretty_installed(cask.token) + else + cask.token + end end end end + + prepend Extension end end
true
Other
Homebrew
brew
b265d870ed30a97a1c37e9267efe648d661761c0.json
Allow searching Casks by name.
Library/Homebrew/search.rb
@@ -12,6 +12,11 @@ def query_regexp(query) raise "#{query} is not a valid regex." end + def search_descriptions(string_or_regex) + ohai "Formulae" + Descriptions.search(string_or_regex, :desc).print + end + def search_taps(query, silent: false) if query.match?(Regexp.union(HOMEBREW_TAP_FORMULA_REGEX, HOMEBREW_TAP_CASK_REGEX)) _, _, query = query.split("/", 3)
true
Other
Homebrew
brew
18e46b3ec2068310a133f183564f41d183995346.json
Fix usage of `HOMEBREW_LOAD_PATH`.
Library/Homebrew/brew.rb
@@ -16,14 +16,15 @@ HOMEBREW_LIBRARY_PATH = Pathname.new(__FILE__).realpath.parent require "English" -unless $LOAD_PATH.include?(HOMEBREW_LIBRARY_PATH.to_s) - $LOAD_PATH.unshift(HOMEBREW_LIBRARY_PATH.to_s) -end unless $LOAD_PATH.include?("#{HOMEBREW_LIBRARY_PATH}/cask/lib") $LOAD_PATH.unshift("#{HOMEBREW_LIBRARY_PATH}/cask/lib") end +unless $LOAD_PATH.include?(HOMEBREW_LIBRARY_PATH.to_s) + $LOAD_PATH.unshift(HOMEBREW_LIBRARY_PATH.to_s) +end + require "global" begin
true
Other
Homebrew
brew
18e46b3ec2068310a133f183564f41d183995346.json
Fix usage of `HOMEBREW_LOAD_PATH`.
Library/Homebrew/config.rb
@@ -47,4 +47,7 @@ end # Load path used by standalone scripts to access the Homebrew code base -HOMEBREW_LOAD_PATH = HOMEBREW_LIBRARY_PATH +HOMEBREW_LOAD_PATH = [ + HOMEBREW_LIBRARY_PATH, + HOMEBREW_LIBRARY_PATH/"cask/lib", +].join(File::PATH_SEPARATOR)
true
Other
Homebrew
brew
18e46b3ec2068310a133f183564f41d183995346.json
Fix usage of `HOMEBREW_LOAD_PATH`.
Library/Homebrew/dev-cmd/ruby.rb
@@ -8,6 +8,6 @@ module Homebrew module_function def ruby - exec ENV["HOMEBREW_RUBY_PATH"], "-I#{HOMEBREW_LIBRARY_PATH}", "-rglobal", "-rdev-cmd/irb", *ARGV + exec ENV["HOMEBREW_RUBY_PATH"], "-I", HOMEBREW_LOAD_PATH, "-rglobal", "-rdev-cmd/irb", *ARGV end end
true
Other
Homebrew
brew
18e46b3ec2068310a133f183564f41d183995346.json
Fix usage of `HOMEBREW_LOAD_PATH`.
Library/Homebrew/test/spec_helper.rb
@@ -14,8 +14,8 @@ require "rubocop/rspec/support" require "find" -$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew")) $LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew/cask/lib")) +$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew")) $LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew/test/support/lib")) require "global"
true
Other
Homebrew
brew
18e46b3ec2068310a133f183564f41d183995346.json
Fix usage of `HOMEBREW_LOAD_PATH`.
Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb
@@ -83,9 +83,7 @@ def brew(*args) @ruby_args ||= begin ruby_args = [ "-W0", - "-I", "#{HOMEBREW_LIBRARY_PATH}/test/support/lib", - "-I", HOMEBREW_LIBRARY_PATH.to_s, - "-I", "#{HOMEBREW_LIBRARY_PATH}/cask/lib", + "-I", HOMEBREW_LOAD_PATH, "-rconfig" ] if ENV["HOMEBREW_TESTS_COVERAGE"]
true
Other
Homebrew
brew
18e46b3ec2068310a133f183564f41d183995346.json
Fix usage of `HOMEBREW_LOAD_PATH`.
Library/Homebrew/test/support/lib/config.rb
@@ -15,7 +15,11 @@ # Paths pointing into the Homebrew code base that persist across test runs HOMEBREW_LIBRARY_PATH = Pathname.new(File.expand_path("../../..", __dir__)) HOMEBREW_SHIMS_PATH = HOMEBREW_LIBRARY_PATH.parent+"Homebrew/shims" -HOMEBREW_LOAD_PATH = [File.expand_path(__dir__), HOMEBREW_LIBRARY_PATH].join(":") +HOMEBREW_LOAD_PATH = [ + File.expand_path(__dir__), + HOMEBREW_LIBRARY_PATH, + HOMEBREW_LIBRARY_PATH.join("cask/lib"), +].join(File::PATH_SEPARATOR) # Paths redirected to a temporary directory and wiped at the end of the test run HOMEBREW_PREFIX = Pathname.new(TEST_TMPDIR).join("prefix")
true
Other
Homebrew
brew
a8bfe09c499d725972543c1857365768d5739329.json
Remove tests for `brew cask search`.
Library/Homebrew/test/cask/cli/search_spec.rb
@@ -1,123 +0,0 @@ -require_relative "shared_examples/invalid_option" - -describe Hbc::CLI::Search, :cask do - before do - allow(Tty).to receive(:width).and_return(0) - end - - it_behaves_like "a command that handles invalid options" - - it "lists the available Casks that match the search term" do - allow(GitHub).to receive(:search_code).and_return([]) - - expect { - Hbc::CLI::Search.run("local") - }.to output(<<~EOS).to_stdout.as_tty - ==> Matches - local-caffeine - local-transmission - EOS - end - - it "outputs a plain list when stdout is not a TTY" do - allow(GitHub).to receive(:search_code).and_return([]) - - expect { - Hbc::CLI::Search.run("local") - }.to output(<<~EOS).to_stdout - local-caffeine - local-transmission - EOS - end - - it "returns matches even when online search failed" do - allow(GitHub).to receive(:search_code).and_raise(GitHub::Error.new("reason")) - - expect { - Hbc::CLI::Search.run("local") - }.to output(<<~EOS).to_stdout - local-caffeine - local-transmission - EOS - .and output(/^Warning: Error searching on GitHub: reason/).to_stderr - end - - it "shows that there are no Casks matching a search term that did not result in anything" do - expect { - Hbc::CLI::Search.run("foo-bar-baz") - }.to output(<<~EOS).to_stdout.as_tty - No Cask found for "foo-bar-baz". - EOS - end - - it "doesn't output anything to non-TTY stdout when there are no matches" do - allow(GitHub).to receive(:search_code).and_return([]) - - expect { Hbc::CLI::Search.run("foo-bar-baz") } - .to not_to_output.to_stdout - .and not_to_output.to_stderr - end - - it "lists all Casks available offline with no search term" do - allow(GitHub).to receive(:search_code).and_raise(GitHub::Error.new("reason")) - expect { Hbc::CLI::Search.run } - .to output(/local-caffeine/).to_stdout.as_tty - .and not_to_output.to_stderr - end - - it "ignores hyphens in search terms" do - expect { - Hbc::CLI::Search.run("lo-cal-caffeine") - }.to output(/local-caffeine/).to_stdout.as_tty - end - - it "ignores hyphens in Cask tokens" do - expect { - Hbc::CLI::Search.run("localcaffeine") - }.to output(/local-caffeine/).to_stdout.as_tty - end - - it "accepts multiple arguments" do - expect { - Hbc::CLI::Search.run("local caffeine") - }.to output(/local-caffeine/).to_stdout.as_tty - end - - it "accepts a regexp argument" do - expect { - Hbc::CLI::Search.run("/^local-c[a-z]ffeine$/") - }.to output(<<~EOS).to_stdout.as_tty - ==> Matches - local-caffeine - EOS - end - - it "returns both exact and partial matches" do - expect { - Hbc::CLI::Search.run("test-opera") - }.to output(<<~EOS).to_stdout.as_tty - ==> Matches - test-opera - test-opera-mail - EOS - end - - it "does not search the Tap name" do - expect { - Hbc::CLI::Search.run("caskroom") - }.to output(<<~EOS).to_stdout.as_tty - No Cask found for "caskroom". - EOS - end - - it "highlights installed packages" do - Hbc::CLI::Install.run("local-caffeine") - - expect { - Hbc::CLI::Search.run("local-caffeine") - }.to output(<<~EOS).to_stdout.as_tty - ==> Matches - local-caffeine ✔ - EOS - end -end
false
Other
Homebrew
brew
97c12b4bbfa5a4e2d4ff0a1e59788b12503a698c.json
brew audit: avoid error on head-only formulae
Library/Homebrew/dev-cmd/audit.rb
@@ -584,6 +584,7 @@ def audit_specs ] throttled.each_slice(2).to_a.map do |a, b| + next if formula.stable.nil? version = formula.stable.version.to_s.split(".").last.to_i if @strict && a.include?(formula.name) && version.modulo(b.to_i).nonzero? problem "should only be updated every #{b} releases on multiples of #{b}"
false
Other
Homebrew
brew
e5212d74a6166b1c84bcc32910705da89cc1a95b.json
Diagnostic: require CLT headers on 10.14
Library/Homebrew/extend/os/mac/diagnostic.rb
@@ -20,6 +20,7 @@ def fatal_development_tools_checks check_xcode_minimum_version check_clt_minimum_version check_if_xcode_needs_clt_installed + check_if_clt_needs_headers_installed ].freeze end @@ -135,6 +136,17 @@ def check_if_xcode_needs_clt_installed EOS end + def check_if_clt_needs_headers_installed + return unless MacOS::CLT.separate_header_package? + return if MacOS::CLT.headers_installed? + + <<~EOS + The Command Line Tools header package must be installed on #{MacOS.version.pretty_name}. + The installer is located at: + #{MacOS::CLT::HEADER_PKG_PATH.sub(":macos_version", MacOS.version)} + EOS + end + def check_for_other_package_managers ponk = MacOS.macports_or_fink return if ponk.empty?
true
Other
Homebrew
brew
e5212d74a6166b1c84bcc32910705da89cc1a95b.json
Diagnostic: require CLT headers on 10.14
Library/Homebrew/test/os/mac/diagnostic_spec.rb
@@ -32,6 +32,19 @@ .to match("Xcode alone is not sufficient on El Capitan") end + specify "#check_if_clt_needs_headers_installed" do + allow(MacOS).to receive(:version).and_return(OS::Mac::Version.new("10.14")) + allow(MacOS::CLT).to receive(:installed?).and_return(true) + allow(MacOS::CLT).to receive(:headers_installed?).and_return(false) + + expect(subject.check_if_clt_needs_headers_installed) + .to match("The Command Line Tools header package must be installed on Mojave.") + + allow(MacOS).to receive(:version).and_return(OS::Mac::Version.new("10.13")) + expect(subject.check_if_clt_needs_headers_installed) + .to be_nil + end + specify "#check_homebrew_prefix" do # the integration tests are run in a special prefix expect(subject.check_homebrew_prefix)
true
Other
Homebrew
brew
296f3c309ed4a44a550e454fc18a306749f06e86.json
CLT: add checks for the header package
Library/Homebrew/os/mac/xcode.rb
@@ -196,16 +196,32 @@ module CLT STANDALONE_PKG_ID = "com.apple.pkg.DeveloperToolsCLILeo".freeze FROM_XCODE_PKG_ID = "com.apple.pkg.DeveloperToolsCLI".freeze - MAVERICKS_PKG_ID = "com.apple.pkg.CLTools_Executables".freeze + # EXECUTABLE_PKG_ID now means two things: + # 1. The original Mavericks CLT package ID, and + # 2. The additional header package included in Mojave. + EXECUTABLE_PKG_ID = "com.apple.pkg.CLTools_Executables".freeze MAVERICKS_NEW_PKG_ID = "com.apple.pkg.CLTools_Base".freeze # obsolete PKG_PATH = "/Library/Developer/CommandLineTools".freeze + HEADER_PKG_PATH = "/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_:macos_version.pkg".freeze # Returns true even if outdated tools are installed, e.g. # tools from Xcode 4.x on 10.9 def installed? !version.null? end + def separate_header_package? + MacOS.version >= :mojave + end + + def headers_installed? + if !separate_header_package? + installed? + else + headers_version == version + end + end + def update_instructions if MacOS.version >= "10.9" <<~EOS @@ -282,6 +298,18 @@ def version end end + # Version string of the header package, which is a + # separate package as of macOS 10.14. + def headers_version + if !separate_header_package? + version + else + @header_version ||= MacOS.pkgutil_info(EXECUTABLE_PKG_ID)[/version: (.+)$/, 1] + return ::Version::NULL unless @header_version + ::Version.new(@header_version) + end + end + def detect_version # CLT isn't a distinct entity pre-4.3, and pkgutil doesn't exist # at all on Tiger, so just count it as installed if Xcode is installed @@ -290,7 +318,7 @@ def detect_version end version = nil - [MAVERICKS_PKG_ID, MAVERICKS_NEW_PKG_ID, STANDALONE_PKG_ID, FROM_XCODE_PKG_ID].each do |id| + [EXECUTABLE_PKG_ID, MAVERICKS_NEW_PKG_ID, STANDALONE_PKG_ID, FROM_XCODE_PKG_ID].each do |id| if MacOS.version >= :mavericks next unless File.exist?("#{PKG_PATH}/usr/bin/clang") end
false
Other
Homebrew
brew
abb917f3819bbb2681a18ad5d2ddd30dd9c311dd.json
rubocop: exclude .simplecov under vendor
Library/Homebrew/.rubocop.yml
@@ -3,7 +3,7 @@ inherit_from: AllCops: Include: - - '**/.simplecov' + - 'Library/Homebrew/.simplecov' Exclude: - 'bin/*' - '**/Casks/**/*'
false
Other
Homebrew
brew
34ae75d511b2ff696ece406826eb2b0aff01ce6b.json
brew.sh: enable linkage cache for developers. This seems stable on CI so I think we can expose it to more people.
Library/Homebrew/brew.sh
@@ -277,6 +277,11 @@ then HOMEBREW_BASH_COMMAND="$HOMEBREW_LIBRARY/Homebrew/dev-cmd/$HOMEBREW_COMMAND.sh" fi +if [[ -n "$HOMEBREW_DEVELOPER" || -n "$HOMEBREW_DEV_CMD_RUN" ]] +then + export HOMEBREW_LINKAGE_CACHE="1" +fi + check-run-command-as-root() { [[ "$(id -u)" = 0 ]] || return
true
Other
Homebrew
brew
34ae75d511b2ff696ece406826eb2b0aff01ce6b.json
brew.sh: enable linkage cache for developers. This seems stable on CI so I think we can expose it to more people.
Library/Homebrew/dev-cmd/tests.rb
@@ -38,7 +38,6 @@ def tests ENV.delete("VERBOSE") ENV.delete("HOMEBREW_CASK_OPTS") ENV.delete("HOMEBREW_TEMP") - ENV.delete("HOMEBREW_LINKAGE_CACHE") ENV.delete("HOMEBREW_NO_GITHUB_API") ENV.delete("HOMEBREW_NO_EMOJI") ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1"
true
Other
Homebrew
brew
c68526ac09261f29bf261b530a5d449544380ecb.json
audit: remove appcast checkpoints
Library/Homebrew/cask/lib/hbc/audit.rb
@@ -26,7 +26,7 @@ def run! check_version_and_checksum check_version check_sha256 - check_appcast + check_appcast_checkpoint check_url check_generic_artifacts check_token_conflicts @@ -185,58 +185,11 @@ def check_sha256_invalid(sha256: cask.sha256, stanza: "sha256") add_error "cannot use the sha256 for an empty string in #{stanza}: #{empty_sha256}" end - def check_appcast + def check_appcast_checkpoint return unless cask.appcast - odebug "Auditing appcast" - check_appcast_has_checkpoint return unless cask.appcast.checkpoint - check_sha256_actually_256(sha256: cask.appcast.checkpoint, stanza: "appcast :checkpoint") - check_sha256_invalid(sha256: cask.appcast.checkpoint, stanza: "appcast :checkpoint") - return unless download - check_appcast_http_code - check_appcast_checkpoint_accuracy - end - - def check_appcast_has_checkpoint - odebug "Verifying appcast has :checkpoint key" - add_error "a checkpoint sha256 is required for appcast" unless cask.appcast.checkpoint - end - - def check_appcast_http_code - odebug "Verifying appcast returns 200 HTTP response code" - - curl_executable, *args = curl_args( - "--compressed", "--location", "--fail", - "--write-out", "%{http_code}", - "--output", "/dev/null", - cask.appcast, - user_agent: :fake - ) - result = @command.run(curl_executable, args: args, print_stderr: false) - if result.success? - http_code = result.stdout.chomp - add_warning "unexpected HTTP response code retrieving appcast: #{http_code}" unless http_code == "200" - else - add_warning "error retrieving appcast: #{result.stderr}" - end - end - - def check_appcast_checkpoint_accuracy - odebug "Verifying appcast checkpoint is accurate" - result = cask.appcast.calculate_checkpoint - actual_checkpoint = result[:checkpoint] - - if actual_checkpoint.nil? - add_warning "error retrieving appcast: #{result[:command_result].stderr}" - else - expected = cask.appcast.checkpoint - add_warning <<~EOS unless expected == actual_checkpoint - appcast checkpoint mismatch - Expected: #{expected} - Actual: #{actual_checkpoint} - EOS - end + add_error "Appcast checkpoints have been removed from Homebrew-Cask" end def check_latest_with_appcast
true
Other
Homebrew
brew
c68526ac09261f29bf261b530a5d449544380ecb.json
audit: remove appcast checkpoints
Library/Homebrew/test/cask/audit_spec.rb
@@ -317,124 +317,19 @@ def include_msg?(messages, msg) end end - describe "appcast checks" do - context "when appcast has no sha256" do - let(:cask_token) { "appcast-missing-checkpoint" } + describe "appcast checkpoint check" do + let(:error_msg) { "Appcast checkpoints have been removed from Homebrew-Cask" } - it { is_expected.to fail_with(/checkpoint sha256 is required for appcast/) } - end - - context "when appcast checkpoint is not a string of 64 hexadecimal characters" do - let(:cask_token) { "appcast-invalid-checkpoint" } - - it { is_expected.to fail_with(/string must be of 64 hexadecimal characters/) } - end - - context "when appcast checkpoint is sha256 for empty string" do - let(:cask_token) { "appcast-checkpoint-sha256-for-empty-string" } - - it { is_expected.to fail_with(/cannot use the sha256 for an empty string/) } - end - - context "when appcast checkpoint is valid sha256" do - let(:cask_token) { "appcast-valid-checkpoint" } - - it { is_expected.not_to fail_with(/appcast :checkpoint/) } - end - - context "when verifying appcast HTTP code" do - let(:cask_token) { "appcast-valid-checkpoint" } - let(:download) { instance_double(Hbc::Download) } - let(:wrong_code_msg) { /unexpected HTTP response code/ } - let(:curl_error_msg) { /error retrieving appcast/ } - let(:fake_curl_result) { instance_double(Hbc::SystemCommand::Result) } - - before do - allow(audit).to receive(:check_appcast_checkpoint_accuracy) - allow(fake_system_command).to receive(:run).and_return(fake_curl_result) - allow(fake_curl_result).to receive(:success?).and_return(success) - end - - context "when curl succeeds" do - let(:success) { true } - - before do - allow(fake_curl_result).to receive(:stdout).and_return(stdout) - end - - context "when HTTP code is 200" do - let(:stdout) { "200" } - - it { is_expected.not_to warn_with(wrong_code_msg) } - end - - context "when HTTP code is not 200" do - let(:stdout) { "404" } - - it { is_expected.to warn_with(wrong_code_msg) } - end - end - - context "when curl fails" do - let(:success) { false } - - before do - allow(fake_curl_result).to receive(:stderr).and_return("Some curl error") - end + context "when the Cask does not have a checkpoint" do + let(:cask_token) { "with-appcast" } - it { is_expected.to warn_with(curl_error_msg) } - end + it { is_expected.not_to fail_with(error_msg) } end - context "when verifying appcast checkpoint" do - let(:cask_token) { "appcast-valid-checkpoint" } - let(:download) { instance_double(Hbc::Download) } - let(:mismatch_msg) { /appcast checkpoint mismatch/ } - let(:curl_error_msg) { /error retrieving appcast/ } - let(:fake_curl_result) { instance_double(Hbc::SystemCommand::Result) } - let(:expected_checkpoint) { "d5b2dfbef7ea28c25f7a77cd7fa14d013d82b626db1d82e00e25822464ba19e2" } - - before do - allow(audit).to receive(:check_appcast_http_code) - allow(Hbc::SystemCommand).to receive(:run).and_return(fake_curl_result) - allow(fake_curl_result).to receive(:success?).and_return(success) - end - - context "when appcast download succeeds" do - let(:success) { true } - let(:appcast_text) { instance_double(::String) } - - before do - allow(fake_curl_result).to receive(:stdout).and_return(appcast_text) - allow(appcast_text).to receive(:gsub).and_return(appcast_text) - allow(appcast_text).to receive(:end_with?).with("\n").and_return(true) - allow(Digest::SHA2).to receive(:hexdigest).and_return(actual_checkpoint) - end - - context "when appcast checkpoint is out of date" do - let(:actual_checkpoint) { "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef" } - - it { is_expected.to warn_with(mismatch_msg) } - it { is_expected.not_to warn_with(curl_error_msg) } - end - - context "when appcast checkpoint is up to date" do - let(:actual_checkpoint) { expected_checkpoint } - - it { is_expected.not_to warn_with(mismatch_msg) } - it { is_expected.not_to warn_with(curl_error_msg) } - end - end - - context "when appcast download fails" do - let(:success) { false } - - before do - allow(fake_curl_result).to receive(:stderr).and_return("Some curl error") - end + context "when the Cask has a checkpoint" do + let(:cask_token) { "appcast-with-checkpoint" } - it { is_expected.to warn_with(curl_error_msg) } - end + it { is_expected.to fail_with(error_msg) } end end
true
Other
Homebrew
brew
c68526ac09261f29bf261b530a5d449544380ecb.json
audit: remove appcast checkpoints
Library/Homebrew/test/support/fixtures/cask/Casks/appcast-with-checkpoint.rb
@@ -1,4 +1,4 @@ -cask 'appcast-valid-checkpoint' do +cask 'appcast-with-checkpoint' do appcast 'http://localhost/appcast.xml', checkpoint: 'd5b2dfbef7ea28c25f7a77cd7fa14d013d82b626db1d82e00e25822464ba19e2' end
true
Other
Homebrew
brew
fdb2406b2044d74fb28ea7844b0987c8fb9feb20.json
Add failing spec for `DependencyOrder` cop.
Library/Homebrew/test/rubocops/dependency_order_cop_spec.rb
@@ -28,6 +28,18 @@ class Foo < Formula RUBY end + it "supports requirement constants" do + expect_offense(<<~RUBY) + class Foo < Formula + homepage "http://example.com" + url "http://example.com/foo-1.0.tgz" + depends_on FooRequirement + depends_on "bar" + ^^^^^^^^^^^^^^^^ dependency "bar" (line 5) should be put before dependency "FooRequirement" (line 4) + end + RUBY + end + it "wrong conditional depends_on order" do expect_offense(<<~RUBY) class Foo < Formula
false
Other
Homebrew
brew
aaddce4743dd67f569703daba27d72b5bbfbfadf.json
Add `stderr` output to exception.
Library/Homebrew/style.rb
@@ -76,14 +76,14 @@ def check_style_impl(files, output_type, options = {}) system(cache_env, "rubocop", "_#{HOMEBREW_RUBOCOP_VERSION}_", *args) !$CHILD_STATUS.success? when :json - json, _, status = Open3.capture3(cache_env, "rubocop", "_#{HOMEBREW_RUBOCOP_VERSION}_", "--format", "json", *args) + json, err, status = Open3.capture3(cache_env, "rubocop", "_#{HOMEBREW_RUBOCOP_VERSION}_", "--format", "json", *args) # exit status of 1 just means violations were found; other numbers mean # execution errors. # exitstatus can also be nil if RuboCop process crashes, e.g. due to # native extension problems. # JSON needs to be at least 2 characters. if !(0..1).cover?(status.exitstatus) || json.to_s.length < 2 - raise "Error running `rubocop --format json #{args.join " "}`" + raise "Error running `rubocop --format json #{args.join " "}`\n#{err}" end RubocopResults.new(JSON.parse(json)) else
false
Other
Homebrew
brew
3329a9f6d8d7aa6f9e37c33f6d4cc650ab6ea117.json
text_cop: require cargo to use `install` instead of `build`
Library/Homebrew/rubocops/text_cop.rb
@@ -53,6 +53,10 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node) next if parameters_passed?(d, /vendor-only/) problem "use \"dep\", \"ensure\", \"-vendor-only\"" end + + find_method_with_args(body_node, :system, "cargo", "build") do + problem "use \"cargo\", \"install\", \"--root\", prefix" + end end end end
true
Other
Homebrew
brew
3329a9f6d8d7aa6f9e37c33f6d4cc650ab6ea117.json
text_cop: require cargo to use `install` instead of `build`
Library/Homebrew/test/rubocops/text_cop_spec.rb
@@ -191,5 +191,19 @@ def install end RUBY end + + it "When cargo build is executed" do + expect_offense(<<~RUBY) + class Foo < Formula + url "http://example.com/foo-1.0.tgz" + homepage "http://example.com" + + def install + system "cargo", "build" + ^^^^^^^^^^^^^^^^^^^^^^^ use \"cargo\", \"install\", \"--root\", prefix + end + end + RUBY + end end end
true
Other
Homebrew
brew
b2f67c6d776170b64a2963e175f96f23eef4646e.json
Remove the need for `ensure_cache_exists`.
Library/Homebrew/cask/lib/hbc.rb
@@ -28,7 +28,6 @@ module Hbc def self.init - Cache.ensure_cache_exists Caskroom.ensure_caskroom_exists end end
true
Other
Homebrew
brew
b2f67c6d776170b64a2963e175f96f23eef4646e.json
Remove the need for `ensure_cache_exists`.
Library/Homebrew/cask/lib/hbc/cache.rb
@@ -5,12 +5,5 @@ module Cache def path @path ||= HOMEBREW_CACHE.join("Cask") end - - def ensure_cache_exists - return if path.exist? - - odebug "Creating Cache at #{path}" - path.mkpath - end end end
true
Other
Homebrew
brew
b2f67c6d776170b64a2963e175f96f23eef4646e.json
Remove the need for `ensure_cache_exists`.
Library/Homebrew/cask/lib/hbc/cli/cleanup.rb
@@ -8,10 +8,6 @@ def self.help "cleans up cached downloads and tracker symlinks" end - def self.needs_init? - true - end - attr_reader :cache_location def initialize(*args, cache_location: Cache.path) @@ -24,7 +20,7 @@ def run end def cache_files - return [] unless cache_location.exist? + return [] unless cache_location.directory? cache_location.children .map(&method(:Pathname)) .reject(&method(:outdated?))
true
Other
Homebrew
brew
b2f67c6d776170b64a2963e175f96f23eef4646e.json
Remove the need for `ensure_cache_exists`.
Library/Homebrew/cask/lib/hbc/cli/fetch.rb
@@ -17,10 +17,6 @@ def run end end - def self.needs_init? - true - end - def self.help "downloads remote application files to local cache" end
true
Other
Homebrew
brew
b2f67c6d776170b64a2963e175f96f23eef4646e.json
Remove the need for `ensure_cache_exists`.
Library/Homebrew/cask/lib/hbc/download_strategy.rb
@@ -95,6 +95,8 @@ def _fetch end def fetch + tarball_path.dirname.mkpath + ohai "Downloading #{@url}" if tarball_path.exist? puts "Already downloaded: #{tarball_path}" @@ -193,6 +195,8 @@ def repo_url # super does not provide checks for already-existing downloads def fetch + cached_location.dirname.mkpath + if cached_location.directory? puts "Already downloaded: #{cached_location}" else
true
Other
Homebrew
brew
b2f67c6d776170b64a2963e175f96f23eef4646e.json
Remove the need for `ensure_cache_exists`.
Library/Homebrew/test/support/helper/spec/shared_context/homebrew_cask.rb
@@ -23,7 +23,7 @@ begin HOMEBREW_CASK_DIRS.values.each(&:mkpath) - [Hbc::Config.global.binarydir, Hbc::Caskroom.path, Hbc::Cache.path].each(&:mkpath) + [Hbc::Config.global.binarydir, Hbc::Caskroom.path].each(&:mkpath) Tap.default_cask_tap.tap do |tap| FileUtils.mkdir_p tap.path.dirname
true
Other
Homebrew
brew
3d423b0587d54029cc60616d506318425c22e7a4.json
Add `path` method to `Caskroom` and `Cache`.
Library/Homebrew/cask/lib/hbc/cache.rb
@@ -2,11 +2,15 @@ module Hbc module Cache module_function + def path + @path ||= HOMEBREW_CACHE.join("Cask") + end + def ensure_cache_exists - return if Hbc.cache.exist? + return if path.exist? - odebug "Creating Cache at #{Hbc.cache}" - Hbc.cache.mkpath + odebug "Creating Cache at #{path}" + path.mkpath end end end
true
Other
Homebrew
brew
3d423b0587d54029cc60616d506318425c22e7a4.json
Add `path` method to `Caskroom` and `Cache`.
Library/Homebrew/cask/lib/hbc/cask_loader.rb
@@ -78,7 +78,7 @@ def self.can_load?(ref) def initialize(url) @url = URI(url) - super Hbc.cache/File.basename(@url.path) + super Cache.path/File.basename(@url.path) end def load
true
Other
Homebrew
brew
3d423b0587d54029cc60616d506318425c22e7a4.json
Add `path` method to `Caskroom` and `Cache`.
Library/Homebrew/cask/lib/hbc/caskroom.rb
@@ -2,22 +2,26 @@ module Hbc module Caskroom module_function + def path + @path ||= HOMEBREW_PREFIX.join("Caskroom") + end + def ensure_caskroom_exists - return if Hbc.caskroom.exist? + return if path.exist? - ohai "Creating Caskroom at #{Hbc.caskroom}" if $stdout.tty? - sudo = !Hbc.caskroom.parent.writable? + ohai "Creating Caskroom at #{path}" if $stdout.tty? + sudo = !path.parent.writable? ohai "We'll set permissions properly so we won't need sudo in the future" if $stdout.tty? && sudo - SystemCommand.run("/bin/mkdir", args: ["-p", Hbc.caskroom], sudo: sudo) - SystemCommand.run("/bin/chmod", args: ["g+rwx", 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("/bin/mkdir", args: ["-p", path], sudo: sudo) + SystemCommand.run("/bin/chmod", args: ["g+rwx", path], sudo: sudo) + SystemCommand.run("/usr/sbin/chown", args: [Utils.current_user, path], sudo: sudo) + SystemCommand.run("/usr/bin/chgrp", args: ["admin", path], sudo: sudo) end def casks - Pathname.glob(Hbc.caskroom.join("*")).sort.select(&:directory?).map do |path| + Pathname.glob(path.join("*")).sort.select(&:directory?).map do |path| token = path.basename.to_s if tap_path = CaskLoader.tap_paths(token).first
true
Other
Homebrew
brew
3d423b0587d54029cc60616d506318425c22e7a4.json
Add `path` method to `Caskroom` and `Cache`.
Library/Homebrew/cask/lib/hbc/cli/cleanup.rb
@@ -14,7 +14,7 @@ def self.needs_init? attr_reader :cache_location - def initialize(*args, cache_location: Hbc.cache) + def initialize(*args, cache_location: Cache.path) super(*args) @cache_location = Pathname.new(cache_location) end
true
Other
Homebrew
brew
3d423b0587d54029cc60616d506318425c22e7a4.json
Add `path` method to `Caskroom` and `Cache`.
Library/Homebrew/cask/lib/hbc/cli/doctor.rb
@@ -60,7 +60,7 @@ def check_install_location def check_staging_location ohai "Homebrew-Cask Staging Location" - path = Pathname.new(user_tilde(Hbc.caskroom.to_s)) + path = Pathname.new(user_tilde(Caskroom.path.to_s)) if !path.exist? add_error "The staging path #{path} does not exist." @@ -77,7 +77,7 @@ def check_cached_downloads cleanup = CLI::Cleanup.new count = cleanup.cache_files.count size = cleanup.disk_cleanup_size - msg = user_tilde(Hbc.cache.to_s) + msg = user_tilde(Cache.path.to_s) msg << " (#{number_readable(count)} files, #{disk_usage_readable(size)})" unless count.zero? puts msg end @@ -240,7 +240,7 @@ def self.render_cached_downloads cleanup = CLI::Cleanup.new count = cleanup.cache_files.count size = cleanup.disk_cleanup_size - msg = user_tilde(Hbc.cache.to_s) + msg = user_tilde(Cache.path.to_s) msg << " (#{number_readable(count)} files, #{disk_usage_readable(size)})" unless count.zero? msg end
true
Other
Homebrew
brew
3d423b0587d54029cc60616d506318425c22e7a4.json
Add `path` method to `Caskroom` and `Cache`.
Library/Homebrew/cask/lib/hbc/download_strategy.rb
@@ -36,7 +36,7 @@ class HbVCSDownloadStrategy < AbstractDownloadStrategy def initialize(*args, **options) super(*args, **options) @ref_type, @ref = extract_ref - @clone = Hbc.cache.join(cache_filename) + @clone = Cache.path.join(cache_filename) end def extract_ref @@ -65,7 +65,7 @@ def clear_cache class CurlDownloadStrategy < AbstractDownloadStrategy def tarball_path - @tarball_path ||= Hbc.cache.join("#{name}--#{version}#{ext}") + @tarball_path ||= Cache.path.join("#{name}--#{version}#{ext}") end def temporary_path
true
Other
Homebrew
brew
3d423b0587d54029cc60616d506318425c22e7a4.json
Add `path` method to `Caskroom` and `Cache`.
Library/Homebrew/cask/lib/hbc/dsl.rb
@@ -220,7 +220,7 @@ def artifacts end def caskroom_path - @caskroom_path ||= Hbc.caskroom.join(token) + @caskroom_path ||= Caskroom.path.join(token) end def staged_path
true
Other
Homebrew
brew
3d423b0587d54029cc60616d506318425c22e7a4.json
Add `path` method to `Caskroom` and `Cache`.
Library/Homebrew/cask/lib/hbc/locations.rb
@@ -6,14 +6,6 @@ def self.included(base) end module ClassMethods - def caskroom - @caskroom ||= HOMEBREW_PREFIX.join("Caskroom") - end - - def cache - @cache ||= HOMEBREW_CACHE.join("Cask") - end - attr_writer :default_tap def default_tap
true