module RBT::Errors::MapLineToASpecificError

Public Class Methods

behaviour_changes?() click to toggle source
#

RBT::Errors::MapLineToASpecificError.behaviour_changes?

#
# File lib/rbt/errors/map_line_to_a_specific_error.rb, line 81
def self.behaviour_changes?
  @behaviour_changes
end
do_not_run_ldconfig() click to toggle source
#

RBT::Errors::MapLineToASpecificError.do_not_run_ldconfig

#
# File lib/rbt/errors/map_line_to_a_specific_error.rb, line 150
def self.do_not_run_ldconfig
  register_this_behaviour_change __method__
end
do_not_run_make() click to toggle source
#

RBT::Errors::MapLineToASpecificError.do_not_run_make

#
# File lib/rbt/errors/map_line_to_a_specific_error.rb, line 192
def self.do_not_run_make
  register_this_behaviour_change __method__
end
do_not_run_make_install() click to toggle source
#

RBT::Errors::MapLineToASpecificError.do_not_run_make_install

#
# File lib/rbt/errors/map_line_to_a_specific_error.rb, line 185
def self.do_not_run_make_install
  register_this_behaviour_change __method__
end
do_not_run_ninja() click to toggle source
#

RBT::Errors::MapLineToASpecificError.do_not_run_ninja

#
# File lib/rbt/errors/map_line_to_a_specific_error.rb, line 164
def self.do_not_run_ninja
  register_this_behaviour_change __method__
end
do_not_strip_binaries() click to toggle source
#

RBT::Errors::MapLineToASpecificError.do_not_strip_binaries

#
# File lib/rbt/errors/map_line_to_a_specific_error.rb, line 199
def self.do_not_strip_binaries
  register_this_behaviour_change __method__
end
e(i = '') click to toggle source
#

RBT::Errors::MapLineToASpecificError.e

#
# File lib/rbt/errors/map_line_to_a_specific_error.rb, line 206
def self.e(i = '')
  puts i
end
erroneous_libtool_entry?() click to toggle source
#

RBT::Errors::MapLineToASpecificError.erroneous_libtool_entry?

#
# File lib/rbt/errors/map_line_to_a_specific_error.rb, line 95
def self.erroneous_libtool_entry?
  @erroneous_libtool_entry
end
missing_package?() click to toggle source
#

RBT::Errors::MapLineToASpecificError.missing_package?

#
# File lib/rbt/errors/map_line_to_a_specific_error.rb, line 59
def self.missing_package?
  @missing_package
end
no_postinstall_step() click to toggle source
#

RBT::Errors::MapLineToASpecificError.no_postinstall_step

#
# File lib/rbt/errors/map_line_to_a_specific_error.rb, line 157
def self.no_postinstall_step
  register_this_behaviour_change __method__
end
parse_this_line(i) click to toggle source
#

RBT::Errors::MapLineToASpecificError.parse_this_line

