class RBT::CompileViaSQLDatabase
Constants
- DEFAULT_LOCATION_OF_THE_DATABASE
#¶ ↑
DEFAULT_LOCATION_OF_THE_DATABASE
¶ ↑#¶ ↑
Public Class Methods
location_of_the_database?()
click to toggle source
new( i = ARGV, run_already = true )
click to toggle source
#¶ ↑
initialize¶ ↑
#¶ ↑
# File lib/rbt/compile_via_sql_database/compile_via_sql_database.rb, line 27 def initialize( i = ARGV, run_already = true ) reset set_commandline_arguments(i) map_the_first_argument_onto_the_compile_this_program_variable case run_already # ======================================================================= # # === :do_not_run_yet # ======================================================================= # when :do_not_run_yet run_already = false end run if run_already end
Public Instance Methods
assumed_local_file_path_for?(this_program)
click to toggle source
#¶ ↑
assumed_local_file_path_for?¶ ↑
This method was specifically added for the Libui GUI
wrapper. It is normally not in use by this class, if used on the commandline.
#¶ ↑
# File lib/rbt/compile_via_sql_database/compile_via_sql_database.rb, line 257 def assumed_local_file_path_for?(this_program) if this_program and is_this_program_included_in_the_database?(this_program) result = `sqlite3 #{location_of_the_database?} "select * from REGISTERED_PROGRAMS where PROGRAM_NAME = '#{this_program}';"` splitted = result.strip.split('|') return splitted[2] # This is the local path - at the least on 27.08.2022. end return this_program end
assumed_version_of_this_program?(this_program)
click to toggle source
#¶ ↑
assumed_version_of_this_program?¶ ↑
This method will use a SQL query to determine the (assumed) version of a particular program. It was added specifically because the LibUI GUI
may need to know this information.
#¶ ↑
# File lib/rbt/compile_via_sql_database/compile_via_sql_database.rb, line 297 def assumed_version_of_this_program?(this_program) this_program = this_program.dup this_program.delete!('-') if this_program.include?('-') result = `sqlite3 #{location_of_the_database?} "select * from REGISTERED_PROGRAMS where PROGRAM_NAME = '#{this_program}';"` if result and result.include? '|' result = result.split('|')[4] # Version is at position 4. # So we use the local name for that. result = ProgramInformation.return_version(File.basename(result)) end return result end
available_programs?()
click to toggle source
#¶ ↑
available_programs?¶ ↑
#¶ ↑
# File lib/rbt/compile_via_sql_database/compile_via_sql_database.rb, line 269 def available_programs? result = `sqlite3 #{location_of_the_database?} "select * from REGISTERED_PROGRAMS;"`.split("\n") array = result.map {|entry| splitted = entry.split('|') splitted[1] } return array end
compile_which_program?()
click to toggle source
#¶ ↑
compile_which_program?¶ ↑
#¶ ↑
# File lib/rbt/compile_via_sql_database/compile_via_sql_database.rb, line 154 def compile_which_program? @internal_hash[:compile_this_program].to_s end
Also aliased as: program_name_that_is_to_be_installed?
do_compile_via_this_variant(i)
click to toggle source
#¶ ↑
do_compile_via_this_variant
¶ ↑
#¶ ↑
# File lib/rbt/compile_via_sql_database/compile_via_sql_database.rb, line 410 def do_compile_via_this_variant(i) if is_it_a_rubygem? RBT.action(:install_this_rubygem, local_path?) # Delegate to the specific action here. return end case i # ======================================================================= # # === configure # ======================================================================= # when 'configure' do_install_via_configure_then_make_then_make_install # ======================================================================= # # === meson # ======================================================================= # when 'meson' do_install_via_meson_then_use_ninja # ======================================================================= # # === cmake # ======================================================================= # when 'cmake' do_install_via_cmake else e opne tomato("Unhandled variant: #{i}") e opne 'Please register this compilation-mode or handle otherwise.' end end
do_extract_this_locally_existing_archive( what, to = '/tmp/' )
click to toggle source
#¶ ↑
do_extract_this_locally_existing_archive
¶ ↑
#¶ ↑
# File lib/rbt/compile_via_sql_database/compile_via_sql_database.rb, line 312 def do_extract_this_locally_existing_archive( what, to = '/tmp/' ) _result_containing_the_extracter_class = Extracter.what_to(what, to) end
Also aliased as: extract_the_program
do_install_via_cmake()
click to toggle source
do_install_via_configure_then_make_then_make_install()
click to toggle source
do_install_via_meson_then_use_ninja()
click to toggle source
#¶ ↑
do_install_via_meson_then_use_ninja
¶ ↑
#¶ ↑
# File lib/rbt/compile_via_sql_database/compile_via_sql_database.rb, line 161 def do_install_via_meson_then_use_ninja esystem "meson --prefix=#{use_which_prefix?} --libdir=#{use_which_prefix?}lib BUILD_DIRECTORY" cd 'BUILD_DIRECTORY' esystem 'ninja' esystem 'ninja install' end
do_the_actual_compilation( _ = location_of_the_database? )
click to toggle source
#¶ ↑
do_the_actual_compilation
¶ ↑
#¶ ↑
# File lib/rbt/compile_via_sql_database/compile_via_sql_database.rb, line 337 def do_the_actual_compilation( _ = location_of_the_database? ) cd(log_directory?) # We must always try to cd to the base directory. if File.exist? _ e rev+'Loading the sqlite database from '+sfile(_)+' next.' e steelblue(n_programs_are_available?.to_s)+ ' programs are available in that sqlite-database.' _ = compile_which_program? if _ and is_this_program_included_in_the_database?(_) e 'The program '+sfancy(_)+' is registered. Thus, proceeding to '\ 'compile / install it.' result = `sqlite3 #{location_of_the_database?} "select * from REGISTERED_PROGRAMS where PROGRAM_NAME = '#{_}';"` # =================================================================== # # Let's keep a reminder for how the splitted dataset may look like: # # 2604, php, /home/x/src/php/php-8.1.9.tar.xz, 8.1.9, # /home/Temp/rbt/php-8.1.9/, configure, 1, unknown, # php-8.1.9, https://www.php.net/, .tar.xz, 11787892 # # =================================================================== # splitted = result.strip.split('|') local_path = splitted[2] # is at 2. set_local_path(local_path) # Keep a reference, for later use. original_extract_where_to = splitted[4].dup # is at 4. compile_how = splitted[5] # is at 5. archive_type = splitted[10] # is at 10. @internal_hash[:archive_type] = archive_type @internal_hash[:program_name_and_program_version] = splitted[8] extract_where_to = rds( File.dirname(original_extract_where_to)+'/' ) e 'The assumed local path is:' e e sfancy(" #{local_path}") e # =================================================================== # # Check whether the file exists locally. # =================================================================== # if File.exist?(local_path) e 'The file exists locally. Proceeding to compile/install it.' do_extract_this_locally_existing_archive( local_path, extract_where_to ) unless is_it_a_rubygem?(local_path) cd original_extract_where_to do_compile_via_this_variant(compile_how) unless are_we_on_windows? handle_postinstallation_symlink end else e 'The file does not exist locally. Trying '\ 'to download it next.' end else e 'The program '+steelblue(_)+' is NOT included. Please provide' e 'a registered program.' end else no_file_exists_at(_) end end
handle_postinstallation_symlink()
click to toggle source
internal_hash_archive_type?()
click to toggle source
is_it_a_rubygem?( i = internal_hash_archive_type? )
click to toggle source
is_this_program_included_in_the_database?(i)
click to toggle source
#¶ ↑
is_this_program_included_in_the_database?¶ ↑
#¶ ↑
# File lib/rbt/compile_via_sql_database/compile_via_sql_database.rb, line 322 def is_this_program_included_in_the_database?(i) result = `sqlite3 #{location_of_the_database?} "select * from REGISTERED_PROGRAMS where PROGRAM_NAME = '#{i}';"` result and result.include?('|') and (result.split('|')[1] == i) end
Also aliased as: is_this_program_included?
local_path?()
click to toggle source
location_of_the_database?()
click to toggle source
#¶ ↑
location_of_the_database?¶ ↑
#¶ ↑
# File lib/rbt/compile_via_sql_database/compile_via_sql_database.rb, line 105 def location_of_the_database? @internal_hash[:location_of_the_database] end
Also aliased as: database_location?
makes_use_of_an_appdir_prefix?()
click to toggle source
map_the_first_argument_onto_the_compile_this_program_variable( i = first_argument? )
click to toggle source
#¶ ↑
map_the_first_argument_onto_the_compile_this_program_variable
¶ ↑
This is normally called before menu().
#¶ ↑
# File lib/rbt/compile_via_sql_database/compile_via_sql_database.rb, line 451 def map_the_first_argument_onto_the_compile_this_program_variable( i = first_argument? ) set_compile_this_program(i) end
n_programs_are_available?()
click to toggle source
#¶ ↑
n_programs_are_available
?¶ ↑
#¶ ↑
# File lib/rbt/compile_via_sql_database/compile_via_sql_database.rb, line 130 def n_programs_are_available? available_programs?.size end
Also aliased as: n_programs_available?, n_programs_are_available
program_name_and_program_version?()
click to toggle source
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
Calls superclass method
RBT::CompileBase#reset
# File lib/rbt/compile_via_sql_database/compile_via_sql_database.rb, line 47 def reset super() try_to_require_the_extracter_gem # ======================================================================= # # === :location_of_the_database # ======================================================================= # @internal_hash[:location_of_the_database] = DEFAULT_LOCATION_OF_THE_DATABASE # ======================================================================= # # === :use_this_prefix # ======================================================================= # @internal_hash[:use_this_prefix] = RBT::Prefix.new('/usr/') # ======================================================================= # # === :local_path # ======================================================================= # set_local_path(nil) # ======================================================================= # # === :archive_type # ======================================================================= # @internal_hash[:archive_type] = nil end
return_a_random_program_from_the_sqlite_database()
click to toggle source
#¶ ↑
return_a_random_program_from_the_sqlite_database
(random tag)¶ ↑
#¶ ↑
# File lib/rbt/compile_via_sql_database/compile_via_sql_database.rb, line 281 def return_a_random_program_from_the_sqlite_database cmd = "SELECT * FROM REGISTERED_PROGRAMS ORDER BY RANDOM() LIMIT 1;" result = `sqlite3 #{location_of_the_database?} "#{cmd}"` if result and result.include? '|' result = result.split('|')[1] end return result end
run()
click to toggle source
run_make()
click to toggle source
run_make_install()
click to toggle source
run_make_then_make_install()
click to toggle source
set_compile_this_program( i = :random )
click to toggle source
#¶ ↑
set_compile_this_program
¶ ↑
#¶ ↑
# File lib/rbt/compile_via_sql_database/compile_via_sql_database.rb, line 112 def set_compile_this_program( i = :random ) case i # ======================================================================= # # === :random # # In this case we query directly from the sqlite-database. # ======================================================================= # when :random i = return_a_random_program_from_the_sqlite_database end @internal_hash[:compile_this_program] = i.to_s end
set_local_path(i)
click to toggle source
set_prefix(i)
click to toggle source
#¶ ↑
set_prefix
¶ ↑
#¶ ↑
# File lib/rbt/compile_via_sql_database/compile_via_sql_database.rb, line 86 def set_prefix(i) case i # ======================================================================= # # === :appdir_prefix # ======================================================================= # when :appdir_prefix result = `sqlite3 #{location_of_the_database?} "select * from REGISTERED_PROGRAMS where PROGRAM_NAME = '#{compile_which_program?}';"`.split('|')[8] i = return_appdir_prefix_for( result ) end i = i.to_s i << '/' unless i.end_with? '/' @internal_hash[:use_this_prefix].set_new_prefix(i) end
Also aliased as: set_new_prefix