class RBT::Libtool
Constants
- FILE_SEARCH_IN_THESE_DIRECTORIES
#¶ ↑
FILE_SEARCH_IN_THESE_DIRECTORIES
¶ ↑#¶ ↑
- REGEX_TO_DISCOVER_PROGRAMS_ENTRIES_IN_DEPENDENCY_LIBS
#¶ ↑
REGEX_TO_DISCOVER_PROGRAMS_ENTRIES_IN_DEPENDENCY_LIBS
¶ ↑Rubular example at:
http://rubular.com/r/E8jSpNAMcX
#¶ ↑
- SYSTEM_LIBRARIES
#¶ ↑
SYSTEM_LIBRARIES
¶ ↑In modern GoboLinux variants, this is pointing towards /System/Index/lib.
#¶ ↑
- ULIB64_LIBRARIES
#¶ ↑
ULIB64_LIBRARIES
¶ ↑#¶ ↑
- ULIB_LIBRARIES
#¶ ↑
ULIB_LIBRARIES
¶ ↑#¶ ↑
Public Class Methods
#¶ ↑
RBT::Libtool.append_this_directory_to_the_list_of_directories_to_search_for
¶ ↑
This should be used on the commandline.
It will permanently set to use a new directory to search for.
#¶ ↑
# File lib/rbt/libtool/class_methods/append_this_directory_to_the_list_of_directories_to_search_for.rb, line 30 def self.append_this_directory_to_the_list_of_directories_to_search_for( i = ARGV ) i = i.first if i.is_a? Array case i when 'PROGRAMS' i = program_dir? end unless File.exist?(i) i = i.dup if i.frozen? i << '/' unless i.end_with? '/' target_file = FILE_SEARCH_IN_THESE_DIRECTORIES array_search_in_these_directories = YAML.load_file(target_file) # ======================================================================= # # Only add new entries. # ======================================================================= # if array_search_in_these_directories.include? i opn; e "Can not add #{Colours.sdir(i)} as it is already a part "\ "of the search-directories." # ======================================================================= # # Add the new entry into our main yaml file. # ======================================================================= # else array_search_in_these_directories << i opn; e 'We will append the directory `'+Colours.sdir(i)+'` to the '\ 'list of directories' opn; e 'that we will search for incorrect .la files.' File.open(target_file, 'w+') { |file| file.write(YAML.dump(array_search_in_these_directories)) } opn; e "Done! The new file can be found at `#{Colours.sfile(target_file)}`." if RBT.is_on_roebe? this_file = "#{RUBY_SRC_DIR}roebe/lib/roebe/yaml/"\ "#{File.basename(target_file)}" File.open(this_file, 'w+') { |file| file.write(YAML.dump(array_search_in_these_directories)) } opn; e 'Done! The new file can be found at '+Colours.sfile(this_file) end end end
#¶ ↑
RBT::Libtool.autocorrect_this_file
¶ ↑
The argument for this method should be an erroneous libtool entry such as /usr/lib/glib.la.
#¶ ↑
# File lib/rbt/libtool/class_methods/autocorrect_this_file.rb, line 19 def self.autocorrect_this_file(i) RBT::Libtool.new(:do_not_run_yet).remove_this_entry(i) end
#¶ ↑
Libtool.autofix_every_la_file
¶ ↑
Use this method to fix every .la file on your system.
Invocation example:
rubylibtool --autofix
#¶ ↑
# File lib/rbt/libtool/libtool.rb, line 418 def self.autofix_every_la_file ensure_that_we_have_found_la_files if Libtool.faulty_la_files?.empty? # ===================================================================== # # In this case, fill up the Array first. # ===================================================================== # Libtool.fill_up_array_that_holds_faulty_la_files end Libtool.faulty_la_files?.each {|file| opne "Now working on the #{orange('.la')} file `#{sfile(file)}`." dataset = File.readlines(file) new_file_content = '' dataset.each {|line| if line.include?('dependency_libs') and line.include? PROGRAMS_DIRECTORY.chop # .chop because we have a trailing '/'. splitted = line.split(' ') splitted.map! {|entry| if entry.include? PROGRAMS_DIRECTORY.chop entry = rds(entry) # ============================================================= # # /usr//Programs/Libx11/1.6.3/lib/libX11.la # or # /usr//usr//usr//Programs/Atspi2core/2.18.2/lib/libatspi.la # really strange # ============================================================= # regex = REGEX_TO_DISCOVER_PROGRAMS_ENTRIES_IN_DEPENDENCY_LIBS entry =~ regex match = $1.to_s.dup entry.sub!(/#{match}/, '/usr/') end entry } line = splitted.join(' ')+N end new_file_content << line } what = new_file_content into = file opne "Now storing into `#{sfile(into)}`." write_what_into(what, into) } end
#¶ ↑
initialize¶ ↑
#¶ ↑
# File lib/rbt/libtool/libtool.rb, line 34 def initialize( i = ARGV, run_already = true ) reset case i # ======================================================================= # # === :do_not_run_yet # ======================================================================= # when :do_not_run_yet # In this case, do not run anything. else # This else clause here is the default clause. set_commandline_arguments(i) run if run_already end end
#¶ ↑
RBT::Libtool.return_every_la_file
¶ ↑
If you want to return every .la file on a given computer system, then, use this method here.
This will obtain from /usr/lib/, /usr/lib64 and /System/Libraries/ by default. Otherwise, we will make use of an Array.
#¶ ↑
# File lib/rbt/libtool/class_methods/return_every_la_file.rb, line 22 def self.return_every_la_file ::RBT::Libtool.new.every_la_file end
#¶ ↑
RBT::Libtool.use_this_directory
¶ ↑
The PWD macro means Dir.pwd actually.
#¶ ↑
# File lib/rbt/libtool/class_methods/use_this_directory.rb, line 41 def self.use_this_directory(i) i = i.to_s case i when 'PWD' i = return_pwd end unless File.exist? i i << '/' unless i.end_with? '/' @use_this_directory = i end
Public Instance Methods
#¶ ↑
append_this_directory_to_the_list_of_directories_to_search_for
¶ ↑
#¶ ↑
# File lib/rbt/libtool/libtool.rb, line 215 def append_this_directory_to_the_list_of_directories_to_search_for(i) case i when 'PROGRAMS' i = program_dir? end unless File.exist?(i) i = i.dup if i.frozen? i << '/' unless i.end_with? '/' unless @search_in_these_directories.include? i if block_given? yielded = yield case yielded # =================================================================== # # === :be_verbose # =================================================================== # when :be_verbose opne "Adding the directory `#{sdir(i)}"\ "` to the search path of this class." end end @search_in_these_directories << i end end
#¶ ↑
obtain_all_the_la_files
¶ ↑
#¶ ↑
# File lib/rbt/libtool/libtool.rb, line 257 def obtain_all_the_la_files( i = @search_in_these_directories ) i.each {|this_dir| these_la_files = Dir["#{this_dir}**/**.la"] @array_all_libtool_files << these_la_files @array_all_libtool_files.flatten! } return @array_all_libtool_files end
#¶ ↑
remove_the_last_faulty_libtool_entry_stored_in_a_file
¶ ↑
Invocation example:
rubylibtool --remove-from-file
#¶ ↑
# File lib/rbt/libtool/libtool.rb, line 359 def remove_the_last_faulty_libtool_entry_stored_in_a_file _ = "#{rbt_log_directory?}libtool/last_faulty_libtool_file.md" # ======================================================================= # # (1) Read the entry from the .md file, if it exists # ======================================================================= # if File.exist? _ this_is_a_faulty_libtool_entry = File.read(_).strip # ===================================================================== # # (2) pass this into remove_this_entry() # ===================================================================== # remove_this_entry(this_is_a_faulty_libtool_entry) else opnn; no_file_exists_at(_) end end
#¶ ↑
remove_this_entry
¶ ↑
Use this method to remove a specific entry within all .la files.
#¶ ↑
# File lib/rbt/libtool/libtool.rb, line 281 def remove_this_entry(i) clear_array_log_these_files # Reset the Array first. if i.end_with?(':') and !File.exist?(i) i.chop! end opne 'The following entry will be removed from every '\ 'encountered .la file on this computer:' e e " #{seagreen(i)}" e if ::RBT::Libtool.use_this_directory? la_files = Dir["#{RBT::Libtool.use_this_directory?}**/**.la"] else la_files = obtain_all_libtool_files end notify_the_user_which_directories_will_be_searched # ======================================================================= # # Next, reject those who do not contain the given search term "i". # We will also log these files. # ======================================================================= # la_files.select! {|file| # ===================================================================== # # Must first check whether it is a symlink that exists. # ===================================================================== # if File.symlink?(file) and !File.exist?(File.readlink(file)) symlink_target = File.readlink(file) opne 'No file exists at '+sfile(file)+rev+ ' (a symlink pointing '\ 'at '+sfile(symlink_target)+')' end if File.exist? file dataset = File.read(file) dataset.include?(i) else opne "No file could be found at `#{sfile(file)}#{rev}`." end } if la_files.empty? opne "We did not find any .la file that includes "\ "the entry `#{simp(i)}#{rev}`." else la_files.each {|file| opne "#{rev}Working on `#{sfile(file)}#{rev}` next." dataset = File.readlines(file) _ = ''.dup dataset.each {|line| if line.include?('dependency_libs') and line.include?(i) line.gsub!(/#{Regexp.quote(i)}/,'') @array_log_these_files << i end _ << line } # =================================================================== # # Write the new content into that .la file. # =================================================================== # write_what_into(_, file) } unless @array_log_these_files.empty? what = N+@array_log_these_files.join(N)+('-' * 40)+N # ===================================================================== # # Store the modified files in a file: # ===================================================================== # into = "#{rbt_log_directory?}libtool_modified_these_files.md" opne "#{rev}Keeping a backup of which libtool files were" opne "modified, at `#{sfile(into)}#{rev}`." append_what_into(what, into) end end end
#¶ ↑
report_how_many_la_files_were_found
¶ ↑
#¶ ↑
# File lib/rbt/libtool/libtool.rb, line 378 def report_how_many_la_files_were_found opne "There are a total of #{sfancy(n_la_files?.to_s)}"\ " .la files on this system." opne 'The directories '+sdir(target_directories?.join(', '))+ ' were searched.' end
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
RBT::LeanPrototype#reset
# File lib/rbt/libtool/reset.rb, line 16 def reset super() infer_the_namespace # ======================================================================= # # === @array_all_libtool_files # ======================================================================= # @array_all_libtool_files = [] clear_array_log_these_files _ = FILE_SEARCH_IN_THESE_DIRECTORIES if File.exist? _ set_search_in_these_directories(YAML.load_file(_)) else opne "No file called #{sfile(_)} exists. Thus, "\ "we can not load the dataset." end end
#¶ ↑
search_in_these_directories?¶ ↑
#¶ ↑
# File lib/rbt/libtool/libtool.rb, line 249 def search_in_these_directories? @search_in_these_directories end
#¶ ↑
set_search_in_these_directories
¶ ↑
Note that the variable that is set here, called @search_in_these_directories, will keep track of the directories that we will search for, by default.
A directory must end with a trailing ‘/’ character, which is ensured here by this method too, if an Array is used as input.
On my home system, the .yml file that is searched is at:
bl $RSRC/libtool/lib/libtool/yaml/search_in_these_directories/search_in_these_directories.yml
#¶ ↑
# File lib/rbt/libtool/search_in_these_directories.rb, line 23 def set_search_in_these_directories( i = FILE_SEARCH_IN_THESE_DIRECTORIES ) if i.end_with?('.yml') i = YAML.load_file(i) end if i.is_a? String # ======================================================================= # # Modify the Array by ensuring a trailing '/' is used. # ======================================================================= # if i.is_a? Array i.map! {|line| # =================================================================== # # Check for ALL_CAPS constants next - these will be handled as # shortcut for ENV[]. # =================================================================== # if (line == line.upcase) and ENV.has_key?(line.upcase) line = ENV[line.upcase].dup end line << '/' unless line.end_with? '/' line } end @search_in_these_directories = i end
#¶ ↑
show_every_la_file
¶ ↑
Invocation example:
roebelibtool --show-every-la-file
#¶ ↑
# File lib/rbt/libtool/libtool.rb, line 398 def show_every_la_file ensure_that_we_have_found_la_files opne 'Every .la file on this computer will be shown next' e @array_all_libtool_files.each_with_index {|this_libtool_file, index| index += 1 index = (index.to_s+')').ljust(6) e " #{sfancy(index)}#{sfile(this_libtool_file)}" }; e end
#¶ ↑
show_help
(help tag)¶ ↑
Give some information to the user how RBT::Libtool
can be used.
Invoke this like so:
roebelibtool --help
#¶ ↑
# File lib/rbt/libtool/help.rb, line 21 def show_help e opnn; ecomment ' --remove-this-entry=/usr/lib/libpng16.la # remove this entry from all .la files' opnn; ecomment ' --stats # show some statistics from your system' opnn; ecomment ' --show-every-la-file # show every .la file on your system' opnn; ecomment ' --all # an alias to the above ^^^' opnn; ecomment ' --search-in-which-directories? # report in which '\ 'directories we will look for .la files' opnn; ecomment ' --stats # show some statistics about your .la files' opnn; ecomment ' --report # report how many .la files we have found' opnn; ecomment ' --autofix # autofix every faulty .la file' opnn; ecomment ' --purge # purge a specific entry from a '\ '.la file; also note that we will log this action' opnn; ecomment ' --remove-this-entry # Remove a specific entry '\ 'from all .la files' opnn; ecomment ' --from-this-directory= # use '\ 'another directory to search in' opnn; ecomment ' --remove-from-stored-file # remove '\ 'the .la file last registered' ecomment ' '\ '# as faulty, from a local file' e opnn; ecomment ' rubylibtool --remove-this-entry=/usr/lib/libpng16.la # Remove this entry.' e e opne 'Note that you can also add new entries to the '\ 'array of files that' opne 'will be searched from the commandline, by doing this:' e opnn; ecomment ' --search-in-this-directory= # add this directory to '\ 'the list of directories that will be searched' opnn; ecomment ' --add= # ^^^ same as above, but shorter' e end