class Easycompile::Base

Constants

THIS_FILE
#

THIS_FILE

This constant refers to the main .rb file for class Easycompile::Base, that is the file that contains most of the ruby code for the Base class.

#

Public Class Methods

new( commandline_arguments = ARGV, run_already = true ) click to toggle source
#

initialize

#
# File lib/easycompile/base/initialize.rb, line 14
def initialize(
    commandline_arguments = ARGV,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  case run_already
  # ======================================================================= #
  # === :dont_run_yet
  # ======================================================================= #
  when :dont_run_yet,
       :do_not_run_yet
    run_already = false
  end
  run if run_already
end
version?() click to toggle source
#

Easycompile::Base.version?

#
# File lib/easycompile/base/misc.rb, line 137
def self.version?
  Easycompile.version?
end

Public Instance Methods

_(i)
Alias for: esystem
add(i)
Alias for: add_this_archive
add_these_files(i)
Alias for: add_this_archive
add_this_archive(i) click to toggle source
#

add_this_archive (add tag)

#
# File lib/easycompile/base/misc.rb, line 584
def add_this_archive(i)
  if i
    @compile_these_programs << i
    @compile_these_programs.flatten!
    @compile_these_programs.compact!
  end
end
add_to_commandline_arguments(i)
Alias for: add_this_archive
are_we_on_gobolinux?() click to toggle source
#

are_we_on_gobolinux?

#
# File lib/easycompile/base/misc.rb, line 289
def are_we_on_gobolinux?
  ENV['IS_ON_GOBOLINUX'].to_s == '1'
end
attempt_to_find_a_valid_file(i) click to toggle source
#

attempt_to_find_a_valid_file

This method will attempt to sanitize incomplete entries such as “nettle-2.7” towards “nettle-2.7.tar.xz”.

When we pass something such as “htop.yml” and this file does not exist in the current directory, then we will attempt to find it in another directory.

#
# File lib/easycompile/base/misc.rb, line 475
def attempt_to_find_a_valid_file(i)
  if i.is_a? Array
    i.map! {|entry|
      unless File.exist? entry
        entry = File.basename(entry)
        if entry.include?('.yml') or entry.end_with?('.')
          entry = INDIVIDUAL_COOKBOOKS+entry
          yaml_dataset = get_dataset_from(entry)
          entry = yaml_dataset['program_path']
          set_program_version(yaml_dataset['program_version'])
        else
          # Then we try a glob.
          _ = Dir["#{entry}*"]
          entry = _.first unless _.empty?
        end
      end
      entry
    }
  end
  return i
end
base_dir?() click to toggle source
#

base_dir`

#
# File lib/easycompile/base/misc.rb, line 454
def base_dir?
  @base_dir
end
can_not_continue() click to toggle source
#

can_not_continue

Set @continue_past_configure_stage to false, so tha we won't continue.

#
# File lib/easycompile/base/misc.rb, line 321
def can_not_continue
  @continue_past_configure_stage = false
end
cd(i)
Alias for: change_directory
change_directory(i) click to toggle source
#

change_directory (cd tag)

Use this method when changing directories.

#
# File lib/easycompile/base/change_directory.rb, line 16
def change_directory(i)
  if i
    File.expand_path(i) if i.start_with? '.'
    if File.exist?(i)
      Dir.chdir(i)
    else
      show_namespace
      e "Can not change into #{sdir(i)} as it does not exist."
    end
  end
end
Also aliased as: cd
check_for_dependencies() click to toggle source
#

check_for_dependencies

#
# File lib/easycompile/base/misc.rb, line 598
def check_for_dependencies
  # ======================================================================= #
  # Next, add dependencies. To try this, do:
  #
  #   ecompile metacity.yml wdeps
  #
  # ======================================================================= #
  if @compile_with_dependencies
    dependencies = get_dataset_from(@original_input)['required_deps_on']
    dependencies.map! {|entry|
      entry = entry.dup if entry.frozen?
      entry << '.yml'
    }
    add(dependencies)
  end
end
cmake_file?() click to toggle source
#

cmake_file?

This method wille ssentially refer to “CMakeLists.txt”.

#
# File lib/easycompile/base/cmake.rb, line 16
def cmake_file?
  CMAKE_FILE
end
commandline_arguments?() click to toggle source
#

commandline_arguments?

#
# File lib/easycompile/base/commandline_arguments.rb, line 14
def commandline_arguments?
  @commandline_arguments
end
compile_as_meson_based_project() click to toggle source
#

compile_as_meson_based_project

#
# File lib/easycompile/base/meson_and_ninja.rb, line 14
def compile_as_meson_based_project
  use_this_build_directory = name_of_the_build_directory?
  esystem 'meson --prefix='+prefix?+' '+use_this_build_directory
  cd(use_this_build_directory)
  ninjait
end
compile_these_programs?() click to toggle source
#

compile_these_programs?

This method will return on which input-files we will be working on, that is our target-programs.

#
# File lib/easycompile/base/misc.rb, line 576
def compile_these_programs?
  @compile_these_programs
end
Also aliased as: files?, file?
consider_creating_a_build_directory( where = return_pwd ) click to toggle source
#

consider_creating_a_build_directory

Here we will consider whether we will create a build directory or whether we will not do so.

If such a directory already exists then we do not need to create a new directory.

#
# File lib/easycompile/base/misc.rb, line 536
def consider_creating_a_build_directory(
    where = return_pwd
  )
  if shall_we_create_a_build_directory?
    _ = name_of_build_directory?
    if File.exist? _
      show_namespace
      e "We will use the already existing build directory "\
        "called `#{sdir(_)}`."
      set_build_directory(_)
    else
      @base_dir = rds(where)
      set_this_build_dir(File.absolute_path(_))
      show_namespace
      e 'We will create a build directory next called `'+sdir(_)+'` '\
        '(Full target will be: '+@build_directory_is_stored_here+').'
      # =================================================================== #
      # Keep track of where the build directory is.
      # =================================================================== #
      mkdir @build_directory_is_stored_here # Creating the build directory finally.
    end
    # ===================================================================== #
    # Next, we will enter that BUILD directory.
    # ===================================================================== #
    cd @build_directory_is_stored_here
    show_namespace
    # ===================================================================== #
    # Notify the user that we have cd-ed already.
    # ===================================================================== #
    e 'Now entering the directory '+
       sdir(@build_directory_is_stored_here)+'.'
  end
end
consider_extracting_this_archive( this_archive, extract_to = extract_to? )
Alias for: try_to_extract
consider_purging_empty_build_directory( i = @build_directory_is_stored_here )
consider_removing_the_archive( i = @build_directory_is_stored_here ) click to toggle source
#

consider_removing_the_archive

#
# File lib/easycompile/base/misc.rb, line 707
def consider_removing_the_archive(
    i = @build_directory_is_stored_here
  )
  if remove_all_after_compile?
    if i.responds_to? :each
      i.each {|entry|
        remove_directory(entry)
      }
    else
      i = i.to_s
      if shall_we_create_a_build_directory?
        if File.exist?(i) and empty_dir?(i)
          # =============================================================== #
          # Ok, we found an empty build-directory. Since it is empty,
          # we can safely remove it.
          # =============================================================== #
          remove_directory(i)
        end
      end
    end
  end
end
consider_removing_this_archive( i = @build_directory_is_stored_here )
consider_symlinking_appdir() click to toggle source
#

consider_symlinking_appdir

Use this method to consider symlinking into the AppDir hierarchy.

We use class SymlinkProgram for this, from the RBT project. However had, when we are on GoboLinux, we will instead use the GoboLinux program called SymlinkProgram.

#
# File lib/easycompile/base/misc.rb, line 398
def consider_symlinking_appdir
  _ = rds(prefix?+'/')
  opn :namespace => NAMESPACE
  e 'Next attempting to symlink at '+sdir(_)
  if are_we_on_gobolinux?
    cmd = 'SymlinkProgram '+_
    esystem cmd
  else
    begin
      require 'rbt/requires/require_symlink_this_program.rb'
    rescue LoadError; end
    if Object.const_defined?('RBT') and
       RBT.const_defined?(SymlinkFromToCurrent)
      RBT::SymlinkFromToCurrent.new(_)
    end
  end 
end
continue_after_extracting?() click to toggle source
#

continue_after_extracting?

#
# File lib/easycompile/base/misc.rb, line 328
def continue_after_extracting?
  @continue_after_extracting
end
continue_past_configure_stage?() click to toggle source
#

continue_past_configure_stage?

#
# File lib/easycompile/base/misc.rb, line 275
def continue_past_configure_stage?
  @continue_past_configure_stage
end
copy_setup_rb() click to toggle source
#

copy_setup_rb

#
# File lib/easycompile/base/misc.rb, line 106
def copy_setup_rb
  FileUtils.cp(LOCATION_OF_SETUP_RB, return_pwd)
end
cparser_is_available?() click to toggle source
#

cparser_is_available?

Determine whether we can use the ColourizeParser from the RBT project.

#
# File lib/easycompile/base/esystem.rb, line 34
def cparser_is_available?
  Object.const_defined?(:RBT) and
  RBT.const_defined?(:ColourizeParser)
end
determine_which_programs_to_compile() click to toggle source
#

determine_which_programs_to_compile

#
# File lib/easycompile/base/misc.rb, line 933
def determine_which_programs_to_compile
  if @commandline_arguments.empty?
    # ===================================================================== #
    # If we did not input anything then use all archives from the
    # current working directory.
    # ===================================================================== #
    _ = Dir['*'].select {|entry| is_an_archive?(entry) }
  else
    if @commandline_arguments.any? {|entry| entry.end_with? '.yml' }
      # =================================================================== #
      # Handle .yml files here.
      # =================================================================== #
      @commandline_arguments = replace_all_yaml_files(@commandline_arguments)
    end
    _ = @commandline_arguments.select {|entry| File.exist?(entry) }
  end
  set_compile_these_programs(_)
end
do_compile_with_dependencies() click to toggle source
#

do_compile_with_dependencies

#
# File lib/easycompile/base/misc.rb, line 335
def do_compile_with_dependencies
  opn_namespace; e 'We will compile the dependencies first.'
  @compile_with_dependencies = true
end
do_make_use_of_a_build_directory() click to toggle source
#

do_make_use_of_a_build_directory

#
# File lib/easycompile/base/misc.rb, line 282
def do_make_use_of_a_build_directory
  @shall_we_create_a_build_directory = true
end
do_not_compile() click to toggle source
#

do_not_compile

#
# File lib/easycompile/base/misc.rb, line 375
def do_not_compile
  show_namespace; e 'We will not compile after extracting the source archive.'
  do_not_continue
end
do_not_continue() click to toggle source
#

do_not_continue

This method does not output anything to the user, on purpose.

#
# File lib/easycompile/base/misc.rb, line 368
def do_not_continue
  @continue_after_extracting = false
end
do_not_create_a_build_directory() click to toggle source
#

do_not_create_a_build_directory

Use this method if you do not wish to create a build directory.

#
# File lib/easycompile/base/misc.rb, line 160
def do_not_create_a_build_directory
  @shall_we_create_a_build_directory = false
end
do_remove_all_after_compile() click to toggle source
#

do_remove_all_after_compile

#
# File lib/easycompile/base/remove.rb, line 65
def do_remove_all_after_compile
  opn_namespace; e 'We will remove all after compile.'
  @remove_all_after_compile = true
end
does_a_meson_build_file_exist?() click to toggle source
#

does_a_meson_build_file_exist?

#
# File lib/easycompile/base/meson_and_ninja.rb, line 24
def does_a_meson_build_file_exist?
  File.exist?(MESON_BUILD_FILE)
end
e_colourize(i) click to toggle source
#

e_colourize

#
# File lib/easycompile/base/colours.rb, line 69
def e_colourize(i)
  if use_colours?
    e sfancy(i)
  else
    e i
  end
end
ecomment(i) click to toggle source
#

ecomment

#
# File lib/easycompile/base/colours.rb, line 80
def ecomment(i)
  if use_colours?
    ::Colours.ecomment(i)
  else
    i
  end
end
empty_dir?(i) click to toggle source
#

empty_dir?

#
# File lib/easycompile/base/misc.rb, line 189
def empty_dir?(i)
  Dir["#{i}/*"].empty?
end
enable_skip_make_install() click to toggle source
#

enable_skip_make_install

#
# File lib/easycompile/base/misc.rb, line 343
def enable_skip_make_install
  show_namespace; e 'We will skip running the "make install" step.'
  @skip_make_install = true
end
enter_extracted_directory(i = @original_input) click to toggle source
#

enter_extracted_directory

We use this method to enter the extracted directory.

#
# File lib/easycompile/base/misc.rb, line 421
def enter_extracted_directory(i = @original_input)
  i = remove_extension_from(i)
  if File.directory? i
    _ = i
  else
    _ = "#{@temp_directory}#{get_program_name(i)}"
  end
  i = i.dup
  _ << '/' unless _.end_with? '/'
  if Dir.exist? _ # Only inform the user that we cd if that directory exists.
    show_namespace; e "Now entering the directory `#{sdir(_)}`."
    cd _
  end
end
esystem(i) click to toggle source
#

esystem

Run a colourized system() command here.

This can either be through oldschool system(), or as of August 2017, preferentially via IO.popen().

#
# File lib/easycompile/base/esystem.rb, line 20
def esystem(i)
  e_colourize(i) # Output it here already.
  i = i.dup if i.frozen?
  i << ERROR_LINE
  @result = i # Not in use right now.
  internal_system(i) # Defined in this file here.
end
Also aliased as: _
extract( this_archive, extract_to = extract_to? )
Alias for: try_to_extract
extract_archive( this_archive, extract_to = extract_to? )
Alias for: try_to_extract
extract_to?()
extract_to_this_directory?() click to toggle source
#

extract_to_this_directory?

#
# File lib/easycompile/base/misc.rb, line 230
def extract_to_this_directory?
  @extract_to_this_directory
end
Also aliased as: extract_to?
file?()
filename() click to toggle source
#

filename

#
# File lib/easycompile/base/misc.rb, line 120
def filename
  return File.basename(__FILE__)+':'
end
Also aliased as: filename?
filename?()
Alias for: filename
files?()
find_partial_match_for(i) click to toggle source
#

find_partial_match_for

#
# File lib/easycompile/base/misc.rb, line 127
def find_partial_match_for(i)
  possible_matches = Dir["#{i}*"]
  return_value = false
  return_value = true unless possible_matches.empty?
  return [return_value, possible_matches] # Returns an Array.
end
find_this_program?() click to toggle source
#

find_this_program?

#
# File lib/easycompile/base/misc.rb, line 53
def find_this_program?
  @find_this_program
end
Also aliased as: find_which_program?
find_which_program?()
Alias for: find_this_program?
get_dataset_from(i) click to toggle source
#

get_dataset_from

#
# File lib/easycompile/base/misc.rb, line 890
def get_dataset_from(i)
  if !Object.const_defined?(:RBT) and !RBT.const_defined?(:Cookbooks)
    begin
      require 'rbt/requires/require_the_cookbook_class.rb'
    rescue LoadError; end
  end
  i.chop! if i.end_with? '.'
  if is_the_cookbook_class_available?
    i = RBT::Cookbooks::SanitizeCookbook.new(i).dataset?
  end
  return i
end
get_program_name(i = @original_input) click to toggle source
#

get_program_name

Obtain the program name here.

#
# File lib/easycompile/base/misc.rb, line 983
def get_program_name(i = @original_input)
  if i.include? ' '
    i = i.split(' ').first
  end
  program_name = remove_file_suffix(File.basename(i))
  return program_name
end
install_this_gem(i) click to toggle source
#

install_this_gem

Consistently use this method when trying to install a gem.

We will ignore the dependencies, though, to speed up the installation process.

#
# File lib/easycompile/base/gem.rb, line 23
def install_this_gem(i)
  _ = "gem install --ignore-dependencies #{i}"
  esystem(_)
end
internal_system(i) click to toggle source
#

internal_system

The key idea for this method is to handle system()-related calls via IO.popen(). This gives us more control over as to what to do with the given input and output.

#
# File lib/easycompile/base/esystem.rb, line 46
def internal_system(i)
  cparser_is_available = cparser_is_available?
  cparser = @colourize_parser if cparser_is_available
  io_object = IO.popen(i, :err => [:child, :out]).each { |line|
    if cparser_is_available
      cparser.grab_this_line(line) # The cparser object will deal with colours.
      line = cparser.line?
    end
    e line # Output here.
  }
  io_object.close # Close it here.
end
is_a_gem?(i) click to toggle source
#

is_a_gem?

#
# File lib/easycompile/base/gem.rb, line 31
def is_a_gem?(i)
  i.end_with? '.gem'
end
is_an_appdir?() click to toggle source
#

is_an_appdir?

Return true if this is an appdir-based program.

#
# File lib/easycompile/base/misc.rb, line 926
def is_an_appdir?
  @hash.has_key?(:prefix) and @hash[:prefix] == :appdir
end
is_an_archive?(i)
Alias for: is_archive?
is_archive?(i) click to toggle source
#

is_archive?

Return true if the given input is an archive.

#
# File lib/easycompile/base/misc.rb, line 385
def is_archive?(i)
  ::Easycompile.is_archive?(i)
end
Also aliased as: is_an_archive?
is_the_cookbook_class_available?() click to toggle source
#

is_the_cookbook_class_available?

#
# File lib/easycompile/base/misc.rb, line 881
def is_the_cookbook_class_available?
  Object.const_defined?(:RBT) and
  RBT.const_defined?(:Cookbooks) and
  RBT::Cookbooks.const_defined?(:Cookbook)
end
make_distclean() click to toggle source
#

make_distclean

#
# File lib/easycompile/base/misc.rb, line 1031
def make_distclean
  esystem 'make distclean'
end
menu( i = commandline_arguments? ) click to toggle source
#

menu

#
mkdir(i) click to toggle source
#

mkdir (mkdir tag)

#
# File lib/easycompile/base/misc.rb, line 312
def mkdir(i)
  FileUtils.mkdir_p(i)
end
name_for_build_dir?()
name_of_build_directory?() click to toggle source
#

name_of_build_directory?

This method will return the name of the BUILD/ directory. For now this is static but perhaps one day we may wish to change this, in order to make it more dynamic.

#
# File lib/easycompile/base/misc.rb, line 267
def name_of_build_directory?
  @name_of_build_directory
end
name_of_the_build_directory?()
ninjait() click to toggle source
#

ninjait

#
# File lib/easycompile/base/meson_and_ninja.rb, line 31
def ninjait
  esystem 'ninja'
  esystem 'ninja install'
end
open_this_file(this_file = self.class::THIS_FILE) click to toggle source
#

open_this_file

#
# File lib/easycompile/base/misc.rb, line 151
def open_this_file(this_file = self.class::THIS_FILE)
  esystem "bluefish #{this_file}"
end
opn_namespace() click to toggle source
#

opn_namespace

We use a special namespace-name here.

#
# File lib/easycompile/base/opn.rb, line 16
def opn_namespace
  opn(namespace: NAMESPACE)
end
original_input?() click to toggle source
#

original_input?

#
# File lib/easycompile/base/misc.rb, line 305
def original_input?
  @original_input
end
prefix?() click to toggle source
#

prefix?

#
# File lib/easycompile/base/misc.rb, line 73
def prefix?
  @prefix
end
process_the_input( i = compile_these_programs? ) click to toggle source
#

process_the_input

#
# File lib/easycompile/base/process_the_input.rb, line 14
def process_the_input(
    i = compile_these_programs?
  )
  i.each {|this_entry|
    # ===================================================================== #
    # The this_entry part may look like so:
    #
    #   "php-7.4.2.tar.xz"
    #
    # ===================================================================== #
    # The entry may be nil at this point, though. In that case, we
    # fetch a random element.
    # ===================================================================== #
    this_entry = Dir['*'].first if this_entry.nil?
    this_entry = this_entry.to_s
    this_entry.sub!(/\^/,'') if this_entry.include? '^' # Remove ^ from the input here, if it is included.
    # ===================================================================== #
    # If input is a (positional) number, such as "3".
    # ===================================================================== #
    unless File.exist?(this_entry)
      if this_entry =~ /^\d+$/
        # ================================================================= #
        # Obtain all entries next.
        # ================================================================= #
        entries = Dir['*']
        unless entries.empty?
          this_entry = this_entry.to_i
          this_entry = entries.size if this_entry > entries.size # This is to fetch the proper last entry, if input is too long.
          this_entry = entries.sort[ (this_entry.to_i - 1) ] # Fetch an entry here.
        end
      end
    end
    # ===================================================================== #
    # === Handle .gem files too, early on - they won't need a build directory.
    # ===================================================================== #
    if this_entry =~ /\.gem$/ # If it is a gem file.
      do_not_create_a_build_directory # Gem files typically do not need a build dir.
    end
    # ===================================================================== #
    # === Handle yaml files first.
    #
    # If the input file is a yaml file, we will assume that the user wants
    # to change directory first into the SRC_DIR hierarchy.
    #
    # Invoke this by doing something like:
    # ===================================================================== #
    if this_entry.include? '.yml'
      yaml_dataset = get_dataset_from(this_entry)
      this_entry = yaml_dataset['program_path']
    end
    if File.directory? this_entry
      _ = Dir["#{this_entry}/*"].first # Fetch the first entry from this directory, in this case. But retain it only when it is an archive.
      if is_archive? _
        this_entry = _
      end # else we discard it.
    end
    # ===================================================================== #
    # Next, we need to check whether the input is an archive or whether
    # it is not. If it is a directory, then we will simply enter
    # this directory instead, without doing any further extraction.
    # ===================================================================== #
    unless this_entry.start_with?('--')
      if File.directory? this_entry # No need to do anything special in this case.
        # ================================================================= #
        # In this case we will enter the given directory at hand.
        # ================================================================= #
        cd this_entry
        consider_creating_a_build_directory
        run_configure_make_and_make_install
      else
        if File.exist?(this_entry)
          # ================================================================= #
          # Past this point we know that the entry must exist.
          # ================================================================= #
          set_original_input(this_entry)
          set_find_this_program(
            ProgramInformation.return_name(this_entry)
          )
          # =================================================================== #
          # The next method will also extract the archive, if the
          # archive exists and there is no other instruction given
          # by the user to NOT extract it.
          # =================================================================== #
          try_to_compile_or_install_this_program(this_entry)
          consider_symlinking_appdir if is_an_appdir?
          return_to_start_directory_again
          consider_removing_this_archive(this_entry)
        end
      end
    end
  }
end
program_name?() click to toggle source
#

program_name?

#
# File lib/easycompile/base/misc.rb, line 523
def program_name?
  @program_name
end
program_version?() click to toggle source
#

program_version?

#
# File lib/easycompile/base/misc.rb, line 461
def program_version?
  @program_version
end
Also aliased as: version?
rds(i) click to toggle source
#

rds

#
# File lib/easycompile/base/misc.rb, line 46
def rds(i)
  i.squeeze('/')
end
remove(i)
Alias for: remove_this_file
remove_all_after_compile?() click to toggle source
#

remove_all_after_compile?

#
# File lib/easycompile/base/remove.rb, line 73
def remove_all_after_compile?
  @remove_all_after_compile
end
remove_archive_at_the_end(i)
remove_directory(i = nil) click to toggle source
#

remove_directory

This method will remove a directory (if the input argument is a directory that is).

#
# File lib/easycompile/base/remove.rb, line 17
def remove_directory(i = nil)
  if i and File.directory?(i)
    i = i.dup if i.frozen?
    i.squeeze!('/')
    FileUtils.rm_rf(i) unless i == '/' # Don't delete "/" ever.
  end
end
Also aliased as: remove_this_directory
remove_extension_from(i) click to toggle source
#

remove_extension_from

#
# File lib/easycompile/base/remove.rb, line 41
def remove_extension_from(i)
  i = i.dup # Work on a copy.
  i.sub!(/\.xz$/,'')    if i.end_with? '.xz'
  i.sub!(/\.gz$/,'')    if i.end_with? '.gz'
  i.sub!(/\.bzip2$/,'') if i.end_with? '.bzip2'
  i.sub!(/\.bzip$/,'')  if i.end_with? '.bzip'
  i.sub!(/\.tar$/,'')   if i.end_with? '.tar'
  i.sub!(/\.zip$/,'')   if i.end_with? '.zip'
  i
end
remove_file_suffix(i)
remove_this_archive(i) click to toggle source
#

remove_this_archive

This method can only be used to remove an archive, that is some file like “foobar-1.2.0.tar.xz”. It may never remove a directory.

#
# File lib/easycompile/base/remove.rb, line 32
def remove_this_archive(i)
  if is_an_archive?(i)
    remove_file(i)
  end
end
remove_this_directory(i = nil)
Alias for: remove_directory
remove_this_file(i) click to toggle source
#

remove_this_file

#
# File lib/easycompile/base/remove.rb, line 56
def remove_this_file(i)
  i = @start_dir+File.basename(i)
  opn_namespace; e 'Now deleting `'+sfile(i)+'`.'
  File.delete(i) if File.exist? i
end
Also aliased as: remove
replace_all_yaml_files(i = @commandline_arguments) click to toggle source
#

replace_all_yaml_files

#
# File lib/easycompile/base/misc.rb, line 955
def replace_all_yaml_files(i = @commandline_arguments)
  i.map {|entry|
    if entry.end_with?('.yml')
      begin
        require 'rbt/requires/require_the_cookbook_class.rb'
        entry = return_yaml_file(entry)
      rescue LoadError; end
    end
    entry
  }
end
reset() click to toggle source
#

reset (reset tag)

The instance variable we will use here:

@prefix_to_base_directory # This is used to denote what is the base

directory.

#
# File lib/easycompile/base/reset.rb, line 26
def reset
  set_base_dir
  set_start_dir
  # ======================================================================= #
  # === @commandline_arguments
  #
  # This Array will hold all commandline arguments, e. g. ARGV.
  # ======================================================================= #
  @commandline_arguments = []
  # ======================================================================= #
  # === @compile_these_programs
  #
  # These are the programs, as an Array, that we wish to compile.
  # ======================================================================= #
  @compile_these_programs = []
  # ======================================================================= #
  # === @program_name
  # ======================================================================= #
  @program_name = nil
  # ======================================================================= #
  # === @compile_with_dependencies
  # ======================================================================= #
  @compile_with_dependencies = false # If true then we will first compile all dependencies.
  # ======================================================================= #
  # === @program_version
  # ======================================================================= #
  @program_version = '1.0.0' # Default.
  # ======================================================================= #
  # Designate the default extract-to directory next.
  # ======================================================================= #
  set_extract_to(:default)
  # ======================================================================= #
  # === @hash
  # ======================================================================= #
  @hash = {}
  # ======================================================================= #
  # === @skip_extracting
  # ======================================================================= #
  @skip_extracting = false # Whether to skip extracting or not.
  # ======================================================================= #
  # === @continue_after_extracting
  # ======================================================================= #
  @continue_after_extracting = true # if true we continue after extracting.
  # ======================================================================= #
  # === @build_directory_is_stored_here
  # ======================================================================= #
  @build_directory_is_stored_here = nil
  # ======================================================================= #
  # === @continue_past_configure_stage
  # ======================================================================= #
  @continue_past_configure_stage = true
  # ======================================================================= #
  # === @skip_make_install
  # ======================================================================= #
  @skip_make_install = false
  set_prefix # Default.
  # ======================================================================= #
  # === @prefix_to_base_directory
  # ======================================================================= #
  @prefix_to_base_directory = ''
  # ======================================================================= #
  # === @shall_we_create_a_build_directory
  #
  # This variable keeps track as to whether we will create a
  # build directory or not.
  # ======================================================================= #
  @shall_we_create_a_build_directory = SHALL_WE_CREATE_A_BUILD_DIRECTORY
  # ======================================================================= #
  # === @prefix
  #
  # Which prefix is to be used. Defaults to /usr/.
  # ======================================================================= #
  @prefix = '/usr/'
  # ======================================================================= #
  # === @original_input
  # ======================================================================= #
  @original_input = nil
  # ======================================================================= #
  # === @temp_directory
  # ======================================================================= #
  @temp_directory = ::Easycompile.temp_directory?
  # ======================================================================= #
  # === @remove_all_after_compile
  # ======================================================================= #
  @remove_all_after_compile = false
  # ======================================================================= #
  # === @try_to_use_extended_configure_options
  #
  # If this variable is set to true then we will try to
  # return the extended configure options, which are
  # part of the RBT project.
  # ======================================================================= #
  @try_to_use_extended_configure_options = false
  # ======================================================================= #
  # === @colourize_parser
  # ======================================================================= #
  if cparser_is_available?
    @colourize_parser = RBT::ColourizeParser.new
  else
    @colourize_parser = nil
  end
  # ======================================================================= #
  # === @name_of_build_directory
  #
  # Choose a default name for the build directory. This can be
  # overruled if we have a .yml file that tells us to do so.
  # ======================================================================= #
  set_name_of_build_directory 'BUILD_DIRECTORY/'
  if File.exist? FILE_NAME_OF_THE_BUILD_DIRECTORY
    require 'yaml'
    set_name_of_build_directory(:load_the_yaml_file)
  end
end
return_all_arguments_with_hyphens() click to toggle source
#

return_all_arguments_with_hyphens

This method will select all commandline arguments that begin with two – hyphens.

#
# File lib/easycompile/base/commandline_arguments.rb, line 31
def return_all_arguments_with_hyphens
  @commandline_arguments.select {|entry|
    entry.start_with? '--'
  }
end
return_pwd() click to toggle source
#

return_pwd

#
# File lib/easycompile/base/misc.rb, line 28
def return_pwd
  ("#{Dir.pwd}/").squeeze '/'
end
return_to_start_directory_again() click to toggle source
#

return_to_start_directory_again

#
# File lib/easycompile/base/misc.rb, line 874
def return_to_start_directory_again
  cd start_dir?
end
return_yaml_file(i) click to toggle source
#

return_yaml_file

#
# File lib/easycompile/base/misc.rb, line 970
def return_yaml_file(i)
  begin
    require 'rbt/requires/require_the_cookbook_class.rb'
    i = RBT::Cookbooks::SanitizeCookbook.new(i).program_path?
  rescue LoadError; end
  return i
end
rev() click to toggle source
#

rev

#
# File lib/easycompile/base/colours.rb, line 58
def rev
  if use_colours?
    ::Colours.rev
  else
    ''
  end
end
run() click to toggle source
#

run (run tag)

#
# File lib/easycompile/base/run.rb, line 14
def run
  @start_dir = return_pwd
  determine_which_programs_to_compile
  # ======================================================================= #
  # Next check against the menu (commandline-interface).
  # ======================================================================= #
  menu(
    return_all_arguments_with_hyphens
  )
  process_the_input
end
run_build_sh() click to toggle source
#

run_build_sh

Run sh build.sh

#
# File lib/easycompile/base/misc.rb, line 1023
def run_build_sh
  _ = "#{@prefix_to_base_directory}sh build.sh"
  esystem _
end
run_cmake()
Alias for: run_cmake_command
run_cmake_command() click to toggle source
#

run_cmake_command (cmake tag)

Compiling via cmake can yield errors. We will try to capture such an error.

Note that cmake-based projects typically require a dedicated build directory - this is why the method do_make_use_of_a_build_directory() is called within this method.

cmake -DCMAKE_INSTALL_PREFIX=/usr

#
# File lib/easycompile/base/cmake.rb, line 32
def run_cmake_command
  do_make_use_of_a_build_directory
  _ = 'cmake'.dup
  # ======================================================================= #
  # Next, we will use the install prefix.
  # ======================================================================= #
  _ << " -DCMAKE_INSTALL_PREFIX=#{prefix?}"
  _ << ' .'
  _ << '.' if shall_we_create_a_build_directory? # Append this.
  if shall_we_create_a_build_directory?
    use_this_name = name_of_build_directory?
    unless File.directory?(use_this_name)
      opn; e "Next creating the build directory called `"\
             "#{sdir(use_this_name)}`."
      mkdir(use_this_name)
    end
    cd use_this_name
  end
  esystem _
end
Also aliased as: run_cmake
run_configure() click to toggle source
#

run_configure (configure tag)

This method runs the classical configure command with a specific prefix. It is equivalent to just run “./configure”.

#
# File lib/easycompile/base/misc.rb, line 737
def run_configure
  if shall_we_create_a_build_directory?
    @prefix_to_base_directory << '../'
  end
  # ======================================================================= #
  # === Check for Rakefile
  # ======================================================================= #
  if File.exist?(@prefix_to_base_directory+'Rakefile')
    run_rinstall2
  # ======================================================================= #
  # === Check for cmake-file
  #
  # Here we will run cmake.
  # ======================================================================= #
  elsif File.exist?("#{@prefix_to_base_directory}#{cmake_file?}")
    run_cmake_command
  # ======================================================================= #
  # === Check for setup.py file
  #
  # Note that a file called setup.py may exist, but the program itself
  # may still require a "configure" invocation. This is the case with
  # the official source archive for Python.
  # ======================================================================= #
  elsif File.exist?(@prefix_to_base_directory+'setup.py')
    run_python_installation
  # ======================================================================= #
  # === Check for Makefile.PL
  # ======================================================================= #
  elsif File.exist?(@prefix_to_base_directory+'Makefile.PL')
    run_perl_installation
  # ======================================================================= #
  # === Check for build.sh file
  #
  # This was disabled on 20.06.2020 as it was not working for the
  # program called "make". At a later time this may have to be
  # re-enabled again, but for now it has to stay disabled.
  # ======================================================================= #
  # elsif File.exist? @prefix_to_base_directory+'build.sh'
  #   run_build_sh
  # ======================================================================= #
  # === Run the configure command next
  # ======================================================================= #
  elsif File.exist? @prefix_to_base_directory+'configure'
    simply_run_the_configure_command
  # ======================================================================= #
  # === Check for ruby .gem files next
  # ======================================================================= #
  elsif (@original_input =~ /\.gem$/)
    install_this_gem(@original_input)
    exit
  # ======================================================================= #
  # === Check whether 'meson.build' exists
  # ======================================================================= #
  elsif does_a_meson_build_file_exist?
    compile_as_meson_based_project
    exit
  else # The default, that is - we will run ./configure here.
    show_namespace; e 'We could not find a configure script, no cmake'
    show_namespace; e 'file and we also could not find various other '
    show_namespace; e 'files. We will now assume that configure may'
    show_namespace; e 'still work, and thus run, but be aware that'
    show_namespace; e 'this may fail.'
    simply_run_the_configure_command
  end
end
run_configure_command()
Alias for: run_configure
run_configure_command_or_another_command()
Alias for: run_configure
run_configure_make_and_make_install() click to toggle source
#

run_configure_make_and_make_install

#
# File lib/easycompile/base/misc.rb, line 1047
def run_configure_make_and_make_install
  run_configure_command_or_another_command
  if continue_past_configure_stage?
    run_make_command_or_equivalent
    run_make_install_command
  end
end
run_configure_or_cmake()
Alias for: run_configure
run_configure_then_make_then_make_install()
run_make()
run_make_command()
run_make_command_or_equivalent() click to toggle source
#

run_make_command_or_equivalent (make tag)

This method will either run “make”, or another command.

For now we assume the alternative is via cmake. Please note that the command “make install” usually follows the “make” command.

#
# File lib/easycompile/base/misc.rb, line 911
def run_make_command_or_equivalent
  show_namespace; e 'Running "make" in '+sdir(return_pwd)+' next.'
  if File.exist? 'Makefile'
    esystem 'make' if continue_past_configure_stage?
  else # Else assume cmake.
    esystem 'make' if continue_past_configure_stage?
  end
end
Also aliased as: run_make_command, run_make
run_make_install_command() click to toggle source
#

run_make_install_command

This will run “make install”.

#
# File lib/easycompile/base/misc.rb, line 1040
def run_make_install_command
  esystem 'make install' unless skip_make_install?
end
run_make_then_make_install() click to toggle source
#

run_make_then_make_install

#
# File lib/easycompile/base/misc.rb, line 1058
def run_make_then_make_install
  run_make_command_or_equivalent
  run_make_install_command
end
run_perl_installation() click to toggle source
#

run_perl_installation

#
# File lib/easycompile/base/misc.rb, line 99
def run_perl_installation
  _ 'perl Makefile.PL'
end
run_python_installation() click to toggle source
#

run_python_installation (python tag)

This method will additionally check for a file called 'configure'.

#
# File lib/easycompile/base/misc.rb, line 1068
def run_python_installation
  if File.exist?("#{@prefix_to_base_directory}configure")
    simply_run_the_configure_command
    run_make_then_make_install
  else
    _ 'python setup.py configure'
    _ 'python setup.py build'
    _ 'python setup.py install'
  end
end
run_rinstall2() click to toggle source
#

run_rinstall2

#
# File lib/easycompile/base/misc.rb, line 60
def run_rinstall2
  copy_setup_rb
  internal_system 'ruby setup.rb config'
  internal_system 'ruby setup.rb setup'
  internal_system 'ruby setup.rb install'
  internal_system 'rm setup.rb'
  internal_system 'rm InstalledFiles'
  internal_system 'rm .config'
end
set_base_dir(i = return_pwd) click to toggle source
#

set_base_dir

#
# File lib/easycompile/base/misc.rb, line 446
def set_base_dir(i = return_pwd)
  i = i.squeeze('/')
  @base_dir = i
end
set_build_directory(i = :pwd)
Alias for: set_this_build_dir
set_commandline_arguments(i) click to toggle source
#

set_commandline_arguments

#
# File lib/easycompile/base/commandline_arguments.rb, line 21
def set_commandline_arguments(i)
  @commandline_arguments = [i].flatten.compact
end
set_compile_these_programs(i) click to toggle source
#

set_compile_these_programs

This method specifies which programs this class will compile.

#
# File lib/easycompile/base/misc.rb, line 676
def set_compile_these_programs(i)
  i = [i].flatten.compact
  i.map! {|entry|
    # ======================================================================= #
    # The file in question may not exist, for instance if it is a remote URL
    # link. In that case we enter here.
    # ======================================================================= #
    unless File.exist? entry
      case entry # case tag
      when 'ALL','A' # simply get all.
        entry = Dir['*'].reject {|inner_entry| File.directory? inner_entry }
      when /LAST/,/LAT/ # Special instruction.
        entry = File.readlines(LAST_DOWNLOADED_FILE).first
      else # Try a (silent) glob here if the file does not exist.
        if entry.include?('http') # Assume this to be a remote file.
          esystem "wget #{entry}"
          entry = File.basename(entry)
        else
          glob = Dir["#{entry}*"]
          entry = glob.first unless glob.empty?
        end
      end
    end
    entry
  }
  @compile_these_programs = i
end
set_extract_to(i = :default)
set_extract_to_this_directory(i = :default) { || ... } click to toggle source
#

set_extract_to_this_directory

#
# File lib/easycompile/base/misc.rb, line 196
def set_extract_to_this_directory(i = :default)
  case i
  # ======================================================================= #
  # === :default
  # ======================================================================= #
  when :default,
       nil
    i = temp_dir?
  end
  i = i.to_s.dup
  unless i.end_with? '/'
    i = i.dup if i.frozen?
    i << '/'
  end
  # ======================================================================= #
  # === Handle blocks given to this method next:
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :be_verbose
    # ===================================================================== #
    when :be_verbose
      e "#{rev}Using the directory #{sdir(i)} as temp-directory next."
      e '(The archive at hand will be extracted to this directory.)'
    end
  end
  @extract_to_this_directory = i
end
Also aliased as: set_extract_to
set_files(i)
Alias for: add_this_archive
set_find_this_program(i) click to toggle source
#

set_find_this_program

This will store e. g. “php”, so that we can designate to work on a particular program, and pass this information to external programs if necessary.

#
# File lib/easycompile/base/misc.rb, line 39
def set_find_this_program(i)
  @find_this_program = i
end
set_hash(i = {}) click to toggle source
#

set_hash

#
# File lib/easycompile/base/misc.rb, line 500
def set_hash(i = {})
  if i.is_a? Hash
    if i.has_key? :extract_to
      set_extract_to(i[:extract_to])
    end
    if i.has_key? :program_version
      set_version(i[:program_version])
    end
    if i.has_key? :prefix
      set_prefix(i[:prefix])
    end
    if i.has_key? :appdir_layout
      set_prefix(i[:appdir_layout])
    elsif i.has_key? :usr_prefix
      set_prefix(i[:usr_prefix])
    end
  end
  @hash = i
end
set_name_of_build_directory( i = :default ) click to toggle source
#

set_name_of_build_directory

#
# File lib/easycompile/base/misc.rb, line 244
def set_name_of_build_directory(
    i = :default
  )
  case i
  # ======================================================================= #
  # === :load_the_yaml_file
  # ======================================================================= #
  when :load_the_yaml_file,
       :default
    i = YAML.load_file(FILE_NAME_OF_THE_BUILD_DIRECTORY)
  end
  i = i.dup if i.frozen?
  i << '/' unless i.end_with? '/'
  @name_of_build_directory = i
end
set_original_input(i) click to toggle source
#

set_original_input

This method will keep track of the “original” input.

#
# File lib/easycompile/base/misc.rb, line 298
def set_original_input(i)
  @original_input = i
end
set_prefix( i = '/usr' ) click to toggle source
#

set_prefix

Set the prefix here. By default the prefix will be /usr, but some programs, in particular app-dir like programs, will default to a prefix such as /Programs/Gimp/2.5.2.

#
# File lib/easycompile/base/misc.rb, line 1086
def set_prefix(
    i = '/usr'
  )
  if i.is_a? Symbol # This may be triggered via :appdir, for instance.
    case i
    # ===================================================================== #
    # === :home_directory
    # ===================================================================== #
    when :home_directory,
         :home_dir,
         :home
      i = ENV['HOME'].to_s
    end
    i = i.to_s # Work on a String here.
    i = remove_file_suffix(i)
    # ===================================================================== #
    # Simply assemble the prefix now, based on the capitalized variant
    # of the program name, and then the version.
    # For this to work, program_name? and program_version? must have
    # been already defined.
    # ===================================================================== #
    # if program_name?.nil? and program_version?.nil?
    #   # In this case, we must first define these two entries.
    #   # This has not yet happened - stub.
    # end
    case i
    when /usr(_|-)?prefix/
      i = '/usr/'
    # ===================================================================== #
    # === appdir
    # ===================================================================== #
    when 'appdir',
         'app'
      # =================================================================== #
      # We will first check on the original input. If that original
      # input was an existing file, in form of an archive, then
      # we may make use of ProgramInformation to change the
      # version of the program at hand.
      # =================================================================== #
      if @original_input and
         File.exist?(@original_input) and
         File.file?(@original_input) and
         is_archive?(@original_input)
        # ================================================================= #
        # Ok, in this case, we will make use of ProgramInformation.
        # ================================================================= #
        _ = remove_archive_at_the_end(
          File.basename(
            @original_input
          )
        )
        set_program_name(_)
        set_program_version(
          ProgramInformation.return_version(@original_input)
        )
      end
      # =================================================================== #
      # Build up the full appdir-prefix next:
      # =================================================================== #
      i = "#{::Easycompile.programs_directory?}"\
          "#{program_name?.to_s.capitalize.delete('-')}"\
          "/#{program_version?}"
    end
  end
  if i.is_a? String # We can do this because the next step is rds().
    i = i.dup if i.frozen?
    i = rds("#{i}/")
  end
  @prefix = i
end
Also aliased as: set_prefix_for_this_program
set_prefix_for_this_program( i = '/usr' )
Alias for: set_prefix
set_program_name(i = nil) click to toggle source
#

set_program_name

Note that this method can make use of ProgramInformation.

#
# File lib/easycompile/base/misc.rb, line 996
def set_program_name(i = nil)
  i = i.first if i.is_a? Array
  if i
    i = get_program_name(i)
    # ===================================================================== #
    # Next, we need to obtain the real program name, without the
    # version. We used the following line for this in the past:
    #   _ = _.split('-').first if _.include? '-'
    # However had, as of 08.08.2015, we will instead use ProgramInformation.
    # ===================================================================== #
    i = ProgramInformation.return_name(i) # .first() will return the right name.
  end
  @program_name = i
end
set_program_version(i) click to toggle source
#

set_program_version

#
# File lib/easycompile/base/misc.rb, line 439
def set_program_version(i)
  @program_version = i
end
set_start_dir(i = return_pwd) click to toggle source
#

set_start_dir

#
# File lib/easycompile/base/misc.rb, line 174
def set_start_dir(i = return_pwd)
  i.squeeze! '/'
  @start_dir = i # This is not @base_dir.
end
set_this_build_dir(i = :pwd) click to toggle source
#

set_this_build_dir

#
# File lib/easycompile/base/misc.rb, line 80
def set_this_build_dir(i = :pwd)
  case i
  when :pwd
    i = return_pwd
  end
  i = i.to_s
  unless i.include? '/'
    i = File.absolute_path(i)
  end
  unless i.end_with? '/'
    i = i.dup if i.frozen?
    i << '/'
  end
  @build_directory_is_stored_here = i
end
Also aliased as: set_build_directory
shall_we_create_a_build_directory?() click to toggle source
#

shall_we_create_a_build_directory?

#
# File lib/easycompile/base/misc.rb, line 237
def shall_we_create_a_build_directory?
  @shall_we_create_a_build_directory
end
show_help(optional_shall_we_exit = false) click to toggle source
#

show_help (help tag)

#
# File lib/easycompile/base/help.rb, line 14
def show_help(optional_shall_we_exit = false)
  if optional_shall_we_exit == :then_exit
    optional_shall_we_exit = true
  end
  e
  opn_namespace; e 'Documented help options are these here:'
  opn_namespace; e
  opn_namespace; ecomment '  --appdir                   # Compile as Appdir, into '\
                 'its own prefix.'
  opn_namespace; ecomment '  --remove-all-after-compile # Remove '\
                 'the archive after compilation is done.'
  opn_namespace; ecomment '  --with-deps                '\
                 '# Compile with dependencies.'
  opn_namespace; ecomment '  --extract-to=/Depot/opt/  '\
                 '# extract to that particular directory.'
  opn_namespace; ecomment '  --homedir                  # '\
                          'Compile into the home-directory as prefix'
  opn_namespace; e
  exit if optional_shall_we_exit
end
show_namespace() click to toggle source
#

show_namespace

#
# File lib/easycompile/base/opn.rb, line 23
def show_namespace
  opn(namespace: Constants::NAMESPACE)
end
simply_run_the_configure_command() click to toggle source
#

simply_run_the_configure_command

#
# File lib/easycompile/base/misc.rb, line 808
def simply_run_the_configure_command
  _  = ''.dup # ← Buildup the command.
  _ << '.' if shall_we_create_a_build_directory?
  _ << "./configure --prefix=#{prefix?}"
  # ======================================================================= #
  # === Check for etended configure options next
  # ======================================================================= #
  if @try_to_use_extended_configure_options
    begin
      require 'rbt/requires/require_show_configuration_options.rb'
    rescue LoadError; end
    if RBT.respond_to? :return_configuration_options_for?
      _ << " #{RBT.return_configuration_options_for?(find_which_program?)}"
    end
  end
  begin
    # This part invokes the actual "./configure" run.
    esystem(_) # Also show the ./configure command we will use.
  rescue Errno::ENOENT
    show_namespace
    e 'An error happened - the configure-file could not be found. '\
      'The faulty line was:'
    show_namespace
    e "  #{simp(_)}"
    show_namespace
    e "It was issued from the directory: #{sdir(return_pwd)}"
    if return_pwd.include? name_for_build_dir?
      set_this_build_dir(:pwd)
    end
    can_not_continue # We can not continue past the configure-step.
    # ======================================================================= #
    # Do "make distclean" here.
    # ======================================================================= #
    if _.include?('configure: error: source directory already configured') or
       _.include?('source directory already configured; run "make distclean"')
      @base_dir = return_pwd
      cd '..'
      make_distclean
      cd @base_dir
      run_configure_command
    end if _
  end
end
skip_extracting() click to toggle source
#

skip_extracting

#
# File lib/easycompile/base/misc.rb, line 358
def skip_extracting
  show_namespace; e 'We will not extract.'
  @skip_extracting = true
end
skip_extracting?() click to toggle source
#

skip_extracting?

#
# File lib/easycompile/base/misc.rb, line 351
def skip_extracting?
  @skip_extracting
end
skip_make_install?() click to toggle source
#

skip_make_install?

#
# File lib/easycompile/base/misc.rb, line 167
def skip_make_install?
  @skip_make_install
end
start_dir?() click to toggle source
#

start_dir?

#
# File lib/easycompile/base/misc.rb, line 182
def start_dir?
  @start_dir
end
temp_dir?() click to toggle source
#

temp_dir?

#
# File lib/easycompile/base/misc.rb, line 113
def temp_dir?
  ::Easycompile.temp_dir?
end
temp_directory?() click to toggle source
#

temp_directory?

#
# File lib/easycompile/base/misc.rb, line 144
def temp_directory?
  @temp_directory
end
try_to_compile_or_install_this_program(this_archive) click to toggle source
#

try_to_compile_or_install_this_program

#
# File lib/easycompile/base/misc.rb, line 855
def try_to_compile_or_install_this_program(this_archive)
  if is_a_gem?(this_archive)
    e "#{rev}Now installing the gem at #{sfile(this_archive)}."
    install_this_gem(this_archive)
  else
    extracted_to = try_to_extract(this_archive)
    if continue_after_extracting?
      if File.directory? extracted_to
        enter_extracted_directory(extracted_to)
        consider_creating_a_build_directory
        run_configure_make_and_make_install
      end
    end
  end
end
try_to_extract( this_archive, extract_to = extract_to? ) click to toggle source
#

try_to_extract

Use this method here to extract a given archive.

#
# File lib/easycompile/base/misc.rb, line 621
def try_to_extract(
    this_archive, extract_to = extract_to?
  )
  if this_archive.is_a? Array # Obtain only the first element in this case.
    this_archive = this_archive.first
  end
  cd start_dir?
  if File.exist? this_archive.to_s
    # ===================================================================== #
    # In this case, we will assume that an valid archive was given to us.
    # ===================================================================== #
    unless skip_extracting?
      show_namespace; e "Now trying to extract `#{sfancy(this_archive)}`."
      @extracter = Extracter.what_to(this_archive, extract_to)
      return remove_archive_at_the_end(
        extract_to+
        File.basename(this_archive)
      )
    else
      nil
    end
  elsif File.exist? base_dir?+this_archive
    unless skip_extracting?
      @extracter = Extracter.what_to(base_dir?+this_archive, extract_to)
    end 
  else
    # ===================================================================== #
    # The file does not exist here at this point. Thus, we will
    # do some further checks.
    # ===================================================================== #
    if this_archive =~ /^\d+$/ # Ok, user inputted a number alone, check first.
      this_archive = Dir['*'].sort[ this_archive.to_i - 1 ]
      if File.exist? this_archive
        @extracter = Extracter.what_to(this_archive, extract_to)
      end
    elsif find_partial_match_for(this_archive).first # Ok, user could input a partial number and a string, like: "baobab-3.9"
      matched = find_partial_match_for(i)[1]
      consider_extracting_this_archive(matched)
    else # Ok, it indeed does not exist.
      show_namespace; e 'File `'+sfile(this_archive)+'` does '+
                        'not exist. We thus can not continue.'
      show_namespace; e 'We will not continue as a consequence.'
      do_not_continue
      return nil
    end
  end
end
use_colours?() click to toggle source
#

use_colours?

#
# File lib/easycompile/base/colours.rb, line 51
def use_colours?
  ::Easycompile.can_we_use_colours?
end
use_the_home_directory_as_prefix() click to toggle source
#

use_the_home_directory_as_prefix

#
# File lib/easycompile/base/misc.rb, line 1014
def use_the_home_directory_as_prefix
  set_prefix(:home_directory)
end
version?()
Alias for: program_version?