class RBT::Base

Public Class Methods

registered_binaries?() click to toggle source
#

RBT::Base.registered_binaries?

Tell us where our binaries are registered.

#
# File lib/rbt/base/base.rb, line 501
def self.registered_binaries?
  RBT.all_binaries?
end

Public Instance Methods

available_cookbook_files?( show_how = :show_only_name )
Alias for: cookbook_files?
cat(i) click to toggle source
#

cat (cat tag)

#
# File lib/rbt/base/base.rb, line 519
def cat(i)
  if File.exist? i
    return readlines_with_proper_encoding(i).join
  end
end
ccache_is_available?()
cd_back_to_the_current_working_directory() { || ... } click to toggle source
#

cd_back_to_the_current_working_directory

This method can be used to ensure that we are back in the old “current working directory”, after invoking the given block.

#
# File lib/rbt/base/base.rb, line 448
def cd_back_to_the_current_working_directory
  working_directory = return_pwd
  if block_given?
    yield
  end
  cd(working_directory)
end
consider_reporting_how_many_programs_are_registered( shall_we_report = false ) click to toggle source
#

consider_reporting_how_many_programs_are_registered

#
# File lib/rbt/base/base.rb, line 302
def consider_reporting_how_many_programs_are_registered(
    shall_we_report = false
  )
  if shall_we_report
    action(:report_the_registered_programs)
  end
end
cookbook_files?( show_how = :show_only_name ) click to toggle source
#

cookbook_files?

This method will return all available cookbook files in an Array.

Usage example:

cookbook_files?(:show_full_path)
#
# File lib/rbt/base/base.rb, line 466
def cookbook_files?(
    show_how = :show_only_name
  )
  result = Dir["#{individual_cookbooks_directory?}*yml"].sort
  case show_how
  when :show_only_name # In this case, show only the name.
    result.map! {|entry|
      File.basename(entry).gsub( File.extname(entry), '' )
    }
  when :show_full_path # In this case make no modifications.
  end
  return result
end
Also aliased as: available_cookbook_files?
cookbooks_include_this_program?( i, optional_arguments = nil )
copy_recursively( what, where_to = '/usr/', be_verbose = false ) click to toggle source
#

copy_recursively

#
# File lib/rbt/base/base.rb, line 368
def copy_recursively(
    what,
    where_to   = '/usr/',
    be_verbose = false
  )
  ::RBT.copy_recursively(what, where_to, be_verbose)
end
delete_code_of_conduct?() click to toggle source
#

delete_code_of_conduct?

Query method over as to whether we will try to remove code-of-conduct files. This is usually only valid for my home system, or when a config-option has been set to true. Note that the default value is false, so that other users can decide on their own whether they want to retain code of conducts or not.

#
# File lib/rbt/base/base.rb, line 138
def delete_code_of_conduct?
  if is_on_roebe?
    true
  else # else try to check for the config file.
    if config?
      config?.automatically_delete_code_of_conduct_files_when_repackaging
    else
      false
    end
  end
end
determine_appdir_prefix_from_this_input( i = nil, program_version = nil ) click to toggle source
#

determine_appdir_prefix_from_this_input

This method has to return a String, which constitutes the AppDir prefix of the target program at hand.

#
# File lib/rbt/base/base.rb, line 254
def determine_appdir_prefix_from_this_input(
    i               = nil,
    program_version = nil
  )
  return RBT.determine_appdir_prefix_from_this_input(
    i, program_version
  )
end
Also aliased as: static_appdir_prefix_of?
directory_validation?() click to toggle source
#

directory_validation?

#
# File lib/rbt/base/base.rb, line 219
def directory_validation?
  RBT.directory_validation?
end
do_not_show_names() click to toggle source
#

do_not_show_names

#
# File lib/rbt/base/base.rb, line 105
def do_not_show_names
  RBT.do_not_show_names
end
fast_return_file_size_of_this_program(i) click to toggle source
#

