class RBT::CompileBase

Public Class Methods

new( run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/compile_base/compile_base.rb, line 58
def initialize(
    run_already = true
  )
  reset
  run if run_already
end

Public Instance Methods

appdir_prefix?( use_this_as_prefix = prefix?.to_s, use_this_as_cookbook_dataset = cookbook_dataset? )
Alias for: uses_appdir_prefix?
check_whether_we_will_install_only_programs_from_the_bin_subdirectory() click to toggle source
#

check_whether_we_will_install_only_programs_from_the_bin_subdirectory

#
# File lib/rbt/compile_base/compile_base.rb, line 347
def check_whether_we_will_install_only_programs_from_the_bin_subdirectory
  if install_only_binaries?
    opne 'We will only retain the '+sdir('bin/')+' subdirectory.'
    delete_these_directories = Dir[return_proper_prefix?.to_s+'*'].select {|entry|
      File.directory? entry
    }
    delete_these_directories.reject! {|entry| entry.end_with? 'bin' }
    unless delete_these_directories.empty?
      opne 'We will now delete several directories that we did find.'
      remove(delete_these_directories)
    end
  end
end
cleanup_system_tag_directory() click to toggle source
#

cleanup_system_tag_directory

#
# File lib/rbt/compile_base/compile_base.rb, line 388
def cleanup_system_tag_directory
  # ======================================================================= #
  # Be quiet - and only report when a stray symlink is removed.
  # ======================================================================= #
  RBT::CleanupSystemTags.new { :be_quiet }
end
consider_removing_libtool_la_files() click to toggle source
#

consider_removing_libtool_la_files

To test this, try:

ry apr ntrad
#
# File lib/rbt/compile_base/compile_base.rb, line 247
def consider_removing_libtool_la_files
  # ======================================================================= #
  # Must check for two conditions:
  #
  #   (a) the user specifically wants to delete libtool files, due
  #       to setting a configuration value
  #   (b) the program at hand uses an appdir-like prefix
  #
  # ======================================================================= #
  if delete_libtool_files?
    require 'rbt/libtool/remove_libtool_files/remove_libtool_files.rb'
    prefix_to_the_libtool_files = rds("#{prefix?.to_s}/lib/")
    RBT::Libtool::RemoveLibtoolFiles.new(
      prefix_to_the_libtool_files
    )
  end
end
consider_symlinking_cmake_modules() click to toggle source
#

consider_symlinking_cmake_modules

Prior to entering this method, there is already a check whether we are using an AppDir-like prefix. Only if this is the case, will this method here be entered at all.

This method will normally be called from the method consider_performing_postinstall_actions().

#
# File lib/rbt/compile_base/compile_base.rb, line 412
def consider_symlinking_cmake_modules
  # ======================================================================= #
  # We must first check whether there are any cmake modules in the
  # first place.
  # ======================================================================= #
  target_cmake_dir = "#{prefix?}lib64/cmake/"
  if File.directory? target_cmake_dir
    # ===================================================================== #
    # But we must also check whether a cmake directory exists at a
    # /usr hierarchy.
    # ===================================================================== #
    if File.directory? '/usr/lib/cmake/'
      opne "Symlinking from #{sdir(target_cmake_dir)} into "\
           "#{sdir('/usr/lib/cmake/')}"
      # =================================================================== #
      # Symlink only directories.
      # =================================================================== #
      all_dirs = Dir["#{target_cmake_dir}*"].select {|entry| File.directory? entry }
      all_dirs.each {|this_directory|
        basename = File.basename(this_directory)
        target_in_usr_lib_cmake = "/usr/lib/cmake/#{basename}"
        # ================================================================= #
        # Only on roebe-like systems will we also remove the target
        # directory.
        # ================================================================= #
        if is_on_roebe?
          if File.exist?(target_in_usr_lib_cmake) and
             File.directory?(target_in_usr_lib_cmake) and
            !File.symlink?(target_in_usr_lib_cmake)
            remove_directory(target_in_usr_lib_cmake)
          end
        end
        symlink(this_directory, target_in_usr_lib_cmake)
      }
    end
  end
end
consider_symlinking_header_files_into_the_usr_include_hierarchy( i = compile_which_program?, shall_we_symlink_the_header_files_into_the_usr_include_hierarchy = shall_we_symlink_the_header_files_into_the_usr_include_hierarchy? ) click to toggle source
#

consider_symlinking_header_files_into_the_usr_include_hierarchy

This method can be called if you wish to symlink any .h files or directories within the AppDir at hand, into the /usr/include/ hierarchy.

#
# File lib/rbt/compile_base/compile_base.rb, line 368
def consider_symlinking_header_files_into_the_usr_include_hierarchy(
    i                                                                = compile_which_program?,
    shall_we_symlink_the_header_files_into_the_usr_include_hierarchy =
      shall_we_symlink_the_header_files_into_the_usr_include_hierarchy?
  )
  if shall_we_symlink_the_header_files_into_the_usr_include_hierarchy
    # ===================================================================== #
    # Delegate into class RBT::SymlinkHeaders next.
    # ===================================================================== #
    opne "Next attempting to symlink all #{royalblue('.h')} files into "\
         "the #{sdir('/usr/include/')} hierarchy."
    opne "In order for this to work, #{royalblue('.h ')}"\
         " files have to exist in the AppDir directory."
    RBT::SymlinkHeaders.new(i) { :do_not_notify_if_there_were_no_header_files }
  end
end
consider_symlinking_lib64_into_lib( shall_we_symlink = cookbook_dataset_autosymlink_lib64? ) click to toggle source
#

consider_symlinking_lib64_into_lib

This method will symlink lib64/ into lib/. Only invoke this method if you have an AppDir versioned directory though.

#
# File lib/rbt/compile_base/compile_base.rb, line 271
def consider_symlinking_lib64_into_lib(
    shall_we_symlink = cookbook_dataset_autosymlink_lib64?
  )
  if shall_we_symlink
    old_dir = Dir.pwd # Keep a reference to the old directory.
    cd prefix?.to_s # cd into the AppDir prefix.
    opne 'Next trying to symlink '+sdir('lib64/')+' into '+
         sdir('lib/')+' from the directory '+sdir(return_pwd)+':'
    symlink('lib64','lib')
    # ===================================================================== #
    # Next check whether the operation was a success, so that we can
    # inform the user about this.
    # ===================================================================== #
    if File.symlink?('lib') and
       File.directory?('lib')
      opne 'Success!'
    else
      opne swarn('Failed to symlink `')+sdir('lib64/')+
           swarn('` towards `')+sdir('lib/')+swarn('`.')
    end
    cd old_dir # And go back again.
  end
end
cookbook_dataset_program_version?() click to toggle source
#

cookbook_dataset_program_version?

Obtain the version string of the program at hand through this method. This method is quite reliable and can ideally be used whenever we need to determine the version of a program.

#
# File lib/rbt/compile_base/compile_base.rb, line 457
def cookbook_dataset_program_version?
  if cookbook_dataset?
    return cookbook_dataset?.program_version?
  end
  nil
end
create_architecture_file( create_where = prefix?.to_s, can_we_create_the_architecture_file = is_on_gobolinux? ) click to toggle source
#

create_architecture_file

This method here will create a file called “Architecture”.

The first argument, ‘create_where`, should be the AppDir path to the program in question, such as /Programs/Htop/Current.

#
# File lib/rbt/compile_base/compile_base.rb, line 310
def create_architecture_file(
    create_where                        = prefix?.to_s,
    can_we_create_the_architecture_file = is_on_gobolinux?
  )
  if can_we_create_the_architecture_file
    this_architecture = `uname -m`
    resources_directory = rds("#{create_where}/Resources/")
    # ===================================================================== #
    # Point to the new target that will hold the file Architecture:
    # ===================================================================== #
    file_location = rds(resources_directory+'Architecture')
    mkdir(resources_directory) unless File.directory? resources_directory
    # ===================================================================== #
    # Remove the old file it if already exists.
    # ===================================================================== #
    remove_file(file_location) if File.exist? file_location
    write_what_into(this_architecture, file_location)
  end
end
did_we_use_an_appdir_prefix?( use_this_as_prefix = prefix?.to_s, use_this_as_cookbook_dataset = cookbook_dataset? )
Alias for: uses_appdir_prefix?
do_play_song( song_location = '/home/x/songs/YoonDohyun_Dolgo.mp3', use_this_player = 'mpv' ) click to toggle source
#

play_song

Play a song when the compilation phase has finished. This can be disabled via the configuration file, in the entry called play_song. Please call CONFIG.play_song before calling this method. We will play the audio file only if it exists, otherwise we will be silent.

#
# File lib/rbt/compile_base/compile_base.rb, line 95
def do_play_song(
    song_location =
      '/home/x/songs/YoonDohyun_Dolgo.mp3',
    use_this_player = 'mpv'
  )
  _ = "#{use_this_player} #{song_location} -endpos 4"
  esystem(_) if File.exist? song_location
end
Also aliased as: play_song
has_an_error_occurred?() click to toggle source
#

has_an_error_occurred?

#
# File lib/rbt/compile_base/compile_base.rb, line 563
def has_an_error_occurred?
  RBT.has_an_error_occurred?
end
host_cpu?() click to toggle source
#

host_cpu?

#
# File lib/rbt/compile_base/compile_base.rb, line 607
def host_cpu?
  ::RBT.host_cpu?
end
install_only_binaries?() click to toggle source
#

install_only_binaries?

#
# File lib/rbt/compile_base/compile_base.rb, line 333
def install_only_binaries?
  @internal_hash[:install_only_binaries]
end
is_an_appdir_installation?( use_this_as_prefix = prefix?.to_s, use_this_as_cookbook_dataset = cookbook_dataset? )
Alias for: uses_appdir_prefix?
is_an_appdir_program?( use_this_as_prefix = prefix?.to_s, use_this_as_cookbook_dataset = cookbook_dataset? )
Alias for: uses_appdir_prefix?
is_appdir_compilation_style?( use_this_as_prefix = prefix?.to_s, use_this_as_cookbook_dataset = cookbook_dataset? )
Alias for: uses_appdir_prefix?
is_installed_in_an_appdir_like_fashion?( use_this_as_prefix = prefix?.to_s, use_this_as_cookbook_dataset = cookbook_dataset? )
Alias for: uses_appdir_prefix?
is_make_available?( path = query_path? ) click to toggle source
#

is_make_available?

This method will attempt to find out whether make is available. It will do so by checking on the available path of the host ruby.

#
# File lib/rbt/compile_base/compile_base.rb, line 582
def is_make_available?(
    path = query_path?
  )
  is_make_available = false # By default it is assumed that make is NOT available.
  if path.include? ':'
    check_these_directories = path.split(':')
    check_these_directories.each {|dir|
      if File.exist?("#{dir}/make")
        is_make_available = true # Yup, make is available.
      end
    }
  end
  return is_make_available
end
no_error_has_occurred?() click to toggle source
#

no_error_has_occurred?

#
# File lib/rbt/compile_base/compile_base.rb, line 467
def no_error_has_occurred?
  !has_an_error_occurred?
end
original_stdout()
Alias for: silent_redirection?
original_stdout?()
Alias for: silent_redirection?
play_song( song_location = '/home/x/songs/YoonDohyun_Dolgo.mp3', use_this_player = 'mpv' )
Alias for: do_play_song
query_path?() click to toggle source
#

query_path?

Query the $PATH variable, from within ENV.

#
# File lib/rbt/compile_base/compile_base.rb, line 572
def query_path?
  ENV['PATH'].dup # .dup-ing it is better in the long run.
end
register_program( this_program = compile_which_program?, can_we_register_the_program = RBT.register_program_files_into_yaml_database? ) click to toggle source
#

register_program

This method will register the program files into a yaml “database”.

The first argument to this method may be an AppDir (String) such as ‘/home/Programs/Libfontenc/1.1.5/’.

The second argument to this method can be used to determine whether we will really register the program at hand.

#
# File lib/rbt/compile_base/compile_base.rb, line 641
def register_program(
    this_program                = compile_which_program?,
    can_we_register_the_program = RBT.register_program_files_into_yaml_database?
  )
  if can_we_register_the_program
    require 'rbt/utility_scripts/register_program_files_into_yaml_database.rb'
    if this_program.include?('/')
      # In this case assume a target such as
      # "/home/Programs/Libfontenc/1.1.5/"
      appdir_prefix_of_this_program = this_program.dup
    else # else we have to determine the AppDir on our own
      appdir_prefix_of_this_program = static_appdir_prefix_of?(this_program)
    end
    # ===================================================================== #
    # Next we will delegate towards class
    # RBT::RegisterProgramFilesIntoYamlDatabase, but this can be
    # controlled via the above flag.
    # ===================================================================== #
    RBT::RegisterProgramFilesIntoYamlDatabase.new(
      appdir_prefix_of_this_program
    ) # bl RegisterProgramFilesIntoYamlDatabase
  end
end
remove_compiling_is_in_progress( this_file = 'COMPILING_IS_IN_PROGRESS.md' ) click to toggle source
#

remove_compiling_is_in_progress

We must get rid of special files. Right now only of a file called “COMPILING_IS_IN_PROGRESS” - this file will be created when we start compiling.

#
# File lib/rbt/compile_base/compile_base.rb, line 111
def remove_compiling_is_in_progress(
    this_file = 'COMPILING_IS_IN_PROGRESS.md'
  )
  remove_file(this_file) if File.exist? this_file
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::Base#reset
# File lib/rbt/compile_base/compile_base.rb, line 68
def reset
  super()
  # ======================================================================= #
  # === :silent_redirection
  #
  # The following instance-variable can be used to determine whether we
  # will silently redirect the output-stream or whether we will not.
  # ======================================================================= #
  @internal_hash[:silent_redirection] = false
end
return_chained_programs() click to toggle source
#

return_chained_programs

#
# File lib/rbt/compile_base/compile_base.rb, line 536
def return_chained_programs
  ::RBT.chained_programs?
end
return_files_from_the_profiles_directory( target_directory = DIRECTORY_RBT_PROFILES ) click to toggle source
#

return_files_from_the_profiles_directory

This method will return all .md files from the RBT profiles directory.

#
# File lib/rbt/compile_base/compile_base.rb, line 122
def return_files_from_the_profiles_directory(
    target_directory = DIRECTORY_RBT_PROFILES
  )
  Dir["#{target_directory}*.md"]
end
return_these_programs(i) click to toggle source
#

return_these_programs

This method will essentially return the information stored in the file ‘chained_programs.yml’.

#
# File lib/rbt/compile_base/compile_base.rb, line 529
def return_these_programs(i)
  return return_chained_programs[i.to_s]
end
run() click to toggle source
#

run

#
# File lib/rbt/compile_base/compile_base.rb, line 712
def run
end
silent_redirection?() click to toggle source
#

silent_redirection?

#
# File lib/rbt/compile_base/compile_base.rb, line 82
def silent_redirection?
  @internal_hash[:silent_redirection]
end
Also aliased as: original_stdout, original_stdout?
store_full_configure_command_into_resources_directory() click to toggle source
#

store_full_configure_command_into_resources_directory

We will store the full configure command into:

/Programs/Name/Version/Resources/full_configure_command
#
# File lib/rbt/compile_base/compile_base.rb, line 479
def store_full_configure_command_into_resources_directory
  what = full_configure_command?
  unless what.strip.empty?
    # ===================================================================== #
    # Designate the file into where to store this:
    # ===================================================================== #
    into = real_prefix?.to_s.dup
    into << '/Resources/full_configure_command.md'
    unless File.directory? File.dirname(into)
      mkdir(File.dirname(into))
    end
    # ===================================================================== #
    # Remove old files at that position first.
    # ===================================================================== #
    delete_file(into) if File.exist? into
    append_what_into(what, into)
  end
end
use_appdir_prefix?( use_this_as_prefix = prefix?.to_s, use_this_as_cookbook_dataset = cookbook_dataset? )
Alias for: uses_appdir_prefix?
use_gobolinux_symlinkprogram?() click to toggle source
#

use_gobolinux_symlinkprogram?

#
# File lib/rbt/compile_base/compile_base.rb, line 600
def use_gobolinux_symlinkprogram?
  @internal_hash[:use_gobolinux_symlinkprogram]
end
uses_an_appdir_prefix?( use_this_as_prefix = prefix?.to_s, use_this_as_cookbook_dataset = cookbook_dataset? )
Alias for: uses_appdir_prefix?
uses_appdir_approach?( use_this_as_prefix = prefix?.to_s, use_this_as_cookbook_dataset = cookbook_dataset? )
Alias for: uses_appdir_prefix?
uses_appdir_prefix?( use_this_as_prefix = prefix?.to_s, use_this_as_cookbook_dataset = cookbook_dataset? ) click to toggle source
#

uses_appdir_prefix?

This method will return true if the program at hand is compiled in an AppDir-like fashion (e. g. having a prefix including the String “/Programs/” directory), and false otherwise.

#
# File lib/rbt/compile_base/compile_base.rb, line 505
def uses_appdir_prefix?(
    use_this_as_prefix           = prefix?.to_s,
    use_this_as_cookbook_dataset = cookbook_dataset?
  )
  if use_this_as_cookbook_dataset.nil?
    ensure_dataset_for_this_program(compile_which_program?)
  end
  use_this_as_prefix.to_s.include? programs_dir?
end