Class: RBT::CompileViaSQLDatabase
- Inherits:
-
CompileBase
show all
- Defined in:
- lib/rbt/compile_via_sql_database/compile_via_sql_database.rb
Overview
RBT::CompileViaSQLDatabase
Constant Summary
collapse
- DEFAULT_LOCATION_OF_THE_DATABASE =
#
DEFAULT_LOCATION_OF_THE_DATABASE
#
::RBT.log_dir?+'database/registered_programs.db'
RBT::CompileBaseModule::FILE_AUTOGEN
LeanPrototype::ALL_COLOUR_METHODS, LeanPrototype::ARRAY_KDE_KONSOLE_COLOURS_IN_USE, LeanPrototype::DAY_NAMES, LeanPrototype::NAMESPACE, LeanPrototype::SILENT_REDIRECTION
Class Method Summary
collapse
Instance Method Summary
collapse
#always_show_dependencies?, #capitalize_program_names?, #cflags?, #check_whether_we_will_install_only_programs_from_the_bin_subdirectory, #cleanup_system_tag_directory, #config?, #consider_removing_libtool_la_files, #consider_symlinking_cmake_modules, #consider_symlinking_header_files_into_the_usr_include_hierarchy, #consider_symlinking_lib64_into_lib, #cookbook_dataset_autosymlink_lib64?, #cookbook_dataset_program_version?, #create_a_new_current_symlink_here, #create_architecture_file, #do_invoke_symlink_program, #do_play_song, #editor_to_use?, #email?, #exit_on_unregistered_cookbook_entries?, #has_an_error_occurred?, #host_cpu?, #install_only_binaries?, #installer_constant?, make_command?, #no_error_has_occurred?, #play_song?, #recipes_dir?, #register_program, #remove_compiling_is_in_progress, #report_to_developers, #reset_the_module, #return_build_type, #return_chained_programs, #return_files_from_the_profiles_directory, #return_these_programs, #run_ldconfig?, #shall_we_symlink_the_header_files_into_the_usr_include_hierarchy?, #store_full_configure_command_into_resources_directory, #symlink_into_tags, #symlink_into_usr_lib_dir?, #symlink_m4_macros, #symlink_program, #symlink_program?, #update_kde_apps, #use_ccache?, #use_gobolinux_symlinkprogram?, #use_mrxvt?, #use_porg?, #use_stow?, #use_tags?, #uses_appdir_prefix?, #validate_the_cookbook_aliases
Methods inherited from Base
#cat, #cd_back_to_the_current_working_directory, #consider_reporting_how_many_programs_are_registered, #cookbook_files?, #copy_recursively, #delete_code_of_conduct?, #determine_appdir_prefix_from_this_input, #directory_validation?, #do_not_show_names, #fast_return_file_size_of_this_program, #file_last_symlinked_program?, #file_programs_version_url, #gem_version, #is_a_64bit_system?, #is_ccache_available?, #is_porg_available?, #is_this_binary_registered?, #make_command?, #make_install_command?, #new_cookbook_instance_for, #program_exists?, #publish_list_of_all_programs_version, #rcp, registered_binaries?, #remove_symlink, #rename_kde_konsole_tab, #repackage, #report_n_programs, #report_working_directory, #return_compile_time_statistics, #return_n_random_characters, #return_version_of_this_program, #sanitize_url1_entry, #set_source_directory, #show_overview_over_available_utility_scripts, #symlink_all_files_from_this_directory_to_that_directory, #system_tags?, #upload_list_of_all_programs_version, #use_yaml_database_for_tags?, #warn_and_exit, #wget
#a_or_an?, #abbreviations?, #absolute_path, #action, #add_to_the_commandline_arguments, #all_binaries?, #all_files_from, #all_libraries?, #allowed_cookbook_entries?, #appdir_location_of?, #append_onto_the_internal_hash, #append_what_into, #archive_type_of?, #be_quiet?, #be_verbose?, #begins_with_a_comment?, #capitalize_first_alphabetical_character, #cd_to_the_log_directory, #cd_to_the_temp_directory, #change_directory, #change_permission, #cheering_person?, #chmod, #chop_off_archive, #clear_commandline_arguments, #cliner, #coloured_and_padded_e, #coloured_and_padded_esystem, #coloured_esystem, #colourize_directory_for_system_results, #colourize_this_error, #colourize_this_file_path, #colourize_this_warning, #commandline_arguments?, #commandline_arguments_without_hyphens?, #comment, #convert_dd_mm_yyyy_to_its_long_variant, #convert_env_variable, #copy_directory, #copy_files, #cpr, #create_directory, #current_hour?, #dd_mmm_yyy, #debug, #debug?, #directory_expanded_cookbooks?, #disable_colours, #display_md5sum?, #do_not_debug, #does_the_cookbook_include_this_program?, #does_this_expanded_cookbook_file_exist_for_this_program?, #does_this_file_exist?, #does_this_file_exist_and_is_it_a_file?, #e, #eblue, #ecomment, #ecrimson, #edir, #editor?, #efancy, #eimp, #enable_colours, #enable_debug, #ensure_main_encoding_for, #eparse, #esystem, #esystem_gold, #etomato, #ewarn, #exit_program, #expanded_cookbooks_directory_exists?, #extract_this_archive, #extract_to?, #file_compiled_programs?, #file_dirname_retaining_trailing_slash, #file_predefined_installation_instructions?, #file_specification_of_registered_cookbook_entries, #find_cookbook_alias_for, #find_this_yaml_file, #first_argument?, #first_non_hyphen_argument?, #get_all_directories_from, #get_all_files_from, #get_all_programs, #get_date, #get_extended_date, #get_files_and_directories_from, #go_to_base_dir, #home_dir?, #host_system?, #infer_the_namespace, #internal_hash?, #internal_hash_set_commandline_arguments, #is_an_archive?, #is_directory?, #is_file?, #is_github_url?, #is_make_available?, #is_meson_installed?, #is_on_gobolinux?, #is_on_windows?, #is_roebe?, #is_superuser?, #is_symlink?, #is_this_a_header?, #is_this_a_library?, #iso_encoding?, #load_dataset_from_this_expanded_cookbook, #load_yaml, #load_yaml_file_from_the_cookbook_directory_for_this_program, #log_directory?, #main_encoding?, #meson_build_file_exists?, #months?, #move_file, #namespace?, #no_directory_exists_at, #no_directory_was_found_at, #no_opn, #no_such_file_exists, #open_in_browser, #open_in_editor, #opncomment, #opne, #opnef, #opnerev, #opnerror, #opnesystem, #opnewarn, #opnfancy, #opnn, #packages_directory?, #path_to_this_expanded_cookbooks_dataset, #pkgconfig_directory?, #populate_the_internal_hash_with_default_values, #predefined_installation_instructions?, #prepend_this_commandline_argument, #program_version_of?, #project_base_directory?, #project_yaml_directory?, #query_path?, #rarrow?, #read_file, #read_file_in_default_encoding, #read_file_with_default_encoding, #readlines, #readlines_with_proper_encoding, #register_sigint, #registered_cookbook_entries?, #remove, #remove_archive_from_the_end, #remove_comments_from_each_line, #remove_directory, #remove_double_slashes, #remove_file, #remove_newlines, #remove_parens, #remove_symlink, #remove_the_first_commandline_argument, #remove_this_commandline_argument, #remove_this_entry_from_the_commandline_arguments, #remove_trailing_ANSII_escape_code, #remove_unnecessary_data_from_url, #rename, #report_pwd, #require_the_rbt_aliases, #reset_the_internal_hash, #return_all_archives_from_this_directory, #return_appdir_prefix, #return_commandline_arguments_with_leading_hyphens, #return_current_hour_minutes_second, #return_date, #return_day_of_the_month_based_on_utc, #return_full_time, #return_hours_minutes_seconds_based_on_utc, #return_location_to_this_programs_yaml_file, #return_month_based_on_this_number, #return_month_based_on_utc, #return_opnn, #return_program_information, #return_program_name_for_gobolinux_systems, #return_pwd, #return_unicode_warning_symbol_or_empty_string, #return_utc, #return_utc_time_in_a_format_similar_to_slackware, #return_weekday_based_on_utc, #return_year_based_on_utc, #rev, #run_simulation=, #run_simulation?, #sdir, #sdir_return_pwd, #set_be_silent, #set_be_verbose, #set_first_commandline_argument, #set_namespace, #set_use_opn, #set_xorg_buffer, #sfancy, #sfile, #silent_redirection?, #silently_create_this_directory_if_it_does_not_yet_exist, #simp, #source_base_directory?, #ssym, #stderr, #store_into_this_directory?, #string_right_arrow?, #swarn, #symlink, #sysbin_directory?, #sysetc_directory?, #sysinclude_directory?, #syslib_directory?, #sysshare_directory?, #system_directory?, #temp_directory?, #to_bool, #to_camelcase, #to_iso_encoding, #to_unicode, #today?, #touch, #try_to_require_beautiful_url, #try_to_require_the_environment_information_gem, #try_to_require_the_extracter_gem, #try_to_require_the_open_gem, #try_to_require_the_xorg_buffer, #try_to_require_wget, #try_to_return_a_special_compile_component, #unicode_cliner, #unicode_middle_cliner, #use_colours=, #use_colours?, #use_opn=, #use_opn?, #utf_encoding?, #verbose_truth, #word_wrap, #write_what_into, #write_what_into_via_unicode, #yes_or_no
Constructor Details
#initialize(i = ARGV, run_already = true) ⇒ CompileViaSQLDatabase
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 25
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
when :do_not_run_yet
run_already = false
end
run if run_already
end
|
Class Method Details
.location_of_the_database? ⇒ Boolean
#
RBT::CompileViaSQLDatabase.location_of_the_database?
#
328
329
330
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 328
def self.location_of_the_database?
DEFAULT_LOCATION_OF_THE_DATABASE
end
|
Instance Method Details
#assumed_local_file_path_for?(this_program) ⇒ Boolean
#
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.
#
255
256
257
258
259
260
261
262
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 255
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] end
return this_program
end
|
#assumed_version_of_this_program?(this_program) ⇒ Boolean
#
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.
#
295
296
297
298
299
300
301
302
303
304
305
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 295
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] result = ProgramInformation.return_version(File.basename(result))
end
return result
end
|
#available_programs? ⇒ Boolean
267
268
269
270
271
272
273
274
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 267
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? ⇒ Boolean
Also known as:
program_name_that_is_to_be_installed?
#
compile_which_program?
#
152
153
154
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 152
def compile_which_program?
@internal_hash[:compile_this_program].to_s
end
|
#database_location? ⇒ Boolean
#
location_of_the_database?
#
database_location?
105
106
107
|
# 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
|
#do_compile_via_this_variant(i) ⇒ Object
#
do_compile_via_this_variant
#
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 408
def do_compile_via_this_variant(i)
if is_it_a_rubygem?
RBT.action(:install_this_rubygem, local_path?) return
end
case i
when 'configure'
do_install_via_configure_then_make_then_make_install
when 'meson'
do_install_via_meson_then_use_ninja
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
|
310
311
312
313
314
315
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 310
def (
what,
to = '/tmp/'
)
= Extracter.what_to(what, to)
end
|
#do_install_via_cmake ⇒ Object
#
do_install_via_cmake (cmake tag)
#
199
200
201
202
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 199
def do_install_via_cmake
esystem "cmake -DCMAKE_INSTALL_PREFIX=#{use_which_prefix?} ."
run_make_then_make_install
end
|
169
170
171
172
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 169
def do_install_via_configure_then_make_then_make_install
esystem "./configure --prefix=#{use_which_prefix?}"
run_make_then_make_install
end
|
#do_install_via_meson_then_use_ninja ⇒ Object
#
do_install_via_meson_then_use_ninja
#
159
160
161
162
163
164
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 159
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?
) ⇒ Object
#
do_the_actual_compilation
#
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 335
def do_the_actual_compilation(
_ = location_of_the_database?
)
cd(log_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 = '#{_}';"`
splitted = result.strip.split('|')
local_path = splitted[2] set_local_path(local_path) = splitted[4].dup compile_how = splitted[5] archive_type = splitted[10] @internal_hash[:archive_type] = archive_type
@internal_hash[:program_name_and_program_version] = splitted[8]
= rds(
File.dirname()+'/'
)
e 'The assumed local path is:'
e
e sfancy(" #{local_path}")
e
if File.exist?(local_path)
e 'The file exists locally. Proceeding to compile/install it.'
(
local_path,
) unless is_it_a_rubygem?(local_path)
cd
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 ⇒ Object
#
handle_postinstallation_symlink
#
458
459
460
461
462
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 458
def handle_postinstallation_symlink
if makes_use_of_an_appdir_prefix?
action(:to_current, prefix?.to_s)
end
end
|
#internal_hash_archive_type? ⇒ Boolean
#
internal_hash_archive_type?
#
77
78
79
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 77
def internal_hash_archive_type?
@internal_hash[:archive_type]
end
|
#is_it_a_rubygem?(i = internal_hash_archive_type?
) ⇒ Boolean
#
is_it_a_rubygem? (gem tag)
#
136
137
138
139
140
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 136
def is_it_a_rubygem?(
i = internal_hash_archive_type?
)
i.end_with?('.gem')
end
|
#is_this_program_included_in_the_database?(i) ⇒ Boolean
Also known as:
is_this_program_included?
#
is_this_program_included_in_the_database?
#
320
321
322
323
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 320
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
|
#local_path? ⇒ Boolean
145
146
147
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 145
def local_path?
@internal_hash[:local_path]
end
|
#location_of_the_database? ⇒ Boolean
#
location_of_the_database?
#
103
104
105
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 103
def location_of_the_database?
@internal_hash[:location_of_the_database]
end
|
#makes_use_of_an_appdir_prefix? ⇒ Boolean
#
makes_use_of_an_appdir_prefix?
#
401
402
403
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 401
def makes_use_of_an_appdir_prefix?
use_this_prefix_object?.makes_use_of_an_appdir_prefix? end
|
#map_the_first_argument_onto_the_compile_this_program_variable(i = first_argument?
) ⇒ Object
#
map_the_first_argument_onto_the_compile_this_program_variable
This is normally called before menu().
#
449
450
451
452
453
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 449
def map_the_first_argument_onto_the_compile_this_program_variable(
i = first_argument?
)
set_compile_this_program(i)
end
|
#
Invocation examples:
sqler --random-program
sqler RANDOM
sqler random
#
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 228
def (
i = commandline_arguments?
)
if i and i.is_a?(Array)
i.each {|entry| (entry) }
else
case i
when /^-?-?ntrad/i
set_new_prefix(:appdir_prefix)
when /^-?-?RANDOM/i
set_compile_this_program(:random)
end
end
end
|
#n_programs_are_available? ⇒ Boolean
Also known as:
n_programs_available?, n_programs_are_available
#
n_programs_are_available?
#
128
129
130
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 128
def n_programs_are_available?
available_programs?.size
end
|
#program_name_and_program_version? ⇒ Boolean
#
program_name_and_program_version?
#
440
441
442
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 440
def program_name_and_program_version?
@internal_hash[:program_name_and_program_version]
end
|
#reset ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 45
def reset
super()
@internal_hash[:location_of_the_database] =
DEFAULT_LOCATION_OF_THE_DATABASE
@internal_hash[:use_this_prefix] = action(:prefix, '/usr/')
set_local_path(nil)
@internal_hash[:archive_type] = nil
end
|
#return_a_random_program_from_the_sqlite_database ⇒ Object
#
return_a_random_program_from_the_sqlite_database (random tag)
#
279
280
281
282
283
284
285
286
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 279
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 ⇒ Object
467
468
469
470
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 467
def run
do_the_actual_compilation
end
|
#run_make ⇒ Object
214
215
216
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 214
def run_make
esystem 'make'
end
|
#run_make_install ⇒ Object
207
208
209
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 207
def run_make_install
esystem 'make install'
end
|
#run_make_then_make_install ⇒ Object
#
run_make_then_make_install
#
177
178
179
180
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 177
def run_make_then_make_install
run_make
run_make_install
end
|
#set_compile_this_program(i = :random) ⇒ Object
#
set_compile_this_program
#
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 110
def set_compile_this_program(
i = :random
)
case i
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) ⇒ Object
70
71
72
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 70
def set_local_path(i)
@internal_hash[:local_path] = i
end
|
#set_prefix(i) ⇒ Object
Also known as:
set_new_prefix
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 84
def set_prefix(i)
case i
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
|
#use_this_prefix? ⇒ Boolean
Also known as:
use_this_prefix_object?
192
193
194
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 192
def use_this_prefix?
@internal_hash[:use_this_prefix]
end
|
#use_which_prefix? ⇒ Boolean
Also known as:
prefix?
185
186
187
|
# File 'lib/rbt/compile_via_sql_database/compile_via_sql_database.rb', line 185
def use_which_prefix?
@internal_hash[:use_this_prefix].to_s
end
|