2018-03-14 10:57:08 -04:00
|
|
|
#: * `linkage` [`--test`] [`--reverse`] [`--cached`] <formula>:
|
2016-09-08 09:05:00 +01:00
|
|
|
#: Checks the library links of an installed formula.
|
|
|
|
#:
|
|
|
|
#: Only works on installed formulae. An error is raised if it is run on
|
|
|
|
#: uninstalled formulae.
|
|
|
|
#:
|
|
|
|
#: If `--test` is passed, only display missing libraries and exit with a
|
|
|
|
#: non-zero exit code if any missing libraries were found.
|
|
|
|
#:
|
|
|
|
#: If `--reverse` is passed, print the dylib followed by the binaries
|
|
|
|
#: which link to it for each library the keg references.
|
2018-01-16 17:37:59 -05:00
|
|
|
#:
|
2018-03-14 10:57:08 -04:00
|
|
|
#: If `--cached` is passed, print the cached linkage values stored in
|
|
|
|
#: HOMEBREW_CACHE, set from a previous `brew linkage` run
|
2016-04-17 21:25:11 -04:00
|
|
|
|
2018-02-28 10:39:15 -05:00
|
|
|
require "cache_store"
|
2018-02-28 09:13:17 -08:00
|
|
|
require "linkage_checker"
|
2016-04-17 21:25:11 -04:00
|
|
|
|
|
|
|
module Homebrew
|
2016-09-26 01:44:51 +02:00
|
|
|
module_function
|
|
|
|
|
2016-04-17 21:25:11 -04:00
|
|
|
def linkage
|
2018-05-18 10:06:30 -04:00
|
|
|
DatabaseCache.use(:linkage) do |database_cache|
|
2018-02-24 17:32:29 -05:00
|
|
|
ARGV.kegs.each do |keg|
|
|
|
|
ohai "Checking #{keg.name} linkage" if ARGV.kegs.size > 1
|
2018-01-16 17:37:59 -05:00
|
|
|
|
2018-03-14 10:57:08 -04:00
|
|
|
use_cache = ARGV.include?("--cached") || ENV["HOMEBREW_LINKAGE_CACHE"]
|
2018-05-21 16:15:52 -04:00
|
|
|
result = LinkageChecker.new(keg, database_cache, use_cache)
|
2018-01-16 17:37:59 -05:00
|
|
|
|
2018-02-24 17:32:29 -05:00
|
|
|
if ARGV.include?("--test")
|
|
|
|
result.display_test_output
|
2018-04-24 16:49:51 -04:00
|
|
|
Homebrew.failed = true if result.broken_library_linkage?
|
2018-02-24 17:32:29 -05:00
|
|
|
elsif ARGV.include?("--reverse")
|
|
|
|
result.display_reverse_output
|
|
|
|
else
|
|
|
|
result.display_normal_output
|
|
|
|
end
|
|
|
|
end
|
2016-04-17 21:25:11 -04:00
|
|
|
end
|
|
|
|
end
|
2016-04-19 13:55:47 +08:00
|
|
|
end
|