class RBT::NotFoundLibraries

Constants

NAMESPACE
#

NAMESPACE

#
NOT_FOUND_STRING
#

NOT_FOUND_STRING

#

Public Class Methods

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

[]

#
# File lib/rbt/utility_scripts/not_found_libraries.rb, line 237
def self.[](i = '')
  self.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 38
def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Public Instance Methods

commandline_arguments?() click to toggle source
#

commandline_arguments?

#
# File lib/rbt/utility_scripts/not_found_libraries.rb, line 80
def commandline_arguments?
  @commandline_arguments
end
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 89
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 184
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 176
def notify_the_user_what_will_be_done_next
  opnn; e 'This class will scan for all binaries on this system and'
  opnn; e '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 191
def report_whether_entries_are_missing_and_which_ones_are_missing
  _ = @hash_these_entries_are_missing
  if _.empty?
    opnn; e 'No shared-object library appears to be missing. '\
            'This is good. '+gold('\o/')
    e
    opnn; e 'The following directories were searched:'
    show_the_directories_that_will_be_searched
  else
    opnn; e "These entries appear to be #{orange('missing')}:"
    _.each {|this_library_is_missing, array_these_binaries_have_problems|
      e '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::Base#reset
# File lib/rbt/utility_scripts/not_found_libraries.rb, line 52
def reset
  super()
  @namespace = NAMESPACE
  # ======================================================================= #
  # 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 = %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 226
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 102
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

#
# File lib/rbt/utility_scripts/not_found_libraries.rb, line 216
def save_the_hash_into_a_yaml_file
  what = YAML.dump(@hash_these_entries_are_missing)
  into = rbt_log_dir?+'missing_libraries.yml'
  opnn; e 'Also keeping a log of these files into `'+sfile(into)+'`.'
  write_what_into(what, into)
end
set_commandline_arguments(i = '') click to toggle source
#

set_input

#
# File lib/rbt/utility_scripts/not_found_libraries.rb, line 72
def set_commandline_arguments(i = '')
  i = [i].flatten.compact
  @commandline_arguments = i
end
show_help() click to toggle source
#

show_help (help tag)

#
# File lib/rbt/utility_scripts/not_found_libraries.rb, line 130
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 165
def show_the_directories_that_will_be_searched
  e
  @search_through_these_directories.each {|this_directory|
    e sdir("  #{this_directory}")
  }
  e
end