Compare commits
10 Commits
1019f9ef21
...
eda9e78529
Author | SHA1 | Date | |
---|---|---|---|
![]() |
eda9e78529 | ||
![]() |
5f4e42a2c8 | ||
![]() |
852574dedf | ||
![]() |
3e413b4521 | ||
![]() |
2d9e9ce5d1 | ||
![]() |
2fe1076281 | ||
![]() |
05985fabc3 | ||
![]() |
6297f98d06 | ||
![]() |
07091cfbea | ||
![]() |
896edb4451 |
2
.github/workflows/actionlint.yml
vendored
2
.github/workflows/actionlint.yml
vendored
@ -93,7 +93,7 @@ jobs:
|
||||
path: results.sarif
|
||||
|
||||
- name: Upload SARIF file
|
||||
uses: github/codeql-action/upload-sarif@2d92b76c45b91eb80fc44c74ce3fce0ee94e8f9d # v3.30.0
|
||||
uses: github/codeql-action/upload-sarif@192325c86100d080feab897ff886c34abd4c83a3 # v3.30.3
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
category: zizmor
|
||||
|
4
.github/workflows/codeql-analysis.yml
vendored
4
.github/workflows/codeql-analysis.yml
vendored
@ -27,7 +27,7 @@ jobs:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@2d92b76c45b91eb80fc44c74ce3fce0ee94e8f9d # v3.30.0
|
||||
uses: github/codeql-action/init@192325c86100d080feab897ff886c34abd4c83a3 # v3.30.3
|
||||
with:
|
||||
languages: ruby
|
||||
config: |
|
||||
@ -35,4 +35,4 @@ jobs:
|
||||
- Library/Homebrew/vendor
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@2d92b76c45b91eb80fc44c74ce3fce0ee94e8f9d # v3.30.0
|
||||
uses: github/codeql-action/analyze@192325c86100d080feab897ff886c34abd4c83a3 # v3.30.3
|
||||
|
@ -57,7 +57,7 @@ GEM
|
||||
redcarpet (3.6.1)
|
||||
regexp_parser (2.11.2)
|
||||
require-hooks (0.2.2)
|
||||
rexml (3.4.2)
|
||||
rexml (3.4.4)
|
||||
rspec (3.13.1)
|
||||
rspec-core (~> 3.13.0)
|
||||
rspec-expectations (~> 3.13.0)
|
||||
@ -96,10 +96,10 @@ GEM
|
||||
rubocop-md (2.0.2)
|
||||
lint_roller (~> 1.1)
|
||||
rubocop (>= 1.72.1)
|
||||
rubocop-performance (1.25.0)
|
||||
rubocop-performance (1.26.0)
|
||||
lint_roller (~> 1.1)
|
||||
rubocop (>= 1.75.0, < 2.0)
|
||||
rubocop-ast (>= 1.38.0, < 2.0)
|
||||
rubocop-ast (>= 1.44.0, < 2.0)
|
||||
rubocop-rspec (3.7.0)
|
||||
lint_roller (~> 1.1)
|
||||
rubocop (~> 1.72, >= 1.72.1)
|
||||
@ -124,15 +124,15 @@ GEM
|
||||
simplecov-html (0.13.2)
|
||||
simplecov_json_formatter (0.1.4)
|
||||
simpleidn (0.2.3)
|
||||
sorbet (0.6.12479)
|
||||
sorbet-static (= 0.6.12479)
|
||||
sorbet-runtime (0.6.12479)
|
||||
sorbet-static (0.6.12479-aarch64-linux)
|
||||
sorbet-static (0.6.12479-universal-darwin)
|
||||
sorbet-static (0.6.12479-x86_64-linux)
|
||||
sorbet-static-and-runtime (0.6.12479)
|
||||
sorbet (= 0.6.12479)
|
||||
sorbet-runtime (= 0.6.12479)
|
||||
sorbet (0.6.12521)
|
||||
sorbet-static (= 0.6.12521)
|
||||
sorbet-runtime (0.6.12521)
|
||||
sorbet-static (0.6.12521-aarch64-linux)
|
||||
sorbet-static (0.6.12521-universal-darwin)
|
||||
sorbet-static (0.6.12521-x86_64-linux)
|
||||
sorbet-static-and-runtime (0.6.12521)
|
||||
sorbet (= 0.6.12521)
|
||||
sorbet-runtime (= 0.6.12521)
|
||||
spoom (1.7.6)
|
||||
erubi (>= 1.10.0)
|
||||
prism (>= 0.28.0)
|
||||
@ -154,9 +154,9 @@ GEM
|
||||
thor (>= 1.2.0)
|
||||
yard-sorbet
|
||||
thor (1.4.0)
|
||||
unicode-display_width (3.1.5)
|
||||
unicode-emoji (~> 4.0, >= 4.0.4)
|
||||
unicode-emoji (4.0.4)
|
||||
unicode-display_width (3.2.0)
|
||||
unicode-emoji (~> 4.1)
|
||||
unicode-emoji (4.1.0)
|
||||
vernier (1.8.0)
|
||||
warning (1.5.0)
|
||||
yard (0.9.37)
|
||||
|
@ -79,8 +79,9 @@ module Cask
|
||||
# Try to make the asset searchable under the target name. Spotlight
|
||||
# respects this attribute for many filetypes, but ignores it for App
|
||||
# bundles. Alfred 2.2 respects it even for App bundles.
|
||||
def add_altname_metadata(file, altname, command: nil)
|
||||
return if altname.to_s.casecmp(file.basename.to_s).zero?
|
||||
sig { params(file: Pathname, altname: Pathname, command: T.class_of(SystemCommand)).returns(T.nilable(SystemCommand::Result)) }
|
||||
def add_altname_metadata(file, altname, command:)
|
||||
return if altname.to_s.casecmp(file.basename.to_s)&.zero?
|
||||
|
||||
odebug "Adding #{ALT_NAME_ATTRIBUTE} metadata"
|
||||
altnames = command.run("/usr/bin/xattr",
|
||||
@ -108,3 +109,5 @@ module Cask
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
require "extend/os/cask/artifact/relocated"
|
||||
|
@ -6,6 +6,7 @@ require "cask/cask"
|
||||
require "uri"
|
||||
require "utils/curl"
|
||||
require "utils/output"
|
||||
require "utils/path"
|
||||
require "extend/hash/keys"
|
||||
require "api"
|
||||
|
||||
@ -112,9 +113,7 @@ module Cask
|
||||
|
||||
return unless path.expand_path.exist?
|
||||
return if invalid_path?(path)
|
||||
|
||||
return if Homebrew::EnvConfig.forbid_packages_from_paths? &&
|
||||
!path.realpath.to_s.start_with?("#{Caskroom.path}/", "#{HOMEBREW_LIBRARY}/Taps/")
|
||||
return unless ::Utils::Path.loadable_package_path?(path, :cask)
|
||||
|
||||
new(path)
|
||||
end
|
||||
|
@ -733,7 +733,7 @@ module Homebrew
|
||||
formulae_names = removable_formulae.map(&:full_name).sort
|
||||
|
||||
verb = dry_run ? "Would autoremove" : "Autoremoving"
|
||||
oh1 "#{verb} #{formulae_names.count} unneeded #{Utils.pluralize("formula", formulae_names.count, plural: "e")}:"
|
||||
oh1 "#{verb} #{formulae_names.count} unneeded #{Utils.pluralize("formula", formulae_names.count)}:"
|
||||
puts formulae_names.join("\n")
|
||||
return if dry_run
|
||||
|
||||
|
@ -233,8 +233,8 @@ module Homebrew
|
||||
.map(&:name)
|
||||
next if dep_names.blank?
|
||||
|
||||
ohai "Would install #{::Utils.pluralize("dependenc", dep_names.count, plural: "ies", singular: "y",
|
||||
include_count: true)} for #{cask.full_name}:"
|
||||
ohai "Would install #{::Utils.pluralize("dependency", dep_names.count, include_count: true)} " \
|
||||
"for #{cask.full_name}:"
|
||||
puts dep_names.join(" ")
|
||||
end
|
||||
return
|
||||
|
@ -57,7 +57,7 @@ module Homebrew
|
||||
end
|
||||
info = Utils.pluralize("tap", tap_count, include_count: true)
|
||||
info += ", #{private_count} private"
|
||||
info += ", #{Utils.pluralize("formula", formula_count, plural: "e", include_count: true)}"
|
||||
info += ", #{Utils.pluralize("formula", formula_count, include_count: true)}"
|
||||
info += ", #{Utils.pluralize("command", command_count, include_count: true)}"
|
||||
info += ", #{HOMEBREW_TAP_DIRECTORY.dup.abv}" if HOMEBREW_TAP_DIRECTORY.directory?
|
||||
puts info
|
||||
|
@ -842,7 +842,7 @@ class ReporterHub
|
||||
msg = ""
|
||||
|
||||
if outdated_formulae.positive?
|
||||
noun = Utils.pluralize("formula", outdated_formulae, plural: "e")
|
||||
noun = Utils.pluralize("formula", outdated_formulae)
|
||||
msg += "#{Tty.bold}#{outdated_formulae}#{Tty.reset} outdated #{noun}"
|
||||
end
|
||||
|
||||
|
@ -294,9 +294,7 @@ module Homebrew
|
||||
errors_summary = Utils.pluralize("problem", total_problems_count, include_count: true)
|
||||
|
||||
error_sources = []
|
||||
if formula_count.positive?
|
||||
error_sources << Utils.pluralize("formula", formula_count, plural: "e", include_count: true)
|
||||
end
|
||||
error_sources << Utils.pluralize("formula", formula_count, include_count: true) if formula_count.positive?
|
||||
error_sources << Utils.pluralize("cask", cask_count, include_count: true) if cask_count.positive?
|
||||
error_sources << Utils.pluralize("tap", tap_count, include_count: true) if tap_count.positive?
|
||||
|
||||
|
@ -579,7 +579,7 @@ class UnbottledError < RuntimeError
|
||||
require "utils"
|
||||
|
||||
msg = <<~EOS
|
||||
The following #{Utils.pluralize("formula", formulae.count, plural: "e")} cannot be installed from #{Utils.pluralize("bottle", formulae.count)} and must be
|
||||
The following #{Utils.pluralize("formula", formulae.count)} cannot be installed from #{Utils.pluralize("bottle", formulae.count)} and must be
|
||||
built from source.
|
||||
#{formulae.to_sentence}
|
||||
EOS
|
||||
|
4
Library/Homebrew/extend/os/cask/artifact/relocated.rb
Normal file
4
Library/Homebrew/extend/os/cask/artifact/relocated.rb
Normal file
@ -0,0 +1,4 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "extend/os/linux/cask/artifact/relocated" if OS.linux?
|
23
Library/Homebrew/extend/os/linux/cask/artifact/relocated.rb
Normal file
23
Library/Homebrew/extend/os/linux/cask/artifact/relocated.rb
Normal file
@ -0,0 +1,23 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
module OS
|
||||
module Linux
|
||||
module Cask
|
||||
module Artifact
|
||||
module Relocated
|
||||
extend T::Helpers
|
||||
|
||||
requires_ancestor { ::Cask::Artifact::Relocated }
|
||||
|
||||
sig { params(file: Pathname, altname: Pathname, command: T.class_of(SystemCommand)).returns(T.nilable(SystemCommand::Result)) }
|
||||
def add_altname_metadata(file, altname, command:)
|
||||
# no-op on Linux: /usr/bin/xattr for setting extended attributes is not available there.
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Cask::Artifact::Relocated.prepend(OS::Linux::Cask::Artifact::Relocated)
|
@ -1,26 +1,13 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "os/linux/ld"
|
||||
require "utils/output"
|
||||
|
||||
module OS
|
||||
module Linux
|
||||
module Install
|
||||
module ClassMethods
|
||||
# This is a list of known paths to the host dynamic linker on Linux if
|
||||
# the host glibc is new enough. The symlink_ld_so method will fail if
|
||||
# the host linker cannot be found in this list.
|
||||
DYNAMIC_LINKERS = %w[
|
||||
/lib64/ld-linux-x86-64.so.2
|
||||
/lib64/ld64.so.2
|
||||
/lib/ld-linux.so.3
|
||||
/lib/ld-linux.so.2
|
||||
/lib/ld-linux-aarch64.so.1
|
||||
/lib/ld-linux-armhf.so.3
|
||||
/system/bin/linker64
|
||||
/system/bin/linker
|
||||
].freeze
|
||||
|
||||
# We link GCC runtime libraries that are not specifically used for Fortran,
|
||||
# which are linked by the GCC formula. We only use the versioned shared libraries
|
||||
# as the other shared and static libraries are only used at build time where
|
||||
@ -67,7 +54,7 @@ module OS
|
||||
|
||||
ld_so = HOMEBREW_PREFIX/"opt/glibc/bin/ld.so"
|
||||
unless ld_so.readable?
|
||||
ld_so = DYNAMIC_LINKERS.find { |s| File.executable? s }
|
||||
ld_so = OS::Linux::Ld.system_ld_so
|
||||
if ld_so.blank?
|
||||
::Kernel.raise "Unable to locate the system's dynamic linker" unless brew_ld_so.readable?
|
||||
|
||||
|
@ -7,6 +7,7 @@ require "tab"
|
||||
require "utils"
|
||||
require "utils/bottles"
|
||||
require "utils/output"
|
||||
require "utils/path"
|
||||
require "service"
|
||||
require "utils/curl"
|
||||
require "deprecate_disable"
|
||||
@ -727,29 +728,7 @@ module Formulary
|
||||
end
|
||||
|
||||
return unless path.expand_path.exist?
|
||||
|
||||
if Homebrew::EnvConfig.forbid_packages_from_paths?
|
||||
path_realpath = path.realpath.to_s
|
||||
path_string = path.to_s
|
||||
if (path_realpath.end_with?(".rb") || path_string.end_with?(".rb")) &&
|
||||
!path_realpath.start_with?("#{HOMEBREW_CELLAR}/", "#{HOMEBREW_LIBRARY}/Taps/") &&
|
||||
!path_string.start_with?("#{HOMEBREW_CELLAR}/", "#{HOMEBREW_LIBRARY}/Taps/")
|
||||
if path_string.include?("./") || path_string.end_with?(".rb") || path_string.count("/") != 2
|
||||
raise <<~WARNING
|
||||
Homebrew requires formulae to be in a tap, rejecting:
|
||||
#{path_string} (#{path_realpath})
|
||||
|
||||
To create a tap, run e.g.
|
||||
brew tap-new <user|org>/<repository>
|
||||
To create a formula in a tap run e.g.
|
||||
brew create <url> --tap=<user|org>/<repository>
|
||||
WARNING
|
||||
elsif path_string.count("/") == 2
|
||||
# Looks like a tap, let's quietly return but not error.
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
return unless ::Utils::Path.loadable_package_path?(path, :formula)
|
||||
|
||||
if (tap = Tap.from_path(path))
|
||||
# Only treat symlinks in taps as aliases.
|
||||
|
@ -405,8 +405,7 @@ module Homebrew
|
||||
return if formulae_names_to_install.empty?
|
||||
|
||||
if dry_run
|
||||
ohai "Would install #{Utils.pluralize("formula", formulae_names_to_install.count,
|
||||
plural: "e", include_count: true)}:"
|
||||
ohai "Would install #{Utils.pluralize("formula", formulae_names_to_install.count, include_count: true)}:"
|
||||
puts formulae_names_to_install.join(" ")
|
||||
|
||||
formula_installers.each do |fi|
|
||||
@ -429,8 +428,8 @@ module Homebrew
|
||||
def print_dry_run_dependencies(formula, dependencies)
|
||||
return if dependencies.empty?
|
||||
|
||||
ohai "Would install #{Utils.pluralize("dependenc", dependencies.count, plural: "ies", singular: "y",
|
||||
include_count: true)} for #{formula.name}:"
|
||||
ohai "Would install #{Utils.pluralize("dependency", dependencies.count, include_count: true)} " \
|
||||
"for #{formula.name}:"
|
||||
formula_names = dependencies.map { |(dep, _options)| yield dep.to_formula }
|
||||
puts formula_names.join(" ")
|
||||
end
|
||||
@ -446,7 +445,7 @@ module Homebrew
|
||||
|
||||
sizes = compute_total_sizes(formulae, debug: args.debug?)
|
||||
|
||||
puts "#{::Utils.pluralize("Formula", formulae.count, plural: "e")} \
|
||||
puts "#{::Utils.pluralize("Formula", formulae.count)} \
|
||||
(#{formulae.count}): #{formulae.join(", ")}\n\n"
|
||||
puts "Download Size: #{disk_usage_readable(sizes.fetch(:download))}"
|
||||
puts "Install Size: #{disk_usage_readable(sizes.fetch(:installed))}"
|
||||
|
@ -5,37 +5,69 @@ module OS
|
||||
module Linux
|
||||
# Helper functions for querying `ld` information.
|
||||
module Ld
|
||||
sig { returns(String) }
|
||||
def self.brewed_ld_so_diagnostics
|
||||
@brewed_ld_so_diagnostics ||= T.let({}, T.nilable(T::Hash[Pathname, String]))
|
||||
# This is a list of known paths to the host dynamic linker on Linux if
|
||||
# the host glibc is new enough. Brew will fail to create a symlink for
|
||||
# ld.so if the host linker cannot be found in this list.
|
||||
DYNAMIC_LINKERS = %w[
|
||||
/lib64/ld-linux-x86-64.so.2
|
||||
/lib64/ld64.so.2
|
||||
/lib/ld-linux.so.3
|
||||
/lib/ld-linux.so.2
|
||||
/lib/ld-linux-aarch64.so.1
|
||||
/lib/ld-linux-armhf.so.3
|
||||
/system/bin/linker64
|
||||
/system/bin/linker
|
||||
].freeze
|
||||
|
||||
brewed_ld_so = HOMEBREW_PREFIX/"lib/ld.so"
|
||||
return "" unless brewed_ld_so.exist?
|
||||
# The path to the system's dynamic linker or `nil` if not found
|
||||
sig { returns(T.nilable(Pathname)) }
|
||||
def self.system_ld_so
|
||||
@system_ld_so ||= T.let(nil, T.nilable(Pathname))
|
||||
@system_ld_so ||= begin
|
||||
linker = DYNAMIC_LINKERS.find { |s| File.executable? s }
|
||||
Pathname(linker) if linker
|
||||
end
|
||||
end
|
||||
|
||||
brewed_ld_so_target = brewed_ld_so.readlink
|
||||
@brewed_ld_so_diagnostics[brewed_ld_so_target] ||= begin
|
||||
ld_so_output = Utils.popen_read(brewed_ld_so, "--list-diagnostics")
|
||||
sig { params(brewed: T::Boolean).returns(String) }
|
||||
def self.ld_so_diagnostics(brewed: true)
|
||||
@ld_so_diagnostics ||= T.let({}, T.nilable(T::Hash[Pathname, String]))
|
||||
|
||||
ld_so_target = if brewed
|
||||
ld_so = HOMEBREW_PREFIX/"lib/ld.so"
|
||||
return "" unless ld_so.exist?
|
||||
|
||||
ld_so.readlink
|
||||
else
|
||||
ld_so = system_ld_so
|
||||
return "" unless ld_so&.exist?
|
||||
|
||||
ld_so
|
||||
end
|
||||
|
||||
@ld_so_diagnostics[ld_so_target] ||= begin
|
||||
ld_so_output = Utils.popen_read(ld_so, "--list-diagnostics")
|
||||
ld_so_output if $CHILD_STATUS.success?
|
||||
end
|
||||
|
||||
@brewed_ld_so_diagnostics[brewed_ld_so_target].to_s
|
||||
@ld_so_diagnostics[ld_so_target].to_s
|
||||
end
|
||||
|
||||
sig { returns(String) }
|
||||
def self.sysconfdir
|
||||
sig { params(brewed: T::Boolean).returns(String) }
|
||||
def self.sysconfdir(brewed: true)
|
||||
fallback_sysconfdir = "/etc"
|
||||
|
||||
match = brewed_ld_so_diagnostics.match(/path.sysconfdir="(.+)"/)
|
||||
match = ld_so_diagnostics(brewed:).match(/path.sysconfdir="(.+)"/)
|
||||
return fallback_sysconfdir unless match
|
||||
|
||||
match.captures.compact.first || fallback_sysconfdir
|
||||
end
|
||||
|
||||
sig { returns(T::Array[String]) }
|
||||
def self.system_dirs
|
||||
sig { params(brewed: T::Boolean).returns(T::Array[String]) }
|
||||
def self.system_dirs(brewed: true)
|
||||
dirs = []
|
||||
|
||||
brewed_ld_so_diagnostics.split("\n").each do |line|
|
||||
ld_so_diagnostics(brewed:).split("\n").each do |line|
|
||||
match = line.match(/path.system_dirs\[0x.*\]="(.*)"/)
|
||||
next unless match
|
||||
|
||||
@ -45,9 +77,9 @@ module OS
|
||||
dirs
|
||||
end
|
||||
|
||||
sig { params(conf_path: T.any(Pathname, String)).returns(T::Array[String]) }
|
||||
def self.library_paths(conf_path = Pathname(sysconfdir)/"ld.so.conf")
|
||||
conf_file = Pathname(conf_path)
|
||||
sig { params(conf_path: T.any(Pathname, String), brewed: T::Boolean).returns(T::Array[String]) }
|
||||
def self.library_paths(conf_path = "ld.so.conf", brewed: true)
|
||||
conf_file = Pathname(sysconfdir(brewed:))/conf_path
|
||||
return [] unless conf_file.exist?
|
||||
return [] unless conf_file.file?
|
||||
return [] unless conf_file.readable?
|
||||
@ -68,8 +100,7 @@ module OS
|
||||
line.sub!(/\s*#.*$/, "")
|
||||
|
||||
if line.start_with?(/\s*include\s+/)
|
||||
include_path = Pathname(line.sub(/^\s*include\s+/, "")).expand_path
|
||||
wildcard = include_path.absolute? ? include_path : directory/include_path
|
||||
wildcard = Pathname(line.sub(/^\s*include\s+/, "")).expand_path(directory)
|
||||
|
||||
Dir.glob(wildcard.to_s).each do |include_file|
|
||||
paths += library_paths(include_file)
|
||||
|
@ -93,7 +93,7 @@ module Homebrew
|
||||
|
||||
wait = 2 ** @try
|
||||
unless quiet
|
||||
what = Utils.pluralize("tr", tries_remaining, plural: "ies", singular: "y")
|
||||
what = Utils.pluralize("try", tries_remaining)
|
||||
ohai "Retrying download in #{wait}s... (#{tries_remaining} #{what} left)"
|
||||
end
|
||||
sleep wait
|
||||
|
@ -34,7 +34,7 @@ module Homebrew
|
||||
unofficial = Tap.all.sum { |tap| tap.official? ? 0 : tap.formula_files.size }
|
||||
if unofficial.positive?
|
||||
opoo "Use `--eval-all` to search #{unofficial} additional " \
|
||||
"#{Utils.pluralize("formula", unofficial, plural: "e")} in third party taps."
|
||||
"#{Utils.pluralize("formula", unofficial)} in third party taps."
|
||||
end
|
||||
descriptions = Homebrew::API::Formula.all_formulae.transform_values { |data| data["desc"] }
|
||||
Descriptions.search(string_or_regex, search_type, descriptions, eval_all, cache_store_hash: true).print
|
||||
|
@ -738,7 +738,7 @@ class Tap
|
||||
end
|
||||
|
||||
if (formula_count = formula_files.count).positive?
|
||||
contents << Utils.pluralize("formula", formula_count, plural: "e", include_count: true)
|
||||
contents << Utils.pluralize("formula", formula_count, include_count: true)
|
||||
end
|
||||
|
||||
contents
|
||||
|
52
Library/Homebrew/test/cask/artifact/relocated_spec.rb
Normal file
52
Library/Homebrew/test/cask/artifact/relocated_spec.rb
Normal file
@ -0,0 +1,52 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cask/artifact/relocated"
|
||||
|
||||
RSpec.describe Cask::Artifact::Relocated, :cask do
|
||||
let(:cask) do
|
||||
Cask::Cask.new("test-cask") do
|
||||
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
|
||||
homepage "https://brew.sh/"
|
||||
version "1.0"
|
||||
sha256 "67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94"
|
||||
end
|
||||
end
|
||||
|
||||
let(:command) { NeverSudoSystemCommand }
|
||||
let(:artifact) { described_class.new(cask, "test_file.txt") }
|
||||
|
||||
describe "#add_altname_metadata" do
|
||||
let(:file) { Pathname("/tmp/test_file.txt") }
|
||||
let(:altname) { Pathname("alternate_name.txt") }
|
||||
|
||||
before do
|
||||
allow(file).to receive_messages(basename: Pathname("test_file.txt"), writable?: true, realpath: file)
|
||||
end
|
||||
|
||||
context "when running on Linux", :needs_linux do
|
||||
it "is a no-op and does not call xattr commands" do
|
||||
expect(command).not_to receive(:run)
|
||||
expect(command).not_to receive(:run!)
|
||||
|
||||
artifact.send(:add_altname_metadata, file, altname, command: command)
|
||||
end
|
||||
end
|
||||
|
||||
context "when running on macOS", :needs_macos do
|
||||
before do
|
||||
stdout_double = instance_double(SystemCommand::Result, stdout: "")
|
||||
allow(command).to receive(:run).and_return(stdout_double)
|
||||
allow(command).to receive(:run!)
|
||||
end
|
||||
|
||||
it "calls xattr commands to set metadata" do
|
||||
expect(command).to receive(:run).with("/usr/bin/xattr",
|
||||
args: ["-p", "com.apple.metadata:kMDItemAlternateNames", file],
|
||||
print_stderr: false)
|
||||
expect(command).to receive(:run!).twice
|
||||
|
||||
artifact.send(:add_altname_metadata, file, altname, command: command)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -236,4 +236,73 @@ RSpec.describe Cask::CaskLoader, :cask do
|
||||
expect(described_class.load_prefer_installed("test-cask").tap).to eq(foo_tap)
|
||||
end
|
||||
end
|
||||
|
||||
describe "FromPathLoader with symlinked taps" do
|
||||
let(:cask_token) { "testcask" }
|
||||
let(:tmpdir) { mktmpdir }
|
||||
let(:real_tap_path) { tmpdir / "real_tap" }
|
||||
let(:homebrew_prefix) { tmpdir / "homebrew" }
|
||||
let(:taps_dir) { homebrew_prefix / "Library" / "Taps" / "testuser" }
|
||||
let(:symlinked_tap_path) { taps_dir / "homebrew-testtap" }
|
||||
let(:cask_file_path) { symlinked_tap_path / "Casks" / "#{cask_token}.rb" }
|
||||
let(:cask_content) do
|
||||
<<~RUBY
|
||||
cask "#{cask_token}" do
|
||||
version "1.0.0"
|
||||
sha256 "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
|
||||
|
||||
url "https://example.com/#{cask_token}-\#{version}.dmg"
|
||||
name "Test Cask"
|
||||
desc "A test cask for symlink testing"
|
||||
homepage "https://example.com"
|
||||
|
||||
app "TestCask.app"
|
||||
end
|
||||
RUBY
|
||||
end
|
||||
|
||||
after do
|
||||
tmpdir.rmtree if tmpdir.exist?
|
||||
end
|
||||
|
||||
before do
|
||||
# Create real tap directory structure
|
||||
(real_tap_path / "Casks").mkpath
|
||||
(real_tap_path / "Casks" / "#{cask_token}.rb").write(cask_content)
|
||||
|
||||
# Create homebrew prefix structure
|
||||
taps_dir.mkpath
|
||||
|
||||
# Create symlink to the tap (this simulates what setup-homebrew does)
|
||||
symlinked_tap_path.make_symlink(real_tap_path)
|
||||
|
||||
# Set HOMEBREW_LIBRARY to our test prefix for the security check
|
||||
stub_const("HOMEBREW_LIBRARY", homebrew_prefix / "Library")
|
||||
allow(Homebrew::EnvConfig).to receive(:forbid_packages_from_paths?).and_return(true)
|
||||
end
|
||||
|
||||
context "when HOMEBREW_FORBID_PACKAGES_FROM_PATHS is enabled" do
|
||||
it "allows loading casks from symlinked taps" do
|
||||
loader = Cask::CaskLoader::FromPathLoader.try_new(cask_file_path)
|
||||
expect(loader).not_to be_nil
|
||||
expect(loader).to be_a(Cask::CaskLoader::FromPathLoader)
|
||||
|
||||
cask = loader.load(config: nil)
|
||||
expect(cask.token).to eq(cask_token)
|
||||
expect(cask.version).to eq(Version.new("1.0.0"))
|
||||
end
|
||||
end
|
||||
|
||||
context "when HOMEBREW_FORBID_PACKAGES_FROM_PATHS is disabled" do
|
||||
before do
|
||||
allow(Homebrew::EnvConfig).to receive(:forbid_packages_from_paths?).and_return(false)
|
||||
end
|
||||
|
||||
it "allows loading casks from symlinked taps" do
|
||||
loader = Cask::CaskLoader::FromPathLoader.try_new(cask_file_path)
|
||||
expect(loader).not_to be_nil
|
||||
expect(loader).to be_a(Cask::CaskLoader::FromPathLoader)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -4,6 +4,61 @@ require "os/linux/ld"
|
||||
require "tmpdir"
|
||||
|
||||
RSpec.describe OS::Linux::Ld do
|
||||
let(:diagnostics) do
|
||||
<<~EOS
|
||||
path.prefix="/usr"
|
||||
path.sysconfdir="/usr/local/etc"
|
||||
path.system_dirs[0x0]="/lib64"
|
||||
path.system_dirs[0x1]="/var/lib"
|
||||
EOS
|
||||
end
|
||||
|
||||
describe "::system_ld_so" do
|
||||
let(:ld_so) { "/lib/ld-linux.so.3" }
|
||||
|
||||
before do
|
||||
allow(File).to receive(:executable?).and_return(false)
|
||||
described_class.instance_variable_set(:@system_ld_so, nil)
|
||||
end
|
||||
|
||||
it "returns the path to a known dynamic linker" do
|
||||
allow(File).to receive(:executable?).with(ld_so).and_return(true)
|
||||
expect(described_class.system_ld_so).to eq(Pathname(ld_so))
|
||||
end
|
||||
|
||||
it "returns nil when there is no known dynamic linker" do
|
||||
expect(described_class.system_ld_so).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
describe "::sysconfdir" do
|
||||
it "returns path.sysconfdir" do
|
||||
allow(described_class).to receive(:ld_so_diagnostics).and_return(diagnostics)
|
||||
expect(described_class.sysconfdir).to eq("/usr/local/etc")
|
||||
expect(described_class.sysconfdir(brewed: false)).to eq("/usr/local/etc")
|
||||
end
|
||||
|
||||
it "returns fallback on blank diagnostics" do
|
||||
allow(described_class).to receive(:ld_so_diagnostics).and_return("")
|
||||
expect(described_class.sysconfdir).to eq("/etc")
|
||||
expect(described_class.sysconfdir(brewed: false)).to eq("/etc")
|
||||
end
|
||||
end
|
||||
|
||||
describe "::system_dirs" do
|
||||
it "returns all path.system_dirs" do
|
||||
allow(described_class).to receive(:ld_so_diagnostics).and_return(diagnostics)
|
||||
expect(described_class.system_dirs).to eq(["/lib64", "/var/lib"])
|
||||
expect(described_class.system_dirs(brewed: false)).to eq(["/lib64", "/var/lib"])
|
||||
end
|
||||
|
||||
it "returns an empty array on blank diagnostics" do
|
||||
allow(described_class).to receive(:ld_so_diagnostics).and_return("")
|
||||
expect(described_class.system_dirs).to eq([])
|
||||
expect(described_class.system_dirs(brewed: false)).to eq([])
|
||||
end
|
||||
end
|
||||
|
||||
describe "::library_paths" do
|
||||
ld_etc = Pathname("")
|
||||
before do
|
||||
|
@ -251,7 +251,7 @@ module Homebrew
|
||||
ohai "No outdated dependents to upgrade!" unless dry_run
|
||||
else
|
||||
installed_formulae = (dry_run ? formulae : FormulaInstaller.installed.to_a).dup
|
||||
formula_plural = Utils.pluralize("formula", installed_formulae.count, plural: "e")
|
||||
formula_plural = Utils.pluralize("formula", installed_formulae.count)
|
||||
upgrade_verb = dry_run ? "Would upgrade" : "Upgrading"
|
||||
ohai "#{upgrade_verb} #{Utils.pluralize("dependent", upgradeable.count,
|
||||
include_count: true)} of upgraded #{formula_plural}:"
|
||||
|
@ -160,6 +160,15 @@ module Utils
|
||||
params(stem: String, count: Integer, plural: String, singular: String, include_count: T::Boolean).returns(String)
|
||||
}
|
||||
def self.pluralize(stem, count, plural: "s", singular: "", include_count: false)
|
||||
case stem
|
||||
when "formula"
|
||||
plural = "e"
|
||||
when "dependency", "try"
|
||||
stem = stem.delete_suffix("y")
|
||||
plural = "ies"
|
||||
singular = "y"
|
||||
end
|
||||
|
||||
prefix = include_count ? "#{count} " : ""
|
||||
suffix = (count == 1) ? singular : plural
|
||||
"#{prefix}#{stem}#{suffix}"
|
||||
|
@ -10,5 +10,44 @@ module Utils
|
||||
child_pathname.ascend { |p| return true if p == parent_pathname }
|
||||
false
|
||||
end
|
||||
|
||||
sig { params(path: Pathname, package_type: Symbol).returns(T::Boolean) }
|
||||
def self.loadable_package_path?(path, package_type)
|
||||
return true unless Homebrew::EnvConfig.forbid_packages_from_paths?
|
||||
|
||||
path_realpath = path.realpath.to_s
|
||||
path_string = path.to_s
|
||||
|
||||
allowed_paths = ["#{HOMEBREW_LIBRARY}/Taps/"]
|
||||
allowed_paths << if package_type == :formula
|
||||
"#{HOMEBREW_CELLAR}/"
|
||||
else
|
||||
"#{Cask::Caskroom.path}/"
|
||||
end
|
||||
|
||||
return true if !path_realpath.end_with?(".rb") && !path_string.end_with?(".rb")
|
||||
return true if allowed_paths.any? { |path| path_realpath.start_with?(path) }
|
||||
return true if allowed_paths.any? { |path| path_string.start_with?(path) }
|
||||
|
||||
# Looks like a local path, Ruby file and not a tap.
|
||||
if path_string.include?("./") || path_string.end_with?(".rb") || path_string.count("/") != 2
|
||||
package_type_plural = Utils.pluralize(package_type.to_s, 2)
|
||||
path_realpath_if_different = " (#{path_realpath})" if path_realpath != path_string
|
||||
create_flag = " --cask" if package_type == :cask
|
||||
|
||||
raise <<~WARNING
|
||||
Homebrew requires #{package_type_plural} to be in a tap, rejecting:
|
||||
#{path_string}#{path_realpath_if_different}
|
||||
|
||||
To create a tap, run e.g.
|
||||
brew tap-new <user|org>/<repository>
|
||||
To create a #{package_type} in a tap run e.g.
|
||||
brew create#{create_flag} <url> --tap=<user|org>/<repository>
|
||||
WARNING
|
||||
else
|
||||
# Looks like a tap, let's quietly reject but not error.
|
||||
path_string.count("/") != 2
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
16
Library/Homebrew/vendor/bundle/bundler/setup.rb
vendored
16
Library/Homebrew/vendor/bundle/bundler/setup.rb
vendored
@ -55,7 +55,7 @@ $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/regexp_parser-2.11.2/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/simpleidn-0.2.3/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/json_schemer-2.4.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rexml-3.4.2/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rexml-3.4.4/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/kramdown-2.5.1/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/language_server-protocol-3.17.0.5/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/lint_roller-1.1.0/lib")
|
||||
@ -89,16 +89,16 @@ $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rspec-3.13.1/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rspec-github-3.0.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rspec-retry-0.6.2/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/sorbet-runtime-0.6.12479/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/sorbet-runtime-0.6.12521/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rspec-sorbet-1.9.2/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rspec_junit_formatter-0.6.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-ast-1.46.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/ruby-progressbar-1.13.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/unicode-emoji-4.0.4/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/unicode-display_width-3.1.5/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/unicode-emoji-4.1.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/unicode-display_width-3.2.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-1.80.2/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-md-2.0.2/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-performance-1.25.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-performance-1.26.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-rspec-3.7.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-sorbet-0.10.5/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/ruby-lsp-0.26.1/lib")
|
||||
@ -109,9 +109,9 @@ $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/simplecov_json_formatter-0.1.4/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/simplecov-0.22.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/simplecov-cobertura-3.1.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/sorbet-static-0.6.12479-universal-darwin/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/sorbet-0.6.12479/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/sorbet-static-and-runtime-0.6.12479/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/sorbet-static-0.6.12521-universal-darwin/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/sorbet-0.6.12521/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/sorbet-static-and-runtime-0.6.12521/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/thor-1.4.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/spoom-1.7.6/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/arm64-darwin-20/#{Gem.extension_api_version}/stackprof-0.2.27")
|
||||
|
@ -132,17 +132,14 @@ module T::Props
|
||||
end
|
||||
|
||||
# Shorthand helper to define a `prop` with `immutable => true`
|
||||
sig { params(name: Symbol, cls_or_args: T.untyped, args: T.untyped).void }
|
||||
def const(name, cls_or_args, **args)
|
||||
if (cls_or_args.is_a?(Hash) && cls_or_args.key?(:immutable)) || args.key?(:immutable)
|
||||
sig { params(name: Symbol, cls: T.untyped, rules: T.untyped).void }
|
||||
def const(name, cls, **rules)
|
||||
if rules.key?(:immutable)
|
||||
Kernel.raise ArgumentError.new("Cannot pass 'immutable' argument when using 'const' keyword to define a prop")
|
||||
end
|
||||
|
||||
if cls_or_args.is_a?(Hash)
|
||||
self.prop(name, **cls_or_args.merge(immutable: true))
|
||||
else
|
||||
self.prop(name, cls_or_args, **args.merge(immutable: true))
|
||||
end
|
||||
rules[:immutable] = true
|
||||
self.prop(name, cls, **rules)
|
||||
end
|
||||
|
||||
def included(child)
|
@ -238,7 +238,9 @@ class T::Props::Decorator
|
||||
end
|
||||
|
||||
if rules.keys.any? { |k| !valid_rule_key?(k) }
|
||||
raise ArgumentError.new("At least one invalid prop arg supplied in #{self}: #{rules.keys.inspect}")
|
||||
invalid_keys = rules.keys.reject { |k| valid_rule_key?(k) }
|
||||
suffix = invalid_keys.size == 1 ? "" : "s"
|
||||
raise ArgumentError.new("Invalid prop arg#{suffix} supplied in #{self}: #{invalid_keys.inspect}")
|
||||
end
|
||||
|
||||
if !rules[:clobber_existing_method!] && !rules[:without_accessors] && BANNED_METHOD_NAMES.include?(name.to_sym)
|
@ -34,6 +34,8 @@ module T::Types
|
||||
case other
|
||||
when TEnum
|
||||
@val == other.val
|
||||
when Simple
|
||||
other.raw_type.===(@val)
|
||||
else
|
||||
false
|
||||
end
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user