Class: Easycompile::Base
- Inherits:
-
Object
show all
- Includes:
- Colours, Constants
- Defined in:
- lib/easycompile/base/colours.rb,
lib/easycompile/base/gem.rb,
lib/easycompile/base/opn.rb,
lib/easycompile/base/run.rb,
lib/easycompile/base/help.rb,
lib/easycompile/base/menu.rb,
lib/easycompile/base/misc.rb,
lib/easycompile/base/cmake.rb,
lib/easycompile/base/reset.rb,
lib/easycompile/base/remove.rb,
lib/easycompile/base/esystem.rb,
lib/easycompile/base/constants.rb,
lib/easycompile/base/initialize.rb,
lib/easycompile/base/meson_and_ninja.rb,
lib/easycompile/base/change_directory.rb,
lib/easycompile/base/process_the_input.rb,
lib/easycompile/base/commandline_arguments.rb
Overview
Constant Summary
collapse
- 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.
#
"#{PROJECT_BASE_DIR}base/misc.rb"
Constants included
from Constants
Constants::ARRAY_POSSIBLE_ARCHIVES, Constants::CMAKE_FILE, Constants::ERROR_LINE, Constants::FILE_NAME_OF_THE_BUILD_DIRECTORY, Constants::INDIVIDUAL_COOKBOOKS, Constants::LAST_DOWNLOADED_FILE, Constants::LOCATION_OF_SETUP_RB, Constants::MESON_BUILD_FILE, Constants::NAMESPACE, Constants::PROGRAMS_DIRECTORY, Constants::RUBY_SRC, Constants::SHALL_WE_CREATE_A_BUILD_DIRECTORY, Constants::SRC_DIR, Constants::TEMP_DIR
Class Method Summary
collapse
-
.version? ⇒ Boolean
# === Easycompile::Base.version? ========================================================================= #.
Instance Method Summary
collapse
-
#add_this_archive(i) ⇒ Object
(also: #add_to_commandline_arguments, #set_files, #add_these_files, #add)
# === add_this_archive (add tag) ========================================================================= #.
-
#are_we_on_gobolinux? ⇒ Boolean
# === are_we_on_gobolinux? ========================================================================= #.
-
#attempt_to_find_a_valid_file(i) ⇒ Object
# === attempt_to_find_a_valid_file.
-
#base_dir? ⇒ Boolean
# === base_dir` ========================================================================= #.
-
#can_not_continue ⇒ Object
# === can_not_continue.
-
#change_directory(i) ⇒ Object
(also: #cd)
# === change_directory (cd tag).
-
#check_for_dependencies ⇒ Object
# === check_for_dependencies ========================================================================= #.
-
#cmake_file? ⇒ Boolean
# === cmake_file?.
-
#commandline_arguments? ⇒ Boolean
# === commandline_arguments? ========================================================================= #.
-
#compile_as_meson_based_project ⇒ Object
# === compile_as_meson_based_project ========================================================================= #.
-
#compile_these_programs? ⇒ Boolean
(also: #files?, #file?)
# === compile_these_programs?.
-
#consider_creating_a_build_directory(where = return_pwd) ⇒ Object
# === consider_creating_a_build_directory.
-
#consider_removing_the_archive(i = @build_directory_is_stored_here) ⇒ Object
(also: #consider_removing_this_archive, #consider_purging_empty_build_directory)
# === consider_removing_the_archive ========================================================================= #.
-
#consider_symlinking_appdir ⇒ Object
# === consider_symlinking_appdir.
-
#continue_after_extracting? ⇒ Boolean
-
#continue_past_configure_stage? ⇒ Boolean
-
#copy_setup_rb ⇒ Object
# === copy_setup_rb ========================================================================= #.
-
#cparser_is_available? ⇒ Boolean
# === cparser_is_available?.
-
#determine_which_programs_to_compile ⇒ Object
# === determine_which_programs_to_compile ========================================================================= #.
-
#do_compile_with_dependencies ⇒ Object
# === do_compile_with_dependencies ========================================================================= #.
-
#do_make_use_of_a_build_directory ⇒ Object
# === do_make_use_of_a_build_directory ========================================================================= #.
-
#do_not_compile ⇒ Object
# === do_not_compile ========================================================================= #.
-
#do_not_continue ⇒ Object
# === do_not_continue.
-
#do_not_create_a_build_directory ⇒ Object
# === do_not_create_a_build_directory.
-
#do_remove_all_after_compile ⇒ Object
# === do_remove_all_after_compile ========================================================================= #.
-
#does_a_meson_build_file_exist? ⇒ Boolean
# === does_a_meson_build_file_exist? ========================================================================= #.
-
#e_colourize(i) ⇒ Object
# === e_colourize ========================================================================= #.
-
#ecomment(i) ⇒ Object
-
#empty_dir?(i) ⇒ Boolean
# === empty_dir? ========================================================================= #.
-
#enable_skip_make_install ⇒ Object
# === enable_skip_make_install ========================================================================= #.
-
#enter_extracted_directory(i = @original_input) ⇒ Object
-
#esystem(i) ⇒ Object
(also: #_)
# === esystem.
-
#extract_to_this_directory? ⇒ Boolean
(also: #extract_to?)
-
#filename ⇒ Object
(also: #filename?)
# === filename ========================================================================= #.
-
#find_partial_match_for(i) ⇒ Object
# === find_partial_match_for ========================================================================= #.
-
#find_this_program? ⇒ Boolean
(also: #find_which_program?)
# === find_this_program? ========================================================================= #.
-
#get_dataset_from(i) ⇒ Object
# === get_dataset_from ========================================================================= #.
-
#get_program_name(i = @original_input) ⇒ Object
# === get_program_name.
-
#initialize(commandline_arguments = ARGV, run_already = true) ⇒ Base
constructor
# === initialize ========================================================================= #.
-
#install_this_gem(i) ⇒ Object
# === install_this_gem.
-
#internal_system(i) ⇒ Object
# === internal_system.
-
#is_a_gem?(i) ⇒ Boolean
# === is_a_gem? ========================================================================= #.
-
#is_an_appdir? ⇒ Boolean
# === is_an_appdir?.
-
#is_archive?(i) ⇒ Boolean
(also: #is_an_archive?)
# === is_archive?.
-
#is_the_cookbook_class_available? ⇒ Boolean
# === is_the_cookbook_class_available? ========================================================================= #.
-
#make_distclean ⇒ Object
# === make_distclean ========================================================================= #.
-
#menu(i = commandline_arguments? ) ⇒ Object
-
#mkdir(i) ⇒ Object
# === mkdir (mkdir tag) ========================================================================= #.
-
#name_of_build_directory? ⇒ Boolean
(also: #name_for_build_dir?, #name_of_the_build_directory?)
# === name_of_build_directory?.
-
#ninjait ⇒ Object
# === ninjait ========================================================================= #.
-
#open_this_file(this_file = self.class::THIS_FILE) ⇒ Object
# === open_this_file ========================================================================== #.
-
#opn_namespace ⇒ Object
# === opn_namespace.
-
#original_input? ⇒ Boolean
-
#prefix? ⇒ Boolean
# === prefix? ========================================================================= #.
-
#process_the_input(i = compile_these_programs? ) ⇒ Object
-
#program_name? ⇒ Boolean
# === program_name? ========================================================================= #.
-
#program_version? ⇒ Boolean
(also: #version?)
# === program_version? ========================================================================= #.
-
#rds(i) ⇒ Object
# === rds ========================================================================= #.
-
#remove_all_after_compile? ⇒ Boolean
# === remove_all_after_compile? ========================================================================= #.
-
#remove_directory(i = nil) ⇒ Object
(also: #remove_this_directory)
# === remove_directory.
-
#remove_extension_from(i) ⇒ Object
(also: #remove_file_suffix, #remove_archive_at_the_end)
# === remove_extension_from ========================================================================= #.
-
#remove_this_archive(i) ⇒ Object
# === remove_this_archive.
-
#remove_this_file(i) ⇒ Object
(also: #remove)
# === remove_this_file ========================================================================= #.
-
#replace_all_yaml_files(i = @commandline_arguments) ⇒ Object
# === replace_all_yaml_files ========================================================================= #.
-
#reset ⇒ Object
# === reset (reset tag).
-
#return_all_arguments_with_hyphens ⇒ Object
# === return_all_arguments_with_hyphens.
-
#return_pwd ⇒ Object
# === return_pwd ========================================================================= #.
-
#return_to_start_directory_again ⇒ Object
# === return_to_start_directory_again ========================================================================= #.
-
#return_yaml_file(i) ⇒ Object
# === return_yaml_file ========================================================================= #.
-
#rev ⇒ Object
# === rev ========================================================================= #.
-
#run ⇒ Object
# === run (run tag) ========================================================================= #.
-
#run_build_sh ⇒ Object
# === run_build_sh.
-
#run_cmake_command ⇒ Object
(also: #run_cmake)
# === run_cmake_command (cmake tag).
-
#run_configure ⇒ Object
(also: #run_configure_command, #run_configure_command_or_another_command, #run_configure_or_cmake)
-
#run_configure_make_and_make_install ⇒ Object
(also: #run_configure_then_make_then_make_install)
-
#run_make_command_or_equivalent ⇒ Object
(also: #run_make_command, #run_make)
# === run_make_command_or_equivalent (make tag).
-
#run_make_install_command ⇒ Object
# === run_make_install_command.
-
#run_make_then_make_install ⇒ Object
# === run_make_then_make_install ========================================================================= #.
-
#run_perl_installation ⇒ Object
# === run_perl_installation ========================================================================= #.
-
#run_python_installation ⇒ Object
# === run_python_installation (python tag).
-
#run_rinstall2 ⇒ Object
# === run_rinstall2 ========================================================================= #.
-
#set_base_dir(i = return_pwd) ⇒ Object
# === set_base_dir ========================================================================= #.
-
#set_commandline_arguments(i) ⇒ Object
# === set_commandline_arguments ========================================================================= #.
-
#set_compile_these_programs(i) ⇒ Object
# === set_compile_these_programs.
-
#set_extract_to_this_directory(i = :default) ⇒ Object
(also: #set_extract_to)
-
#set_find_this_program(i) ⇒ Object
# === set_find_this_program.
-
#set_hash(i = {}) ⇒ Object
# === set_hash ========================================================================= #.
-
#set_name_of_build_directory(i = :default) ⇒ Object
# === set_name_of_build_directory ========================================================================= #.
-
#set_original_input(i) ⇒ Object
-
#set_prefix(i = '/usr') ⇒ Object
(also: #set_prefix_for_this_program)
# === set_prefix.
-
#set_program_name(i = nil) ⇒ Object
# === set_program_name.
-
#set_program_version(i) ⇒ Object
# === set_program_version ========================================================================= #.
-
#set_start_dir(i = return_pwd) ⇒ Object
# === set_start_dir ========================================================================= #.
-
#set_this_build_dir(i = :pwd) ⇒ Object
(also: #set_build_directory)
# === set_this_build_dir ========================================================================= #.
-
#shall_we_create_a_build_directory? ⇒ Boolean
# === shall_we_create_a_build_directory? ========================================================================= #.
-
#show_help(optional_shall_we_exit = false) ⇒ Object
# === show_help (help tag) ========================================================================= #.
-
#show_namespace ⇒ Object
# === show_namespace ========================================================================= #.
-
#simply_run_the_configure_command ⇒ Object
-
#skip_extracting ⇒ Object
-
#skip_extracting? ⇒ Boolean
-
#skip_make_install? ⇒ Boolean
# === skip_make_install? ========================================================================= #.
-
#start_dir? ⇒ Boolean
# === start_dir? ========================================================================= #.
-
#temp_dir? ⇒ Boolean
# === temp_dir? ========================================================================= #.
-
#temp_directory? ⇒ Boolean
# === temp_directory? ========================================================================= #.
-
#try_to_compile_or_install_this_program(this_archive) ⇒ Object
# === try_to_compile_or_install_this_program ========================================================================= #.
-
#try_to_extract(this_archive, extract_to = extract_to? ) ⇒ Object
(also: #extract_archive, #extract, #consider_extracting_this_archive)
-
#use_colours? ⇒ Boolean
# === use_colours? ========================================================================= #.
-
#use_the_home_directory_as_prefix ⇒ Object
# === use_the_home_directory_as_prefix ========================================================================= #.
Methods included from Constants
#ruby_src?, #source_dir?, temp_dir?
Constructor Details
#initialize(commandline_arguments = ARGV, run_already = true) ⇒ Base
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# 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
when :dont_run_yet,
:do_not_run_yet
run_already = false
end
run if run_already
end
|
Class Method Details
.version? ⇒ Boolean
#
Easycompile::Base.version?
#
137
138
139
|
# File 'lib/easycompile/base/misc.rb', line 137
def self.version?
Easycompile.version?
end
|
Instance Method Details
#add_this_archive(i) ⇒ Object
Also known as:
add_to_commandline_arguments, set_files, add_these_files, add
#
add_this_archive (add tag)
#
584
585
586
587
588
589
590
|
# 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
|
#are_we_on_gobolinux? ⇒ Boolean
289
290
291
|
# 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) ⇒ Object
#
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.
#
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
|
# 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
_ = Dir["#{entry}*"]
entry = _.first unless _.empty?
end
end
entry
}
end
return i
end
|
#base_dir? ⇒ Boolean
454
455
456
|
# File 'lib/easycompile/base/misc.rb', line 454
def base_dir?
@base_dir
end
|
#can_not_continue ⇒ Object
#
can_not_continue
Set @continue_past_configure_stage to false, so tha we won’t continue.
#
321
322
323
|
# File 'lib/easycompile/base/misc.rb', line 321
def can_not_continue
@continue_past_configure_stage = false
end
|
#change_directory(i) ⇒ Object
Also known as:
cd
#
change_directory (cd tag)
Use this method when changing directories.
#
16
17
18
19
20
21
22
23
24
25
26
|
# 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
|
#check_for_dependencies ⇒ Object
#
check_for_dependencies
#
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
|
# File 'lib/easycompile/base/misc.rb', line 598
def check_for_dependencies
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? ⇒ Boolean
#
cmake_file?
This method wille ssentially refer to “CMakeLists.txt”.
#
16
17
18
|
# File 'lib/easycompile/base/cmake.rb', line 16
def cmake_file?
CMAKE_FILE
end
|
#commandline_arguments? ⇒ Boolean
#
commandline_arguments?
#
14
15
16
|
# File 'lib/easycompile/base/commandline_arguments.rb', line 14
def commandline_arguments?
@commandline_arguments
end
|
#compile_as_meson_based_project ⇒ Object
#
compile_as_meson_based_project
#
14
15
16
17
18
19
|
# 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? ⇒ Boolean
Also known as:
files?, file?
#
compile_these_programs?
This method will return on which input-files we will be working on, that is our target-programs.
#
576
577
578
|
# File 'lib/easycompile/base/misc.rb', line 576
def compile_these_programs?
@compile_these_programs
end
|
#consider_creating_a_build_directory(where = return_pwd) ⇒ Object
#
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.
#
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
|
# 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+').'
mkdir @build_directory_is_stored_here end
cd @build_directory_is_stored_here
show_namespace
e 'Now entering the directory '+
sdir(@build_directory_is_stored_here)+'.'
end
end
|
#consider_removing_the_archive(i = @build_directory_is_stored_here) ⇒ Object
Also known as:
consider_removing_this_archive, consider_purging_empty_build_directory
#
consider_removing_the_archive
#
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
|
# 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)
remove_directory(i)
end
end
end
end
end
|
#consider_symlinking_appdir ⇒ Object
#
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.
#
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
|
# 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
|
328
329
330
|
# File 'lib/easycompile/base/misc.rb', line 328
def
@continue_after_extracting
end
|
275
276
277
|
# File 'lib/easycompile/base/misc.rb', line 275
def continue_past_configure_stage?
@continue_past_configure_stage
end
|
#copy_setup_rb ⇒ Object
106
107
108
|
# File 'lib/easycompile/base/misc.rb', line 106
def copy_setup_rb
FileUtils.cp(LOCATION_OF_SETUP_RB, return_pwd)
end
|
#cparser_is_available? ⇒ Boolean
#
cparser_is_available?
Determine whether we can use the ColourizeParser from the RBT project.
#
34
35
36
37
|
# 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 ⇒ Object
#
determine_which_programs_to_compile
#
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
|
# File 'lib/easycompile/base/misc.rb', line 933
def determine_which_programs_to_compile
if @commandline_arguments.empty?
_ = Dir['*'].select {|entry| is_an_archive?(entry) }
else
if @commandline_arguments.any? {|entry| entry.end_with? '.yml' }
@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 ⇒ Object
#
do_compile_with_dependencies
#
335
336
337
338
|
# 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 ⇒ Object
#
do_make_use_of_a_build_directory
#
282
283
284
|
# 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 ⇒ Object
375
376
377
378
|
# 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 ⇒ Object
#
do_not_continue
This method does not output anything to the user, on purpose.
#
368
369
370
|
# File 'lib/easycompile/base/misc.rb', line 368
def do_not_continue
@continue_after_extracting = false
end
|
#do_not_create_a_build_directory ⇒ Object
#
do_not_create_a_build_directory
Use this method if you do not wish to create a build directory.
#
160
161
162
|
# 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 ⇒ Object
#
do_remove_all_after_compile
#
65
66
67
68
|
# 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? ⇒ Boolean
#
does_a_meson_build_file_exist?
#
24
25
26
|
# 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) ⇒ Object
69
70
71
72
73
74
75
|
# File 'lib/easycompile/base/colours.rb', line 69
def e_colourize(i)
if use_colours?
e sfancy(i)
else
e i
end
end
|
80
81
82
83
84
85
86
|
# File 'lib/easycompile/base/colours.rb', line 80
def (i)
if use_colours?
::Colours.(i)
else
i
end
end
|
#empty_dir?(i) ⇒ Boolean
189
190
191
|
# File 'lib/easycompile/base/misc.rb', line 189
def empty_dir?(i)
Dir["#{i}/*"].empty?
end
|
#enable_skip_make_install ⇒ Object
#
enable_skip_make_install
#
343
344
345
346
|
# 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
|
#
We use this method to enter the extracted directory.
#
421
422
423
424
425
426
427
428
429
430
431
432
433
434
|
# File 'lib/easycompile/base/misc.rb', line 421
def (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? _ show_namespace; e "Now entering the directory `#{sdir(_)}`."
cd _
end
end
|
#esystem(i) ⇒ Object
Also known as:
_
#
esystem
Run a colourized system() command here.
This can either be through oldschool system(), or as of August 2017, preferentially via IO.popen().
#
20
21
22
23
24
25
26
|
# File 'lib/easycompile/base/esystem.rb', line 20
def esystem(i)
e_colourize(i) i = i.dup if i.frozen?
i << ERROR_LINE
@result = i internal_system(i) end
|
230
231
232
|
# File 'lib/easycompile/base/misc.rb', line 230
def
@extract_to_this_directory
end
|
#filename ⇒ Object
Also known as:
filename?
120
121
122
|
# File 'lib/easycompile/base/misc.rb', line 120
def filename
return File.basename(__FILE__)+':'
end
|
#find_partial_match_for(i) ⇒ Object
#
find_partial_match_for
#
127
128
129
130
131
132
|
# 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] end
|
#find_this_program? ⇒ Boolean
Also known as:
find_which_program?
53
54
55
|
# File 'lib/easycompile/base/misc.rb', line 53
def find_this_program?
@find_this_program
end
|
#get_dataset_from(i) ⇒ Object
890
891
892
893
894
895
896
897
898
899
900
901
|
# 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) ⇒ Object
#
get_program_name
Obtain the program name here.
#
983
984
985
986
987
988
989
|
# 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) ⇒ Object
#
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.
#
23
24
25
26
|
# File 'lib/easycompile/base/gem.rb', line 23
def install_this_gem(i)
_ = "gem install --ignore-dependencies #{i}"
esystem(_)
end
|
#internal_system(i) ⇒ Object
#
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.
#
46
47
48
49
50
51
52
53
54
55
56
57
|
# 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) line = cparser.line?
end
e line }
io_object.close end
|
#is_a_gem?(i) ⇒ Boolean
31
32
33
|
# File 'lib/easycompile/base/gem.rb', line 31
def is_a_gem?(i)
i.end_with? '.gem'
end
|
#is_an_appdir? ⇒ Boolean
#
is_an_appdir?
Return true if this is an appdir-based program.
#
926
927
928
|
# File 'lib/easycompile/base/misc.rb', line 926
def is_an_appdir?
@hash.has_key?(:prefix) and @hash[:prefix] == :appdir
end
|
#is_archive?(i) ⇒ Boolean
Also known as:
is_an_archive?
#
is_archive?
Return true if the given input is an archive.
#
385
386
387
|
# File 'lib/easycompile/base/misc.rb', line 385
def is_archive?(i)
::Easycompile.is_archive?(i)
end
|
#is_the_cookbook_class_available? ⇒ Boolean
#
is_the_cookbook_class_available?
#
881
882
883
884
885
|
# 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 ⇒ Object
1031
1032
1033
|
# File 'lib/easycompile/base/misc.rb', line 1031
def make_distclean
esystem 'make distclean'
end
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
# File 'lib/easycompile/base/menu.rb', line 14
def (
i = commandline_arguments?
)
if i.is_a? Array
i.each {|entry| (entry) }
else
case i
when /^-?-?home(_|-)?dir$/,
/^-?-?home(_|-)?directory$/,
/^-?-?home$/
set_prefix(:home_directory)
when /^-?-?help$/i,
/^-?h$/i
show_help :then_exit
when /^-?-?home(_|-)?dir$/i
use_the_home_directory_as_prefix
when /^-?-?OPEN(_|-)?ITSELF$/i,
/^-?-?OPEN$i/ open_this_file
exit
when /^-?-?all$/i,
/^-?-?everything$/i
set_compile_these_programs Dir['*']
when /^-?-?remove(_|-| )?all(_|-| )?after(_|-| )?compile$/i
do_remove_all_after_compile
when /^-?-?set(_|-| )?extract(_|-| )?to=(.+)$/i, /^-?-?extract(_|-| )?to=(.+)$/i _ = $2
_ = $3.to_s.dup if $3
(_) { :be_verbose }
when /^-?-?sco$/i,
/^-?-?extended-configure-options$/i,
/^-?-?use-configure-options$/i
@try_to_use_extended_configure_options = true
when /^-?-?wdeps$/i,
/^-?-?with(_|-| )?deps$/i
do_compile_with_dependencies
when /^-?-?SKIP_?MAKE_?INSTALL/i,
'NO_MAKE_INSTALL',
'NOMAKEINSTALL',
'NOINSTALL',
'SKIPINSTALL'
enable_skip_make_install when /^-?-?DONT(_|-| )?COMPILE$/i
enable_dont_compile
when 'SKIP_EXTRACT',
/^-?-?SKIP(_|-| )?EXTRACTING$/i,
'SKIPEXTRACTING'
when /^-?-?appdir$/i
set_prefix :appdir
opn; e 'Will compile as AppDir. The prefix now is '+simp(prefix?.to_s)
else if File.exist?(i) or i.end_with?('.yml')
add_this_archive(i)
else
i = attempt_to_find_a_valid_file(i)
if i.respond_to?(:select)
add_these_files(
i.select {|file|
File.exist? file.to_s
}
)
end
end
end
end
end
|
#mkdir(i) ⇒ Object
312
313
314
|
# File 'lib/easycompile/base/misc.rb', line 312
def mkdir(i)
FileUtils.mkdir_p(i)
end
|
#name_of_build_directory? ⇒ Boolean
Also known as:
name_for_build_dir?, name_of_the_build_directory?
#
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.
#
267
268
269
|
# File 'lib/easycompile/base/misc.rb', line 267
def name_of_build_directory?
@name_of_build_directory
end
|
#ninjait ⇒ Object
31
32
33
34
|
# 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) ⇒ Object
151
152
153
|
# 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 ⇒ Object
#
opn_namespace
We use a special namespace-name here.
#
16
17
18
|
# File 'lib/easycompile/base/opn.rb', line 16
def opn_namespace
opn(namespace: NAMESPACE)
end
|
305
306
307
|
# File 'lib/easycompile/base/misc.rb', line 305
def original_input?
@original_input
end
|
#prefix? ⇒ Boolean
73
74
75
|
# File 'lib/easycompile/base/misc.rb', line 73
def prefix?
@prefix
end
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/easycompile/base/process_the_input.rb', line 14
def process_the_input(
i = compile_these_programs?
)
i.each {|this_entry|
this_entry = Dir['*'].first if this_entry.nil?
this_entry = this_entry.to_s
this_entry.sub!(/\^/,'') if this_entry.include? '^' unless File.exist?(this_entry)
if this_entry =~ /^\d+$/
entries = Dir['*']
unless entries.empty?
this_entry = this_entry.to_i
this_entry = entries.size if this_entry > entries.size this_entry = entries.sort[ (this_entry.to_i - 1) ] end
end
end
if this_entry =~ /\.gem$/ do_not_create_a_build_directory end
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 if is_archive? _
this_entry = _
end end
unless this_entry.start_with?('--')
if File.directory? this_entry cd this_entry
consider_creating_a_build_directory
run_configure_make_and_make_install
else
if File.exist?(this_entry)
set_original_input(this_entry)
set_find_this_program(
ProgramInformation.return_name(this_entry)
)
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? ⇒ Boolean
523
524
525
|
# File 'lib/easycompile/base/misc.rb', line 523
def program_name?
@program_name
end
|
#program_version? ⇒ Boolean
Also known as:
version?
461
462
463
|
# File 'lib/easycompile/base/misc.rb', line 461
def program_version?
@program_version
end
|
#rds(i) ⇒ Object
46
47
48
|
# File 'lib/easycompile/base/misc.rb', line 46
def rds(i)
i.squeeze('/')
end
|
#remove_all_after_compile? ⇒ Boolean
#
remove_all_after_compile?
#
73
74
75
|
# File 'lib/easycompile/base/remove.rb', line 73
def remove_all_after_compile?
@remove_all_after_compile
end
|
#remove_directory(i = nil) ⇒ Object
Also known as:
remove_this_directory
#
remove_directory
This method will remove a directory (if the input argument is a directory that is).
#
17
18
19
20
21
22
23
|
# 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 == '/' end
end
|
#remove_extension_from(i) ⇒ Object
Also known as:
remove_file_suffix, remove_archive_at_the_end
#
remove_extension_from
#
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/easycompile/base/remove.rb', line 41
def remove_extension_from(i)
i = i.dup 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_this_archive(i) ⇒ Object
#
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.
#
32
33
34
35
36
|
# 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_file(i) ⇒ Object
Also known as:
remove
56
57
58
59
60
|
# 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
|
#replace_all_yaml_files(i = @commandline_arguments) ⇒ Object
#
replace_all_yaml_files
#
955
956
957
958
959
960
961
962
963
964
965
|
# 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 ⇒ Object
#
reset (reset tag)
The instance variable we will use here:
@prefix_to_base_directory
directory.
#
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
# File 'lib/easycompile/base/reset.rb', line 26
def reset
set_base_dir
set_start_dir
@commandline_arguments = []
@compile_these_programs = []
@program_name = nil
@compile_with_dependencies = false @program_version = '1.0.0' (:default)
@hash = {}
@skip_extracting = false @continue_after_extracting = true @build_directory_is_stored_here = nil
@continue_past_configure_stage = true
@skip_make_install = false
set_prefix @prefix_to_base_directory = ''
@shall_we_create_a_build_directory = SHALL_WE_CREATE_A_BUILD_DIRECTORY
@prefix = '/usr/'
@original_input = nil
@temp_directory = ::Easycompile.temp_directory?
@remove_all_after_compile = false
@try_to_use_extended_configure_options = false
if cparser_is_available?
@colourize_parser = RBT::ColourizeParser.new
else
@colourize_parser = nil
end
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 ⇒ Object
#
return_all_arguments_with_hyphens
This method will select all commandline arguments that begin with two – hyphens.
#
31
32
33
34
35
|
# 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 ⇒ Object
28
29
30
|
# File 'lib/easycompile/base/misc.rb', line 28
def return_pwd
("#{Dir.pwd}/").squeeze '/'
end
|
#return_to_start_directory_again ⇒ Object
#
return_to_start_directory_again
#
874
875
876
|
# File 'lib/easycompile/base/misc.rb', line 874
def return_to_start_directory_again
cd start_dir?
end
|
#return_yaml_file(i) ⇒ Object
970
971
972
973
974
975
976
|
# 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 ⇒ Object
58
59
60
61
62
63
64
|
# File 'lib/easycompile/base/colours.rb', line 58
def rev
if use_colours?
::Colours.rev
else
''
end
end
|
#run ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/easycompile/base/run.rb', line 14
def run
@start_dir = return_pwd
determine_which_programs_to_compile
(
return_all_arguments_with_hyphens
)
process_the_input
end
|
#run_build_sh ⇒ Object
#
run_build_sh
Run sh build.sh
#
1023
1024
1025
1026
|
# File 'lib/easycompile/base/misc.rb', line 1023
def run_build_sh
_ = "#{@prefix_to_base_directory}sh build.sh"
esystem _
end
|
#run_cmake_command ⇒ Object
Also known as:
run_cmake
#
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
#
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/easycompile/base/cmake.rb', line 32
def run_cmake_command
do_make_use_of_a_build_directory
_ = 'cmake'.dup
_ << " -DCMAKE_INSTALL_PREFIX=#{prefix?}"
_ << ' .'
_ << '.' if shall_we_create_a_build_directory? 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
|
#
This method runs the classical configure command with a specific prefix. It is equivalent to just run “./configure”.
#
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
|
# File 'lib/easycompile/base/misc.rb', line 737
def run_configure
if shall_we_create_a_build_directory?
@prefix_to_base_directory << '../'
end
if File.exist?(@prefix_to_base_directory+'Rakefile')
run_rinstall2
elsif File.exist?("#{@prefix_to_base_directory}#{cmake_file?}")
run_cmake_command
elsif File.exist?(@prefix_to_base_directory+'setup.py')
run_python_installation
elsif File.exist?(@prefix_to_base_directory+'Makefile.PL')
run_perl_installation
elsif File.exist? @prefix_to_base_directory+'configure'
simply_run_the_configure_command
elsif (@original_input =~ /\.gem$/)
install_this_gem(@original_input)
exit
elsif does_a_meson_build_file_exist?
compile_as_meson_based_project
exit
else 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
|
1047
1048
1049
1050
1051
1052
1053
|
# 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_make_command_or_equivalent ⇒ Object
Also known as:
run_make_command, run_make
#
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.
#
911
912
913
914
915
916
917
918
|
# 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 esystem 'make' if continue_past_configure_stage?
end
end
|
#run_make_install_command ⇒ Object
#
run_make_install_command
This will run “make install”.
#
1040
1041
1042
|
# 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 ⇒ Object
#
run_make_then_make_install
#
1058
1059
1060
1061
|
# 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 ⇒ Object
#
run_perl_installation
#
99
100
101
|
# File 'lib/easycompile/base/misc.rb', line 99
def run_perl_installation
_ 'perl Makefile.PL'
end
|
#run_python_installation ⇒ Object
#
run_python_installation (python tag)
This method will additionally check for a file called ‘configure’.
#
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
|
# 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 ⇒ Object
60
61
62
63
64
65
66
67
68
|
# 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) ⇒ Object
446
447
448
449
|
# File 'lib/easycompile/base/misc.rb', line 446
def set_base_dir(i = return_pwd)
i = i.squeeze('/')
@base_dir = i
end
|
#set_commandline_arguments(i) ⇒ Object
#
set_commandline_arguments
#
21
22
23
|
# 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) ⇒ Object
#
set_compile_these_programs
This method specifies which programs this class will compile.
#
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
|
# File 'lib/easycompile/base/misc.rb', line 676
def set_compile_these_programs(i)
i = [i].flatten.compact
i.map! {|entry|
unless File.exist? entry
case entry when 'ALL','A' entry = Dir['*'].reject {|inner_entry| File.directory? inner_entry }
when /LAST/,/LAT/ entry = File.readlines(LAST_DOWNLOADED_FILE).first
else if entry.include?('http') 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
|
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
# File 'lib/easycompile/base/misc.rb', line 196
def (i = :default)
case i
when :default,
nil
i = temp_dir?
end
i = i.to_s.dup
unless i.end_with? '/'
i = i.dup if i.frozen?
i << '/'
end
if block_given?
yielded = yield
case yielded
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
|
#set_find_this_program(i) ⇒ Object
#
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.
#
39
40
41
|
# File 'lib/easycompile/base/misc.rb', line 39
def set_find_this_program(i)
@find_this_program = i
end
|
#set_hash(i = {}) ⇒ Object
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
|
# File 'lib/easycompile/base/misc.rb', line 500
def set_hash(i = {})
if i.is_a? Hash
if i.has_key? :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) ⇒ Object
#
set_name_of_build_directory
#
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
|
# File 'lib/easycompile/base/misc.rb', line 244
def set_name_of_build_directory(
i = :default
)
case i
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
|
#
This method will keep track of the “original” input.
#
298
299
300
|
# File 'lib/easycompile/base/misc.rb', line 298
def set_original_input(i)
@original_input = i
end
|
#set_prefix(i = '/usr') ⇒ Object
Also known as:
set_prefix_for_this_program
#
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.
#
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
|
# File 'lib/easycompile/base/misc.rb', line 1086
def set_prefix(
i = '/usr'
)
if i.is_a? Symbol case i
when :home_directory,
:home_dir,
:home
i = ENV['HOME'].to_s
end
i = i.to_s i = remove_file_suffix(i)
case i
when /usr(_|-)?prefix/
i = '/usr/'
when 'appdir',
'app'
if @original_input and
File.exist?(@original_input) and
File.file?(@original_input) and
is_archive?(@original_input)
_ = remove_archive_at_the_end(
File.basename(
@original_input
)
)
set_program_name(_)
set_program_version(
ProgramInformation.return_version(@original_input)
)
end
i = "#{::Easycompile.programs_directory?}"\
"#{program_name?.to_s.capitalize.delete('-')}"\
"/#{program_version?}"
end
end
if i.is_a? String i = i.dup if i.frozen?
i = rds("#{i}/")
end
@prefix = i
end
|
#set_program_name(i = nil) ⇒ Object
#
set_program_name
Note that this method can make use of ProgramInformation.
#
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
|
# 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)
i = ProgramInformation.return_name(i) end
@program_name = i
end
|
#set_program_version(i) ⇒ Object
439
440
441
|
# File 'lib/easycompile/base/misc.rb', line 439
def set_program_version(i)
@program_version = i
end
|
#set_start_dir(i = return_pwd) ⇒ Object
174
175
176
177
|
# File 'lib/easycompile/base/misc.rb', line 174
def set_start_dir(i = return_pwd)
i.squeeze! '/'
@start_dir = i end
|
#set_this_build_dir(i = :pwd) ⇒ Object
Also known as:
set_build_directory
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# 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
|
#shall_we_create_a_build_directory? ⇒ Boolean
#
shall_we_create_a_build_directory?
#
237
238
239
|
# 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) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/easycompile/base/help.rb', line 14
def show_help(
optional_shall_we_exit = false
)
case optional_shall_we_exit
when :then_exit
optional_shall_we_exit = true
end
e
opn_namespace; e 'The following help options are documented:'
e
' --appdir # Compile as Appdir, into '\
'its own prefix.'
' --remove-all-after-compile # Remove '\
'the archive after compilation is done.'
' --with-deps '\
'# Compile with dependencies.'
' --extract-to=/Depot/opt/ '\
'# extract to that particular directory.'
' --homedir # '\
'Compile into the home-directory as prefix'
e
exit if optional_shall_we_exit
end
|
#show_namespace ⇒ Object
23
24
25
|
# File 'lib/easycompile/base/opn.rb', line 23
def show_namespace
opn(namespace: Constants::NAMESPACE)
end
|
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
|
# File 'lib/easycompile/base/misc.rb', line 808
def simply_run_the_configure_command
_ = ''.dup _ << '.' if shall_we_create_a_build_directory?
_ << "./configure --prefix=#{prefix?}"
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
esystem(_) 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 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
|
358
359
360
361
|
# File 'lib/easycompile/base/misc.rb', line 358
def
show_namespace; e 'We will not extract.'
@skip_extracting = true
end
|
351
352
353
|
# File 'lib/easycompile/base/misc.rb', line 351
def
@skip_extracting
end
|
#skip_make_install? ⇒ Boolean
167
168
169
|
# File 'lib/easycompile/base/misc.rb', line 167
def skip_make_install?
@skip_make_install
end
|
#start_dir? ⇒ Boolean
182
183
184
|
# File 'lib/easycompile/base/misc.rb', line 182
def start_dir?
@start_dir
end
|
#temp_dir? ⇒ Boolean
113
114
115
|
# File 'lib/easycompile/base/misc.rb', line 113
def temp_dir?
::Easycompile.temp_dir?
end
|
#temp_directory? ⇒ Boolean
144
145
146
|
# File 'lib/easycompile/base/misc.rb', line 144
def temp_directory?
@temp_directory
end
|
#try_to_compile_or_install_this_program(this_archive) ⇒ Object
#
try_to_compile_or_install_this_program
#
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
|
# 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
= (this_archive)
if
if File.directory?
()
consider_creating_a_build_directory
run_configure_make_and_make_install
end
end
end
end
|
#
Use this method here to extract a given archive.
#
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
|
# File 'lib/easycompile/base/misc.rb', line 621
def (
this_archive, =
)
if this_archive.is_a? Array this_archive = this_archive.first
end
cd start_dir?
if File.exist? this_archive.to_s
unless
show_namespace; e "Now trying to extract `#{sfancy(this_archive)}`."
@extracter = Extracter.what_to(this_archive, )
return remove_archive_at_the_end(
+
File.basename(this_archive)
)
else
nil
end
elsif File.exist? base_dir?+this_archive
unless
@extracter = Extracter.what_to(base_dir?+this_archive, )
end
else
if this_archive =~ /^\d+$/ this_archive = Dir['*'].sort[ this_archive.to_i - 1 ]
if File.exist? this_archive
@extracter = Extracter.what_to(this_archive, )
end
elsif find_partial_match_for(this_archive).first matched = find_partial_match_for(i)[1]
(matched)
else 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_the_home_directory_as_prefix ⇒ Object
#
use_the_home_directory_as_prefix
#
1014
1015
1016
|
# File 'lib/easycompile/base/misc.rb', line 1014
def use_the_home_directory_as_prefix
set_prefix(:home_directory)
end
|