@@ -66,22 +66,25 @@ def initialize(project)
6666 def run!
6767 measure ( "Health check time" ) do
6868 log . info ( log_key ) { "Running health on #{ project . name } " }
69- bad_libs , good_libs = case Ohai [ "platform" ]
70- when "mac_os_x"
71- health_check_otool
72- when "aix"
73- health_check_aix
74- when "windows"
75- # TODO: objdump -p will provided a very limited check of
76- # explicit dependencies on windows. Most dependencies are
77- # implicit and hence not detected.
78- log . warn ( log_key ) { "Skipping dependency health checks on Windows." }
79- [ { } , { } ]
80- when "solaris2"
81- health_check_solaris
82- else
83- health_check_ldd
84- end
69+ bad_libs , good_libs =
70+ case Ohai [ "platform" ]
71+ when "mac_os_x"
72+ health_check_otool
73+ when "aix"
74+ health_check_aix
75+ when "windows"
76+ # TODO: objdump -p will provided a very limited check of
77+ # explicit dependencies on windows. Most dependencies are
78+ # implicit and hence not detected.
79+ log . warn ( log_key ) { "Skipping dependency health checks on Windows." }
80+ [ { } , { } ]
81+ when "solaris2"
82+ health_check_solaris
83+ when "freebsd" , "openbsd" , "netbsd"
84+ health_check_freebsd
85+ else
86+ health_check_linux
87+ end
8588
8689 unresolved = [ ]
8790 unreliable = [ ]
@@ -366,18 +369,52 @@ def health_check_solaris
366369 [ bad_libs , good_libs ]
367370 end
368371
372+ #
373+ # Run healthchecks on FreeBSD
374+ #
375+ # @return [Hash<String, Hash<String, Hash<String, Int>>>]
376+ # the bad libraries (library_name -> dependency_name -> satisfied_lib_path -> count)
377+ #
378+ def health_check_freebsd
379+ current_library = nil
380+ bad_libs = { }
381+ good_libs = { }
382+
383+ read_shared_libs ( "find #{ project . install_dir } / -type f | xargs file | grep \" ELF\" | awk -F: '{print $1}' | sed -e 's/:$//'" , "xargs ldd" ) do |line |
384+ case line
385+ when /^(.+):$/
386+ current_library = Regexp . last_match [ 1 ]
387+ log . debug ( log_key ) { "Analyzing dependencies for #{ current_library } " }
388+ when /^\s +(.+) \= \> \s +(.+)( \( .+\) )?$/
389+ name = Regexp . last_match [ 1 ]
390+ linked = Regexp . last_match [ 2 ]
391+ ( bad_libs , good_libs ) = check_for_bad_library ( bad_libs , good_libs , current_library , name , linked )
392+ when /^\s +(.+) \( .+\) $/
393+ next
394+ when /^\s +statically linked$/
395+ next
396+ when /^\s +not a dynamic executable$/ # ignore non-executable files
397+ else
398+ log . warn ( log_key ) do
399+ "Line did not match for #{ current_library } \n #{ line } "
400+ end
401+ end
402+ end
403+
404+ [ bad_libs , good_libs ]
405+ end
406+
369407 #
370408 # Run healthchecks against ldd.
371409 #
372410 # @return [Hash<String, Hash<String, Hash<String, Int>>>]
373411 # the bad libraries (library_name -> dependency_name -> satisfied_lib_path -> count)
374412 #
375- def health_check_ldd
413+ def health_check_linux
376414 current_library = nil
377415 bad_libs = { }
378416 good_libs = { }
379417
380- # This algorithm runs on both Linux and FreeBSD and needs to be MANUALLY tested on both
381418 read_shared_libs ( "find #{ project . install_dir } / -type f" , "xargs ldd" ) do |line |
382419 case line
383420 when /^(.+):$/
0 commit comments