diff --git a/Library/Homebrew/extend/os/linux/formula.rb b/Library/Homebrew/extend/os/linux/formula.rb index f060c1590d..0816edbb87 100644 --- a/Library/Homebrew/extend/os/linux/formula.rb +++ b/Library/Homebrew/extend/os/linux/formula.rb @@ -7,25 +7,6 @@ class Formula "#{name}.so#{"." unless version.nil?}#{version}" end - undef allowed_missing_lib? - def allowed_missing_lib?(lib) - raise TypeError, "Library must be a string; got a #{lib.class} (#{lib})" unless lib.is_a? String - - # 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 diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 834b6ab4ea..6114a8896c 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -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? diff --git a/Library/Homebrew/linkage_checker.rb b/Library/Homebrew/linkage_checker.rb index 372cddb2a2..31b6c0e3cc 100644 --- a/Library/Homebrew/linkage_checker.rb +++ b/Library/Homebrew/linkage_checker.rb @@ -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,37 @@ 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 allowed_missing_lib?(lib) + raise TypeError, "Library must be a string; got a #{lib.class} (#{lib})" unless lib.is_a? String + + # 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} + @formula.class.allowed_missing_libraries.any? do |x| + case x + when Regexp + x.match? lib + when String + lib.include? x + end + end + end + + def unexpected_broken_dylibs + return @unexpected_broken_dylibs if @unexpected_broken_dylibs + + @unexpected_broken_dylibs = @broken_dylibs.reject { |lib| allowed_missing_lib? lib } end def broken_dylibs_with_expectations output = {} @broken_dylibs.each do |lib| - output[lib] = if unexpected_broken_libs.include? lib + output[lib] = if unexpected_broken_dylibs.include? lib ["unexpected"] else ["expected"]