class Easycompile::Base
Constants
- THIS_FILE
#¶ ↑
THIS_FILE
¶ ↑This constant refers to the main .rb file for class
Easycompile::Base
, that is the file that contains most of the ruby code for theBase
class.#¶ ↑
Public Class Methods
#¶ ↑
initialize¶ ↑
#¶ ↑
# File lib/easycompile/base/initialize.rb, line 14 def initialize( commandline_arguments = ARGV, run_already = true ) reset set_commandline_arguments( commandline_arguments ) case run_already # ======================================================================= # # === :dont_run_yet # ======================================================================= # when :dont_run_yet, :do_not_run_yet run_already = false end run if run_already end
Public Instance Methods
#¶ ↑
attempt_to_find_a_valid_file
¶ ↑
This method will attempt to sanitize incomplete entries such as “nettle-2.7” towards “nettle-2.7.tar.xz”.
When we pass something such as “htop.yml” and this file does not exist in the current directory, then we will attempt to find it in another directory.
#¶ ↑
# File lib/easycompile/base/misc.rb, line 475 def attempt_to_find_a_valid_file(i) if i.is_a? Array i.map! {|entry| unless File.exist? entry entry = File.basename(entry) if entry.include?('.yml') or entry.end_with?('.') entry = INDIVIDUAL_COOKBOOKS+entry yaml_dataset = get_dataset_from(entry) entry = yaml_dataset['program_path'] set_program_version(yaml_dataset['program_version']) else # Then we try a glob. _ = Dir["#{entry}*"] entry = _.first unless _.empty? end end entry } end return i end
#¶ ↑
change_directory
(cd tag)¶ ↑
Use this method when changing directories.
#¶ ↑
# File lib/easycompile/base/change_directory.rb, line 16 def change_directory(i) if i File.expand_path(i) if i.start_with? '.' if File.exist?(i) Dir.chdir(i) else show_namespace e "Can not change into #{sdir(i)} as it does not exist." end end end
#¶ ↑
check_for_dependencies
¶ ↑
#¶ ↑
# File lib/easycompile/base/misc.rb, line 598 def check_for_dependencies # ======================================================================= # # Next, add dependencies. To try this, do: # # ecompile metacity.yml wdeps # # ======================================================================= # if @compile_with_dependencies dependencies = get_dataset_from(@original_input)['required_deps_on'] dependencies.map! {|entry| entry = entry.dup if entry.frozen? entry << '.yml' } add(dependencies) end end
#¶ ↑
consider_creating_a_build_directory
¶ ↑
Here we will consider whether we will create a build directory or whether we will not do so.
If such a directory already exists then we do not need to create a new directory.
#¶ ↑
# File lib/easycompile/base/misc.rb, line 536 def consider_creating_a_build_directory( where = return_pwd ) if shall_we_create_a_build_directory? _ = name_of_build_directory? if File.exist? _ show_namespace e "We will use the already existing build directory "\ "called `#{sdir(_)}`." set_build_directory(_) else @base_dir = rds(where) set_this_build_dir(File.absolute_path(_)) show_namespace e 'We will create a build directory next called `'+sdir(_)+'` '\ '(Full target will be: '+@build_directory_is_stored_here+').' # =================================================================== # # Keep track of where the build directory is. # =================================================================== # mkdir @build_directory_is_stored_here # Creating the build directory finally. end # ===================================================================== # # Next, we will enter that BUILD directory. # ===================================================================== # cd @build_directory_is_stored_here show_namespace # ===================================================================== # # Notify the user that we have cd-ed already. # ===================================================================== # e 'Now entering the directory '+ sdir(@build_directory_is_stored_here)+'.' end end
#¶ ↑
consider_removing_the_archive
¶ ↑
#¶ ↑
# File lib/easycompile/base/misc.rb, line 707 def consider_removing_the_archive( i = @build_directory_is_stored_here ) if remove_all_after_compile? if i.responds_to? :each i.each {|entry| remove_directory(entry) } else i = i.to_s if shall_we_create_a_build_directory? if File.exist?(i) and empty_dir?(i) # =============================================================== # # Ok, we found an empty build-directory. Since it is empty, # we can safely remove it. # =============================================================== # remove_directory(i) end end end end end
#¶ ↑
consider_symlinking_appdir
¶ ↑
Use this method to consider symlinking into the AppDir hierarchy.
We use class SymlinkProgram for this, from the RBT project. However had, when we are on GoboLinux, we will instead use the GoboLinux program called SymlinkProgram.
#¶ ↑
# File lib/easycompile/base/misc.rb, line 398 def consider_symlinking_appdir _ = rds(prefix?+'/') opn :namespace => NAMESPACE e 'Next attempting to symlink at '+sdir(_) if are_we_on_gobolinux? cmd = 'SymlinkProgram '+_ esystem cmd else begin require 'rbt/requires/require_symlink_this_program.rb' rescue LoadError; end if Object.const_defined?('RBT') and RBT.const_defined?(SymlinkFromToCurrent) RBT::SymlinkFromToCurrent.new(_) end end end
#¶ ↑
determine_which_programs_to_compile
¶ ↑
#¶ ↑
# File lib/easycompile/base/misc.rb, line 933 def determine_which_programs_to_compile if @commandline_arguments.empty? # ===================================================================== # # If we did not input anything then use all archives from the # current working directory. # ===================================================================== # _ = Dir['*'].select {|entry| is_an_archive?(entry) } else if @commandline_arguments.any? {|entry| entry.end_with? '.yml' } # =================================================================== # # Handle .yml files here. # =================================================================== # @commandline_arguments = replace_all_yaml_files(@commandline_arguments) end _ = @commandline_arguments.select {|entry| File.exist?(entry) } end set_compile_these_programs(_) end
#¶ ↑
enter_extracted_directory
¶ ↑
We use this method to enter the extracted directory.
#¶ ↑
# File lib/easycompile/base/misc.rb, line 421 def enter_extracted_directory(i = @original_input) i = remove_extension_from(i) if File.directory? i _ = i else _ = "#{@temp_directory}#{get_program_name(i)}" end i = i.dup _ << '/' unless _.end_with? '/' if Dir.exist? _ # Only inform the user that we cd if that directory exists. show_namespace; e "Now entering the directory `#{sdir(_)}`." cd _ end end
#¶ ↑
esystem¶ ↑
Run a colourized system() command here.
This can either be through oldschool system(), or as of August 2017, preferentially via IO.popen().
#¶ ↑
# File lib/easycompile/base/esystem.rb, line 20 def esystem(i) e_colourize(i) # Output it here already. i = i.dup if i.frozen? i << ERROR_LINE @result = i # Not in use right now. internal_system(i) # Defined in this file here. end
#¶ ↑
extract_to_this_directory?¶ ↑
#¶ ↑
# File lib/easycompile/base/misc.rb, line 230 def extract_to_this_directory? @extract_to_this_directory end
#¶ ↑
filename¶ ↑
#¶ ↑
# File lib/easycompile/base/misc.rb, line 120 def filename return File.basename(__FILE__)+':' end
#¶ ↑
find_this_program?¶ ↑
#¶ ↑
# File lib/easycompile/base/misc.rb, line 53 def find_this_program? @find_this_program end
#¶ ↑
get_dataset_from
¶ ↑
#¶ ↑
# File lib/easycompile/base/misc.rb, line 890 def get_dataset_from(i) if !Object.const_defined?(:RBT) and !RBT.const_defined?(:Cookbooks) begin require 'rbt/requires/require_the_cookbook_class.rb' rescue LoadError; end end i.chop! if i.end_with? '.' if is_the_cookbook_class_available? i = RBT::Cookbooks::SanitizeCookbook.new(i).dataset? end return i end
#¶ ↑
internal_system
¶ ↑
The key idea for this method is to handle system()-related calls via IO.popen(). This gives us more control over as to what to do with the given input and output.
#¶ ↑
# File lib/easycompile/base/esystem.rb, line 46 def internal_system(i) cparser_is_available = cparser_is_available? cparser = @colourize_parser if cparser_is_available io_object = IO.popen(i, :err => [:child, :out]).each { |line| if cparser_is_available cparser.grab_this_line(line) # The cparser object will deal with colours. line = cparser.line? end e line # Output here. } io_object.close # Close it here. end
#¶ ↑
is_archive?¶ ↑
Return true if the given input is an archive.
#¶ ↑
# File lib/easycompile/base/misc.rb, line 385 def is_archive?(i) ::Easycompile.is_archive?(i) end
#¶ ↑
name_of_build_directory?¶ ↑
This method will return the name of the BUILD/ directory. For now this is static but perhaps one day we may wish to change this, in order to make it more dynamic.
#¶ ↑
# File lib/easycompile/base/misc.rb, line 267 def name_of_build_directory? @name_of_build_directory end
#¶ ↑
process_the_input
¶ ↑
#¶ ↑
# File lib/easycompile/base/process_the_input.rb, line 14 def process_the_input( i = compile_these_programs? ) i.each {|this_entry| # ===================================================================== # # The this_entry part may look like so: # # "php-7.4.2.tar.xz" # # ===================================================================== # # The entry may be nil at this point, though. In that case, we # fetch a random element. # ===================================================================== # this_entry = Dir['*'].first if this_entry.nil? this_entry = this_entry.to_s this_entry.sub!(/\^/,'') if this_entry.include? '^' # Remove ^ from the input here, if it is included. # ===================================================================== # # If input is a (positional) number, such as "3". # ===================================================================== # unless File.exist?(this_entry) if this_entry =~ /^\d+$/ # ================================================================= # # Obtain all entries next. # ================================================================= # entries = Dir['*'] unless entries.empty? this_entry = this_entry.to_i this_entry = entries.size if this_entry > entries.size # This is to fetch the proper last entry, if input is too long. this_entry = entries.sort[ (this_entry.to_i - 1) ] # Fetch an entry here. end end end # ===================================================================== # # === Handle .gem files too, early on - they won't need a build directory. # ===================================================================== # if this_entry =~ /\.gem$/ # If it is a gem file. do_not_create_a_build_directory # Gem files typically do not need a build dir. end # ===================================================================== # # === Handle yaml files first. # # If the input file is a yaml file, we will assume that the user wants # to change directory first into the SRC_DIR hierarchy. # # Invoke this by doing something like: # ===================================================================== # if this_entry.include? '.yml' yaml_dataset = get_dataset_from(this_entry) this_entry = yaml_dataset['program_path'] end if File.directory? this_entry _ = Dir["#{this_entry}/*"].first # Fetch the first entry from this directory, in this case. But retain it only when it is an archive. if is_archive? _ this_entry = _ end # else we discard it. end # ===================================================================== # # Next, we need to check whether the input is an archive or whether # it is not. If it is a directory, then we will simply enter # this directory instead, without doing any further extraction. # ===================================================================== # unless this_entry.start_with?('--') if File.directory? this_entry # No need to do anything special in this case. # ================================================================= # # In this case we will enter the given directory at hand. # ================================================================= # cd this_entry consider_creating_a_build_directory run_configure_make_and_make_install else if File.exist?(this_entry) # ================================================================= # # Past this point we know that the entry must exist. # ================================================================= # set_original_input(this_entry) set_find_this_program( ProgramInformation.return_name(this_entry) ) # =================================================================== # # The next method will also extract the archive, if the # archive exists and there is no other instruction given # by the user to NOT extract it. # =================================================================== # try_to_compile_or_install_this_program(this_entry) consider_symlinking_appdir if is_an_appdir? return_to_start_directory_again consider_removing_this_archive(this_entry) end end end } end
#¶ ↑
program_version?¶ ↑
#¶ ↑
# File lib/easycompile/base/misc.rb, line 461 def program_version? @program_version end
#¶ ↑
remove_directory
¶ ↑
This method will remove a directory (if the input argument is a directory that is).
#¶ ↑
# File lib/easycompile/base/remove.rb, line 17 def remove_directory(i = nil) if i and File.directory?(i) i = i.dup if i.frozen? i.squeeze!('/') FileUtils.rm_rf(i) unless i == '/' # Don't delete "/" ever. end end
#¶ ↑
remove_extension_from
¶ ↑
#¶ ↑
# File lib/easycompile/base/remove.rb, line 41 def remove_extension_from(i) i = i.dup # Work on a copy. i.sub!(/\.xz$/,'') if i.end_with? '.xz' i.sub!(/\.gz$/,'') if i.end_with? '.gz' i.sub!(/\.bzip2$/,'') if i.end_with? '.bzip2' i.sub!(/\.bzip$/,'') if i.end_with? '.bzip' i.sub!(/\.tar$/,'') if i.end_with? '.tar' i.sub!(/\.zip$/,'') if i.end_with? '.zip' i end
#¶ ↑
remove_this_file
¶ ↑
#¶ ↑
# File lib/easycompile/base/remove.rb, line 56 def remove_this_file(i) i = @start_dir+File.basename(i) opn_namespace; e 'Now deleting `'+sfile(i)+'`.' File.delete(i) if File.exist? i end
#¶ ↑
replace_all_yaml_files
¶ ↑
#¶ ↑
# File lib/easycompile/base/misc.rb, line 955 def replace_all_yaml_files(i = @commandline_arguments) i.map {|entry| if entry.end_with?('.yml') begin require 'rbt/requires/require_the_cookbook_class.rb' entry = return_yaml_file(entry) rescue LoadError; end end entry } end
#¶ ↑
reset (reset tag)¶ ↑
The instance variable we will use here:
@prefix_to_base_directory # This is used to denote what is the base
directory.
#¶ ↑
# File lib/easycompile/base/reset.rb, line 26 def reset set_base_dir set_start_dir # ======================================================================= # # === @commandline_arguments # # This Array will hold all commandline arguments, e. g. ARGV. # ======================================================================= # @commandline_arguments = [] # ======================================================================= # # === @compile_these_programs # # These are the programs, as an Array, that we wish to compile. # ======================================================================= # @compile_these_programs = [] # ======================================================================= # # === @program_name # ======================================================================= # @program_name = nil # ======================================================================= # # === @compile_with_dependencies # ======================================================================= # @compile_with_dependencies = false # If true then we will first compile all dependencies. # ======================================================================= # # === @program_version # ======================================================================= # @program_version = '1.0.0' # Default. # ======================================================================= # # Designate the default extract-to directory next. # ======================================================================= # set_extract_to(:default) # ======================================================================= # # === @hash # ======================================================================= # @hash = {} # ======================================================================= # # === @skip_extracting # ======================================================================= # @skip_extracting = false # Whether to skip extracting or not. # ======================================================================= # # === @continue_after_extracting # ======================================================================= # @continue_after_extracting = true # if true we continue after extracting. # ======================================================================= # # === @build_directory_is_stored_here # ======================================================================= # @build_directory_is_stored_here = nil # ======================================================================= # # === @continue_past_configure_stage # ======================================================================= # @continue_past_configure_stage = true # ======================================================================= # # === @skip_make_install # ======================================================================= # @skip_make_install = false set_prefix # Default. # ======================================================================= # # === @prefix_to_base_directory # ======================================================================= # @prefix_to_base_directory = '' # ======================================================================= # # === @shall_we_create_a_build_directory # # This variable keeps track as to whether we will create a # build directory or not. # ======================================================================= # @shall_we_create_a_build_directory = SHALL_WE_CREATE_A_BUILD_DIRECTORY # ======================================================================= # # === @prefix # # Which prefix is to be used. Defaults to /usr/. # ======================================================================= # @prefix = '/usr/' # ======================================================================= # # === @original_input # ======================================================================= # @original_input = nil # ======================================================================= # # === @temp_directory # ======================================================================= # @temp_directory = ::Easycompile.temp_directory? # ======================================================================= # # === @remove_all_after_compile # ======================================================================= # @remove_all_after_compile = false # ======================================================================= # # === @try_to_use_extended_configure_options # # If this variable is set to true then we will try to # return the extended configure options, which are # part of the RBT project. # ======================================================================= # @try_to_use_extended_configure_options = false # ======================================================================= # # === @colourize_parser # ======================================================================= # if cparser_is_available? @colourize_parser = RBT::ColourizeParser.new else @colourize_parser = nil end # ======================================================================= # # === @name_of_build_directory # # Choose a default name for the build directory. This can be # overruled if we have a .yml file that tells us to do so. # ======================================================================= # set_name_of_build_directory 'BUILD_DIRECTORY/' if File.exist? FILE_NAME_OF_THE_BUILD_DIRECTORY require 'yaml' set_name_of_build_directory(:load_the_yaml_file) end end
#¶ ↑
run (run tag)¶ ↑
#¶ ↑
# File lib/easycompile/base/run.rb, line 14 def run @start_dir = return_pwd determine_which_programs_to_compile # ======================================================================= # # Next check against the menu (commandline-interface). # ======================================================================= # menu( return_all_arguments_with_hyphens ) process_the_input end
#¶ ↑
run_cmake_command
(cmake tag)¶ ↑
Compiling via cmake can yield errors. We will try to capture such an error.
Note that cmake-based projects typically require a dedicated build directory - this is why the method do_make_use_of_a_build_directory
() is called within this method.
cmake -DCMAKE_INSTALL_PREFIX=/usr
#¶ ↑
# File lib/easycompile/base/cmake.rb, line 32 def run_cmake_command do_make_use_of_a_build_directory _ = 'cmake'.dup # ======================================================================= # # Next, we will use the install prefix. # ======================================================================= # _ << " -DCMAKE_INSTALL_PREFIX=#{prefix?}" _ << ' .' _ << '.' if shall_we_create_a_build_directory? # Append this. if shall_we_create_a_build_directory? use_this_name = name_of_build_directory? unless File.directory?(use_this_name) opn; e "Next creating the build directory called `"\ "#{sdir(use_this_name)}`." mkdir(use_this_name) end cd use_this_name end esystem _ end
#¶ ↑
run_configure
(configure tag)¶ ↑
This method runs the classical configure command with a specific prefix. It is equivalent to just run “./configure”.
#¶ ↑
# File lib/easycompile/base/misc.rb, line 737 def run_configure if shall_we_create_a_build_directory? @prefix_to_base_directory << '../' end # ======================================================================= # # === Check for Rakefile # ======================================================================= # if File.exist?(@prefix_to_base_directory+'Rakefile') run_rinstall2 # ======================================================================= # # === Check for cmake-file # # Here we will run cmake. # ======================================================================= # elsif File.exist?("#{@prefix_to_base_directory}#{cmake_file?}") run_cmake_command # ======================================================================= # # === Check for setup.py file # # Note that a file called setup.py may exist, but the program itself # may still require a "configure" invocation. This is the case with # the official source archive for Python. # ======================================================================= # elsif File.exist?(@prefix_to_base_directory+'setup.py') run_python_installation # ======================================================================= # # === Check for Makefile.PL # ======================================================================= # elsif File.exist?(@prefix_to_base_directory+'Makefile.PL') run_perl_installation # ======================================================================= # # === Check for build.sh file # # This was disabled on 20.06.2020 as it was not working for the # program called "make". At a later time this may have to be # re-enabled again, but for now it has to stay disabled. # ======================================================================= # # elsif File.exist? @prefix_to_base_directory+'build.sh' # run_build_sh # ======================================================================= # # === Run the configure command next # ======================================================================= # elsif File.exist? @prefix_to_base_directory+'configure' simply_run_the_configure_command # ======================================================================= # # === Check for ruby .gem files next # ======================================================================= # elsif (@original_input =~ /\.gem$/) install_this_gem(@original_input) exit # ======================================================================= # # === Check whether 'meson.build' exists # ======================================================================= # elsif does_a_meson_build_file_exist? compile_as_meson_based_project exit else # The default, that is - we will run ./configure here. show_namespace; e 'We could not find a configure script, no cmake' show_namespace; e 'file and we also could not find various other ' show_namespace; e 'files. We will now assume that configure may' show_namespace; e 'still work, and thus run, but be aware that' show_namespace; e 'this may fail.' simply_run_the_configure_command end end
#¶ ↑
run_configure_make_and_make_install
¶ ↑
#¶ ↑
# File lib/easycompile/base/misc.rb, line 1047 def run_configure_make_and_make_install run_configure_command_or_another_command if continue_past_configure_stage? run_make_command_or_equivalent run_make_install_command end end
#¶ ↑
run_make_command_or_equivalent
(make tag)¶ ↑
This method will either run “make”, or another command.
For now we assume the alternative is via cmake. Please note that the command “make install” usually follows the “make” command.
#¶ ↑
# File lib/easycompile/base/misc.rb, line 911 def run_make_command_or_equivalent show_namespace; e 'Running "make" in '+sdir(return_pwd)+' next.' if File.exist? 'Makefile' esystem 'make' if continue_past_configure_stage? else # Else assume cmake. esystem 'make' if continue_past_configure_stage? end end
#¶ ↑
run_python_installation
(python tag)¶ ↑
This method will additionally check for a file called 'configure'.
#¶ ↑
# File lib/easycompile/base/misc.rb, line 1068 def run_python_installation if File.exist?("#{@prefix_to_base_directory}configure") simply_run_the_configure_command run_make_then_make_install else _ 'python setup.py configure' _ 'python setup.py build' _ 'python setup.py install' end end
#¶ ↑
run_rinstall2
¶ ↑
#¶ ↑
# 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_compile_these_programs
¶ ↑
This method specifies which programs this class will compile.
#¶ ↑
# File lib/easycompile/base/misc.rb, line 676 def set_compile_these_programs(i) i = [i].flatten.compact i.map! {|entry| # ======================================================================= # # The file in question may not exist, for instance if it is a remote URL # link. In that case we enter here. # ======================================================================= # unless File.exist? entry case entry # case tag when 'ALL','A' # simply get all. entry = Dir['*'].reject {|inner_entry| File.directory? inner_entry } when /LAST/,/LAT/ # Special instruction. entry = File.readlines(LAST_DOWNLOADED_FILE).first else # Try a (silent) glob here if the file does not exist. if entry.include?('http') # Assume this to be a remote file. esystem "wget #{entry}" entry = File.basename(entry) else glob = Dir["#{entry}*"] entry = glob.first unless glob.empty? end end end entry } @compile_these_programs = i end
#¶ ↑
set_extract_to_this_directory
¶ ↑
#¶ ↑
# File lib/easycompile/base/misc.rb, line 196 def set_extract_to_this_directory(i = :default) case i # ======================================================================= # # === :default # ======================================================================= # when :default, nil i = temp_dir? end i = i.to_s.dup unless i.end_with? '/' i = i.dup if i.frozen? i << '/' end # ======================================================================= # # === Handle blocks given to this method next: # ======================================================================= # if block_given? yielded = yield case yielded # ===================================================================== # # === :be_verbose # ===================================================================== # when :be_verbose e "#{rev}Using the directory #{sdir(i)} as temp-directory next." e '(The archive at hand will be extracted to this directory.)' end end @extract_to_this_directory = i end
#¶ ↑
set_hash
¶ ↑
#¶ ↑
# File lib/easycompile/base/misc.rb, line 500 def set_hash(i = {}) if i.is_a? Hash if i.has_key? :extract_to set_extract_to(i[:extract_to]) end if i.has_key? :program_version set_version(i[:program_version]) end if i.has_key? :prefix set_prefix(i[:prefix]) end if i.has_key? :appdir_layout set_prefix(i[:appdir_layout]) elsif i.has_key? :usr_prefix set_prefix(i[:usr_prefix]) end end @hash = i end
#¶ ↑
set_name_of_build_directory
¶ ↑
#¶ ↑
# File lib/easycompile/base/misc.rb, line 244 def set_name_of_build_directory( i = :default ) case i # ======================================================================= # # === :load_the_yaml_file # ======================================================================= # when :load_the_yaml_file, :default i = YAML.load_file(FILE_NAME_OF_THE_BUILD_DIRECTORY) end i = i.dup if i.frozen? i << '/' unless i.end_with? '/' @name_of_build_directory = i end
#¶ ↑
set_prefix
¶ ↑
Set the prefix here. By default the prefix will be /usr, but some programs, in particular app-dir like programs, will default to a prefix such as /Programs/Gimp/2.5.2.
#¶ ↑
# File lib/easycompile/base/misc.rb, line 1086 def set_prefix( i = '/usr' ) if i.is_a? Symbol # This may be triggered via :appdir, for instance. case i # ===================================================================== # # === :home_directory # ===================================================================== # when :home_directory, :home_dir, :home i = ENV['HOME'].to_s end i = i.to_s # Work on a String here. i = remove_file_suffix(i) # ===================================================================== # # Simply assemble the prefix now, based on the capitalized variant # of the program name, and then the version. # For this to work, program_name? and program_version? must have # been already defined. # ===================================================================== # # if program_name?.nil? and program_version?.nil? # # In this case, we must first define these two entries. # # This has not yet happened - stub. # end case i when /usr(_|-)?prefix/ i = '/usr/' # ===================================================================== # # === appdir # ===================================================================== # when 'appdir', 'app' # =================================================================== # # We will first check on the original input. If that original # input was an existing file, in form of an archive, then # we may make use of ProgramInformation to change the # version of the program at hand. # =================================================================== # if @original_input and File.exist?(@original_input) and File.file?(@original_input) and is_archive?(@original_input) # ================================================================= # # Ok, in this case, we will make use of ProgramInformation. # ================================================================= # _ = remove_archive_at_the_end( File.basename( @original_input ) ) set_program_name(_) set_program_version( ProgramInformation.return_version(@original_input) ) end # =================================================================== # # Build up the full appdir-prefix next: # =================================================================== # i = "#{::Easycompile.programs_directory?}"\ "#{program_name?.to_s.capitalize.delete('-')}"\ "/#{program_version?}" end end if i.is_a? String # We can do this because the next step is rds(). i = i.dup if i.frozen? i = rds("#{i}/") end @prefix = i end
#¶ ↑
set_program_name
¶ ↑
Note that this method can make use of ProgramInformation.
#¶ ↑
# File lib/easycompile/base/misc.rb, line 996 def set_program_name(i = nil) i = i.first if i.is_a? Array if i i = get_program_name(i) # ===================================================================== # # Next, we need to obtain the real program name, without the # version. We used the following line for this in the past: # _ = _.split('-').first if _.include? '-' # However had, as of 08.08.2015, we will instead use ProgramInformation. # ===================================================================== # i = ProgramInformation.return_name(i) # .first() will return the right name. end @program_name = i end
#¶ ↑
set_this_build_dir
¶ ↑
#¶ ↑
# File lib/easycompile/base/misc.rb, line 80 def set_this_build_dir(i = :pwd) case i when :pwd i = return_pwd end i = i.to_s unless i.include? '/' i = File.absolute_path(i) end unless i.end_with? '/' i = i.dup if i.frozen? i << '/' end @build_directory_is_stored_here = i end
#¶ ↑
show_help
(help tag)¶ ↑
#¶ ↑
# File lib/easycompile/base/help.rb, line 14 def show_help(optional_shall_we_exit = false) if optional_shall_we_exit == :then_exit optional_shall_we_exit = true end e opn_namespace; e 'Documented help options are these here:' opn_namespace; e opn_namespace; ecomment ' --appdir # Compile as Appdir, into '\ 'its own prefix.' opn_namespace; ecomment ' --remove-all-after-compile # Remove '\ 'the archive after compilation is done.' opn_namespace; ecomment ' --with-deps '\ '# Compile with dependencies.' opn_namespace; ecomment ' --extract-to=/Depot/opt/ '\ '# extract to that particular directory.' opn_namespace; ecomment ' --homedir # '\ 'Compile into the home-directory as prefix' opn_namespace; e exit if optional_shall_we_exit end
#¶ ↑
simply_run_the_configure_command
¶ ↑
#¶ ↑
# File lib/easycompile/base/misc.rb, line 808 def simply_run_the_configure_command _ = ''.dup # ← Buildup the command. _ << '.' if shall_we_create_a_build_directory? _ << "./configure --prefix=#{prefix?}" # ======================================================================= # # === Check for etended configure options next # ======================================================================= # if @try_to_use_extended_configure_options begin require 'rbt/requires/require_show_configuration_options.rb' rescue LoadError; end if RBT.respond_to? :return_configuration_options_for? _ << " #{RBT.return_configuration_options_for?(find_which_program?)}" end end begin # This part invokes the actual "./configure" run. esystem(_) # Also show the ./configure command we will use. rescue Errno::ENOENT show_namespace e 'An error happened - the configure-file could not be found. '\ 'The faulty line was:' show_namespace e " #{simp(_)}" show_namespace e "It was issued from the directory: #{sdir(return_pwd)}" if return_pwd.include? name_for_build_dir? set_this_build_dir(:pwd) end can_not_continue # We can not continue past the configure-step. # ======================================================================= # # Do "make distclean" here. # ======================================================================= # if _.include?('configure: error: source directory already configured') or _.include?('source directory already configured; run "make distclean"') @base_dir = return_pwd cd '..' make_distclean cd @base_dir run_configure_command end if _ end end
#¶ ↑
try_to_compile_or_install_this_program
¶ ↑
#¶ ↑
# File lib/easycompile/base/misc.rb, line 855 def try_to_compile_or_install_this_program(this_archive) if is_a_gem?(this_archive) e "#{rev}Now installing the gem at #{sfile(this_archive)}." install_this_gem(this_archive) else extracted_to = try_to_extract(this_archive) if continue_after_extracting? if File.directory? extracted_to enter_extracted_directory(extracted_to) consider_creating_a_build_directory run_configure_make_and_make_install end end end end
#¶ ↑
try_to_extract
¶ ↑
Use this method here to extract a given archive.
#¶ ↑
# File lib/easycompile/base/misc.rb, line 621 def try_to_extract( this_archive, extract_to = extract_to? ) if this_archive.is_a? Array # Obtain only the first element in this case. this_archive = this_archive.first end cd start_dir? if File.exist? this_archive.to_s # ===================================================================== # # In this case, we will assume that an valid archive was given to us. # ===================================================================== # unless skip_extracting? show_namespace; e "Now trying to extract `#{sfancy(this_archive)}`." @extracter = Extracter.what_to(this_archive, extract_to) return remove_archive_at_the_end( extract_to+ File.basename(this_archive) ) else nil end elsif File.exist? base_dir?+this_archive unless skip_extracting? @extracter = Extracter.what_to(base_dir?+this_archive, extract_to) end else # ===================================================================== # # The file does not exist here at this point. Thus, we will # do some further checks. # ===================================================================== # if this_archive =~ /^\d+$/ # Ok, user inputted a number alone, check first. this_archive = Dir['*'].sort[ this_archive.to_i - 1 ] if File.exist? this_archive @extracter = Extracter.what_to(this_archive, extract_to) end elsif find_partial_match_for(this_archive).first # Ok, user could input a partial number and a string, like: "baobab-3.9" matched = find_partial_match_for(i)[1] consider_extracting_this_archive(matched) else # Ok, it indeed does not exist. show_namespace; e 'File `'+sfile(this_archive)+'` does '+ 'not exist. We thus can not continue.' show_namespace; e 'We will not continue as a consequence.' do_not_continue return nil end end end