fast_return_file_size_of_this_program

#
# File lib/rbt/base/base.rb, line 98
def fast_return_file_size_of_this_program(i)
  RBT.fast_return_file_size_of_this_program(i)
end
file_last_symlinked_program?() click to toggle source
#

file_last_symlinked_program?

#
# File lib/rbt/base/base.rb, line 313
def file_last_symlinked_program?
  RBT.file_last_symlinked_program?
end
file_programs_version_url() click to toggle source
#

file_programs_version_url

#
# File lib/rbt/base/base.rb, line 379
def file_programs_version_url
  RBT.send(__method__)
end
gem_version(i) click to toggle source
#

gem_version

This method is a wrapper over Gem::Version.new()

The reason as to why this resides in a method is so that we can do some input-sanitizing, and easier rescue, if this is necessary one day.

#
# File lib/rbt/base/base.rb, line 325
def gem_version(i)
  i = i.to_s.delete('vr')
  begin
    if i =~ /\d+/ # Must have at the least one number.
      return Gem::Version.new(i)
    end
  rescue ArgumentError => error
    opne 'An error occurred in gem_version()'
    pp error
  end
  nil # Indicate "failure" aka unable to parse this version.
end
is_a_64bit_system?() click to toggle source
#

is_a_64bit_system?

This method will return true if the underlying system is a 64-bit system.

#
# File lib/rbt/base/base.rb, line 115
def is_a_64bit_system?
  RUBY_PLATFORM.include? '_64' # Due to → "x86_64-linux".
end
Also aliased as: is_on_64_bit?
is_ccache_available?() click to toggle source
#

is_ccache_available?

This method queries as to whether ccache is available or whether it is not.

#
# File lib/rbt/base/base.rb, line 269
def is_ccache_available?
  result = true
  begin
    check_for_ccache = `ccache 2>&1`
    if check_for_ccache.include? 'command not found'
      result = false
    end
  rescue Errno::ENOENT
    # ===================================================================== #
    # This clause can happen when there is no
    # /bin/sh symlink.
    # ===================================================================== #
    check_for_ccache = false
  end
  result
end
Also aliased as: ccache_is_available?
is_on_64_bit?()
Alias for: is_a_64bit_system?
is_porg_available?() click to toggle source
#

is_porg_available?

This method is required to determine whether porg is available or not.

#
# File lib/rbt/base/base.rb, line 388
def is_porg_available?
  result = `porg 2>&1`.include? 'porg: command not found'
  return !result
end
Also aliased as: porg_is_available?
is_this_binary_registered?(i) click to toggle source
#

is_this_binary_registered?

#
# File lib/rbt/base/base.rb, line 508
def is_this_binary_registered?(i)
  unless RBT.respond_to?(:registered_binaries?)
    require 'rbt/registered/registered_binaries.rb'
  end
  array = RBT.registered_binaries?
  array.include?(i.to_s)
end
is_this_program_included?( i, optional_arguments = nil ) click to toggle source
#

is_this_program_included?

Use this method to query whether a program is included or whether it is not.

The second argument is, by default, nil. It can be a symbol such as :include_abbreviations, in which case we will include abbreviations.

Usage example:

is_this_program_included?(:htop, :include_abbreviations)
#
# File lib/rbt/base/base.rb, line 359
def is_this_program_included?(
    i, optional_arguments = nil
  )
  RBT.is_this_program_included?(i, optional_arguments) # bl $RBT/toplevel_methods/available_programs.rb
end
make_command?() click to toggle source
#

make_command?

#
# File lib/rbt/base/base.rb, line 417
def make_command?
  RBT::Base.make_command?
end
make_install_command?() click to toggle source
#

make_install_command?

This is the default “make install” command for now.

#
# File lib/rbt/base/base.rb, line 426
def make_install_command?
  'make install'
end
new_cookbook_instance_for(name_of_the_program) click to toggle source
#

new_cookbook_instance_for