#
# File lib/rbt/errors/map_line_to_a_specific_error.rb, line 213
def self.parse_this_line(i)
  # ======================================================================= #
  # === General error handling
  #
  # Here, we should also gather general errors. These will be colourized,
  # and can also optional include an error_is or problem_is line, to be
  # more specific and indicative of an error.
  # ======================================================================= #
  if i.start_with?("Couldn't find include") or
     # ==================================================================== #
     # === Some configure error
     # ==================================================================== #
     i.start_with?('configure: error:') or
     i.include?('ld: warning:')
    if i.include? '.gir'
      error_is :gir_file_could_not_be_found
    end
    if i.start_with?('configure: error:')
      error_is :configure_error
      if i.include?('headers not found') and i.include?('required')
        error_is :configure_error_could_not_find_certain_headers
      end
    end
    do_not_run_make
    do_not_run_make_install
    do_not_strip_binaries
    no_postinstall_step
    do_not_run_ldconfig
  # ======================================================================= #
  # === Cmake warning that a required package was not found
  # ======================================================================= #
  elsif i.include?('A required package was not found')
    error_is :required_package_was_not_found
  # ======================================================================= #
  # === /System/Index/bin/ld: error: cannot find -lxml2
  # ======================================================================= #
  elsif i.include? 'ld: error: cannot find -l'
    error_is :ld_could_not_find_a_library
    we_can_not_continue_and_we_will_not_run_make_install
  # ======================================================================= #
  # === --   No package 'gwenhywfar' found
  # ======================================================================= #
  elsif i.include?('No package') and i.include?(' found')
    # ===================================================================== #
    # In this case we must register which package was not found.
    # ===================================================================== #
    register_this_missing_package(i)
  # ======================================================================= #
  # === collect2: error: ld returned 1 exit status
  # ======================================================================= #
  elsif i.include?('collect2: error: ld returned 1 exit status')
    error_is :collect2_and_ld_returned_an_error
  # ======================================================================= #
  # === ninja: build stopped: subcommand failed
  # ======================================================================= #
  elsif i.include?('ninja: build stopped: subcommand failed')
    error_is :ninja_build_encountered_an_error
  # ======================================================================= #
  # === Must specify at least one directory name.
  #
  # This error happens mostly when meson could not use a proper directory.
  # ======================================================================= #
  elsif i.include?('Must specify at least one directory name.')
    error_is :unable_to_find_a_proper_build_directory
    do_not_run_ninja
  # ======================================================================= #
  # === CMake Error: we could not find the file CMakeLists.txt
  # ======================================================================= #
  elsif i.include?('CMake Error: The source directory') and
        i.include?('does not appear to contain CMakeLists.txt.')
    error_is :cmake_could_not_find_a_cmakelists_txt_file
  # ======================================================================= #
  # === CMake Error at CMakeLists.txt
  # ======================================================================= #
  elsif i.include?('CMake Error at CMakeLists.txt:') and
        i.include?('find_package')
    error_is :cmake_error_we_could_not_find_a_package
  # ======================================================================= #
  # === cc1: some warnings being treated as errors
  # ======================================================================= #
  elsif i.include?('cc1: some warnings being treated as errors')
    error_is :cc1_treats_some_warnings_as_errors
  end
  # ======================================================================= #
  # === General make-related errors
  # ======================================================================= #
  if i.include?("make: *** No rule to make target 'install'.  Stop.") or
     i.include?('error adding symbols') or
    (i.include?('make: ***') and i.include?(' Error 2')) or
    (i.include?('make: ***') and i.include?(' Stop.'))
    # ===================================================================== #
    # When we notice that "make install" can not possibly work, then
    # there is no need to run ldconfig - so we will disable that.
    # ===================================================================== #
    do_not_run_ldconfig
    if i.include?('error adding symbols')
      register_error :error_adding_symbols
    elsif (i.include?('make: ***') and i.include?(' Error 2')) or
          (i.include?('make: ***') and i.include?(' Stop.'))
      error_is :make_encountered_some_error
      do_not_run_make_install
    end
  end
  # ======================================================================= #
  # === Failed to find required LADSPA header ladspa.h
  #
  # Missing a specific header file, ladspa
  # ======================================================================= #
  if i.include? 'Failed to find required LADSPA header ladspa.h'
    problem_is :missing_header_ladspa
    we_can_not_continue_and_we_will_not_run_make_install
  # ======================================================================= #
  # === Some C .h file is missing
  # ======================================================================= #
  elsif i.include?('.h: No such file or directory')
    if i.include?('.c:')
      problem_is :missing_c_header_file
      we_can_not_continue_and_we_will_not_run_make_install
    # ===================================================================== #
    # === /usr/include/json-c/json.h:31:10: fatal error: json_object_iterator.h: No such file or directory
    # ===================================================================== #
    elsif i.include?(' fatal error: ')
      problem_is :missing_c_header_file
      we_can_not_continue_and_we_will_not_run_make_install
    end
  # ======================================================================= #
  # === Meson-related errors
  # ======================================================================= #
  elsif i.include?("Command 'meson' not found") or
        i.include?('sh: meson: command not found')
    error_is :meson_could_not_be_found
  # ======================================================================= #
  # === Meson had some Unicode-related error
  # ======================================================================= #
  elsif i.include? 'UnicodeEncodeError: '
    error_is :meson_encountered_a_unicode_encode_error
    we_can_not_continue_and_we_will_not_run_make_install
  # ======================================================================= #
  # === More Meson-related errors
  # ======================================================================= #
  elsif i.include? 'meson.' and i.include? 'ERROR: '
    # ===================================================================== #
    # Detect the specific error at hand next:
    # ===================================================================== #
    error_is :meson_encountered_an_error
    if i.include? 'Invalid version of dependency, need'
      error_is :meson_discovered_an_invalid_version_of_a_dependency
      # =================================================================== #
      # See: http://rubular.com/r/ADXLYIvc6f
      # =================================================================== #
      regex_to_use = /Invalid version of dependency, need '(.+)' \['\S+(.+)'\]/
      i =~ regex_to_use
      # =================================================================== #
      # We register this as an invalid dependency next:
      # =================================================================== #
      register_required_dependency($1.to_s.dup, $2.to_s.dup)
    end
  # ======================================================================= #
  # === configure: error: totem playlist parsing library not found or too old
  #
  # This error may occur when the user does not have the totem-playlist
  # installed.
  # ======================================================================= #
  elsif i.include? 'configure: error: totem playlist parsing library not found or too old'
    problem_is :totem_playlist_was_not_found
    we_can_not_continue_and_we_will_not_run_make_install
  # ======================================================================= #
  # === Error adding symbols (collect2: error: ld returned 1 exit status)
  # ======================================================================= #
  elsif i.include? 'error adding symbols: bad value'
    error_is :bad_value_for_symbols
  # ======================================================================= #
  # === Handle Python invalid syntax situation
  #
  # This entry point specifically exists to handle python2-grammer
  # related errors - in particular a SyntaxError. When such an error
  # is encountered, compilation/installation is likely to fail, if
  # it depends on python for being compiled/installed.
  # ======================================================================= #
  elsif i.include? 'SyntaxError: invalid syntax'
    error_is :python_syntax_error_invalid_syntax
  # ======================================================================= #
  # === Handle Python import-errors
  # ======================================================================= #
  elsif i.include? 'ImportError: '
    # ===================================================================== #
    # For example:
    #   ImportError: ./.libs/_giscanner.so: undefined symbol: PyString_AsString
    # ===================================================================== #
    if i.include? '.so: undefined symbol'
      problem_is :python_import_error_undefined_symbol
      we_can_not_continue
    # ===================================================================== #
    # === Handle missing python-modules next
    #
    # An example would be:
    #   ImportError: No module named libxml2
    # ===================================================================== #
    elsif i.include? 'ImportError: No module named'
      this_module_is_missing =
        i.scan(/ImportError: No module named (.+)/).flatten
      problem_is :python_import_error_missing_module, this_module_is_missing
      we_can_not_continue
    end
  # ======================================================================= #
  # === I/O error : Attempt to load network entity
  # ======================================================================= #
  elsif i.include? 'I/O error : Attempt to load network entity '
    problem_is :docbook_failed_to_load_a_network_entity
    we_can_not_continue_and_we_will_not_run_make_install
  # ======================================================================= #
  # === Jam is missing
  # ======================================================================= #
  elsif i.include? 'configure: error: Jam is missing!'
    problem_is :jam_is_missing
    we_can_not_continue_and_we_will_not_run_make_install
  # ======================================================================= #
  # === libtool error: cannot install to a directory
  # ======================================================================= #
  elsif i.include?('libtool:   error: error: cannot install') and
        i.include?('to a directory not ending in')
    problem_is :libtool_can_not_install_to_another_prefix
    we_can_not_continue_and_we_will_not_run_make_install
  # ======================================================================= #
  # === Encountered an invalid libtool archive
  #
  # An example for such an invalid line would be:
  #   /usr/bin/sed: can't read /usr/lib/libfontconfig.la: No such file or directory
  # ======================================================================= #
  elsif ( (i.include?('libtool: ')) and (i.include?('error: ')) ) or
        (i.include?('.la: No such file or directory'))
    # ===================================================================== #
    # Next we will catch all libtool-related errors.
    # ===================================================================== #
    # ===================================================================== #
    # === .la: No such file or directory
    #
    # For example, for:
    #   /usr/bin/sed: can't read /usr/lib/libfontconfig.la: No such file or directory
    # ===================================================================== #
    if i.include?('.la: No such file or directory')
      error_is :libtool_could_not_find_an_existing_la_file
      do_not_run_make_install
      # =================================================================== #
      # We will also extract the faulty libtool file next:
      # =================================================================== #
      use_this_regex = /: (.+\.la): No such file or directory/
      if (i =~ use_this_regex)
        i = $1.to_s.dup
      end
    # ===================================================================== #
    # === is not a valid libtool archive
    #
    # A typical error for this if-clause may be:
    #   libtool:   error: '/usr/lib/libfontconfig.la' is not a valid libtool archive
    # ===================================================================== #
    elsif i.include?('is not a valid libtool archive')
      problem_is :encountered_an_invalid_libtool_archive
      do_not_run_make_install
      if (i =~ /error: '(.+\.la)' is not a valid libtool archive/)
        i = $1.to_s.dup
      end
    # ===================================================================== #
    # === cannot find the library
    #
    # Specifically the error may be like so:
    #   libtool:   error: cannot find the library '/Programs/Pango/1.42.3/lib/libpango-1.0.la' or unhandled argument '/Programs/Pango/1.42.3/lib/libpango-1.0.la'
    # ===================================================================== #
    elsif i.include?('cannot find the library')
      use_this_regex =
        /libtool:\s*error: cannot find the library '(\S+)' or unhandled/ # See: http://rubular.com/r/NKm5erjg1A
      error_is :libtool_could_not_find_the_library
      do_not_run_make_install
      if (i =~ use_this_regex)
        i = $1.to_s.dup # <- We have to store it here, so it can be fixed automatically lateron.
      end
    end
    register_this_erroneous_libtool_entry(i)
  # ======================================================================= #
  # === Some unspecified cmake error occurred during configure
  # ======================================================================= #
  elsif i.include? '-- Configuring incomplete, errors occurred!'
    problem_is :incomplete_configure_error_via_cmake
    we_can_not_continue_and_we_will_not_run_make_install
  end
