module RBT::Action::SoftwareManager::Deprecated
Public Instance Methods
#¶ ↑
an_error_has_occurred
¶ ↑
This is a setter-method.
#¶ ↑
# File lib/rbt/actions/individual_actions/software_manager/deprecated.rb, line 720 def an_error_has_occurred we_can_not_continue_and_we_will_not_run_make_install @internal_hash[:an_error_has_occurred] = true the_program_has_failed_to_install end
#¶ ↑
check_for_common_errors
¶ ↑
This mehod can be used to check (and handle) errors that we have encountered.
#¶ ↑
# File lib/rbt/actions/individual_actions/software_manager/deprecated.rb, line 344 def check_for_common_errors _ = errors? if _.is_a? Array _.each {|entry| case entry # =================================================================== # # === :gir_file_could_not_be_found # =================================================================== # when :gir_file_could_not_be_found opne 'A required package could not be found, related '\ 'to .gir (gobject introspection) files.' error_is(:required_package_was_not_found) # =================================================================== # # === :required_package_was_not_found # =================================================================== # when :required_package_was_not_found error_is(:required_package_was_not_found) # =================================================================== # # === :ninja_build_encountered_an_error # =================================================================== # when :ninja_build_encountered_an_error error_is(:ninja_build_encountered_an_error) # =================================================================== # # === :configure_error # # This error occurs when configure failed for some reason. It is # a somewhat generic error and may occur, for example, when a # certain package is missing. # # Example for this: # # No package 'libmate-menu' found # # =================================================================== # when :configure_error opnerror 'Some configure-related error has occurred.' # =================================================================== # # === Python syntax error: Invalid Syntax # =================================================================== # when :python_syntax_error_invalid_syntax opnerror 'This InvalidSyntax error is often related to the different' opnerror 'syntax that python2 and python3 use.' # ================================================================= # # Consider autoswitching the python-version next: # ================================================================= # if is_on_roebe? if autoswitch_python? opne "#{rev}The configuration file "\ "#{slateblue('autoswitch_python.yml')}"\ " #{rev}has been set to true." opne "#{rev}We will consider switching python "\ "next (to #{slateblue('python')})#{rev}." result_of_enabling_python2 = enable_python2 if result_of_enabling_python2 == true clear_errors do_compile_this_program( compile_which_program? ) end else # ============================================================= # # In this case, notify the user that autoswitching could # be enabled. This clause here is entered when autoswitching # has been disabled. # ============================================================= # opne 'Do note that you could set the autoswitch-python '\ 'variable to true.' opne "This could be done by modifying the content "\ "of the file #{slateblue('autoswitch_python.yml')}." opne 'Having autoswitch-python enabled may, however had, '\ 'also lead to problems sometimes, so' opne 'make sure that you really want to enable this '\ 'functionality, prior to changing that file.' end end # =================================================================== # # === A general make-related error # =================================================================== # when :make_encountered_some_error # ================================================================= # # This error type is too generic for now - but perhaps in the # future we may also handle it somehow, or give the user # more information about it. # ================================================================= # else # ================================================================= # # For now this "debugging" part only occurs on roebe-systems. # ================================================================= # if is_on_roebe? opnn stderr "Unregistered error: #{slateblue(entry)} "\ "#{rev}(class: #{lightblue(entry.class.to_s)})" end end } end end
#¶ ↑
check_for_common_problems
(problems tag, problem tag)¶ ↑
This method will check for some problems and offer ways to resolve these issues. For this to work, the particular problem at hand has to be registered in the following case/when menu.
This method is for checking problems - but for the time being (Nov 2018) we will also check for common errors within this method. This is perhaps not ideal, but simplifies the code for now. In the future this may have to be changed (or the method may have to be renamed).
#¶ ↑
# File lib/rbt/actions/individual_actions/software_manager/deprecated.rb, line 527 def check_for_common_problems _ = problems? if _ # ===================================================================== # # We will only handle registered Symbols next. # ===================================================================== # if _.is_a? Symbol case _ # case tag # =================================================================== # # === Libtool could not find the library # =================================================================== # when :libtool_could_not_find_the_library if is_on_roebe? unless @internal_hash[:invalid_libtool_archive].nil? line = @internal_hash[:invalid_libtool_archive] try_to_autocorrect_this_erroneous_libtool_entry(line) end end # =================================================================== # # === Encountered an invalid libtool archive # =================================================================== # when :encountered_an_invalid_libtool_archive if is_on_roebe? unless @internal_hash[:invalid_libtool_archive].nil? line = @internal_hash[:invalid_libtool_archive] try_to_autocorrect_this_erroneous_libtool_entry(line) end end # =================================================================== # # === Libtool can not install to another prefix # =================================================================== # when :libtool_can_not_install_to_another_prefix opne 'Libtool apparently can not install to another prefix.' opne 'The main reason for this is usually that the configure script' opne 'was run from a directory before, but with another --prefix.' opne 'Try to run "make clean" in the base directory or remove the' opne 'extracted archive, in order to try to fix this problem.' if is_on_roebe? opne tomato('Removing')+' the extracted archive next.' remove_the_extracted_archive end # =================================================================== # # === missing_header_ladspa # =================================================================== # when :missing_header_ladspa opne 'The header ladspa.h is missing. This is part of the '\ 'ladspa-sdk package.' orev 'The remote URL should be at: '+ sfancy(return_url_for(:ladspa)) e e 'This program can probably be installed via:' e e " #{sfancy('rbt ladspa')}" e # =================================================================== # # === Incomplete configure error via cmake # # This entry point is for cmake-related errors that are not further # specified - in other words, generic cmake-related errors. # =================================================================== # when :incomplete_configure_error_via_cmake do_skip_postinstall_actions opne "Something went wrong via `#{powderblue('cmake')}`." # =================================================================== # # === The totem playlist was not found # =================================================================== # when :totem_playlist_was_not_found opne 'The totem playlist was not found. You can try '\ 'to compile it:' e opne sfancy(' rbt totem-playlist') e # =================================================================== # # === Missing C .h (header) file # =================================================================== # when :missing_c_header_file opne swarn('An important C .h file is missing - the compilation '\ 'can not proceed.') # ================================================================= # # The next line was added on 22.08.2018. I wanted to make sure to # easily look at the error for programs that have failed, like # this program here. # ================================================================= # do_not_remove_extracted_archive which_h_file = sys_command_string?.select {|inner_line| inner_line.include?('fatal error:') and inner_line.include?('No such file or directory') } use_this_regex = /fatal error. (.+\.h):/ which_h_file.first =~ use_this_regex this_file = $1.to_s.dup case this_file # ================================================================= # # === xf86Resources.h # ================================================================= # when 'xf86Resources.h' opne "The file #{sfile(this_file)} belongs to the very old package" opne 'xf86-video-amd-2.7.7.7.tar.xz. This has not been updated since' opne '2008 so things will most likely no longer compile.' end # =================================================================== # # === Python import error: an undefined symbol # # Note that this is a problem, not necessarily an error. # =================================================================== # when :python_import_error_undefined_symbol opne 'A python '+swarn('ImportError')+' has happened, about '\ 'a missing/undefined Symbol.' if sys_command_string?.any? {|inner_line| inner_line.include? 'lib/gobject-introspection' } opne 'The problem appears to be somehow related to gobject-introspection.' opne 'This error may appear when different python versions or ' opne 'different library locations are used at the same time.' end # =================================================================== # # === Docbook failed to load a network entity # # This entry point is related to docbook. # =================================================================== # when :docbook_failed_to_load_a_network_entity opne "Docbook failed to load a "\ "#{steelblue('(remote) network entity')}." opne 'In theory, this could be resolved by installing the docbook' opne 'stack, but this is not necessarily trivial. Have a look at the' opne 'LFS page for now:' e result = action(:return_blfs_entry_for, 'docbook') e " #{sfancy(result)}" e # =================================================================== # # === No configure file # =================================================================== # when :no_configure_file opnn; _ = "No #{sfancy('configure')}#{rev} file was found." # =================================================================== # # === Jam is missing # =================================================================== # when :jam_is_missing do_skip_postinstall_actions notify_the_user_that_this_program_is_missing(:jam) # =================================================================== # # === Meson could not be found # =================================================================== # when :meson_could_not_be_found do_skip_postinstall_actions notify_the_user_that_this_program_is_missing(:meson) { e orange( 'Note that this will require a recent python 3.x '\ 'version on your host system.' ) e orange( 'Additionally, you may need the build tool called '\ 'ninja:' ) e e ' '+sfancy('rbt ninja') e } end elsif _.is_a? Array _ = problem? first = _.first last = _.last last = last.first if last.is_a? Array case first # case tag # =================================================================== # # === python_import_error_missing_module # =================================================================== # when :python_import_error_missing_module orev "The python module `#{sfancy(last)}#{rev}` is missing." case last # ================================================================= # # === libxml2 # ================================================================= # when /libxml2?/ orev "You may be able to resolve this problem, by "\ "#{steelblue('compiling libxml2')}#{rev}:" e orev " #{sfancy('rbt libxml2')}" e end end end end end
#¶ ↑
check_for_errors?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/software_manager/deprecated.rb, line 49 def check_for_errors? !ignore_errors? end
#¶ ↑
do_ignore_errors
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/software_manager/deprecated.rb, line 192 def do_ignore_errors @internal_hash[:ignore_errors] = true end
#¶ ↑
error_is
(error_is
tag)¶ ↑
This registered an error. An error is always a problem, but some problems allow us to continue the installation steps. An error on the other hand will end the installation procedure.
#¶ ↑
# File lib/rbt/actions/individual_actions/software_manager/deprecated.rb, line 162 def error_is( this_error = :meson_could_not_be_found ) problem_is(this_error) an_error_has_occurred # ======================================================================= # # Register the error on the main RBT namespace as well. # ======================================================================= # RBT.append_error_message( this_error ) end
#¶ ↑
error_message?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/software_manager/deprecated.rb, line 185 def error_message? RBT.error_message? end
#¶ ↑
has_a_problem_occurred?¶ ↑
Query-method over as to whether a problem has occurred or whether it has not.
#¶ ↑
# File lib/rbt/actions/individual_actions/software_manager/deprecated.rb, line 320 def has_a_problem_occurred? problem? end
#¶ ↑
ignore_errors?¶ ↑
This query-method allows the user to ignore errors.
#¶ ↑
# File lib/rbt/actions/individual_actions/software_manager/deprecated.rb, line 213 def ignore_errors? @internal_hash[:ignore_errors] end
#¶ ↑
no_error_was_encountered?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/software_manager/deprecated.rb, line 56 def no_error_was_encountered? !an_error_has_occurred? end
#¶ ↑
no_problem_has_occurred?¶ ↑
This method will return true if no problem has occurred - otherwise it will return false.
#¶ ↑
# File lib/rbt/actions/individual_actions/software_manager/deprecated.rb, line 310 def no_problem_has_occurred? !problem? end
#¶ ↑
problem_is
¶ ↑
Keep in mind that not every problem is an error. An error will indicate that copilationg will (or already has) fail(ed).
An example for an error may be :missing_headers, which indicates that some .h files may be missing (or could not be found, anyway).
An example for a problem may be some add-on failing, without this being a “critical problem” (aka an error).
This file here holds code, as part of RBT::Action::SoftwareManager
, which handles specific “problems”, in particular during GNU configure invocations, and more serious problems, also called “errors” (aka “critical problems”).
Now - what does this effectively mean?
For instance, consider that the configure script determines that you are missing some .h header file or some linking step can not be done. Then the user should be notified about this problem in a constructive, useful manner as well - or at the least be able to do so. This information should be helpful, and ideally provide suggestions as to how to resolve the issue at hand.
The GNU configure scripts are often extremely cryptic to a user, so this code here also attempts to make it easier to discover what kind of problems are giving issues. Some errors such as faulty libtool files, can sometimes be automatically corrected, to some extent (that is, remove or correct the faulty libtool file, and then continue).
For each of the “triumvirate” of compiling, that is “configure”, “make” and “make install” steps, we can set success or failure individually.
#¶ ↑
# File lib/rbt/actions/individual_actions/software_manager/deprecated.rb, line 113 def problem_is( i = nil, optional_extra_information = nil ) case i when :default, :no_problem # This is the default too. The nil value will be used in these cases. i = nil end if i.is_a? Array i = i.first # Only use the first Array entry. end if optional_extra_information @internal_hash[:problem] = [i, optional_extra_information] else # This here is the default - it is a LOT more common. @internal_hash[:problem] = i end end
#¶ ↑
registered_erroneous_libtool_entries?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/software_manager/deprecated.rb, line 455 def registered_erroneous_libtool_entries? RBT::Errors::MapLineToASpecificError.erroneous_libtool_entries? end
#¶ ↑
run_through_the_behaviour_changes
¶ ↑
We run through the module that keeps track of the behaviour changes that out to be run in class RBT::Action::SoftwareManager
.
#¶ ↑
# File lib/rbt/actions/individual_actions/software_manager/deprecated.rb, line 202 def run_through_the_behaviour_changes RBT::Errors::MapLineToASpecificError.behaviour_changes?.each {|do_this_action| self.send(do_this_action) } end
#¶ ↑
run_through_the_registered_errors
¶ ↑
Sync the errors towards class RBT::Action::SoftwareManager
next.
#¶ ↑
# File lib/rbt/actions/individual_actions/software_manager/deprecated.rb, line 498 def run_through_the_registered_errors RBT::Errors::MapLineToASpecificError.registered_errors?.each {|do_this_action| error_is do_this_action } end
#¶ ↑
run_through_the_registered_problems
¶ ↑
Sync the problems towards class RBT::Action::SoftwareManager
next.
#¶ ↑
# File lib/rbt/actions/individual_actions/software_manager/deprecated.rb, line 228 def run_through_the_registered_problems RBT::Errors::MapLineToASpecificError.registered_problems?.each {|do_this_action| problem_is do_this_action } end
#¶ ↑
run_through_the_registered_problems_registered_errors_and_behaviour_changes
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/software_manager/deprecated.rb, line 507 def run_through_the_registered_problems_registered_errors_and_behaviour_changes run_through_the_registered_problems run_through_the_registered_errors run_through_the_behaviour_changes run_through_the_erroneous_libtool_entries run_through_the_required_dependencies end
#¶ ↑
run_through_the_required_dependencies
¶ ↑
We have to sync the dependencies back into class RBT::Action::SoftwareManager
.
#¶ ↑
# File lib/rbt/actions/individual_actions/software_manager/deprecated.rb, line 239 def run_through_the_required_dependencies RBT::Errors::MapLineToASpecificError.required_dependency?.each {|this_array| register_required_dependency(this_array.first, this_array.last) } end
#¶ ↑
stop_on_error
¶ ↑
Method call to stop if the user wanted to.
#¶ ↑
# File lib/rbt/actions/individual_actions/software_manager/deprecated.rb, line 481 def stop_on_error( be_verbose = true ) if be_verbose stderr return_opnn, :use_print stderr 'We will exit now because this behaviour is enabled' stderr return_opnn, :use_print stderr "#{rev}in the configuration file (the entry: #{teal('stop_on_error')})#{rev}." end exit_program if stop_on_error? end
#¶ ↑
try_to_give_additional_information_to_the_user_if_the_missing_header_is_registered
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/software_manager/deprecated.rb, line 248 def try_to_give_additional_information_to_the_user_if_the_missing_header_is_registered # ======================================================================= # # First obtain all errors next: # ======================================================================= # _ = RBT::Errors::MapLineToASpecificError.all_programs_and_errors?.flatten unless _.empty? # ===================================================================== # # We must scan for errors such as: # # ../deps/uvwasi/src/fd_table.c:9:10: fatal error: uv.h: No such file or directory # # ===================================================================== # selection = _.select {|line| line.is_a?(String) and line.include?('fatal error: ') and line.include?('No such file or directory') }.uniq regex_to_use = / ([A-Za-z]+\.h): / scanned = selection.first this_header_file_is_missing = nil if scanned scanned = scanned.scan(regex_to_use) this_header_file_is_missing = scanned.flatten.first end if this_header_file_is_missing this_header_file_is_missing.strip! # =================================================================== # # Now that we have the header file, we will check whether this # .h is registered in the RBT "database". # =================================================================== # if RBT.is_this_partial_header_included?(this_header_file_is_missing) match = RBT::Cookbooks.all_headers?.select {|key, value| # =============================================================== # # Next, we must include the leading / to distinguish between # "libuv.yml: - uv.h" and "freerdp.yml: - freerdp2/freerdp/codec/yuv.h" # Without the '/' the latter would also be included as a potential # match. # =============================================================== # key.include?(this_header_file_is_missing) and !(key =~ /\/[A-Za-z]+#{this_header_file_is_missing}$/) } if match and !match.empty? orev "The .h header file #{steelblue(this_header_file_is_missing)} "\ "is currently not installed" orev "on this system, but it is available as part of the" orev "project #{lightblue(match.values.first)}#{rev}." orev "#{tomato('You could consider compiling it via:')}" e e ' '+lightgreen("rbt #{match.values.first}") e end end end end end