Use a slightly shorter wrapper to access class Cookbook.

Note that you still have to require class Cookbook on your own, prior to calling this method.

The argument to this method should be the name of the program whose cookbook-dataset you wish to access/manipulate.

#
# File lib/rbt/base/base.rb, line 619
def new_cookbook_instance_for(name_of_the_program)
  action(:sanitize_cookbook, name_of_the_program)
end
porg_is_available?()
Alias for: is_porg_available?
program_exists?( this_program ) click to toggle source
#

program_exists?

Use this method to find out whether the given program, as input to this method, exists.

Usage example:

if program_exists? :htop
#
# File lib/rbt/base/base.rb, line 170
def program_exists?(
    this_program
  )
  does_program_exist = false # Defaults to false - the program is not installed.
  this_program = this_program.to_s.dup #. downcase # sanitize. downcase is BAD, it breaks stuff like "Esetroot"
  if this_program.include? ' ' # split it, and take the first word in this case.
    this_program = this_program.split(' ').first 
  end
  path_variable_file = "#{RUBY_SRC_DIR}rcfiles/lib/rcfiles/yaml/path_variable.yml"
  if File.exist? path_variable_filelib
    array_available_paths = load_yaml(path_variable_file)['path'].strip.split(' ')
    array_available_paths.each {|path|
      _ = "#{path}/#{this_program}"
      does_program_exist = true if File.exist?(_)
    }
  end
  # Hack - an exception for configure:
  does_program_exist = true if this_program.include? '/configure'
  return does_program_exist
end
publish_list_of_all_programs_version() click to toggle source
#

publish_list_of_all_programs_version

#
# File lib/rbt/base/base.rb, line 627
def publish_list_of_all_programs_version
  ::RBT.publish_list_of_all_programs_version
end
rcp(i, &block) click to toggle source
#

rcp

This method performs a recursive copy action, through RBT.action().

#
# File lib/rbt/base/base.rb, line 155
def rcp(i, &block)
  action(:rcp, i, &block)
end
rename_kde_konsole_tab( use_this_as_the_new_title = '' ) click to toggle source
#

rename_kde_konsole_tab

#
# File lib/rbt/base/base.rb, line 55
def rename_kde_konsole_tab(
    use_this_as_the_new_title = ''
  )
  if Object.const_defined?(:Roebe) and
     Roebe.respond_to?(:rename_tab)
    Roebe.rename_tab(use_this_as_the_new_title)
  end
end
repackage( i, use_this_for_the_opnn_namespace = 'RBT::Repackage' ) click to toggle source
#

repackage (repackage tag)

This method will repackage an archive format such as .tar.gz into .tar.xz.

#
# File lib/rbt/base/base.rb, line 70
def repackage(
    i,
    use_this_for_the_opnn_namespace = 'RBT::Repackage'
  )
  begin
    require 'repackage'
    if File.exist? i
      opnn(
        namespace_to_use: use_this_for_the_opnn_namespace
      )
      e "#{rev}Trying to repackage `#{sfile(i)}#{rev}` next:"
      Repackage.new(i) {{
        run:                    :run_already,
        delete_code_of_conduct: delete_code_of_conduct?
      }}
    else
      # Not sure whether we should report to the user or not.
    end
  rescue LoadError
    e "#{rev}The gem called \"repackage\" is not available - please install it"
    e "in order to repackage the archive at hand here (`#{sfile(i)}`)."
  end
end
Also aliased as: repackage_this
repackage_this( i, use_this_for_the_opnn_namespace = 'RBT::Repackage' )
Alias for: repackage
report_n_programs() click to toggle source
#

report_n_programs

Usage example for the report functionality of this method:

report_n_programs
#
# File lib/rbt/base/base.rb, line 438
def report_n_programs
  consider_reporting_how_many_programs_are_registered
end
report_working_directory() click to toggle source
#

report_working_directory