end
problem_is( i, optional_problem_is = nil ) click to toggle source
#

RBT::Errors::MapLineToASpecificError.problem_is?

#
# File lib/rbt/errors/map_line_to_a_specific_error.rb, line 112
def self.problem_is(
    i,
    optional_problem_is = nil
  )
  if optional_problem_is
    @problem_is << [i, optional_problem_is ]
  else
    @problem_is << i
  end
end
problem_is?() click to toggle source
#

RBT::Errors::MapLineToASpecificError.behaviour_changes?

#
# File lib/rbt/errors/map_line_to_a_specific_error.rb, line 67
def self.problem_is?
  @problem_is
end
register_required_dependency( name_of_the_program = nil, program_version = nil ) click to toggle source
#

RBT::Errors::MapLineToASpecificError.register_required_dependency

#
# File lib/rbt/errors/map_line_to_a_specific_error.rb, line 42
def self.register_required_dependency(
    name_of_the_program = nil,
    program_version     = nil
  )
  @required_dependency << [name_of_the_program, program_version]
end
register_this_behaviour_change(i) click to toggle source
#

RBT::Errors::MapLineToASpecificError.register_this_behaviour_change

This method can be used to register which “behaviour changes” are possible.

#
# File lib/rbt/errors/map_line_to_a_specific_error.rb, line 129
def self.register_this_behaviour_change(i)
  @behaviour_changes << i
