Merge pull request #8052 from maxim-belkin/missing_libs_follow_up
formula.rb: update 'missing libraries' feature
This commit is contained in:
commit
bb90afbfff
@ -7,23 +7,6 @@ class Formula
|
||||
"#{name}.so#{"." unless version.nil?}#{version}"
|
||||
end
|
||||
|
||||
undef allowed_missing_lib?
|
||||
def allowed_missing_lib?(lib)
|
||||
# lib: Full path to the missing library
|
||||
# Ex.: /home/linuxbrew/.linuxbrew/lib/libsomething.so.1
|
||||
# x - Name of or a pattern for a library, linkage to which is allowed to be missing.
|
||||
# Ex. 1: "libONE.so.1"
|
||||
# Ex. 2: %r{(libONE|libTWO)\.so}
|
||||
self.class.allowed_missing_libraries.any? do |x|
|
||||
case x
|
||||
when Regexp
|
||||
x.match? lib
|
||||
when String
|
||||
lib.include? x
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class << self
|
||||
undef on_linux
|
||||
|
||||
@ -31,9 +14,15 @@ class Formula
|
||||
yield
|
||||
end
|
||||
|
||||
undef ignore_missing_libraries
|
||||
|
||||
def ignore_missing_libraries(*libs)
|
||||
libs.flatten!
|
||||
allowed_missing_libraries.merge(libs)
|
||||
libraries = libs.flatten
|
||||
if libraries.any? { |x| !x.is_a?(String) && !x.is_a?(Regexp) }
|
||||
raise FormulaSpecificationError, "#{__method__} can handle Strings and Regular Expressions only"
|
||||
end
|
||||
|
||||
allowed_missing_libraries.merge(libraries)
|
||||
end
|
||||
|
||||
# @private
|
||||
|
@ -1131,13 +1131,6 @@ class Formula
|
||||
end
|
||||
end
|
||||
|
||||
# Whether this {Formula} is allowed to have a broken linkage to specified library.
|
||||
# Defaults to false.
|
||||
# @return [Boolean]
|
||||
def allowed_missing_lib?(*)
|
||||
false
|
||||
end
|
||||
|
||||
# Whether this {Formula} is deprecated (i.e. warns on installation).
|
||||
# Defaults to false.
|
||||
# @method deprecated?
|
||||
@ -2763,6 +2756,10 @@ class Formula
|
||||
def link_overwrite_paths
|
||||
@link_overwrite_paths ||= Set.new
|
||||
end
|
||||
|
||||
def ignore_missing_libraries(*)
|
||||
raise FormulaSpecificationError, "#{__method__} is available on Linux only"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -15,6 +15,7 @@ class LinkageChecker
|
||||
|
||||
@system_dylibs = Set.new
|
||||
@broken_dylibs = Set.new
|
||||
@unexpected_broken_dylibs = nil
|
||||
@variable_dylibs = Set.new
|
||||
@brewed_dylibs = Hash.new { |h, k| h[k] = Set.new }
|
||||
@reverse_links = Hash.new { |h, k| h[k] = Set.new }
|
||||
@ -62,7 +63,7 @@ class LinkageChecker
|
||||
|
||||
if @broken_dylibs.empty?
|
||||
puts "No broken library linkage detected"
|
||||
elsif unexpected_broken_libs.empty?
|
||||
elsif unexpected_broken_dylibs.empty?
|
||||
puts "No unexpected broken library linkage detected."
|
||||
else
|
||||
puts "Broken library linkage detected"
|
||||
@ -71,17 +72,32 @@ class LinkageChecker
|
||||
|
||||
def broken_library_linkage?
|
||||
issues = [@broken_deps, @unwanted_system_dylibs, @version_conflict_deps]
|
||||
[issues, unexpected_broken_libs].flatten.any?(&:present?)
|
||||
[issues, unexpected_broken_dylibs].flatten.any?(&:present?)
|
||||
end
|
||||
|
||||
def unexpected_broken_libs
|
||||
@broken_dylibs.reject { |lib| @formula.allowed_missing_lib? lib }
|
||||
def unexpected_broken_dylibs
|
||||
return @unexpected_broken_dylibs if @unexpected_broken_dylibs
|
||||
|
||||
@unexpected_broken_dylibs = @broken_dylibs.reject do |broken_lib|
|
||||
@formula.class.allowed_missing_libraries.any? do |allowed_missing_lib|
|
||||
case allowed_missing_lib
|
||||
when Regexp
|
||||
allowed_missing_lib.match? broken_lib
|
||||
when String
|
||||
broken_lib.include? allowed_missing_lib
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def broken_dylibs_with_expectations
|
||||
output = {}
|
||||
@broken_dylibs.each do |lib|
|
||||
output[lib] = (unexpected_broken_libs.include? lib) ? ["unexpected"] : ["expected"]
|
||||
@broken_dylibs.each do |broken_lib|
|
||||
output[broken_lib] = if unexpected_broken_dylibs.include? broken_lib
|
||||
["unexpected"]
|
||||
else
|
||||
["expected"]
|
||||
end
|
||||
end
|
||||
output
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user