2018-08-03 11:15:58 -07:00
|
|
|
#: * `linkage` [`--test`] [`--reverse`] [<formulae>]:
|
|
|
|
#: Checks the library links of installed formulae.
|
2016-09-08 09:05:00 +01:00
|
|
|
#:
|
|
|
|
#: 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-08-03 11:15:58 -07:00
|
|
|
#:
|
|
|
|
#: If <formulae> are given, check linkage for only the specified brews.
|
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"
|
2018-06-02 20:45:50 +05:30
|
|
|
require "cli_parser"
|
2016-04-17 21:25:11 -04:00
|
|
|
|
|
|
|
module Homebrew
|
2016-09-26 01:44:51 +02:00
|
|
|
module_function
|
|
|
|
|
2018-07-30 18:25:38 +05:30
|
|
|
def linkage_args
|
|
|
|
Homebrew::CLI::Parser.new do
|
2018-06-02 20:45:50 +05:30
|
|
|
switch "--test"
|
|
|
|
switch "--reverse"
|
|
|
|
switch :verbose
|
|
|
|
switch :debug
|
|
|
|
end
|
2018-07-30 18:25:38 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def linkage
|
|
|
|
linkage_args.parse
|
2018-06-02 20:45:50 +05:30
|
|
|
|
2018-05-22 14:46:14 +01:00
|
|
|
CacheStoreDatabase.use(:linkage) do |db|
|
2018-08-03 11:15:58 -07:00
|
|
|
kegs = if ARGV.kegs.empty?
|
2018-09-02 20:14:54 +01:00
|
|
|
Formula.installed.map(&:opt_or_installed_prefix_keg).reject(&:nil?)
|
2018-08-03 11:15:58 -07:00
|
|
|
else
|
|
|
|
ARGV.kegs
|
|
|
|
end
|
|
|
|
kegs.each do |keg|
|
|
|
|
ohai "Checking #{keg.name} linkage" if kegs.size > 1
|
2018-01-16 17:37:59 -05:00
|
|
|
|
2018-06-29 19:57:39 +01:00
|
|
|
result = LinkageChecker.new(keg, cache_db: db)
|
2018-01-16 17:37:59 -05:00
|
|
|
|
2018-06-02 20:45:50 +05:30
|
|
|
if args.test?
|
2018-02-24 17:32:29 -05:00
|
|
|
result.display_test_output
|
2018-04-24 16:49:51 -04:00
|
|
|
Homebrew.failed = true if result.broken_library_linkage?
|
2018-06-02 20:45:50 +05:30
|
|
|
elsif args.reverse?
|
2018-02-24 17:32:29 -05:00
|
|
|
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
|