end
register_this_erroneous_libtool_entry(i) click to toggle source
#

RBT::Errors::MapLineToASpecificError.register_this_erroneous_libtool_entry

#
# File lib/rbt/errors/map_line_to_a_specific_error.rb, line 74
def self.register_this_erroneous_libtool_entry(i)
  @erroneous_libtool_entry << i
end
register_this_error(i) click to toggle source
#

RBT::Errors::MapLineToASpecificError.register_this_error

Use this method to register any error.

#
# File lib/rbt/errors/map_line_to_a_specific_error.rb, line 104
def self.register_this_error(i)
  @registered_errors << i
end
register_this_missing_package(i) click to toggle source
#

RBT::Errors::MapLineToASpecificError.register_this_missing_package

We will register missing packages through this method. If the input includes a String such as “No package”, then we will only capture the name of the package itself.

#
# File lib/rbt/errors/map_line_to_a_specific_error.rb, line 140
def self.register_this_missing_package(i)
  if i.include? "  No package '"
    i = i.scan(/ No package '(.+)' found/).flatten.first
  end
  @missing_package << i
end
registered_errors?() click to toggle source
#

RBT::Errors::MapLineToASpecificError.registered_errors?

#
# File lib/rbt/errors/map_line_to_a_specific_error.rb, line 88
def self.registered_errors?
  @registered_errors
end
required_dependency?() click to toggle source
#

RBT::Errors::MapLineToASpecificError.required_dependency?

#
# File lib/rbt/errors/map_line_to_a_specific_error.rb, line 52
def self.required_dependency?
  @required_dependency
end
reset() click to toggle source
#

RBT::Errors::MapLineToASpecificError.reset (reset tag)

#
# File lib/rbt/errors/map_line_to_a_specific_error.rb, line 25
def self.reset
  @registered_errors       = []
  @behaviour_changes       = []
  @problem_is              = []
  @erroneous_libtool_entry = []
  @required_dependency     = []
  @missing_package         = [] # <- Store missing packages here.
end
we_can_not_continue() click to toggle source
#

RBT::Errors::MapLineToASpecificError.we_can_not_continue

#
# File lib/rbt/errors/map_line_to_a_specific_error.rb, line 178
def  self.we_can_not_continue
  register_this_behaviour_change __method__
end
we_can_not_continue_and_we_will_not_run_make_install() click to toggle source
#

RBT::Errors::MapLineToASpecificError.we_can_not_continue_and_we_will_not_run_make_install

#
# File lib/rbt/errors/map_line_to_a_specific_error.rb, line 171
def  self.we_can_not_continue_and_we_will_not_run_make_install
  register_this_behaviour_change __method__
end