in lib/omnibus/health_check.rb [65:218]
def run!
unless Config.health_check
log.info(log_key) { "Health check skipped as specified in config for #{project.name}" }
return true
end
measure("Health check time") do
log.info(log_key) { "Running health on #{project.name}" }
bad_libs, good_libs =
case Ohai["platform"]
when "mac_os_x"
health_check_otool
when "aix"
health_check_aix
when "windows"
log.warn(log_key) { "Skipping dependency health checks on Windows." }
[{}, {}]
when "solaris2"
health_check_solaris
when "freebsd", "openbsd", "netbsd"
health_check_freebsd
else
health_check_linux
end
unresolved = []
unreliable = []
detail = []
if bad_libs.keys.length > 0
bad_libs.each do |name, lib_hash|
lib_hash.each do |lib, linked_libs|
linked_libs.each do |linked, count|
if linked =~ /not found/
unresolved << lib unless unresolved.include? lib
else
unreliable << linked unless unreliable.include? linked
end
detail << "#{name}|#{lib}|#{linked}|#{count}"
end
end
end
log.error(log_key) { "Failed!" }
bad_omnibus_libs, bad_omnibus_bins = bad_libs.keys.partition { |k| k.include? "embedded/lib" }
log.error(log_key) do
out = "The following libraries have unsafe or unmet dependencies:\n"
bad_omnibus_libs.each do |lib|
out << " --> #{lib}\n"
end
out
end
log.error(log_key) do
out = "The following binaries have unsafe or unmet dependencies:\n"
bad_omnibus_bins.each do |bin|
out << " --> #{bin}\n"
end
out
end
if unresolved.length > 0
log.error(log_key) do
out = "The following requirements could not be resolved:\n"
unresolved.each do |lib|
out << " --> #{lib}\n"
end
out
end
end
if unreliable.length > 0
log.error(log_key) do
out = "The following libraries cannot be guaranteed to be on "
out << "target systems:\n"
unreliable.each do |lib|
out << " --> #{lib}\n"
end
out
end
end
log.error(log_key) do
out = "The precise failures were:\n"
detail.each do |line|
item, dependency, location, count = line.split("|")
reason = location =~ /not found/ ? "Unresolved dependency" : "Unsafe dependency"
out << " --> #{item}\n"
out << " DEPENDS ON: #{dependency}\n"
out << " COUNT: #{count}\n"
out << " PROVIDED BY: #{location}\n"
out << " FAILED BECAUSE: #{reason}\n"
end
out
end
raise HealthCheckFailed
end
if good_libs.keys.length == 0 && !windows?
raise "Internal error: no good libraries were found"
end
conflict_map = {}
conflict_map = relocation_check if relocation_checkable?
if conflict_map.keys.length > 0
log.warn(log_key) { "Multiple dlls with overlapping images detected" }
conflict_map.each do |lib_name, data|
base = data[:base]
size = data[:size]
next_valid_base = data[:base] + data[:size]
log.warn(log_key) do
out = "Overlapping dll detected:\n"
out << " #{lib_name} :\n"
out << " IMAGE BASE: #{hex}\n" % base
out << " IMAGE SIZE: #{hex} (#{size} bytes)\n" % size
out << " NEXT VALID BASE: #{hex}\n" % next_valid_base
out << " CONFLICTS:\n"
data[:conflicts].each do |conflict_name|
cbase = conflict_map[conflict_name][:base]
csize = conflict_map[conflict_name][:size]
out << " - #{conflict_name} #{hex} + #{hex}\n" % [cbase, csize]
end
out
end
end
end
true
end
end