This method will simply report the current working directory (pwd), without making use of opnn().

#
# File lib/rbt/base/base.rb, line 212
def report_working_directory
  e "#{rev}The current working directory is #{sdir(return_pwd)}#{rev}."
end
return_compile_time_statistics() click to toggle source
#

return_compile_time_statistics

#
# File lib/rbt/base/base.rb, line 122
def return_compile_time_statistics
  _ = RBT.file_storing_the_time_it_took_to_compile_programs
  if File.exist? _
    return YAML.load_file(_)
  end
end
return_n_random_characters( i = 10 ) click to toggle source
#

return_n_random_characters

This method will return n random characters, as Strings. It is used specifically to “create” a random temporary directory, into which archives can be extracted into.

#
# File lib/rbt/base/base.rb, line 487
def return_n_random_characters(
    i = 10
  )
  array = ('a'..'z').to_a
  _ = ''.dup
  i.times { _ << array.sample }
  _
end
return_version_of_this_program(i) click to toggle source
#

return_version_of_this_program

#
# File lib/rbt/base/base.rb, line 646
def return_version_of_this_program(i)
  RBT.swift_return_version_of_this_program(i)
end
run_make_then_make_install() click to toggle source
#

run_make_then_make_install

#
# File lib/rbt/base/base.rb, line 195
def run_make_then_make_install
  RBT.run_make_then_make_install
end
sanitize_url1_entry( i, optional_hash = {} ) click to toggle source
#

sanitize_url1_entry

#
# File lib/rbt/base/base.rb, line 233
def sanitize_url1_entry(
    i, optional_hash = {}
  )
  RBT.sanitize_url1_entry(i, optional_hash)
end
set_source_dir( i = return_pwd, be_verbose = false )
set_source_directory( i = return_pwd, be_verbose = false ) click to toggle source
#

set_source_directory

Set the source dir to ANY new location. Defaults to Dir.pwd.

Example to test this method:

ry mantis --source_dir=/Depot/j
#
# File lib/rbt/base/base.rb, line 403
def set_source_directory(
    i          = return_pwd,
    be_verbose = false
  )
  i << '/' unless i.end_with? '/'
  RBT.set_source_directory(i)
  if be_verbose?
    e "#{rev}Setting source directory to `#{sdir(i)}#{rev}` next." 
  end
end
Also aliased as: set_source_dir
show_overview_over_available_utility_scripts() click to toggle source
#

show_overview_over_available_utility_scripts

#
# File lib/rbt/base/base.rb, line 243
def show_overview_over_available_utility_scripts
  RBT.show_overview_over_available_utility_scripts
end
static_appdir_prefix_of?( i = nil, program_version = nil )
system_tags?() click to toggle source
#

system_tags?

#
# File lib/rbt/base/base.rb, line 226
def system_tags?
  RBT.system_tags?
end
upload_list_of_all_programs_version() click to toggle source
#

upload_list_of_all_programs_version

#
# File lib/rbt/base/base.rb, line 634
def upload_list_of_all_programs_version
  ::RBT.upload_list_of_all_programs_version
end
use_yaml_database_for_tags?() click to toggle source
#

use_yaml_database_for_tags?

#
# File lib/rbt/base/base.rb, line 202
def use_yaml_database_for_tags?
  RBT.use_yaml_database_for_tags?
end
warn_and_exit(input, exit_mode = true) click to toggle source
#

warn_and_exit

This method will exit from the scripts.

You should be careful when using this, because in some situations we do not actually want to exit completely - for example when we chain-compile something.

#
# File lib/rbt/base/base.rb, line 295
def warn_and_exit(input, exit_mode = true)
  warn(input, exit_mode)
end
Also aliased as: warn_then_exit
warn_then_exit(input, exit_mode = true)
Alias for: warn_and_exit
wget(i) click to toggle source
#

wget

#
# File lib/rbt/base/base.rb, line 341
def wget(i)
  esystem "wget #{i}"
end