class RBT::NotFoundLibraries

Constants

NOT_FOUND_STRING
#

NOT_FOUND_STRING

#

Public Class Methods

[](i = ARGV) click to toggle source
#

RBT::NotFoundLibraries[]

#
# File lib/rbt/utility_scripts/not_found_libraries.rb, line 229
def self.[](i = ARGV)
  new(i)
end
new( commandline_arguments = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/utility_scripts/not_found_libraries.rb, line 36
def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Public Instance Methods

dataset?()
determine_all_binaries_on_this_system() click to toggle source
#

determine_all_binaries_on_this_system

Determine which .sp files exist on this system.

#
# File lib/rbt/utility_scripts/not_found_libraries.rb, line 77
def determine_all_binaries_on_this_system
  @all_shared_object_libaries = []
  @search_through_these_directories.each {|this_directory|
    @all_shared_object_libaries << Dir["#{this_directory}*"]
  }
  @all_shared_object_libaries.flatten!
  @all_shared_object_libaries.uniq!
  @all_shared_object_libaries.select! {|entry| File.exist? entry }
end
hash_these_entries_are_missing?() click to toggle source
#

hash_these_entries_are_missing?

#
# File lib/rbt/utility_scripts/not_found_libraries.rb, line 172
def hash_these_entries_are_missing?
  @hash_these_entries_are_missing
end
Also aliased as: dataset?
menu( i = commandline_arguments? ) click to toggle source
#

menu (menu tag)

#
notify_the_user_what_will_be_done_next() click to toggle source
#

notify_the_user_what_will_be_done_next

#
# File lib/rbt/utility_scripts/not_found_libraries.rb, line 164
def notify_the_user_what_will_be_done_next
  opne 'This class will scan for all binaries on this system and'
  opne 'determine whether any shared-libraries are missing.'
end
report_whether_entries_are_missing_and_which_ones_are_missing() click to toggle source
#

report_whether_entries_are_missing_and_which_ones_are_missing

#
# File lib/rbt/utility_scripts/not_found_libraries.rb, line 179
def report_whether_entries_are_missing_and_which_ones_are_missing
  _ = @hash_these_entries_are_missing
  if _.empty?
    opne 'No shared-object library appears to be missing. '\
         'This is good. '+gold('\o/')
    e
    opne "#{rev}The following directories were searched:"
    show_the_directories_that_will_be_searched
  else
    opne "#{rev}These entries appear to be #{orange('missing')}#{rev}:"
    _.each {|this_library_is_missing, array_these_binaries_have_problems|
      e rev+'The following binaries refer to this missing .so library: '+orange(
          File.basename(this_library_is_missing)
        )
      array_these_binaries_have_problems.each {|this_binary_has_a_problem|
        e royalblue("    #{this_binary_has_a_problem}")
      }
    }
    save_the_hash_into_a_yaml_file
  end
end
Also aliased as: report
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::LeanPrototype#reset
# File lib/rbt/utility_scripts/not_found_libraries.rb, line 50
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @hash_these_entries_are_missing
  #
  # The next Hash is our main data-structure for this class.
  # ======================================================================= #
  @hash_these_entries_are_missing = {}
  @hash_these_entries_are_missing.default = []
  # ======================================================================= #
  # === @search_through_these_directories
  # ======================================================================= #
  @search_through_these_directories = %w(
    /bin/
    /sbin/
    /usr/bin/
    /usr/local/bin/
    /System/Index/bin/
  )
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/utility_scripts/not_found_libraries.rb, line 218
def run
  menu
  notify_the_user_what_will_be_done_next
  determine_all_binaries_on_this_system
  run_ldd_on_each_discovered_binary
  report_whether_entries_are_missing_and_which_ones_are_missing
end
run_ldd_on_each_discovered_binary() click to toggle source
#

run_ldd_on_each_discovered_binary

#
# File lib/rbt/utility_scripts/not_found_libraries.rb, line 90
def run_ldd_on_each_discovered_binary
  @all_shared_object_libaries.each {|this_file|
    result = `ldd #{this_file} 2>&1`
    if result.include? NOT_FOUND_STRING
      matches = result.split("\n").select {|inner_entry|
        inner_entry.include? NOT_FOUND_STRING
      }
      these_matches_are_available = matches.map {|most_inner_entry|
        most_inner_entry.sub(/\t/,'')
      }
      these_matches_are_available.each {|match|
        # ================================================================= #
        # Must eliminate a part of this:
        # ================================================================= #
        match.sub!(/ => not found/,'')
        unless @hash_these_entries_are_missing.has_key? match
          @hash_these_entries_are_missing[match] = []
        end
        @hash_these_entries_are_missing[match] << this_file
        @hash_these_entries_are_missing[match].uniq!
      } 
    end
  }
end
save_the_hash_into_a_yaml_file() click to toggle source
#

save_the_hash_into_a_yaml_file

This method will put the findings into the file called “missing_libraries.yml”.

#
# File lib/rbt/utility_scripts/not_found_libraries.rb, line 207
def save_the_hash_into_a_yaml_file
  what = YAML.dump(@hash_these_entries_are_missing)
  into = "#{rbt_log_dir?}missing_libraries.yml"
  opne "#{rev}Also keeping a log of these files "\
       "into `#{sfile(into)}#{rev}`."
  write_what_into(what, into)
end
show_help() click to toggle source
#

show_help (help tag)

#
# File lib/rbt/utility_scripts/not_found_libraries.rb, line 118
def show_help
  e
  e '  --dirs? # show which directories were searched'
  e
end
show_the_directories_that_will_be_searched() click to toggle source
#

show_the_directories_that_will_be_searched

#
# File lib/rbt/utility_scripts/not_found_libraries.rb, line 153
def show_the_directories_that_will_be_searched
  e
  @search_through_these_directories.each {|this_directory|
    e sdir("  #{this_directory}")
  }
  e
end