class RBT::Compile
Constants
- ALPHABET
#¶ ↑
ALPHABET
¶ ↑#¶ ↑
- ALSO_AUTOMATICALLY_INSTALL_THE_UPDATED_GEM
#¶ ↑
ALSO_AUTOMATICALLY_INSTALL_THE_UPDATED_GEM
¶ ↑If the following constant is set to true, then the
RBT
project will also attempt to automatically install this given ruby-gem.That way you can easily batch-update all registered rubygems; they must have a corresponding .yml file that is registered in the respective .yml file at hand, though.
#¶ ↑
- ARRAY_CHECK_FOR_BINARY_DUPLICATES_OPTIONS
#¶ ↑
ARRAY_CHECK_FOR_BINARY_DUPLICATES_OPTIONS
¶ ↑This constant shall include regexes that check for the following commandline options:
rbt --check-for-binary-duplicates rbt --report-binary-duplicates rbt --report-duplicates rbt --binary-duplicates rbt --duplicate-binaries
#¶ ↑
- ARRAY_FEEDBACK_CONFIGURE_OPTIONS
#¶ ↑
ARRAY_FEEDBACK_CONFIGURE_OPTIONS
¶ ↑#¶ ↑
- ARRAY_FEEDBACK_MAKE_OPTIONS
#¶ ↑
ARRAY_FEEDBACK_MAKE_OPTIONS
¶ ↑#¶ ↑
- ARRAY_HELP_ALL_AVAILABLE_PROGRAMS
#¶ ↑
ARRAY_HELP_ALL_AVAILABLE_PROGRAMS
¶ ↑#¶ ↑
- ARRAY_HELP_AVAILABLE_PROGRAM_VERSIONS
#¶ ↑
ARRAY_HELP_AVAILABLE_PROGRAM_VERSIONS
¶ ↑#¶ ↑
- ARRAY_HELP_CHECK_ALL_TAGS_OPTIONS
#¶ ↑
ARRAY_HELP_CHECK_ALL_TAGS_OPTIONS
¶ ↑#¶ ↑
- ARRAY_HELP_CONFIG_OPTIONS
#¶ ↑
ARRAY_HELP_CONFIG_OPTIONS
¶ ↑These options are valid for when the user wishes to feedback the main configuration options.
#¶ ↑
- ARRAY_HELP_CREATE_SHELLSCRIPT_OPTIONS
#¶ ↑
ARRAY_HELP_CREATE_SHELLSCRIPT_OPTIONS
¶ ↑These options are all used for the creation of a shell script, a shell “recipe”.
#¶ ↑
- ARRAY_HELP_DISABLE_AUTOGEN
#¶ ↑
ARRAY_HELP_DISABLE_AUTOGEN
¶ ↑#¶ ↑
- ARRAY_HELP_DONT_KEEP_EXTRACTED_OPTIONS
#¶ ↑
ARRAY_HELP_DONT_KEEP_EXTRACTED_OPTIONS
¶ ↑Allowed options for when we wish to keep the extracted archive.
#¶ ↑
- ARRAY_HELP_DOWNLOAD_THE_SOURCE_OPTIONS
#¶ ↑
ARRAY_HELP_DOWNLOAD_THE_SOURCE_OPTIONS
¶ ↑All download options are stored here.
#¶ ↑
- ARRAY_HELP_DO_COMPILE_IN_A_NON_TRADITIONAL_WAY_OPTIONS
#¶ ↑
ARRAY_HELP_DO_COMPILE_IN_A_NON_TRADITIONAL_WAY_OPTIONS
(ntrad tag)¶ ↑These are the options for when you wish to install in an app-dir like manner.
#¶ ↑
- ARRAY_HELP_DO_COMPILE_IN_A_TRADITIONAL_WAY_OPTIONS
#¶ ↑
ARRAY_HELP_DO_COMPILE_IN_A_TRADITIONAL_WAY_OPTIONS
(trad tag)¶ ↑These options are for compilation into the “/usr/” hierarchy, also called the traditional way to compile a program.
#¶ ↑
- ARRAY_HELP_DO_NOT_COMPILE_OPTIONS
#¶ ↑
ARRAY_HELP_DO_NOT_COMPILE_OPTIONS
¶ ↑#¶ ↑
- ARRAY_HELP_DO_NOT_SYMLINK_OPTIONS
#¶ ↑
ARRAY_HELP_DO_NOT_SYMLINK_OPTIONS
¶ ↑#¶ ↑
- ARRAY_HELP_DO_USE_STOW_OPTIONS
#¶ ↑
ARRAY_HELP_DO_USE_STOW_OPTIONS
¶ ↑#¶ ↑
- ARRAY_HELP_ENABLE_STATIC
#¶ ↑
ARRAY_HELP_ENABLE_STATIC
(static tag)¶ ↑These are the options for static compilation mode.
#¶ ↑
- ARRAY_HELP_FEEDBACK_ALL_BINARIES_OPTIONS
#¶ ↑
ARRAY_HELP_FEEDBACK_ALL_BINARIES_OPTIONS
¶ ↑Keep track of which binaries a specific program should install.
#¶ ↑
- ARRAY_HELP_FEEDBACK_EVERY_CASE_OPTION_OPTIONS
#¶ ↑
ARRAY_HELP_FEEDBACK_EVERY_CASE_OPTION_OPTIONS
¶ ↑#¶ ↑
- ARRAY_HELP_FEEDBACK_LAST_COMPILED_OPTIONS
#¶ ↑
ARRAY_HELP_FEEDBACK_LAST_COMPILED_OPTIONS
¶ ↑#¶ ↑
- ARRAY_HELP_FEEDBACK_PROGRAM_VERSION_OPTIONS
#¶ ↑
ARRAY_HELP_FEEDBACK_PROGRAM_VERSION_OPTIONS
¶ ↑#¶ ↑
- ARRAY_HELP_FEEDBACK_VERSIONS_OPTIONS
#¶ ↑
ARRAY_HELP_FEEDBACK_VERSIONS_OPTIONS
¶ ↑This Array is used to feedback different versions in use.
#¶ ↑
- ARRAY_HELP_FIND_ALL_ARCHIVES
#¶ ↑
ARRAY_HELP_FIND_ALL_ARCHIVES
¶ ↑#¶ ↑
- ARRAY_HELP_GENERATE_ALL_SLACK_DESC_FILES_OPTIONS
#¶ ↑
ARRAY_HELP_GENERATE_ALL_SLACK_DESC_FILES_OPTIONS
¶ ↑All the registered options for creating slackware .desc files.
#¶ ↑
- ARRAY_HELP_GENERATE_HOMEPAGE_OPTIONS
#¶ ↑
ARRAY_HELP_GENERATE_HOMEPAGE_OPTIONS
¶ ↑#¶ ↑
- ARRAY_HELP_GENERATE_PDF_TUTORIAL_OPTIONS
#¶ ↑
ARRAY_HELP_GENERATE_PDF_TUTORIAL_OPTIONS
¶ ↑All options that can be used to generate the .pdf tutorial.
#¶ ↑
- ARRAY_HELP_GENERATE_SHELL_COMPLETION_OPTIONS
#¶ ↑
ARRAY_HELP_GENERATE_SHELL_COMPLETION_OPTIONS
¶ ↑There are the options for shell-completion.
#¶ ↑
- ARRAY_HELP_GENERATE_SLACK_DESC_FILE
#¶ ↑
ARRAY_HELP_GENERATE_SLACK_DESC_FILE
¶ ↑Help entries to generate a slack-desc file.
#¶ ↑
- ARRAY_HELP_INCLUDED_OPTIONS
#¶ ↑
ARRAY_HELP_INCLUDED_OPTIONS
¶ ↑#¶ ↑
- ARRAY_HELP_KEEP_EXTRACTED_OPTIONS
#¶ ↑
ARRAY_HELP_KEEP_EXTRACTED_OPTIONS
¶ ↑Note that an alias to this is –dont-remove-extracted-archive
#¶ ↑
- ARRAY_HELP_LAST_COMPILED_OPTIONS
#¶ ↑
ARRAY_HELP_LAST_COMPILED_OPTIONS
¶ ↑#¶ ↑
- ARRAY_HELP_LAST_COMPILED_PROGRAM_OPTIONS
#¶ ↑
ARRAY_HELP_LAST_COMPILED_PROGRAM_OPTIONS
¶ ↑#¶ ↑
- ARRAY_HELP_LAST_CONFIGURE_OPTIONS
#¶ ↑
ARRAY_HELP_LAST_CONFIGURE_OPTIONS
¶ ↑#¶ ↑
- ARRAY_HELP_LAST_DOWNLOADED_OPTIONS
#¶ ↑
ARRAY_HELP_LAST_DOWNLOADED_OPTIONS
¶ ↑#¶ ↑
- ARRAY_HELP_LOG_DIR_OPTIONS
#¶ ↑
ARRAY_HELP_LOG_DIR_OPTIONS
¶ ↑#¶ ↑
- ARRAY_HELP_OUTPUT_ALL_URLS_OPTIONS
#¶ ↑
ARRAY_HELP_OUTPUT_ALL_URLS_OPTIONS
¶ ↑#¶ ↑
- ARRAY_HELP_PACKAGE_RBT_OPTIONS
#¶ ↑
ARRAY_HELP_PACKAGE_RBT_OPTIONS
¶ ↑All options if one wishes to package up the
RBT
scripts.#¶ ↑
- ARRAY_HELP_PREFIX_IN_USE
#¶ ↑
ARRAY_HELP_PREFIX_IN_USE
¶ ↑#¶ ↑
- ARRAY_HELP_PURGE_ALL_MAN_ENTRIES
#¶ ↑
ARRAY_HELP_PURGE_ALL_MAN_ENTRIES
¶ ↑#¶ ↑
- ARRAY_HELP_QUERY_THE_EXISTANCE_OF_A_BINARY_NAME
#¶ ↑
ARRAY_HELP_QUERY_THE_EXISTANCE_OF_A_BINARY_NAME
¶ ↑#¶ ↑
- ARRAY_HELP_REMOVE_ALL_SYMLINKS_OPTIONS
#¶ ↑
ARRAY_HELP_REMOVE_ALL_SYMLINKS_OPTIONS
¶ ↑This Array collects all options used for when we wish to remove all symlinks in the /Programs hierarchy.
#¶ ↑
- ARRAY_HELP_REPLACE_SYMLINKS_OPTIONS
#¶ ↑
ARRAY_HELP_REPLACE_SYMLINKS_OPTIONS
¶ ↑#¶ ↑
- ARRAY_HELP_REPORT_N_PROGRAMS_OPTIONS
#¶ ↑
ARRAY_HELP_REPORT_N_PROGRAMS_OPTIONS
¶ ↑#¶ ↑
- ARRAY_HELP_SCAN_SOURCE_ARCHIVE_OPTIONS
#¶ ↑
ARRAY_HELP_SCAN_SOURCE_ARCHIVE_OPTIONS
¶ ↑#¶ ↑
- ARRAY_HELP_SHOW_ALL_OPTIONS
#¶ ↑
ARRAY_HELP_SHOW_ALL_OPTIONS
¶ ↑This covers all options that can be obtained via e. g “ry gcc
show_all
”.#¶ ↑
- ARRAY_HELP_SHOW_HIGHEST_PROGRAMS_OPTIONS
#¶ ↑
ARRAY_HELP_SHOW_HIGHEST_PROGRAMS_OPTIONS
¶ ↑#¶ ↑
- ARRAY_HELP_SHOW_LAST_UPDATE_OPTIONS
#¶ ↑
ARRAY_HELP_SHOW_LAST_UPDATE_OPTIONS
¶ ↑#¶ ↑
- ARRAY_HELP_SHOW_REGISTERED_KEYS
#¶ ↑
ARRAY_HELP_SHOW_REGISTERED_KEYS
¶ ↑#¶ ↑
- ARRAY_HELP_SHOW_WHICH_COLOURS_WILL_BE_USED
#¶ ↑
ARRAY_HELP_SHOW_WHICH_COLOURS_WILL_BE_USED
¶ ↑The constants stored in the Array here can be used to display which colours will be used by the
RBT
project.#¶ ↑
- ARRAY_HELP_SIMULATION_MODE_OPTIONS
#¶ ↑
ARRAY_HELP_SIMULATION_MODE_OPTIONS
¶ ↑#¶ ↑
- ARRAY_HELP_SKIP_EXTRACTING_OPTIONS
#¶ ↑
ARRAY_HELP_SKIP_EXTRACTING_OPTIONS
¶ ↑Options in order to skip extracting the tarball.
#¶ ↑
- ARRAY_HELP_TEMP_DIR
#¶ ↑
RBT::ARRAY_HELP_TEMP_DIR¶ ↑
This constant will keep track of the
RBT
temp directory, e. g. where we will extract archives to.#¶ ↑
- ARRAY_HELP_TOGGLE_DEBUG_VALUE_OPTIONS
#¶ ↑
ARRAY_HELP_TOGGLE_DEBUG_VALUE_OPTIONS
¶ ↑#¶ ↑
- ARRAY_HELP_UPDATE_BINARY_NAMES_OPTIONS
#¶ ↑
ARRAY_HELP_UPDATE_BINARY_NAMES_OPTIONS
¶ ↑#¶ ↑
- ARRAY_HELP_USE_AUTOGEN
#¶ ↑
ARRAY_HELP_USE_AUTOGEN
¶ ↑All options when we wish to use autogen.
#¶ ↑
- ARRAY_HELP_USE_BUILD_DIRECTORY_OPTIONS
#¶ ↑
ARRAY_HELP_USE_BUILD_DIRECTORY_OPTIONS
¶ ↑#¶ ↑
- ARRAY_HELP_VIEW_AVAILABLE_LICENSES_OPTIONS
#¶ ↑
ARRAY_HELP_VIEW_AVAILABLE_LICENSES_OPTIONS
¶ ↑#¶ ↑
- ARRAY_SHOW_LAST_UPDATED_OPTIONS
#¶ ↑
ARRAY_SHOW_LAST_UPDATED_OPTIONS
¶ ↑#¶ ↑
- ARRAY_SYMLINK_ALL_PROGRAMS_OPTIONS
#¶ ↑
ARRAY_SYMLINK_ALL_PROGRAMS_OPTIONS
¶ ↑All “symlink all programs” options are stored here.
#¶ ↑
- DEFAULT_NAME_FOR_THE_BUILD_DIRECTORY
#¶ ↑
DEFAULT_NAME_FOR_THE_BUILD_DIRECTORY
¶ ↑What name will our default build directory have? Useful when we wish to use other build dirs.
The reason the name is so long is because the shorter name “BUILD” sometimes may already be an existing file. The program “brotli” has had this problem - it carried a file called “BUILD” by default, which obviously means that a “cd BUILD/” event will fail lateron.
#¶ ↑
- DEFAULT_PROGRAM
#¶ ↑
DEFAULT_PROGRAM
¶ ↑Set the default program here.
#¶ ↑
- FILE_AUTOGEN
#¶ ↑
FILE_AUTOGEN
¶ ↑#¶ ↑
- OPTIONS_NO_COLOURS
#¶ ↑
OPTIONS_NO_COLOURS
¶ ↑Synonyms for colour usage. All these instructions can be used to disable colours.
#¶ ↑
- SILENT_REDIRECTION
#¶ ↑
SILENT_REDIRECTION
¶ ↑This can simply be appended.
#¶ ↑
- TEMP_DIR
#¶ ↑
TEMP_DIR
¶ ↑#¶ ↑
- TEMP_DIR_FOR_RBT
#¶ ↑
TEMP_DIR_FOR_RBT
¶ ↑#¶ ↑
- THIS_FILE
#¶ ↑
THIS_FILE
¶ ↑#¶ ↑
Public Class Methods
#¶ ↑
RBT::Compile.compile
¶ ↑
The first argument should be the name of the program that you wish to compile, such as :htop or ‘htop’.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 22770 def self.compile( this_program = nil, optional_arguments = nil ) _ = RBT::Compile.new(this_program, :do_not_run_already) # ======================================================================= # # Pass any extra arguments into the menu() interface. # ======================================================================= # _.menu(optional_arguments) if optional_arguments _.run end
#¶ ↑
RBT::Compile.display_standard_help_options
¶ ↑
Set the standard help-options only here.
You can view them by issuing this command:
rbt --help
#¶ ↑
# File lib/rbt/compile/compile.rb, line 22501 def self.display_standard_help_options( exit_now = :default ) case exit_now when :default exit_now = false end pad_to_most_right = ' ' * 40 lpad = ' ' middle_pad = 44 # RBT::Compile.output_namespace? # <- Disabled as of 03.10.2020. e efancy lpad+'The following help subsection describes some of ' efancy lpad+'the available help options for the' efancy lpad+::RBT.steelblue('Compile-Section')+ sfancy(' of the RBT scripts.') e efancy lpad+'The '+ RBT.mediumslateblue('basic ')+ sfancy('command to ')+ RBT.steelblue('compile a program')+ sfancy(' is:') e e e lpad+RBT.gold(' rbt [NAME_OF_THE_PROGRAM]') e lpad+RBT.gold(' rbt python')+RBT.orange(' # ← example input; here we '\ 'would try to compile python') e lpad+RBT.gold(' rbt htop')+RBT.orange(' # ← here, RBT would try to '\ 'compile htop') e lpad+RBT.gold(' rbt php')+RBT.orange(' # ← here, RBT would try to '\ 'compile php') e e efancy lpad+lpad+'-b --build-dir=[] Set a specific build directory' efancy lpad+lpad+'-h --help Display this help subsection here' efancy lpad+' --permanently_extract_to=[] permanently extract the '\ 'archives to another directory' efancy lpad+lpad+'-e --extract_to=[] extract the archives to '\ 'another directory' efancy ' (--homedir= is an alias to this setting)' efancy lpad+lpad+'-k --keep_extracted Keep the sourceball extracted '\ '(normally the extracted' efancy ' archive is '\ 'removed after compilation)' efancy lpad+' --batch-compile= Batch-compile some '\ 'programs such as batch compiling' e e (' ' * middle_pad)+ RBT.royalblue(" rbt --batch-compile=mate\n") efancy lpad+ ' --dont-use-configure-options Do not use any configure options '\ 'from the .yml file' efancy lpad+lpad+'-n --no-harm Run in simulation mode' efancy lpad+lpad+'-nc --nocolour / --nocolor Disable colours' efancy lpad+ ' --use-old-configure-options Re-use old configure '\ 'options, e. g. from GCC' efancy lpad+lpad+'-sl --sleep<number> Sleep for <number> seconds before continuing' efancy lpad+ ' --permanently-disable-ccache Permanently disable ccache, '\ 'via the commandline' efancy lpad+ ' --disable-ccache Do not use ccache for the current run' efancy lpad+lpad+'-S --no-symlink Do not symlink the AppDir that was compiled' efancy lpad+lpad+'-P --no-postinstall Do not run the postinstall instructions' efancy lpad+ ' --preinstall="sh bootstrap" Run the specified pre-install action' efancy lpad+ ' --use-gobolinux-symlinkprogram Use the GoboLinux SymlinkProgram rather than ' efancy ' '\ 'class RBT::SymlinkProgram, for symlinking' efancy lpad+ ' --use-meson Use the meson build system' efancy lpad+lpad+'-no --no-extract Do not extract tarball again '\ '(skip extracting the source archive)' efancy lpad+lpad+'-cmake --cmake Use cmake rather than make' efancy lpad+lpad+'-clang --clang Use clang rather than the default GCC '\ 'to compile C/C++ programs' efancy lpad+ ' --create-yaml-file-for=subversion Create a .yml file for this program, '\ 'holding the relevant ' efancy ' '\ 'information for compiling the program from source' efancy ' (Note that this requires the clang '\ 'compiler of LLVM being' efancy ' available, of course.)' efancy lpad+ ' --create-log-directory Create the log directory.' efancy lpad+ ' --paste-blfs-page Fetch and paste remote '\ 'data from the BLFS page of the given program' efancy lpad+lpad+'-slack --slack-desc Create a Slackware slack-desc file' efancy lpad+ ' --purge-traditional-binaries-of=gnupg Purge binaries of this program' efancy lpad+ ' --valid-sys-tags? Show which '+ sdir('/System/Tag')+ sfancy(' entries are valid') efancy lpad+ ' --symlink-headers Symlink all .h files into '\ 'the '+sdir('/usr/include/')+sfancy(' hierarchy') efancy lpad+ ' --symlink-all-upcased-programs-to-downcased-variants Create '\ 'symlinks' efancy (' ' * (middle_pad-2))+' '\ 'for all upcased program entries under '+ sdir(RBT.programs_dir?)+'.' efancy lpad+ ' --homedir Compile the program into your '\ 'HOME directory such as '+ sdir('/home/name/')+sfancy('.') efancy lpad+lpad+'-ver --verbose Be verbose in the output' efancy lpad+ ' --do-not-use-special-flags Do not use ENV (environmental '\ 'flags) at all.' efancy lpad+ " --update-entry Update a program, such "\ "as via\n" e RBT.royalblue( (' ' * middle_pad)+ " rbt --update-entry "\ "http://ftp.gnu.org/gnu/grep/grep-3.5.tar.xz\n" ) efancy lpad+ ' --edit-file=htop Open the '+ ::Colours.sfile('htop.yml')+ sfancy(' cookbook-file, in order to inspect '\ 'and/or edit it;') efancy ' the '+simp('$EDITOR')+ sfancy(' variable can be used to specify which editor is to be used.') efancy lpad+ " --remove-la-files Remove "\ ".la files of this program (requires the --prefix to include "\ "#{sdir(::RBT.programs_dir?)})" efancy lpad+ ' --suggest-cookbook-for=glib Show a possible '\ 'content of glib.yml file' efancy lpad+lpad+ "-v --version Use a "\ "specific version, such as, for instance:\n" efancy (' ' * middle_pad)+ RBT.royalblue(' rbt bluefish --version=1.0.7') e # ======================================================================= # # === Documented help options for the GUI section # ======================================================================= # efancy lpad+gold('[GUI section]') e efancy lpad+ ' --libui start the libui-wrapper for RBT (in '\ 'regards to compiling programs from source)' efancy lpad+ ' --gtk start the ruby-gtk3 interface '\ '(tabbed notebook interface)' if RBT.is_on_gobolinux? # ===================================================================== # # If we are on gobolinux then we also mention how to create # gobolinux-recipes. # ===================================================================== # efancy ' --gobolinux-recipe '\ 'Create a GoboLinux recipe. (The "-" can be omitted.' efancy pad_to_most_right+' A usage example follows next.)' efancy pad_to_most_right+' Usage example: '+ simp('rbt zenity --gobolinux-recipe') end e efancy lpad+'Some shorter commandline options exist for '\ 'toplevel methods:' e efancy lpad+' rbt --download htop # This will download htop into '\ 'the local directory' efancy lpad+' rbt --extract htop # This will extract htop; or download '\ '+ extract it,' efancy lpad+'# should it not exist locally'.rjust(51) e # Need a spacer before we display the next part. e eimp lpad+'Also note that these options can be chained together. '\ 'Abbreviations ' eimp lpad+'can be used as well. The options '+ sfancy('noext nocol')+ simp(' will all work fine, ') eimp lpad+ simp('being equal to ')+ sfancy('--no-extract --nocolor')+simp('.') e eimp lpad+'Abbreviations allow us to have to type less, but '\ 'the longer variants ' eimp lpad+ 'als work, in the event that you wish '\ 'to be more explicit.' e exit if exit_now end
#¶ ↑
RBT::Compile.is_this_program_included?
¶ ↑
ry --included?
#¶ ↑
# File lib/rbt/compile/compile.rb, line 22701 def self.is_this_program_included?( i, be_verbose = :default ) case be_verbose when :default be_verbose = true when :be_quiet be_verbose = false end if i.is_a? Array i.each {|entry| is_this_program_included?(entry, be_verbose) } else i = i.to_s.dup i.delete!('-') i.delete!('_') # ===================================================================== # # Note that RBT.does_include? tries harder to find a program # than does RBT.is_this_program_included?. # ===================================================================== # is_included = RBT.does_include?(i) if is_included if be_verbose RBT::Compile.opnn e "The program `#{RBT.simp(i)}` is included." end @is_included = true else if be_verbose RBT::Compile.opnn e "The program `#{RBT.simp(i)}` is #{RBT.swarn('not')} included." end @is_included = false end end end
#¶ ↑
initialize¶ ↑
The first argument to this method will contain the commandline arguments for class RBT::Compile
. These are usually the name of the program (or programs) that you wish to compile.
So, for example, “htop” could be passed as the first argument to this method. You can also pass in an Array here, and this class will then attempt to batch-compile these programs.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 1426 def initialize( commandline_arguments = ARGV, # ← This should usually be an Array of programs that is to be compiled. run_already = true ) register_sigint reset # Must come before set_original_input(). do_show_a_deprecation_notice set_original_input( commandline_arguments ) # ======================================================================= # # Handle symbols given as first argument next. # ======================================================================= # case commandline_arguments # ======================================================================= # # === :do_not_run_yet # ======================================================================= # when :do_not_run_yet, :do_not_yet_run, :dont_run_yet run_already = false commandline_arguments = [] end # ======================================================================= # # === Process and sanitize some commandline arguments given next # # Prepend '--' to each entry excluding the first one, unless that # entry already begins with '-'. This way we can simplify the later # checks done within menu(). # ======================================================================= # if commandline_arguments.is_a?(Array) and (commandline_arguments.size > 1) commandline_arguments[1 .. -1] = commandline_arguments[1 .. -1].map {|entry| unless entry.start_with?('-') entry = entry.dup if entry.frozen? entry.prepend('--') end entry } end set_commandline_arguments( commandline_arguments ) case run_already when :do_not_run_yet run_already = false end # ======================================================================= # # === Handle blocks next # ======================================================================= # if block_given? yielded = yield # ===================================================================== # # Handle Symbols first: # ===================================================================== # if yielded.is_a? Symbol case yielded # =================================================================== # # === :do_not_run_yet # =================================================================== # when :do_not_run_yet, :do_not_run, :dont_run_yet run_already = false # =================================================================== # # === :do_not_check_whether_the_program_exists # =================================================================== # when :do_not_check_whether_the_program_exists do_not_check_whether_the_program_exists # ← This method exists, so use it too. end # ===================================================================== # # === Handle Hashes next # ===================================================================== # elsif yielded.is_a? Hash # =================================================================== # # === :run_already # # This entry point should be checked last. # =================================================================== # if yielded.has_key? :run_already case yielded[:run_already] when :do_not_run_yet run_already = false end end # =================================================================== # # === :use_this_prefix # =================================================================== # if yielded.has_key? :use_this_prefix set_use_this_prefix(yielded[:use_this_prefix]) end # =================================================================== # # === :shall_we_check_whether_the_program_exists # =================================================================== # if yielded.has_key? :shall_we_check_whether_the_program_exists case yielded[:shall_we_check_whether_the_program_exists] # ================================================================= # # === nope # # In this case we will not check whether the program exists. # ================================================================= # when :nope, false do_not_check_whether_the_program_exists end end # =================================================================== # # === :prefix # # Handle prefix-related keys first. # =================================================================== # if yielded.has_key? :prefix set_user_prefix(yielded.delete(:prefix)) # ← Set the new prefix via a method call. # =================================================================== # # === :use_this_prefix # =================================================================== # elsif yielded.has_key? :use_this_prefix set_user_prefix(yielded.delete(:use_this_prefix)) # =================================================================== # # === :use_this_as_prefix # =================================================================== # elsif yielded.has_key? :use_this_as_prefix set_user_prefix(yielded.delete(:use_this_as_prefix)) end # =================================================================== # # === :symlink_after_compilation_has_finished # =================================================================== # if yielded.has_key? :symlink_after_compilation_has_finished value = yielded.delete(:symlink_after_compilation_has_finished) if value == false set_do_not_symlink(:be_verbose) # Disable symlinking after compilation. end end # =================================================================== # # Add commandline_arguments if the key is :commandline_arguments # # Such a Hash may have a key like this: # # {:commandline_arguments=>["--dont-use-colours", "ntrad"]} # =================================================================== # if yielded.has_key? :commandline_arguments append_to_the_commandline( yielded.delete(:commandline_arguments) ) end else append_to_the_commandline(yielded) end end # ======================================================================= # # Handle special symbols passed to run_already next: # ======================================================================= # case run_already when :dont_run_yet, :do_not_run_yet, :do_not_run_already run_already = false end time_snapshot # Store the first snapshot, which is the start-mark. run if run_already end
#¶ ↑
RBT::Compile.opnn
¶ ↑
Use this method when you wish to output the RBT::Compile
namespace to the user.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 1915 def self.opnn( i = { namespace: RBT.namespace?, use_colours: RBT.use_colours? } ) if i.is_a? Hash unless i.has_key? :use_colours i.update(use_colours: RBT.use_colours?) end end if RBT.show_the_classname? ::RBT.opnn(i) # Delegate to the module_method here. # else # else we will not use Opn at all. end end
Public Instance Methods
#¶ ↑
action_install_only_headers
¶ ↑
This method handles the actual copying of all headers. It must be called at the proper time.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 21828 def action_install_only_headers( from_this_directory = extract_to?+program_name?+'/' ) from_this_directory = from_this_directory.to_s.dup from_this_directory << '/' unless from_this_directory.end_with? '/' _ = ''.dup all_headers = Dir["#{from_this_directory}*.h"] _ = all_headers.join(',')[0..3] unless all_headers.empty? opne "Now copying all found headers from '{sdir(from_this_directory)}"\ " to #{sdir('/usr/include/')}:" copy_recursively(all_headers, '/usr/include/', true) do_not_continue_after_configure_step do_not_continue_after_make_step be_silent end
#¶ ↑
add_package_user
¶ ↑
This allows you to add a package-user.
Usage example:
ry htop add_package_user
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13688 def add_package_user( name = compile_which_program? ) _ = '/Users/Packages/' cmd_to_run = 'useradd -m -d '+_+name.capitalize+' '+name create_directory _ unless File.directory? _ opne "Adding a new user called `#{simp(name)}`:" custom_system cmd_to_run end
#¶ ↑
add_the_default_dataset_to_the_internal_hash
¶ ↑
The variables in use in this method here can, for the most part, be modified by the user via the commandline.
In other words, the user can change these variables and thus toggle the behaviour of RBT::Compile
. Thus, the user can overrule any setting defined in this method here - this is important to retain for this method, hence why it is documented so extensively.
Many variables in this method will be set to nil initially; that way we can easily find out which values have been modified on the commandline, and which one have not.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 16633 def add_the_default_dataset_to_the_internal_hash # ======================================================================= # # The next variable will keep track of class SymlinkProgram. We # need to be able to modify its behaviour at "runtime". # ======================================================================= # set_symlink_program(nil) # ======================================================================= # # === :name_for_the_build_directory # # Use a default build directory. There is another entry that determines # whether we will use any build directory at all or not, so it is safe # to assign to the variable here - the entry called # @internal_hash[:use_build_directory]. # # Since as of April 2021, we will only use the setter-method for this. # See the line below the commented line. # ======================================================================= # # @internal_hash[:name_for_the_build_directory] = DEFAULT_NAME_FOR_THE_BUILD_DIRECTORY set_name_for_the_build_directory # Set a default name for the build directory. # ======================================================================= # # === :run_configure_script # # Determine whether we will run the configure script or whether we # will not. This is nil initially, so that the user can overrule # this in any way he/she sees fit. # ======================================================================= # @internal_hash[:run_configure_script] = nil # ======================================================================= # # === :extract_where_to # ======================================================================= # @internal_hash[:extract_where_to] = TEMP_DIR_FOR_RBT # ======================================================================= # # === :configure_base_directory # ======================================================================= # @internal_hash[:configure_base_directory] = nil # ======================================================================= # # === :prefix # ======================================================================= # @internal_hash[:prefix] = RBT::Prefix.new(:traditional) # This equals to /usr/. # ======================================================================= # # === :use_a_prefix # # This entry point allows us to use a prefix variable, e. g for # "./configure --prefix=/opt". By default this is enabled (set # to true), but a user may wish to disable this too. # # If you wish to query this value, use the method do_we_use_any_prefix?. # ======================================================================= # @internal_hash[:use_a_prefix] = true # ======================================================================= # # === :use_autogen # # Default value for use_autogen will be nil. The user is able to # override this from the commandline, which is why we will set # this variable to nil. # ======================================================================= # @internal_hash[:use_autogen] = nil # ======================================================================= # # === :use_this_build_system # # Determine which build system is to be used. By default it will be nil. # ======================================================================= # @internal_hash[:use_this_build_system] = nil # ======================================================================= # # === :honour_check_to_ensure_that_the_program_exists # # The next variable has to be kept for if we actually do want to # check whether a program is included or not. Normally we should # check, but there may be situations where you may build up your # own functionality - so we need to provide an option that can be # toggled by the user. This is why the next variable exists, and # is kept at true. # ======================================================================= # @internal_hash[:honour_check_to_ensure_that_the_program_exists] = true # ======================================================================= # # === :shall_we_compile_the_program # # The next variable can be used to determine whether we will compile # a particular program or whether we will not. # ======================================================================= # @internal_hash[:shall_we_compile_the_program] = true # ======================================================================= # # === :last_compiled_program # ======================================================================= # @internal_hash[:last_compiled_program] = nil # Define it once at least. # ======================================================================= # # === :check_for_this_licence # # If the following variable is not nil, and not false, then this # class will check for the given licence matching, before it will # compile the program. So, for instance, the user passes the # commandline flag for GPLv3 licences. If the software at hand is # NOT GPLv3 licenced then it can not be compiled. This is an optional # setting - most users won't need this, but purists may want to have # such an option, so it has been enabled in September 2022. # ======================================================================= # @internal_hash[:check_for_this_licence] = nil # ======================================================================= # # === :do_not_use_special_flags # # The next variable, false on startup, tells RBT::Compile to retain # all environment variables. Sometimes we may want to NOT use the # environment variables, which is why this flag exists. # ======================================================================= # @internal_hash[:do_not_use_special_flags] = false # ======================================================================= # # === :is_on_gobolinux # # Determine whether we are on GoboLinux or whether we are not. # ======================================================================= # @internal_hash[:is_on_gobolinux] = RBT.are_we_on_gobolinux? # ======================================================================= # # === :counter_called_traditional_or_non_traditional_compilation # # Next, how often we invoked traditional or non-traditional compilation. # ======================================================================= # @internal_hash[:counter_called_traditional_or_non_traditional_compilation] = 0 # ======================================================================= # # === :do_not_use_special_environment_flags # # Whether we are allowed to use special ENV flags. By default we are # allowed to use special flags, hence why the variable is set to false. # ======================================================================= # @internal_hash[:do_not_use_special_environment_flags] = false # ======================================================================= # # === use_gobolinux_symlinkprogram # # Next, determine whether we will make use of GoboLinux's SymlinkProgram. # This will be automatically changed if we are on GoboLinux. For other # systems we will prefer to use SymlinkProgram from RBT itself. # ======================================================================= # @internal_hash[:use_gobolinux_symlinkprogram] = false # ======================================================================= # # === :run_postinstall_actions # # Determine whether we will run postinstallation steps. # ======================================================================= # @internal_hash[:run_postinstall_actions] = true # ======================================================================= # # === :we_tried_to_compile_this_program_n_times # ======================================================================= # @internal_hash[:we_tried_to_compile_this_program_n_times] = 0 set_user_prefix(nil) # ← Purposely defined here, outside of other methods. # ======================================================================= # # === :make_use_of_cookbook_aliases # ======================================================================= # @internal_hash[:make_use_of_cookbook_aliases] = true # ======================================================================= # # === :time_compilation # # Determine whether we shall time the compilation or whether we shall # not. # ======================================================================= # @internal_hash[:time_compilation] = YAML.load_file(FILE_TIME_COMPILATION) if @internal_hash[:time_compilation] @internal_hash[:array_time_compilation] = [] end # ======================================================================= # # === :keep_the_extracted_archive # # The keep-extracted setting will lateron be sanitized. The default # value will be nil. # ======================================================================= # @internal_hash[:keep_the_extracted_archive] = nil # ======================================================================= # # === :build_static # # The next variable must be defined here. A value of nil specifies # that this has not been set via the commandline yet. A value of # nil here essentially means a default to false - aka we will not # try to compile a program in a static manner. # ======================================================================= # @internal_hash[:build_static] = nil # ======================================================================= # # === :check_whether_the_given_input_is_a_file_and_does_exist # # The next variable, if true, instructs the class to check whether the # given input argument(s) do exist as a regular local file. If false # this check is skipped. # ======================================================================= # @internal_hash[:check_whether_the_given_input_is_a_file_and_does_exist] = true # ======================================================================= # # === :sed # # Whether to apply a sed-operation. Will be nil by default. If the # user passes in some special option here, then we know that we # have to use this value to overrule any other value for sed. # ======================================================================= # @internal_hash[:sed] = nil # ======================================================================= # # === :symlink_headers # ======================================================================= # @internal_hash[:symlink_headers] = nil # ======================================================================= # # === :symlink_glib_schema # ======================================================================= # @internal_hash[:symlink_glib_schema] = nil # ======================================================================= # # === :symlink_into_usr_lib_dir # # Determine whether we will symlink the content of lib/ into # /usr/lib/. This setting is only honoured if we compile in an # appdir-like fashion. # ======================================================================= # @internal_hash[:symlink_into_usr_lib_dir] = false # ======================================================================= # # Only install the .h header files, if this variable is set to true. # ======================================================================= # @internal_hash[:install_only_the_headers] = false # ======================================================================= # # === :time_compilation # # Whether to time the compilation procedure or not: # ======================================================================= # @internal_hash[:time_compilation] = true # ======================================================================= # # === :exit_before_make_install # # Whether we will exit when we reach the "make install" stage. # ======================================================================= # @internal_hash[:exit_before_make_install] = false # ======================================================================= # # === :exit_before_make # # Whether we will exit when we reach the "make" stage. # ======================================================================= # @internal_hash[:exit_before_make] = false # ======================================================================= # # === :extract_only # # If the next variable is set to true, we will exit after we have # extracted the archive. We will first initialize it to nil, though, # in order to distinguish between the default value and user-supplied # values. # ======================================================================= # @internal_hash[:extract_only] = nil # ======================================================================= # # === :use_porg # # Determine whether we will make use of porg. # ======================================================================= # @internal_hash[:use_porg] = configuration?.use_porg # ======================================================================= # # === :run_simulation # # Whether we will run in simulation-mode or not. Simulation-mode means # that we will not make any real lasting changes. This thus allows a # user to predict (and show a summary) what would happen if a # program would be installed/compiled. # ======================================================================= # @internal_hash[:run_simulation] = false # ======================================================================= # # === @original_stdout # # The next variable is a bit unclear - it used to exist to allow for # easy redirection, but may no longer be that important. We may have to # re-evaluate this at a later time (written at 12.04.2019). # ======================================================================= # @original_stdout = nil # ======================================================================= # # === :extract_to_this_directory_as_specified_by_the_user # # The next variable can be used to allow the user to determine another # directory for where we will extract archives into. Initially set # to nil in order to allow distinction to the default extractable # directory that is to be used. # ======================================================================= # @internal_hash[:extract_to_this_directory_as_specified_by_the_user] = nil # ======================================================================= # # === :postinstallation # ======================================================================= # @internal_hash[:postinstallation] = nil # ======================================================================= # # === :keep_la_files # # The next flag determines whether we will delete .la files or whether # we will keep them. # ======================================================================= # @internal_hash[:keep_la_files] = nil # ======================================================================= # # === :can_we_continue # # The variable at :can_we_continue is reset during every iteration. # It will be true by default. # ======================================================================= # @internal_hash[:can_we_continue] = true # ======================================================================= # # === :install_only_binaries # ======================================================================= # @internal_hash[:install_only_binaries] = false # ======================================================================= # # === :may_we_download # ======================================================================= # @internal_hash[:may_we_download] = RBT::TRY_TO_DOWNLOAD_IF_NOT_FOUND # ======================================================================= # # === :ignore_errors # # By default we will NOT ignore errors, thus stop when we have noticed # an error. This can be overruled by the user on the commandline, # through the following value. # ======================================================================= # @internal_hash[:ignore_errors] = false # ======================================================================= # # === :skip_extracting # # Default value is nil for the next variable. If true then we will # NOT extract. # ======================================================================= # @internal_hash[:skip_extracting] = nil # ======================================================================= # # === Show the flexbox # # Next determine whether we will show the flexbox or whether we will # not. This has to be in the method here so that we do not re-set # it for each program that is to be compiled/installed. # ======================================================================= # @internal_hash[:show_the_flexbox] = true # ======================================================================= # # === :use_autoconf # # Use autoconf or not - by default we will not. # ======================================================================= # @internal_hash[:use_autoconf] = nil # ======================================================================= # # === :use_the_internal_sed_wrapper # # Next, determine whether to use the internal sed-wrapper. No # longer true by default since as of February 2018, but perhaps # we may re-enable it at some later moment in time. # ======================================================================= # @internal_hash[:use_the_internal_sed_wrapper] = false # ======================================================================= # # === @internal_hash[:make_use_of_the_cookbook_aliases] # # If the following variable is set to true then the RBT project # will try to honour the cookbook aliases. # ======================================================================= # @internal_hash[:make_use_of_the_cookbook_aliases] = true # ======================================================================= # # === :create_appdir_skeleton # # Whether to create an AppDir skeleton by default. # ======================================================================= # @internal_hash[:create_appdir_skeleton] = true # ======================================================================= # # === :strip_binaries # # By default we will not strip the binaries. The configuration # setting can change this value though. # ======================================================================= # @internal_hash[:strip_binaries] = false # ======================================================================= # # The configuration setting can change the above default false-value. # ======================================================================= # if config? @internal_hash[:strip_binaries] = config?.use_strip end # ======================================================================= # # === :compiler_to_use # # Specify which compiler is to be used. By default we will use GCC, # but clang may also be an option. It will be stored as a lowercased # Symbol, though, so :gcc would refer to GCC. # ======================================================================= # @internal_hash[:compiler_to_use] = :gcc # ======================================================================= # # === :extract_the_archive # # By default we will extract the archive. # ======================================================================= # @internal_hash[:extract_the_archive] = true # ======================================================================= # # === Keeping track of the commandline arguments # # @commandline_arguments are set on startup only once, so they can not # be put inside the method initialize_default_values(). # ======================================================================= # @internal_hash[:commandline_arguments] = [] # ======================================================================= # # === :use_meson_configure_options # # Whether to use meson-configure options or not. # ======================================================================= # @internal_hash[:use_meson_configure_options] = true # ======================================================================= # # === :cd_into_the_rbt_log_directory # ======================================================================= # @internal_hash[:cd_into_the_rbt_log_directory] = true # ======================================================================= # # === :symlink_gir_files # # This entry point controls whether we will symlink .gir files, # in principle. # ======================================================================= # @internal_hash[:symlink_gir_files] = configuration_setting_for_symlink_gir_files? # ======================================================================= # # === :register_the_last_compiled_program # # Whether to register the last compiled program or not. # ======================================================================= # @internal_hash[:register_the_last_compiled_program] = true # ======================================================================= # # === :parameters_to_make # # The next entry point allows us to pass options/parameters to the # "make" binary. The user can overrule this on the commandline. # # A value of nil is the initialize default state for this variable. # ======================================================================= # @internal_hash[:parameters_to_make] = nil # ======================================================================= # # === :append_shell_error_code # # If this variable is set to true then we will append the shell # error code aka ' 2>&1'. This is true by default, so we will # append it. # ======================================================================= # @internal_hash[:append_shell_error_code] = true # ======================================================================= # # === :use_this_specific_program_version # # Use another program version than the default one via this # variable. # ======================================================================= # @internal_hash[:use_this_specific_program_version] = nil # ======================================================================= # # === :use_build_directory # # Must initialize the build directory to a nil value next. It may # be set to a non-nil value lateron. # ======================================================================= # @internal_hash[:use_build_directory] = nil # ======================================================================= # # === :append_this_to_the_configure_options # # This has been specifically added to allow for the --release flag # to work with cmake-based projects. # ======================================================================= # @internal_hash[:append_this_to_the_configure_options] = nil # ======================================================================= # # === :try_to_use_configure_options # # Determine whether we will try to use any declared configure options # from the cookbook-yaml file. This is true by default. The reason # why the following variable is set to nil initially is so that we # can distinguish the situation from when the user did specifically # want to disable this functionality, from the commandline. So the # nil value does not necessarily mean "false" in this context - it # just means that the user did not specify anything specifically. # ======================================================================= # @internal_hash[:try_to_use_configure_options] = nil # ======================================================================= # # === :use_opn # # This entry point determines whether RBT::Compile will make use of # opn or whether it will not. By default it will be true; if it is # false then we will not show opn in any other class that is called # by RBT::Compile. # ======================================================================= # @internal_hash[:use_opn] = true # ======================================================================= # # === :use_ccache # # The use_ccache entry has to be persistent. # ======================================================================= # @internal_hash[:use_ccache] = RBT.configuration?.use_ccache # ======================================================================= # # === :user_prefix # # This prefix can be determined by the user. # ======================================================================= # @internal_hash[:user_prefix] = nil # ======================================================================= # # === :keep_extracted # ======================================================================= # @internal_hash[:keep_extracted] = nil # ======================================================================= # # === :extract_only # ======================================================================= # @internal_hash[:extract_only] = false # ======================================================================= # # === :configure_options # # Whether we will use special configure options or not. By default # we will not, hence why we initialize the next setting to nil. # ======================================================================= # @internal_hash[:configure_options] = nil # ======================================================================= # # === :use_which_system_command # # There are only two valid settings for this variable: # # :ioparser or # :system # # ======================================================================= # @internal_hash[:use_which_system_command] = :ioparser # ======================================================================= # # === :rename_tab_title # # Whether to rename the tab title or whether we will not. This refers # to the KDE konsole typically. # ======================================================================= # @internal_hash[:rename_tab_title] = RBT.configuration?.rename_tab_title # ======================================================================= # # === :colourize_parser # # Add an instance of class RBT::ColourizeParser. # ======================================================================= # @internal_hash[:colourize_parser] = RBT::ColourizeParser.new end
#¶ ↑
add_the_invariant_dataset_to_the_internal_hash
¶ ↑
The variants in this method are, by default, not amenable to user input. This is the main difference to the method called add_the_default_dataset_to_the_internal_hash.
These values defined in this method are mostly done to use default values.
Note that this is not completely true; :prefix can be changed by the user. But it is true for other entries, such as :have_we_successfully_installed_the_program.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 17159 def add_the_invariant_dataset_to_the_internal_hash # ======================================================================= # # === @handle_this_program # ======================================================================= # @handle_this_program = nil # ======================================================================= # # === @make # # Instantiate a new RBT::Make object next, as our wrapper to 'make'. # ======================================================================= # @make = RBT::Make.new # ======================================================================= # # === :exit_after_a_rubygem_has_been_installed # ======================================================================= # @internal_hash[:exit_after_a_rubygem_has_been_installed] = false # ======================================================================= # # === :may_we_run_ninja # # By default we can always run ninja again. # ======================================================================= # @internal_hash[:may_we_run_ninja] = true # ======================================================================= # # === :make_install_stage_was_a_success # # Whether the "make install" stage was a success. This is true by # default and will only become false if an error is encountered. # ======================================================================= # @internal_hash[:make_install_stage_was_a_success] = true # ======================================================================= # # === :has_the_program_been_installed_successfully # # By default, all programs will have been installed successfully. The # next variable keeps track of this. # ======================================================================= # @internal_hash[:has_the_program_been_installed_successfully] = true # ======================================================================= # # === :array_required_dependencies # # Register any reported dependencies. # ======================================================================= # @internal_hash[:array_required_dependencies] = [] # ======================================================================= # # === :an_error_has_occurred # ======================================================================= # @internal_hash[:an_error_has_occurred] = false # ======================================================================= # # === :try_to_autofix # ======================================================================= # @internal_hash[:try_to_autofix] = true # ======================================================================= # # === :try_to_recompile_upon_error # ======================================================================= # @internal_hash[:try_to_recompile_upon_error] = true # ======================================================================= # # === :continue_after_make_step # ======================================================================= # @internal_hash[:continue_after_make_step] = true # ======================================================================= # # === :have_we_successfully_installed_the_program # # The next variable keeps track over as to whether we have # successfully installed the program or whether we have not. # ======================================================================= # @internal_hash[:have_we_successfully_installed_the_program] = false # ======================================================================= # # === :is_an_abbreviation # # Whether the given input is an abbreviation or not. By default we # assume that the user has NOT used an abbreviated term for a real # program. # ======================================================================= # @internal_hash[:is_an_abbreviation] = false # ======================================================================= # # === :dataset_from_the_file_cookbook_chained_programs # ======================================================================= # @internal_hash[:dataset_from_the_file_cookbook_chained_programs] = YAML.load_file(FILE_COOKBOOK_CHAINED_PROGRAMS) # ======================================================================= # # === :full_configure_command # # We have to store the full configure command as well. It is not just # for configure but also for cmake, meson and so forth. # ======================================================================= # @internal_hash[:full_configure_command] = ''.dup # ======================================================================= # # === :run_make_install # # By default, we will run "make install". This covers most programs # that are to be compiled from source. # ======================================================================= # @internal_hash[:run_make_install] = true # ======================================================================= # # === :run_make_command # # The next variable will be nil by default, so that we can grab the # value that the cookbook-dataset is using here. # ======================================================================= # @internal_hash[:run_make_command] = nil # ======================================================================= # # === :problem # # Whether we have encountered a problem or not. Must be reset for # any new per-compile cycle run. # ======================================================================= # @internal_hash[:problem] = false # ======================================================================= # # === :may_we_initialize_a_new_cookbook_dataset # # The next variable must be true by default. # ======================================================================= # @internal_hash[:may_we_initialize_a_new_cookbook_dataset] = true # ======================================================================= # # === :array_sys_command_string # # The next variable can keep track of sys-commands that were run. # ======================================================================= # @internal_hash[:array_sys_command_string] = [] # ======================================================================= # # === :pid # ======================================================================= # @internal_hash[:pid] = nil end
#¶ ↑
all_configure_options?¶ ↑
Use this method to show all configure options for a given program.
This means all options available through “./configure –help”.
Invocation example:
ry htop allconfigureoptions?
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18104 def all_configure_options? ensure_that_the_main_dataset_exists #_ = extract_to? # TEMP_DIR+File.basename(compile_this_program?) _ = TEMP_DIR_FOR_RBT+ program_name_and_program_version? # ======================================================================= # # The target may be empty though. Rescue this case. # ======================================================================= # _ = rbt_log_directory? if _.nil? or _.empty? opne 'Will extract to '+sdir(_)+'. In the event that you need '\ 'to know ' opne 'where the extracted archive resides.' opne "All configure options for "\ "#{simp(compile_this_program?)} will be shown next, "\ "before exiting." set_extract_to(_) consider_extracting_this_program( program_path? ) _ = rbt_log_directory?+program_name_and_version? opne "We will next cd (change directory) into `#{sdir(_)}`." cd _, :be_quiet # Now we should be in the proper directory. e RBT::BeautifyConfigureHelpOutput.new # Delegate to this class next. e exit_program end
#¶ ↑
an_error_has_occurred
?¶ ↑
Query-method over as to whether an error has occurred.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 20078 def an_error_has_occurred? result = @internal_hash[:an_error_has_occurred] result = false if ignore_errors? result = false if result.is_a?(Array) and result.empty? result end
#¶ ↑
appdir_prefix? (appdir prefix)¶ ↑
This method will return the (assumed) AppDir prefix for a given program at hand.
The program version must be set before calling this method. If the program_version
? has not been defined properly then the method here may return an incorrect result.
This method MUST be guaranteed to return a trailing ‘/’ character.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 23858 def appdir_prefix?( i = compile_which_program?, use_this_program_version = :default ) if cookbook_dataset?.nil? # ===================================================================== # # We do the next method primarily so that we can find # a proper program version. # ===================================================================== # initialize_cookbook_dataset_for(i) end case use_this_program_version when :default use_this_program_version = program_version? when nil initialize_cookbook_dataset_for(i) end # ======================================================================= # # We need a safeguard next, as the program version may be nil. # ======================================================================= # if use_this_program_version.nil? use_this_program_version = cookbook_dataset_program_version? end result = rds( programs_directory?.to_s+ i.to_s.capitalize.to_s+ '/'+ use_this_program_version.to_s+'/' ) # ======================================================================= # # === Handle GoboLinux next # ======================================================================= # if is_on_gobolinux? # ===================================================================== # # If we are on GoboLinux, then we have to honour the other variant # called program_compile_name? instead. # ===================================================================== # result = rds( programs_directory?.to_s+ program_compile_name?.to_s+'/'+ # This line is specific to GoboLinux. use_this_program_version.to_s+'/' ) end return result end
#¶ ↑
append_disable_static_to_the_configure_options
¶ ↑
This method is somewhat similar to the method called append_enable_shared_to_the_configure_options
in that it will also modify the configure options; but it will add “–disable-static” to the configure options.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18345 def append_disable_static_to_the_configure_options append_this_to_the_configure_options(:disable_static) end
#¶ ↑
append_make_options
¶ ↑
This will append parameters issued to “make”. It will also start with a ‘ ’, always.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 11613 def append_make_options(i) if i @make.append_make_options(i) append_this = i.to_s.dup if make_options? joined_make_options = make_options? if joined_make_options.respond_to? :join joined_make_options = joined_make_options.join(' ').strip end unless append_this.include? joined_make_options append_this.prepend(joined_make_options.dup) end end # ======================================================================= # # Prepend a ' ' for some spacing. # ======================================================================= # unless append_this.empty? append_this.prepend(' ') unless append_this.start_with? ' ' set_make_options(append_this) end end end
#¶ ↑
append_these_configure_options
¶ ↑
This method will only append non-nil entries to the extra configure options.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15846 def append_these_configure_options( i = nil ) case i # ======================================================================= # # === :release # ======================================================================= # when :release i = '-DCMAKE_BUILD_TYPE=Release' end if i if @internal_hash[:append_this_to_the_configure_options].nil? # =================================================================== # # In this case we must turn it into a String. # =================================================================== # @internal_hash[:append_this_to_the_configure_options] = ''.dup end @internal_hash[:append_this_to_the_configure_options] << " #{i}" end end
#¶ ↑
append_these_options_to_the_commandline
¶ ↑
Simply append to the commandline options through this method here.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 11168 def append_these_options_to_the_commandline(i) # ======================================================================= # # First check whether the input is a Hash: # ======================================================================= # if i.is_a? Hash if i.has_key? :commandline_arguments i = i.delete(:commandline_arguments) end end @internal_hash[:commandline_arguments] << i @internal_hash[:commandline_arguments].flatten! end
#¶ ↑
append_this_to_full_configure_command
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18082 def append_this_to_full_configure_command(i = ' build') unless i.end_with? ' ' i = i.dup if i.frozen? i << ' ' # Properly pad it here. end i.squeeze!(' ') @internal_hash[:full_configure_command] << i end
#¶ ↑
append_this_to_the_configure_options
¶ ↑
This method can be used to append options to the ./configure line, such as –enable-shared, without having to type the long version. So for example, the Symbol :libdir64 will be expanded to mean –libdir=/usr/lib64. That way the user can get away with typing less on the commandline.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18278 def append_this_to_the_configure_options( i = :enable_bootstrap ) # ======================================================================= # # The following case-when menu could be replaced with generic code # that turns the Symbol-input into the equivalent String e. g. # --disable-something or --enable-something. However had, for the # time being (Dec 2018) I will leave it as it is. In April 2021, # I decided to retain the symbol-as-input approach, since some # symbols get expanded to longer strings than other symbols. # ======================================================================= # case i # ======================================================================= # # === :libdir # ======================================================================= # when :libdir i = ' --libdir=/usr/lib' # ======================================================================= # # === :libdir64 # ======================================================================= # when :libdir64 i = ' --libdir=/usr/lib64' # ======================================================================= # # === :enable_shared # ======================================================================= # when :enable_shared i = ' --enable-shared' # ======================================================================= # # === :disable_static # ======================================================================= # when :disable_static i = ' --disable-static' # ======================================================================= # # === :enable_bootstrap # ======================================================================= # when :enable_bootstrap i = ' --enable-bootstrap' end _ = @internal_hash[:configure_options] _ = ''.dup if _.nil? unless i.start_with? ' ' i = i.dup if i.frozen? i.prepend(' ') end # ======================================================================= # # Next simply append these to the configure options. # ======================================================================= # _ << i @internal_hash[:configure_options] = _ end
#¶ ↑
apply_sed_operation_on
¶ ↑
This method will either use class SedWrapper
, or it will use the sed-binary.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27282 def apply_sed_operation_on(sed_line) if sed_line.is_a? Array sed_line.each {|entry| apply_sed_operation_on(entry) } else if sed_binary_is_available? esystem(sed_line) else if use_the_internal_sed_wrapper? # ================================================================= # # In this case, use the SedWrapper as a fallback. # ================================================================= # SedWrapper.new(sed_line) else # ================================================================= # # Else we will default to the system-sed. # ================================================================= # opne 'We can not use the sed line '+ sfancy(sed_line)+' because '\ 'sed is not available' opne ', and no commandline option has been passed to allow '\ 'us to use the sed wrapper.' end end end end
#¶ ↑
archive_type?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26228 def archive_type? if cookbook_dataset? cookbook_dataset?.archive_type? end end
#¶ ↑
array_compile_these_programs?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15439 def array_compile_these_programs? @array_compile_these_programs end
#¶ ↑
array_sys_command_string?¶ ↑
The array is fed in line by line.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26768 def array_sys_command_string? @internal_hash[:array_sys_command_string] end
#¶ ↑
assign_to_the_main_dataset
¶ ↑
This method should be used when we wish to assign to the main dataset at hand. The expected input should be class ::RBT::Cookbooks::SanitizeCookbook
. If it is not then this will cause an argument error.
The second argument to this method can be used to control how strict the method shall behave.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14795 def assign_to_the_main_dataset( i, check_for_stringent_input = true ) if check_for_stringent_input unless i.is_a? ::RBT::Cookbooks::SanitizeCookbook raise ArgumentError, 'The method assign_to_the_main_dataset() expects input as '\ 'class RBT::Cookbooks::SanitizeCookbook' end set_on_ihash(:cookbook_dataset, i) end end
#¶ ↑
automatically_infer_program_name_and_program_version_from_this_input
¶ ↑
This method will try to automatically set the program_name and @program_version variables.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13196 def automatically_infer_program_name_and_program_version_from_this_input( i, optional_arguments = nil ) if compile_which_program?.nil? set_program_name( program_information_return_program_real_name(i) ) end if program_version?.nil? set_program_version( program_information_return_program_version(i) ) end case optional_arguments when :overwrite_old_values_should_they_exist set_program_name program_information_return_program_real_name(i) set_program_version program_information_return_program_version(i) end set_program_name_and_program_version( compile_which_program?+'-'+program_version? ) end
#¶ ↑
batch_download_all_source_archives
¶ ↑
For this method we have to delegate towards class Cookbooks::DownloadAllSourceArchives
.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 17848 def batch_download_all_source_archives require 'rbt/toplevel_methods/download_all_source_archives.rb' RBT.download_all_source_archives end
#¶ ↑
batch_validate_the_cookbooks
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14485 def batch_validate_the_cookbooks unless RBT::Cookbooks.const_defined? :BatchValidateTheCookbookRecipes require 'rbt/checks_and_validations/batch_validate_the_cookbook_recipes.rb' end BatchValidateTheCookbookRecipes.new end
#¶ ↑
binary?¶ ↑
Wrapper towards answering the question of binary pointing.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26027 def binary?( i = compile_which_program? ) i = i.first if i.is_a? Array i = i.downcase opne "Checking for a binary name called `#{simp(i)}` next:" return_program_based_on_this_binary(i) end
#¶ ↑
build_static?¶ ↑
We have to first check the build_static entry of the cookbook dataset, before we query the value of the @internal_hash.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 29201 def build_static? _ = cookbook_dataset_build_static? unless @internal_hash[:build_static].nil? _ = @internal_hash[:build_static] end _ end
#¶ ↑
cd_to_the_build_directory
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 23021 def cd_to_the_build_directory cd use_this_build_directory? end
#¶ ↑
cd_to_the_configure_base_directory
¶ ↑
This method can be used to cd into the configure base directory.
It can report what it is doing to, in the verbose variant.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 11292 def cd_to_the_configure_base_directory( be_verbose_or_be_quiet = :be_quiet ) target = @internal_hash[:configure_base_directory].dup case be_verbose_or_be_quiet when :be_quiet cd target, :be_quiet else opnn; cd target, :be_verbose end end
#¶ ↑
cd_to_the_extracted_archive
¶ ↑
This method can be used to quickly cd to the extracted archive.
This assumes that:
(a) the archive exists (b) the archive has been extracted to its designated target
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14076 def cd_to_the_extracted_archive target = "#{extract_to_this_directory?}#{program_name_and_program_version?}" cd target end
#¶ ↑
cflags?¶ ↑
Just a convenience wrapper over the CFLAGS environment variable. A getter method, which will tell us the CFLAGS in use of the environment.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 22882 def cflags? ENV['CFLAGS'].to_s.dup end
#¶ ↑
check_for_available_versions
¶ ↑
Use this method if you wish to check for available program versions.
Usage examples:
ry bluefish available_versions ry gcc available_versions
#¶ ↑
# File lib/rbt/compile/compile.rb, line 1597 def check_for_available_versions( for_this_program = program? ) require 'rbt/utility_scripts/check_for_available_versions.rb' cfav = RBT::Cookbooks::CheckForAvailableVersions.new( for_this_program, :do_not_run_yet ) cfav.be_verbose cfav.run end
#¶ ↑
check_for_binary_duplicates_in_this_directory
¶ ↑
This method can be used to check for binary duplicates, aka binaries that exist more than once on the given system, in the given (passed) directory.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15480 def check_for_binary_duplicates_in_this_directory( i = Dir.pwd ) require 'rbt/utility_scripts/check_for_duplicate_binaries.rb' RBT::CheckForDuplicateBinaries.new(Dir.pwd) end
#¶ ↑
check_for_common_errors
¶ ↑
This mehod can be used to check (and handle) errors that we have encountered.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 19943 def check_for_common_errors _ = errors? if _.is_a? Array _.each {|entry| case entry # =================================================================== # # === :gir_file_could_not_be_found # =================================================================== # when :gir_file_could_not_be_found opne 'A required package could not be found, related '\ 'to .gir (gobject introspection) files.' error_is(:required_package_was_not_found) # =================================================================== # # === :required_package_was_not_found # =================================================================== # when :required_package_was_not_found error_is(:required_package_was_not_found) # =================================================================== # # === :ninja_build_encountered_an_error # =================================================================== # when :ninja_build_encountered_an_error error_is(:ninja_build_encountered_an_error) # =================================================================== # # === :configure_error # # This error occurs when configure failed for some reason. It is # a somewhat generic error and may occur, for example, when a # certain package is missing. # # Example for this: # # No package 'libmate-menu' found # # =================================================================== # when :configure_error opnerror 'Some configure-related error has occurred.' # =================================================================== # # === Python syntax error: Invalid Syntax # =================================================================== # when :python_syntax_error_invalid_syntax opnerror 'This InvalidSyntax error is often related to the different' opnerror 'syntax that python2 and python3 use.' # ================================================================= # # Consider autoswitching the python-version next: # ================================================================= # if is_on_roebe? if autoswitch_python? opne "The configuration file "\ "#{slateblue('autoswitch_python.yml')}"\ " has been set to true." opne "We will consider switching python "\ "next (to #{slateblue('python')})." result_of_enabling_python2 = enable_python2 if result_of_enabling_python2 == true clear_errors do_compile_this_program( compile_which_program? ) end else # ============================================================= # # In this case, notify the user that autoswitching could # be enabled. This clause here is entered when autoswitching # has been disabled. # ============================================================= # opne 'Do note that you could set the autoswitch-python '\ 'variable to true.' opne "This could be done by modifying the content "\ "of the file #{slateblue('autoswitch_python.yml')}." opne 'Having autoswitch-python enabled may, however had, '\ 'also lead to problems sometimes, so' opne 'make sure that you really want to enable this '\ 'functionality, prior to changing that file.' end end # =================================================================== # # === A general make-related error # =================================================================== # when :make_encountered_some_error # ================================================================= # # This error type is too generic for now - but perhaps in the # future we may also handle it somehow, or give the user # more information about it. # ================================================================= # else # ================================================================= # # For now this "debugging" part only occurs on roebe-systems. # ================================================================= # if is_on_roebe? opnn stderr "Unregistered error: #{slateblue(entry)}"\ " (class: #{lightblue(entry.class.to_s)})" end end } end end
#¶ ↑
check_for_common_problems
(problems tag, problem tag)¶ ↑
This method will check for some problems and offer ways to resolve these issues. For this to work, the particular problem at hand has to be registered in the following case/when menu.
This method is for checking problems - but for the time being (Nov 2018) we will also check for common errors within this method. This is perhaps not ideal, but simplifies the code for now. In the future this may have to be changed (or the method may have to be renamed).
#¶ ↑
# File lib/rbt/compile/compile.rb, line 19651 def check_for_common_problems _ = problems? if _ # ===================================================================== # # We will only handle registered Symbols next. # ===================================================================== # if _.is_a? Symbol case _ # case tag # =================================================================== # # === Libtool could not find the library # =================================================================== # when :libtool_could_not_find_the_library if is_on_roebe? unless @internal_hash[:invalid_libtool_archive].nil? line = @internal_hash[:invalid_libtool_archive] try_to_autocorrect_this_erroneous_libtool_entry(line) end end # =================================================================== # # === Encountered an invalid libtool archive # =================================================================== # when :encountered_an_invalid_libtool_archive if is_on_roebe? unless @internal_hash[:invalid_libtool_archive].nil? line = @internal_hash[:invalid_libtool_archive] try_to_autocorrect_this_erroneous_libtool_entry(line) end end # =================================================================== # # === Libtool can not install to another prefix # =================================================================== # when :libtool_can_not_install_to_another_prefix opne 'Libtool apparently can not install to another prefix.' opne 'The main reason for this is usually that the configure script' opne 'was run from a directory before, but with another --prefix.' opne 'Try to run "make clean" in the base directory or remove the' opne 'extracted archive, in order to try to fix this problem.' if is_on_roebe? opne tomato('Removing')+' the extracted archive next.' remove_the_extracted_archive end # =================================================================== # # === missing_header_ladspa # =================================================================== # when :missing_header_ladspa opne 'The header ladspa.h is missing. This is part of the '\ 'ladspa-sdk package.' opne 'The remote URL should be at: '+ sfancy(return_url_for(:ladspa)) e e 'This program can probably be installed via:' e e " #{sfancy('rbt ladspa')}" e # =================================================================== # # === Incomplete configure error via cmake # # This entry point is for cmake-related errors that are not further # specified - in other words, generic cmake-related errors. # =================================================================== # when :incomplete_configure_error_via_cmake do_skip_postinstall_actions opne "Something went wrong via `#{powderblue('cmake')}`." # =================================================================== # # === The totem playlist was not found # =================================================================== # when :totem_playlist_was_not_found opne 'The totem playlist was not found. You can try '\ 'to compile it:' e opne sfancy(' rbt totem-playlist') e # =================================================================== # # === Missing C .h (header) file # =================================================================== # when :missing_c_header_file opne swarn('An important C .h file is missing - the compilation '\ 'can not proceed.') # ================================================================= # # The next line was added on 22.08.2018. I wanted to make sure to # easily look at the error for programs that have failed, like # this program here. # ================================================================= # do_not_remove_extracted_archive which_h_file = sys_command_string?.select {|inner_line| inner_line.include?('fatal error:') and inner_line.include?('No such file or directory') } use_this_regex = /fatal error. (.+\.h):/ which_h_file.first =~ use_this_regex this_file = $1.to_s.dup case this_file # ================================================================= # # === xf86Resources.h # ================================================================= # when 'xf86Resources.h' opne "The file #{sfile(this_file)} belongs to the very old package" opne 'xf86-video-amd-2.7.7.7.tar.xz. This has not been updated since' opne '2008 so things will most likely no longer compile.' end # =================================================================== # # === Python import error: an undefined symbol # # Note that this is a problem, not necessarily an error. # =================================================================== # when :python_import_error_undefined_symbol opne 'A python '+swarn('ImportError')+' has happened, about '\ 'a missing/undefined Symbol.' if sys_command_string?.any? {|inner_line| inner_line.include? 'lib/gobject-introspection' } opne 'The problem appears to be somehow related to gobject-introspection.' opne 'This error may appear when different python versions or ' opne 'different library locations are used at the same time.' end # =================================================================== # # === Docbook failed to load a network entity # # This entry point is related to docbook. # =================================================================== # when :docbook_failed_to_load_a_network_entity opne 'Docbook failed to load a '+ steelblue('(remote) network entity')+'.' opne 'In theory, this could be resolved by installing the docbook' opne 'stack, but this is not necessarily trivial. Have a look at the' opne 'LFS page for now:' e e ' '+sfancy(::RBT.return_blfs_entry_for('docbook')) e # =================================================================== # # === No configure file # =================================================================== # when :no_configure_file opnn; _ = 'No '+sfancy('configure')+' file was found.' # =================================================================== # # === Jam is missing # =================================================================== # when :jam_is_missing do_skip_postinstall_actions notify_the_user_that_this_program_is_missing(:jam) # =================================================================== # # === Meson could not be found # =================================================================== # when :meson_could_not_be_found do_skip_postinstall_actions notify_the_user_that_this_program_is_missing(:meson) { e orange( 'Note that this will require a recent python 3.x '\ 'version on your host system.' ) e orange( 'Additionally, you may need the build tool called '\ 'ninja:' ) e e ' '+sfancy('rbt ninja') e } end elsif _.is_a? Array _ = problem? first = _.first last = _.last last = last.first if last.is_a? Array case first # case tag # =================================================================== # # === python_import_error_missing_module # =================================================================== # when :python_import_error_missing_module opne "The python module `#{sfancy(last)}` is missing." case last # ================================================================= # # === libxml2 # ================================================================= # when 'libxml2','libxml' opne 'You may be able to resolve this problem, by '\ 'compiling libxml2:' e opne " #{sfancy('rbt libxml2')}" e end end end end end
#¶ ↑
check_for_inclusion
¶ ↑
We will check the source directory for program-inclusion.
To invoke this method, try something like this:
ry htop --check_for_inclusion
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15029 def check_for_inclusion RBT::Cookbooks::CheckForInclusion.new # bl $RUBY_COOKBOOKS/lib/cookbooks/check_for_inclusion.rb end
#¶ ↑
check_for_latest
¶ ↑
Method-Wrapper over class LocalCheckForLatest.
Invocation example:
ry --checkforlatest
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15256 def check_for_latest require 'rbt/cookbooks/local_check_for_latest.rb' RBT::Cookbooks::LocalCheckForLatest.new # bl $RUBY_COOKBOOKS/lib/cookbooks/local_check_for_latest.rb end
#¶ ↑
check_for_sed_action
(sed tag)¶ ↑
Some programs have a sed-entry. We thus need a method to handle these sed entries.
As of August 2017, we will delegate towards class RBT::SedWrapper
to deal with sed-related editing. However had, since as of February 2018, we will use system-sed (the binary called “sed”), if it is available. The reason as to why is because my sed-wrapper is incomplete and buggy.
Perhaps one day class SedWrapper
may work reliably, but for the time being, and as new default, we will not use the SedWrapper
by default.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27325 def check_for_sed_action _ = sed? # Note that this ought to be an Array. if _ and !_.empty? if use_the_internal_sed_wrapper? unless _.empty? notify_the_user_that_we_will_use_sed_from_the_pwd _.each {|sed_line| # Must be an Array. opne 'Next applying the following sed-operation:' apply_sed_operation_on(sed_line) } end else # ===================================================================== # # Else we will delegate towards class ApplySedOperations. # ===================================================================== # RBT::ApplySedOperations.new(_) end end end
#¶ ↑
check_whether_the_given_input_is_a_file_and_does_exist?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 25830 def check_whether_the_given_input_is_a_file_and_does_exist? @internal_hash[:check_whether_the_given_input_is_a_file_and_does_exist] end
#¶ ↑
clear_commandline_options
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12470 def clear_commandline_options @internal_hash[:commandline_arguments] = [] end
#¶ ↑
clear_env
¶ ↑
This method will clear ENV. This may sometimes be necessary to start from a clean state.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18617 def clear_env( be_verbose = true ) if be_verbose opne "Clearing (resetting) the environment variable of "\ "ruby via #{slateblue('ENV.clear()')}." end ENV.clear end
#¶ ↑
clear_env_variables_but_ensure_the_path_variable_works
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18587 def clear_env_variables_but_ensure_the_path_variable_works old_path = query_path? clear_env unless old_path.empty? # ===================================================================== # # Set a new PATH here, as otherwise compilation would fail. # ===================================================================== # opne "Note that this will lead to compile-time failures because "\ "#{orange('$PATH')}" opne 'would not be set. We will use the old path entry '\ 'there as a consequence:' opne sfancy(" #{old_path}") set_path(old_path) end end
#¶ ↑
clear_global_flags
¶ ↑
Clear the global files in use that may be stored in the file global_flags.yml.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15967 def clear_global_flags _ = RBT.file_global_flags if File.exist?(_) and !File.empty?(_) zero_this_global_flag_file(_) end if is_on_roebe? # And on my home system as well. _ = ROEBE_FILE_GLOBAL_FLAGS zero_this_global_flag_file(_) end end
#¶ ↑
cmake_exists?¶ ↑
This method will try to determine whether “cmake” exists on the local computer host or whether it does not.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12636 def cmake_exists? result = `cmake #{ERROR_LINE}` !result.include?('cmake: command not found') end
#¶ ↑
cmake_file_exists?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12687 def cmake_file_exists? File.exist? 'CMakeLists.txt' end
#¶ ↑
colourize_this_important_system_command
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 10855 def colourize_this_important_system_command(i) # ===================================================================== # # Next, modify this command if it includes "--prefix=". # In that event we will colourize it a bit; the prefix will be # colourized in another colour. # ===================================================================== # if i and i.include?('--prefix=') and use_colours? i = i.dup # ================================================================= # # === Colourize the prefix, in cornflowerblue(). # ================================================================= # i.sub!(/(--prefix=)(\/.+?)\s/, # See: http://rubular.com/r/Df8OzLqXGd '\1'+ cornflowerblue('\2 ')+ ::Colours.remove_escape_sequences( teal('') ) ) end teal(i) end
#¶ ↑
compile_all_kde5_plasma_components
¶ ↑
This entry point allows us to compile all the various KDE5 plasma components.
Invocation example:
ry --compile-all-kde5-plasma-components
#¶ ↑
# File lib/rbt/compile/compile.rb, line 21705 def compile_all_kde5_plasma_components(be_verbose = true) _ = return_kde5_plasma be_verbose = false if be_verbose == :be_quiet if be_verbose opne "We will next compile all #{lightgreen(_.size)}"\ " KDE5 plasma-components:" end set_compile_these_programs(_) end
#¶ ↑
compile_all_lxqt_components
¶ ↑
This entry point allows us to compile all LxQT components, e. g. for the lxqt-desktop.
To compile all LXQT components, try this on the commandline:
ry --compile-lxqt
#¶ ↑
# File lib/rbt/compile/compile.rb, line 20135 def compile_all_lxqt_components set_array_compile_these_programs( return_lxqt_components, :do_not_replace ) end
#¶ ↑
compile_all_of_gstreamer
¶ ↑
This entry point allows us to compile all of gstreamer.
To invoke this, try something like:
ry --gstreamer1
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14186 def compile_all_of_gstreamer e 'Now compiling the various '+steelblue('gstreamer components')+'.' array = %i( gstreamer gstreamerpluginsbase gstpluginsgood gstpluginsbad ) do_compile_these_programs(array) end
#¶ ↑
compile_all_of_kde
¶ ↑
To invoke this method, do:
ry --compile-all-of-kde
#¶ ↑
# File lib/rbt/compile/compile.rb, line 21723 def compile_all_of_kde _ = [] # ======================================================================= # # === The KDE foundation (including extra-cmake-modules) # ======================================================================= # _ << return_these_programs(:kde5_foundation) # ======================================================================= # # === The KDE applications # ======================================================================= # _ << return_kde5_applications # ======================================================================= # # === The KDE plasma stack # ======================================================================= # _ << return_kde5_plasma # ======================================================================= # # === The KDE porting aids # ======================================================================= # _ << return_kde5_porting_aids _.flatten! set_compile_these_programs(_) # ← Set it just in case. end
#¶ ↑
compile_all_programs
¶ ↑
This method is a direct approach to compile every program that we have registered, in our database.
This method accepts one argument, which decides whether we will quit afterwards or whether we will not.
Invocation example:
ry --compile_all_programs
#¶ ↑
# File lib/rbt/compile/compile.rb, line 11347 def compile_all_programs( shall_we_exit = true ) case shall_we_exit when :do_exit_afterwards shall_we_exit = true end _ = return_available_programs.shuffle # We shuffle for more "randomness". n_programs = _.size.to_s clear_commandline_options opne sfancy('Compiling all available programs next (by a brute'\ 'force approach - we found ')+ simp(n_programs)+sfancy(' programs):') compile_every_program(_) exit_program if shall_we_exit end
#¶ ↑
compile_all_programs_that_belong_to_this_tag
¶ ↑
Invocation examples:
rbt --compile-this-tag=gnome rbt --compile-this-tag=kde rbt --compile-this-tag=kde5 rbt --compile-this-tag=game
#¶ ↑
# File lib/rbt/compile/compile.rb, line 21401 def compile_all_programs_that_belong_to_this_tag(i) # ======================================================================= # # (1) first obtain all programs that belong to a particular tag # ======================================================================= # these_programs = RBT.return_array_of_this_tag(i) # ======================================================================= # # (2) then set to the main array # ======================================================================= # set_compile_these_programs( these_programs ) end
#¶ ↑
compile_all_up_until_konsole
¶ ↑
This method can be used to quickly get to compile konsole - and, prior to that, the programs that KDE Konsole depends on.
Invocation example:
ry --compile-towards-konsole
#¶ ↑
# File lib/rbt/compile/compile.rb, line 21771 def compile_all_up_until_konsole _ = [] _ << return_these_programs(:kde5_foundation) # ← This is fine. _ << :konsole _.flatten! set_compile_these_programs(_, false) # ← Set it just in case. end
#¶ ↑
compile_array?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 21499 def compile_array? @array_compile_these_programs end
#¶ ↑
compile_gcc_with_only_c_and_cpp
¶ ↑
To invoke this method, try:
ry gcc --only-c-and-cpp
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14316 def compile_gcc_with_only_c_and_cpp initialize_dataset_for(:gcc) clear_configure_options # ===================================================================== # # --disable-multilib is necessary as otherwise it won't work. # ===================================================================== # append_this_to_the_configure_options( '--enable-languages=c,c++ --disable-multilib' ) end
#¶ ↑
compile_into_the_home_directory_as_appdir
¶ ↑
This method will enable compilation into the user’s home directory, via AppDir style.
Invocation example:
rbt xwd --homedir
#¶ ↑
# File lib/rbt/compile/compile.rb, line 23723 def compile_into_the_home_directory_as_appdir set_user_prefix("$HOME#{static_appdir_prefix?}") end
#¶ ↑
compile_mate_desktop_components_into_one_standalone_directory
¶ ↑
To invoke this method from the commandline, do:
ry --mate-desktop-into-standalone-dir
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12202 def compile_mate_desktop_components_into_one_standalone_directory _ = return_mate_desktop_components # ======================================================================= # # We currently (Oct 2018) will use a hardcoded path. This may change # at a later point in the future. # ======================================================================= # use_this_prefix = "#{programs_dir?}Mate/1.25/" set_use_this_prefix(use_this_prefix) batch_compile_the_programs(_) end
#¶ ↑
compile_mouse_and_keyboard_xorg_server_components
¶ ↑
The input-argument to this method defaults to the components that we wish to compile.
To compile the entries in this method, issue:
ry --compile-mouse-and-keyboard
#¶ ↑
# File lib/rbt/compile/compile.rb, line 17408 def compile_mouse_and_keyboard_xorg_server_components( array_components = %w( xf86-input-evdev xf86-input-joystick xf86-input-libinput xf86-input-synaptics xf86-input-mouse xf86-input-vmmouse xf86-input-wacom ) ) opne "Next compiling `#{royalblue(array_components.size.to_s)}` programs:" array_components.each {|this_component| this_component = set_handle_this_program(this_component) do_compile_this_program(this_component) } end
#¶ ↑
compile_mouse_components
¶ ↑
This method will compile mouse-related components (on a linux system, aka using the xorg-server).
#¶ ↑
# File lib/rbt/compile/compile.rb, line 17388 def compile_mouse_components compile_mouse_and_keyboard_xorg_server_components( %w( xf86-input-vmmouse xf86-input-mouse ) ) end
#¶ ↑
compile_post_xorg_server_components
¶ ↑
Invocation example for this method:
ry --post-xorg-server
#¶ ↑
# File lib/rbt/compile/compile.rb, line 17450 def compile_post_xorg_server_components _ = RBT.report_post_xorg_server_components opne "Next compiling `#{royalblue(_.size.to_s)}` programs:" _.each {|this_program| do_compile_this_program(this_program) } end
#¶ ↑
compile_the_initial_lfs_toolchain
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 16027 def compile_the_initial_lfs_toolchain ENV['PATH'] = '/tools/bin:/bin:/usr/bin' opne 'We will next try to install a LFS-like toolchain - aka, similar to' opne 'How the Linux from Scratch system is bootstrapped.' e e 'In order to do so, certain '+steelblue('assumptions')+' will have to be made.' e # ======================================================================= # # Next comes the general LFS prefix to use. # ======================================================================= # use_this_prefix = '/home/LFS/' prefix_for_tools = use_this_prefix+'tools' # ======================================================================= # # === tools_lib_path # ======================================================================= # tools_lib_path = prefix_for_tools+'/lib' prefix_for_sources = use_this_prefix+'sources' opne 'The target directory for this boostrapped toolchain will be at:' e e " #{steelblue(use_this_prefix)}" e mkdir(use_this_prefix) mkdir(prefix_for_tools) mkdir(prefix_for_sources) mkdir(tools_lib_path) unless File.symlink? '/tools' esystem("ln -sv #{prefix_for_tools} /") end # ======================================================================= # # === Create .bash_profile next: # ======================================================================= # this_file = File.expand_path('~/.bash_profile') unless File.exist? this_file what = <<-EOF exec env -i HOME=$HOME TERM=$TERM PS1=' ' /bin/bash EOF opne 'Next storing into the file `'+sfile(this_file)+'`.' write_what_into(what, this_file) end # ======================================================================= # # === Create .bashrc next: # ======================================================================= # this_file = File.expand_path('~/.bashrc') # ======================================================================= # # Overrule for the LFS user: # ======================================================================= # this_file = File.expand_path('/home/lfs/.bashrc') architecture = `uname -m`.strip # ======================================================================= # # === lfs_target_architecture # # Specify which target architecture is to be used. Oddly enough GCC # seems to be picky about the name chosen here. # ======================================================================= # lfs_target_architecture = "#{architecture}-pc-linux-gnu" unless File.exist? this_file what = "set +h umask 022 LFS=#{use_this_prefix} LC_ALL=POSIX LFS_TGT=#{lfs_target_architecture} PATH=/tools/bin:/bin:/usr/bin export LFS LC_ALL LFS_TGT PATH " opne 'Next storing into the file `'+sfile(this_file)+'`.' write_what_into(what, this_file) end # ======================================================================= # # Next compile binutils, first pass - see also this URL: # # http://www.linuxfromscratch.org/lfs/view/development/chapter05/binutils-pass1.html # # ======================================================================= # _ = RBT::Compile.new(:binutils) { :do_not_run_yet } _.clear_configure_options _.set_prefix_to_use('/tools') _.do_not_store_the_compile_time use_these_configure_options = <<-EOF --with-sysroot=#{use_this_prefix} --with-lib-path=/tools/lib --target=#{lfs_target_architecture} --disable-nls --disable-werror EOF _.set_internal_hash_configure_options use_these_configure_options.tr("\n", ' ') _.skip_postinstallation_step _.do_not_register_the_last_compiled_program _.run if is_on_64_bit? cd prefix_for_tools esystem 'ln -sv lib /tools/lib64' end # ======================================================================= # # Next prepare GCC # ======================================================================= # cd log_dir? _ = RBT::Compile.new(:gcc) { :do_not_run_yet } extract_what_to( _.cookbook_dataset_program_path?, _.extracted_path? ) target_dir = _.extracted_path?+ remove_archive_from_the_end( File.basename(_.cookbook_dataset_program_path?) ) opne 'Changing directory into '+sdir(target_dir)+' next.' cd target_dir path_to_mpfr = return_path_to_the_archive_of_this_program(:mpfr) path_to_gmp = return_path_to_the_archive_of_this_program(:gmp) path_to_mpc = return_path_to_the_archive_of_this_program(:mpc) extract_what_to( path_to_mpfr, return_pwd ) unless File.directory? 'mpfr' opnn; mv remove_archive_from_the_end(File.basename(path_to_mpfr)),'mpfr' end extract_what_to( path_to_gmp, return_pwd ) unless File.directory? 'gmp' opnn; mv remove_archive_from_the_end(File.basename(path_to_gmp)),'gmp' end extract_what_to( path_to_mpc, return_pwd ) unless File.directory? 'mpc' opnn; mv remove_archive_from_the_end(File.basename(path_to_mpc)),'mpc' end what = <<-EOF for file in gcc/config/{linux,i386/linux{,64}}.h do cp -uv $file{,.orig} sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' -e 's@/usr@/tools@g' $file.orig > $file echo ' #undef STANDARD_STARTFILE_PREFIX_1 #undef STANDARD_STARTFILE_PREFIX_2 #define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/" #define STANDARD_STARTFILE_PREFIX_2 ""' >> $file touch $file.orig done EOF esystem what adhoc_fix_gcc _.clear_configure_options _.set_prefix_to_use(prefix_for_tools) _.do_not_store_the_compile_time use_these_configure_options = <<-EOF --target=#{lfs_target_architecture} --with-glibc-version=2.11 --with-sysroot=#{use_this_prefix} --with-newlib --without-headers --with-local-prefix=/tools --with-native-system-header-dir=/tools/include --enable-languages=c,c++ --disable-nls --disable-shared --disable-multilib --disable-decimal-float --disable-threads --disable-libatomic --disable-libgomp --disable-libquadmath --disable-libssp --disable-libvtv --disable-libstdcxx EOF _.set_internal_hash_configure_options use_these_configure_options.tr("\n", ' ').squeeze(' ') _.skip_postinstallation_step _.do_not_register_the_last_compiled_program _.run # ======================================================================= # # Next install the linux kernel header files: # ======================================================================= # path_to_linux = return_path_to_the_archive_of_this_program(:linux) extract_what_to( path_to_linux, return_pwd ) cd remove_archive_at_the_end(File.basename(path_to_linux)) e 'We are in the directory '+sdir(return_pwd)+' and will '\ 'run three commands:' esystem 'make mrproper' esystem 'make headers' esystem 'cp -rv usr/include/* /tools/include' # ======================================================================= # # Next glibc: # ======================================================================= # cd log_dir? _ = RBT::Compile.new(:glibc) { :do_not_run_yet } extract_what_to( _.cookbook_dataset_program_path?, _.extracted_path? ) target_dir = _.extracted_path?+ remove_archive_from_the_end( File.basename(_.cookbook_dataset_program_path?) ) opne 'Changing directory into '+sdir(target_dir)+' next.' _.clear_configure_options _.set_prefix_to_use(prefix_for_tools) _.do_not_store_the_compile_time use_these_configure_options = <<-EOF --host=#{lfs_target_architecture} --build=$(../scripts/config.guess) --enable-kernel=3.2 --with-headers=/tools/include EOF _.set_internal_hash_configure_options use_these_configure_options.tr("\n", ' ').squeeze(' ') _.skip_postinstallation_step _.do_not_register_the_last_compiled_program _.run # ======================================================================= # # Next install Libstdc++ # ======================================================================= # cd log_dir? _ = RBT::Compile.new(:gcc) { :do_not_run_yet } extract_what_to( _.cookbook_dataset_program_path?, _.extracted_path? ) target_dir = _.extracted_path?+ remove_archive_from_the_end( File.basename(_.cookbook_dataset_program_path?) ) opne 'Changing directory into '+sdir(target_dir)+' next.' cd target_dir mkdir 'build' cd 'build' opne 'We are now in the directory '+sdir(target_dir)+'.' ENV['LD_CONFIG_PATH'] = tools_lib_path esystem "../libstdc++-v3/configure --host=#{lfs_target_architecture} --prefix=/tools --disable-bootstrap --disable-multilib --disable-nls --disable-libstdcxx-threads --disable-libstdcxx-pch --with-system-zlib --with-newlib --disable-libquadmath --with-gxx-include-dir=/tools/#{lfs_target_architecture}/include/c++/9.2.0".squeeze(' ').tr("\n",' ').squeeze(' ') # ======================================================================= # # This here may lead to problems - in that event, have a look at the # config.log file, as it should show why, for example, link tests # were disabled. --disable-libquadmath should help in that case, # by the way. # ======================================================================= # esystem 'make' esystem 'make install' end
#¶ ↑
compile_the_main_program_including_the_dependencies
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 21377 def compile_the_main_program_including_the_dependencies ensure_that_the_main_dataset_exists # ======================================================================= # # Prepend to this chain the known dependencies. # ======================================================================= # _ = compile_these_programs? _.prepend( required_deps_on? ) _.flatten! set_array_compile_these_programs(_) end
#¶ ↑
compile_the_python_addons
¶ ↑
This method can be used to compile all the various python addons.
Invocation example:
ry --python-addons
#¶ ↑
# File lib/rbt/compile/compile.rb, line 24982 def compile_the_python_addons( array = chained_programs?['python_addons'] ) opne "Installing various registered python-addons (#{array.size.to_s}) next." set_compile_these_programs(array) end
#¶ ↑
compile_the_ruby_addons
¶ ↑
This method can be used to compile all the various ruby addons.
Invocation example:
ry --ruby-addons
#¶ ↑
# File lib/rbt/compile/compile.rb, line 21899 def compile_the_ruby_addons array = chained_programs?['ruby_addons'].reject {|entry| entry == 'ruby' } opne "Installing various registered ruby-addons "\ "(#{steelblue(array.size.to_s)}) next." set_array_compile_these_programs(array, :do_not_replace) end
#¶ ↑
compile_this_existing_file
¶ ↑
This method can be used to compile an existing file.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 21419 def compile_this_existing_file( i = first_argument? ) _ = extract_to?.dup extract_this_source_archive(i, _) sanitized_first_argument = remove_archive_at_the_end( return_program_name_hyphen_then_program_version_or_first_argument ) unless _.end_with? sanitized_first_argument _ << sanitized_first_argument end _ = remove_archive_from_the_end(_) opne 'Changing directory into '+sdir(_)+' next.' cd _ run_configure run_make_then_make_install end
#¶ ↑
compile_which_programs?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 25823 def compile_which_programs? RBT.compile_which_programs? end
#¶ ↑
compile_xcb_components
¶ ↑
To invoke this method, issue:
ry --compile-xcb-components
#¶ ↑
# File lib/rbt/compile/compile.rb, line 10827 def compile_xcb_components opne "#{rev}Now compiling the various #{steelblue('xcb components')}." array = %i( xcbproto libxcb xcbutil xcbutilcursor xcbutilerrors xcbutilimage xcbutilkeysyms xcbutilrenderutil xcbutilwm xcbutilxrm ) set_array_compile_these_programs(array) end
#¶ ↑
compile_xfce_components_into_one_standalone_directory
¶ ↑
To invoke this method from the commandline, do:
ry --xfce-into-standalone-dir
#¶ ↑
# File lib/rbt/compile/compile.rb, line 17370 def compile_xfce_components_into_one_standalone_directory _ = return_xfce_components # ======================================================================= # # We currently (Oct 2018) will use a hardcoded path. This may change # at a later point in the future. # ======================================================================= # use_this_prefix = programs_dir?+'Xfce/4.16/' set_use_this_prefix( use_this_prefix ) batch_compile_the_programs(_) end
#¶ ↑
compile_xorg_libraries
¶ ↑
Invocation example for this method:
ry --compile_xorg_libraries
#¶ ↑
# File lib/rbt/compile/compile.rb, line 17434 def compile_xorg_libraries _ = RBT.return_xorg_server_libraries opne "Next compiling `#{royalblue(_.size.to_s)}` programs:" _.each {|this_program| do_compile_this_program(this_program) } end
#¶ ↑
compiled_programs?¶ ↑
This will grab the full dataset of compiled_programs.yml
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26103 def compiled_programs?( from_this_file = file_compiled_programs? ) if File.exist? from_this_file return load_yaml(from_this_file) else opne "The file at #{sfile(from_this_file)} does not exist." end end
#¶ ↑
configuration?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 25982 def configuration? RBT.configuration? end
#¶ ↑
configure_base_directory?¶ ↑
This should always have a trailing ‘/’ character IF it is defined. class Cookbook will make sure of that.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18035 def configure_base_directory? _ = @internal_hash[:configure_base_directory] if _.nil? _ = cookbook_dataset_configure_base_directory? end return _ end
#¶ ↑
configure_has_a_higher_priority_than_meson?¶ ↑
This method will return true if “configure” has a higher priority than “meson”. A yaml file keeps track of these priorities.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14558 def configure_has_a_higher_priority_than_meson? ::RBT.configure_has_a_higher_priority_than_meson? end
#¶ ↑
configure_options?¶ ↑
This method will retrieve the configure options. We default to using the configure-options stored in the cookbook dataset, but we can overrule this on the commandline (when we store it onto the @internal_hash).
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26349 def configure_options? _ = cookbook_dataset_configure_options? if @internal_hash[:configure_options] _ = @internal_hash[:configure_options] end _ end
#¶ ↑
configure_script_exists?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26205 def configure_script_exists? File.exist?('configure') end
#¶ ↑
consider_applying_a_patch
¶ ↑
Check whether we should apply a patch_set or not.
This should happen before we make use of preinstall, and after displaying an optional start message.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 16466 def consider_applying_a_patch apply_patch = apply_patch? if apply_patch patchset = apply_patch patchset = [patchset] unless patchset.is_a? Array patchset.flatten.each {|this_patchset| cliner { this_dir = configure_base_directory? opne simp('Trying to ')+ orange('apply a patch')+ simp(' next:')+ simp(' (in ')+ sdir(this_dir)+ simp(')') opne " #{this_patchset}" } # =================================================================== # # (1) Download the patch unless it exists locally. # =================================================================== # unless File.exist? File.basename(this_patchset) opne 'Next trying to download '+steelblue(this_patchset)+'.' do_download_this_program(this_patchset) end this_command = "patch -Np1 -i #{File.basename(this_patchset)}" opne "Running this command next (from the directory "\ "#{sdir(return_pwd)}):" e e "#{sfancy(this_command)}" e # =================================================================== # # (2) Run the patchset. # =================================================================== # custom_system(this_command) # Delegate to Kernel#system. } end end
#¶ ↑
consider_changing_the_tab_title
(shell tag)¶ ↑
Use this method to change the title of a tab in a Terminal like Bash.
# ¶ ↑
# File lib/rbt/compile/compile.rb, line 17948 def consider_changing_the_tab_title( i = return_program_name_then_hyphen_then_the_program_version, shall_we_rename_the_tab_title = rename_tab_title? ) case shall_we_rename_the_tab_title when :do_rename shall_we_rename_the_tab_title = true end # ======================================================================= # # First check whether we ought to rename the tab title or not. # ======================================================================= # if shall_we_rename_the_tab_title case i # ===================================================================== # # === :default # ===================================================================== # when :default # This is the current hardcoded default. May change at a later time. i = return_program_name_then_hyphen_then_the_program_version # ===================================================================== # # === :clear # ===================================================================== # when :clear i = '.' end # ===================================================================== # # Query whether Roebe is available or not. # ===================================================================== # if Object.const_defined?(:Roebe) and rename_tab_title? # Only use it if the user enabled this. if Roebe.respond_to? :rename_konsole_title_to # ================================================================= # # Rename the konsole-title here. # ================================================================= # Roebe.rename_konsole_title_to(i, :be_quiet) else e "The namespace #{sfancy('Roebe')} does not respond to the method" e 'rename_konsole_title_to()' e 'Either the functionality is missing - or something has not' e 'been properly required. Either way, we can not rename the' e 'konsole tab for now.' end end end unless i.empty? end
#¶ ↑
consider_checking_whether_the_compiled_binaries_are_already_registered
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15090 def consider_checking_whether_the_compiled_binaries_are_already_registered if is_on_roebe? and # ← Only allow this on roebe-systems. is_app_dir? and has_to_be_compiled? and compiled_successfully? and !prefix?.include?('Toolchain') # Make /home/Programs/Toolchain exempt from this. locally_existing_executables = Dir["#{prefix?}bin/*"].map {|entry| File.basename(entry) } locally_existing_executables << Dir["#{prefix?}sbin/*"].map {|entry| File.basename(entry) } locally_existing_executables.flatten! locally_existing_executables.uniq! registered_binaries = cookbooks_binaries? # ===================================================================== # # Next compare these entries: # ===================================================================== # locally_existing_executables.each {|entry| if registered_binaries.include? entry # In this case all is fine. else compile_this_program = compile_which_program? # ================================================================= # # Else it is a not-registered binary, so report it. # ================================================================= # cliner opne crimson('The entry ')+steelblue(entry)+ crimson(' is not a registered') opne crimson('binary for the program ')+ royalblue(compile_this_program)+ crimson('.') opne olivedrab('^^^ Consider changing this. ^^^') cliner # ================================================================= # # Since as of 09.12.2019 we will also store this result into a # log file. # ================================================================= # what = "#{entry} belongs to the program called "\ "#{rarrow?} #{compile_this_program}" into = "#{log_dir?}these_binaries.yml" opne 'Storing '+steelblue(entry)+' into the file '+sfile(into)+ ' as well.' append_what_into("#{what}#{N}", into) end } end end
#¶ ↑
consider_comparing_the_installed_libraries_versus_the_assumed_libraries
¶ ↑
This method will try to compare the installed libraries in an AppDir with the ones that are registered in the various cookbook .yml files.
This will happen ONLY if we are on a roebe-system; and ONLY if we use an AppDir approach.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14818 def consider_comparing_the_installed_libraries_versus_the_assumed_libraries if is_on_roebe? and is_an_appdir_installation? and has_been_installed_successfully? assumed_libraries = RBT.infer_these_libraries_will_be_installed_by( compile_which_program? ) if assumed_libraries libraries?.each {|this_already_registered_library| # ================================================================= # # The variable this_already_registered_library may be something # like 'libgmodule-2.0.so'. # ================================================================= # if assumed_libraries.any? {|entry| entry.include? this_already_registered_library } else opne "The library "\ "#{orange(this_already_registered_library)}"\ " is not registered." opne 'Consider '+crimson('updating')+' it (file: '+ sfile(compile_which_program?+'.yml')+ ').' end } end end end
#¶ ↑
consider_creating_appdir_skeleton_then_consider_running_autoconf_then_run_configure_then_make_then_make_install
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13426 def consider_creating_appdir_skeleton_then_consider_running_autoconf_then_run_configure_then_make_then_make_install consider_creating_appdir_skeleton consider_running_autoconf_then_run_configure_then_make_then_make_install end
#¶ ↑
consider_creating_the_appdir_skeleton
¶ ↑
This method will create an AppDir skeleton, by delegating towards class RBT::CreateAppDirSkeleton
.
We will only do so if the prefix includes the AppDir base directory though. By default, that base directory would hold the value of the $PROGRAMS environment variable - at the least on my system, this defaults to /Programs/. You can change this value if you modify a yaml file though. That yaml file is called “programs_dir.yml” and resides in the yaml/configuration/ subdirectory of the RBT
project.
The method accepts one argument, which is either the program name, or alternatively the full name to the program in question.
Normally, the program name will be defined in the yaml data object, but since you can also overrule this setting in the yaml file, we need an argument here to allow this too.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18434 def consider_creating_the_appdir_skeleton( i = return_proper_prefix ) if uses_an_appdir_prefix? # ===================================================================== # # Check for an AppDir prefix next: # ===================================================================== # i = i.to_s.dup if i.include? programs_dir? unless i =~ /\d+/ i << program_version? end i << '/' unless i.end_with? '/' # =================================================================== # # Next, delegate towards class RBT::CreateAppDirSkeleton. Since as # of 20.01.2020 we will specify which programs should NOT modify # the old symlink, for the new 'Current →' symlink. Otherwise # compilation would fail, e. g. if /usr/bin/make would point to # a not-yet compiled target prefix. # =================================================================== # _ = RBT::CreateAppDirSkeleton.new(i.dup, :dont_run_yet) {{ use_colours: use_colours?, use_opn: use_opn?, do_not_symlink_these_programs: %i( make gcc binutils ) # ← An exception for these programs. }} _.no_opn unless use_opn? _.run_simulation = run_simulation? # _.set_base_directory = programs_directory? # ← I think this is no longer needed. _.run end end end
#¶ ↑
consider_enabling_python2
¶ ↑
This may ensure that we will use python 2.x, primarily due to the meson build system. Right now it only works on roebe-systems though.
It can also be enabled from the commandline, such as by issuing the following command:
rbt --enable-python2
#¶ ↑
# File lib/rbt/compile/compile.rb, line 25216 def consider_enabling_python2( shall_we_enable_python_2 = (on_roebe? and !do_we_use_python3?) ) if shall_we_enable_python_2 # ======================================================================= # # Try to use python version 3 here. # ======================================================================= # if File.directory?(programs_directory?+'Python/') availabe_python_versions = Dir[programs_directory?+'Python/*'].select {|entry| File.directory? entry }.select {|entries_with_numbers| entries_with_numbers =~ /\d+/ }.select {|entries_that_might_be_python_version_two| entries_that_might_be_python_version_two.include? 'Python/2' } unless availabe_python_versions.empty? use_this_python_version = availabe_python_versions.first unless RBT.const_defined? :ToCurrent require 'rbt/utility_scripts/to_current.rb' end RBT::ToCurrent.new(use_this_python_version) return true # Determine that it was a success. end end end false end
#¶ ↑
consider_enabling_python3
¶ ↑
This may ensure that we will use python 3.x, primarily due to the meson build system. Right now it only works on roebe-systems though.
It can also be enabled from the commandline, such as by issuing the following command:
rbt --enable-python3
#¶ ↑
# File lib/rbt/compile/compile.rb, line 25263 def consider_enabling_python3( shall_we_enable_python_3 = (on_roebe? and !do_we_use_python3?) ) if shall_we_enable_python_3 # ======================================================================= # # Try to use python version 3 here. # ======================================================================= # if File.directory?(programs_directory?+'Python/') availabe_python_versions = Dir[programs_directory?+'Python/*'].select {|entry| File.directory? entry }.select {|entries_with_numbers| entries_with_numbers =~ /\d+/ }.select {|entries_that_might_be_python_version_three| entries_that_might_be_python_version_three.include? 'Python/3' } unless availabe_python_versions.empty? use_this_python_version = availabe_python_versions.first unless RBT.const_defined? :ToCurrent require 'rbt/utility_scripts/to_current.rb' end RBT::ToCurrent.new(use_this_python_version) return true # Determine that it was a success. end end end false end
#¶ ↑
consider_handling_build_directory
¶ ↑
This method can create a build directory, that is, a directory which will keep other generated files and directories inside of it.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 23031 def consider_handling_build_directory if use_build_directory? # ===================================================================== # # First determine the path we ought to use for the build directory. # # This has to be a correct path since we depend on it for the # change_directory action lateron. Note that if the name for the # build directory begins with a '/' then it will be used as the # full build directory instead - in this case we assume that the # user knew what he wanted to do. # ===================================================================== # if name_for_the_build_directory?.start_with? '/' use_this_as_path_to_the_build_directory = name_for_the_build_directory?.dup else use_this_as_path_to_the_build_directory = @internal_hash[:configure_base_directory]+ name_for_the_build_directory? end # ===================================================================== # # Delegate towards class BuildDirectory next: # ===================================================================== # @build_directory = BuildDirectory.new( path_to_build_directory: use_this_as_path_to_the_build_directory.dup ) # ===================================================================== # # Next assign it onto the @internal_hash variable: # ===================================================================== # # @internal_hash[:build_directory] = @build_directory set_name_for_the_build_directory(@build_directory.full_path?) @build_directory.silently_make_sure_that_the_build_directory_exists # ===================================================================== # # We will not cd into that directory if we use the meson-build system. # ===================================================================== # unless do_we_use_the_meson_build_system? opnn; @build_directory.cd :be_verbose # cd into that directory. end end end
#¶ ↑
consider_modifying_postinstall_with_this_prefix
¶ ↑
This method can be used to modify all prefix-targets in the postinstall Array.
We will only modify the program_version
normally here.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 23376 def consider_modifying_postinstall_with_this_prefix( i = program_version? ) return unless i unless i.start_with? '/' i = i.dup if i.frozen? i.prepend('/') # A bit hackish as a workaround but this works. end # ======================================================================= # # The regex is also stored here: # # https://rubular.com/r/U7J9cbbqUBPI # # ======================================================================= # regex_to_use = /\/(\d{1,2}\.?\d{1,2}\.?\d{0,2})/ cookbook_dataset_postinstallation = cookbook_dataset_postinstallation? if cookbook_dataset_postinstallation set_postinstallation( cookbook_dataset_postinstallation.map {|line| # =================================================================== # # We must use .gsub!() here rather than .sub!() because the # full line may be like this: # # ln -s /Programs/Gtk+/3.24.1/include/gtk-2.0 /Programs/Gtk+/3.24.1/include/gtk # # =================================================================== # line.gsub!(regex_to_use, i) line } ) end end
#¶ ↑
consider_performing_postinstallation_actions
(postinstall tag, post tag)¶ ↑
Postinstall actions are optional - they are done after the “make install” step has finished.
This method here handles postinstall-related actions, like starting a service after compilation has finished, or removing a directory after installation - these sorts of actions.
A song may also be played if the configuration option tells us to do so. (This may give us an audio-cue that compilation has finished. I no longer make use of this, but if others want to, here we go)
We make use of RBT::SymlinkProgram to symlink the AppDir properly, in the event that we compile into AppDirs.
Since as of February 2019, a separate class handles these postinstallation steps.
As a summary and an overview, these are valid postinstall actions:
- Running cleanup actions - Renaming a shell (optional) - Playing a song (when the configuration option told us to do so) - Symlinking files after installation - Copying several files to another location - Deleting any .la files if the user specified so (this is now the default; RBT::Compile will always try to remove .la files under an AppDir prefix, unless the user has specified otherwise)
#¶ ↑
# File lib/rbt/compile/compile.rb, line 23263 def consider_performing_postinstallation_actions( run_postinstall_actions = run_postinstall_actions? ) # ======================================================================= # # Only run these actions if we actually do run postinstall actions: # ======================================================================= # if run_postinstall_actions and can_we_continue? # ===================================================================== # # Next delegate towards class RBT::PostinstallationStep. # ===================================================================== # RBT::PostinstallationStep.new( return_hash_for_the_postinstallation_step ) {{ use_opn: use_opn? }} end end
#¶ ↑
consider_removing_empty_subdirectories
¶ ↑
We will remove empty subdirectories but only from AppDir-like prefixes.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12936 def consider_removing_empty_subdirectories if uses_an_appdir_prefix? prefix = prefix?.to_s # ← This will be like "/Programs/Gcide/0.52/". subdirectories = Dir[prefix+'*'].select {|entry| File.directory?(entry) and Dir.empty?(entry) } remove_directories( subdirectories ) consider_removing_the_current_symlink_if_the_directory_is_empty consider_removing_the_settings_directory_if_it_is_empty consider_removing_the_empty_versioned_directory consider_removing_the_empty_base_directory_of_the_program end end
#¶ ↑
consider_removing_the_current_symlink_if_the_directory_is_empty
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13409 def consider_removing_the_current_symlink_if_the_directory_is_empty if uses_an_appdir_prefix? prefix = prefix?.to_s symlink_current = rds( File.dirname(prefix)+'/Current' ) if File.symlink?(symlink_current) and File.directory?(File.readlink(symlink_current)) and Dir.empty?(File.readlink(symlink_current)) delete_this_symlink(symlink_current) end end end
#¶ ↑
consider_removing_the_empty_base_directory_of_the_program
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12955 def consider_removing_the_empty_base_directory_of_the_program if uses_an_appdir_prefix? and !is_a_gem_file? target = rds( programs_dir?+program_name?.capitalize.delete('-_')+'/' ) if File.directory?(target) and Dir.empty?(target) opne tomato('Removing')+' the empty directory at `'+sdir(target)+'` next.' remove_this_directory(target) end end end
#¶ ↑
consider_removing_the_old_extracted_directory_if_it_exists
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 19177 def consider_removing_the_old_extracted_directory_if_it_exists( i = remove_archive_stuff_from_the_end(will_be_extracted_towards?) ) if File.directory?(i) and i.include?(log_dir?) if i == log_dir? opne 'Can not remove '+sdir(i)+'.' else opne steelblue('Removing')+rev+ ' the extracted directory at '+sdir(i)+' next.' remove_directory(i) end end end
#¶ ↑
consider_removing_the_settings_directory_if_it_is_empty
¶ ↑
This method will attempt to remove the /Settings subdirectory, if it is empty.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13382 def consider_removing_the_settings_directory_if_it_is_empty if uses_an_appdir_prefix? prefix = prefix?.to_s settings_directory = File.dirname(prefix)+'/Settings' if File.directory?(settings_directory) and Dir.empty?(settings_directory) remove_this_directory(settings_directory) end end end
#¶ ↑
consider_reporting_the_time_it_took_to_compile_this_program
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 11070 def consider_reporting_the_time_it_took_to_compile_this_program if time_the_compilation? and no_error_has_occurred? program_name = compile_which_program?.to_s # Keep a reference. _ = @internal_hash[:array_time_compilation] # ===================================================================== # # We need the start-time and the end-time, in order to calculate # the difference. # ===================================================================== # start_time = @internal_hash[:array_time_compilation][-2] end_time = @internal_hash[:array_time_compilation][-1] # ===================================================================== # # We must next check that both end time and start time exist, as # otherwise we would run into an error. # ===================================================================== # if start_time and end_time duration = (end_time - start_time) rounded_duration = duration.round(3) in_minutes = (rounded_duration.to_f / 60.0).round(2) if has_to_be_compiled? compiling_or_installing = 'Compiling' else compiling_or_installing = 'Installing' end # ===================================================================== # # Notify the user how long it took to compile/install the given # program at hand. # ===================================================================== # opne "#{compiling_or_installing} the program `"\ "#{olivedrab(program_name)}"\ "` took #{sfancy(rounded_duration.to_s)} seconds "\ "(aka #{sfancy(in_minutes)} minutes)." # ===================================================================== # # Also store this now into a file. # ===================================================================== # _ = RBT.file_storing_the_time_it_took_to_compile_programs if File.exist? _ dataset = YAML.load_file(_) else dataset = {} # Use a Hash format. end dataset[program_name] = rounded_duration opne 'Also storing this information into the file' opne " #{sfile(_)}" write_what_into(YAML.dump(dataset), _) else opne 'Can not store the time as the variable tracking the time' opne 'is incorrect. It will be displayed next, to aid in debugging:' e pp @internal_hash[:array_time_compilation][-1] e end end end
#¶ ↑
consider_running_autoconf_then_run_configure_then_make_then_make_install
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13155 def consider_running_autoconf_then_run_configure_then_make_then_make_install consider_running_the_pre_configure_steps decide_whether_to_invoke_the_autoconf_command run_configure_then_make_then_make_install end
#¶ ↑
consider_running_the_pre_configure_steps
¶ ↑
This method will perform the pre-configure steps, if they were given at all that is.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18152 def consider_running_the_pre_configure_steps _ = pre_configure_steps? unless _.empty? _.each {|entry| e steelblue('Running the following command next, '\ 'as a pre-configure step') e peru(' (in the directory ')+ sdir(return_pwd)+ peru(')')+ steelblue(':') e e mediumseagreen(" #{entry}") system entry e } end end
#¶ ↑
consider_sanitizing_the_program_path
¶ ↑
This method will only be used when @internal_hash has been set.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13226 def consider_sanitizing_the_program_path if @internal_hash[:use_this_specific_program_version] # ===================================================================== # # The above variable is nil by default, so if it has another value # we can use this. # ===================================================================== # splitted = @internal_hash[:use_this_specific_program_version].split('/') last = splitted.last # ← This will hold the new program version. old_value = cookbook_dataset_program_path?.dup old_version = program_information_return_version(old_value) set_cookbook_dataset_program_version( last ) old_value.sub!(/#{old_version}/, last) set_cookbook_dataset_program( remove_extension( File.basename(old_value) ) ) set_cookbook_dataset_program_path(old_value) end end
#¶ ↑
consider_showing_the_flexbox
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 22134 def consider_showing_the_flexbox show_flexbox if show_flexbox? end
#¶ ↑
consider_symlinking_the_pkgconfig_files
¶ ↑
If the cookbook has symlinking_pkgconfig_files set to true, and if the program is compiled, as AppDir, then we will symlink .pc files into /usr/lib/pkgconfig/, if the latter one exists.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 24676 def consider_symlinking_the_pkgconfig_files target_dir = '/usr/lib/pkgconfig/' if symlink_pkgconfig_files? and is_appdir_compilation_style? and File.directory?(target_dir) and !do_not_symlink? appdir_target_with_pc_files = "#{return_appdir_prefix}lib/pkgconfig/" # ===================================================================== # # Delegate towards class SymlinkPkgconfigFiles next. # ===================================================================== # SymlinkPkgconfigFiles.new(appdir_target_with_pc_files) end end
#¶ ↑
consider_to_run_ldconfig
(ldconfig tag)¶ ↑
Run ‘ldconfig’ here in this method.
Check whether we are allowed to invoke this method before calling it however.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 20184 def consider_to_run_ldconfig return if are_we_on_windows? if continue_after_make_step? # Makes only sense if we are past the make-step. # ===================================================================== # # ruby and python add-ons normally do not require ldconfig, # so we don't have to invoke it. # ===================================================================== # if tags?.include?('ruby') or tags?.include?('python') do_not_run_ldconfig end # ===================================================================== # # Only run it if the config-file tells us to do so and only for # those programs that have to be compiled. # # class RBT::Compile will, however had, NOT run ldconfig when the # program has failed to install - that is specifically if an # error has occurred. # ===================================================================== # if run_ldconfig? and has_to_be_compiled? and can_we_continue? and !a_problem_has_occurred? and # Also check for no problem. !an_error_has_occurred? # =================================================================== # # Build up the command to run next. # =================================================================== # cmd_to_run = 'ldconfig'.dup # =================================================================== # # We could be verbose, but it is not that useful, so uncomment it. # cmd_to_run << ' -v' # =================================================================== # # Since as of July 2011, we will be quieter and ignore whether # ldconfig exists or not. # =================================================================== # cmd_to_run << " #{SHELL_ERROR_CODE}" # =================================================================== # # Check for superuser privilege next. ldconfig requires the # superuser. # =================================================================== # if is_superuser? opne "Now running `#{sfancy(cmd_to_run)}`." # We output the ldconfig command variant here. system cmd_to_run else opne "You are not the superuser so we will not "\ "try to run `#{sfancy(cmd_to_run)}`." end end end end
#¶ ↑
consider_uploading_binaries
¶ ↑
This method can be used to upload some binaries.
Invocation example:
ry htop uploadbinaries
#¶ ↑
# File lib/rbt/compile/compile.rb, line 17753 def consider_uploading_binaries( upload_binaries = upload_binaries? ) if upload_binaries opne 'We will next upload any files found in the bin/ subdirectory.' _ = "#{dataset?.prefix}bin/" files = Dir["#{_}*"] if files.empty? opne "No files were found in #{sdir(_)}." else upload_to( files, :default, 'bin' ) end end end
#¶ ↑
consider_using_maximum_speed_for_compilation
¶ ↑
This method also has to check whether we will compile the given program at all or whether we will not.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13310 def consider_using_maximum_speed_for_compilation if use_maximum_speed_for_compilation? and the_program_has_to_be_compiled? and can_we_continue? opne "The configuration file "\ "#{sfile('use_maximum_speed_for_compilation.yml')}"\ " specified" opne 'that maximum speed should be used for compilation.' opne "This means to pass the #{orange('-j')} option "\ "to the program #{slateblue('make')}," opne 'with the number of processors this computer has.' speed_up_the_compilation end end
#¶ ↑
consider_using_this_file_for_the_configure_options_that_are_to_be_used
¶ ↑
The argument to this method should be the file that contains the configure-options.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14022 def consider_using_this_file_for_the_configure_options_that_are_to_be_used( this_file ) if File.exist? this_file opne 'Making use of the file '+sfile(this_file)+' for configure-options.' dataset = File.read(this_file).strip.tr("\n", ' ').squeeze(' ') opne 'The options are:' e e sfancy(" #{dataset}") e clear_configure_options @internal_hash[:configure_options] = dataset else opnn; no_file_exists_at(this_file) end end
#¶ ↑
considering_setting_any_special_environment_variable
¶ ↑
This is the method that will be used to determine whether we have to set any special environment variable.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18562 def considering_setting_any_special_environment_variable( be_verbose = true ) _ = set_env_variables? if _ and !extract_only? # If we only extract something, then we don't need to do the rest. if be_verbose opne "Making use of these #{aliceblue('special environment variables')}:" e # And an elegant extra line, as of July 2021. end set_these_env_variables( _, :do_set_these_variables, :be_verbose ) end end
#¶ ↑
convert_to_traditional
¶ ↑
Convert to traditional format via this method here.
Invoke this by doing something like:
ry php ctotrad
# ¶ ↑
# File lib/rbt/compile/compile.rb, line 15926 def convert_to_traditional( i = compile_which_program? ) RBT::ConvertToTraditional.new(i) # bl ConvertToTraditional end
#¶ ↑
cookbook? (dataset tag)¶ ↑
Keep this query method on top of this file here, ideally.
This method can be used whenever we wish to query the main data structure of the target program at hand.
The dataset variable will typically be an instance of class RBT::Cookbooks::SanitizeCookbook
.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 25845 def cookbook? @cookbook end
#¶ ↑
cookbook_dataset_apply_patch?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26299 def cookbook_dataset_apply_patch? cookbook_dataset?.apply_patch? end
#¶ ↑
cookbook_dataset_cmake_configure_options?¶ ↑
This method will return all options used for the “cmake” build system of the program at hand, should cmake be used at all.
If GNU configure is used then this method will not be used.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26966 def cookbook_dataset_cmake_configure_options? cookbook_dataset?.cmake_configure_options? end
#¶ ↑
cookbook_dataset_configure_base_directory?¶ ↑
We ask the cookbook-dataset object for the configure base directory.
Most programs will NOT have such a setting.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26198 def cookbook_dataset_configure_base_directory? cookbook_dataset?.configure_base_directory? end
#¶ ↑
cookbook_dataset_configure_command?¶ ↑
Most programs may use GNU autoconfigure, and thus “configure”, but a few programs such as openssl, require another program name, such as “/config”. This method here will query whether the given program needs such a name. If this is the case then this will be used as name rather than the alternative name “configure”.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26176 def cookbook_dataset_configure_command? cookbook_dataset?.configure_command end
#¶ ↑
cookbook_dataset_flatpak_url?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26472 def cookbook_dataset_flatpak_url? cookbook_dataset?.flatpak_url end
#¶ ↑
cookbook_dataset_headers?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26449 def cookbook_dataset_headers? cookbook_dataset?.headers? end
#¶ ↑
cookbook_dataset_keep_extracted?¶ ↑
This method simply wraps over the cookbook_dataset
keep_extracted value.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26564 def cookbook_dataset_keep_extracted? cookbook_dataset?.keep_extracted? end
#¶ ↑
cookbook_dataset_libraries?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26313 def cookbook_dataset_libraries? cookbook_dataset?.libraries? end
#¶ ↑
cookbook_dataset_meson_configure_options?¶ ↑
This method will return all options used for the “meson” build system of the program at hand, should meson be used at all.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26546 def cookbook_dataset_meson_configure_options? cookbook_dataset?.meson_configure_options? end
#¶ ↑
cookbook_dataset_parameters_to_make?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26592 def cookbook_dataset_parameters_to_make? cookbook_dataset?.parameters_to_make? end
#¶ ↑
cookbook_dataset_postinstall?¶ ↑
Query from the cookbook-yaml file at hand whether we will run a postinstall-step or not.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26672 def cookbook_dataset_postinstall? cookbook_dataset?.postinstall? end
#¶ ↑
cookbook_dataset_prefix?¶ ↑
This method name may be a slight misnomer, since class Prefix
may handle the prefix here.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26156 def cookbook_dataset_prefix? if cookbook_dataset? cookbook_dataset?.prefix? else nil end end
#¶ ↑
cookbook_dataset_preinstall?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26775 def cookbook_dataset_preinstall? cookbook_dataset?.preinstall? end
#¶ ↑
cookbook_dataset_program_has_to_be_compiled?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26494 def cookbook_dataset_program_has_to_be_compiled? cookbooks_dataset? and cookbooks_dataset?.has_to_be_compiled? end
#¶ ↑
cookbook_dataset_program_path?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26140 def cookbook_dataset_program_path? if cookbook_dataset? cookbook_dataset?.program_path end end
#¶ ↑
cookbook_dataset_run_configure?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 25947 def cookbook_dataset_run_configure? cookbook_dataset?.run_configure? end
#¶ ↑
cookbook_dataset_set_configure_command
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27519 def cookbook_dataset_set_configure_command(i) case i when :meson i = i.to_s end cookbook_dataset?.set_configure_command_to_use(i) end
#¶ ↑
cookbook_dataset_short_name?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 25968 def cookbook_dataset_short_name? cookbook_dataset?.short_name?.to_s end
#¶ ↑
cookbook_installation_steps?¶ ↑
The installation-steps contain the instructions in how to install a given program at hand.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26932 def cookbook_installation_steps? cookbook_dataset?.installation_steps? end
#¶ ↑
cookbooks_binaries?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26516 def cookbooks_binaries? cookbooks_dataset?.binaries? end
#¶ ↑
cookbooks_dataset_configure_options?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26662 def cookbooks_dataset_configure_options? cookbooks_dataset?.configure_options? end
#¶ ↑
cookbooks_dataset_use_glib_schema?¶ ↑
Whether our dataset uses glib install schema for some .xml files.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26846 def cookbooks_dataset_use_glib_schema? cookbook_dataset?.use_glib_schema end
#¶ ↑
copy_expanded_directory
¶ ↑
Invocation example:
rbt --copy-expanded-directory
#¶ ↑
# File lib/rbt/compile/compile.rb, line 1848 def copy_expanded_directory source_directory = project_yaml_dir?+'expanded_cookbooks/' target_directory = expanded_cookbooks? # This will be e. g. '/home/Temp/rbt/expanded_cookbooks/'. if File.directory? source_directory opne 'Now copying from '+sdir(source_directory) opne 'onto '+sdir(target_directory)+'.' mkdir(target_directory) unless File.directory? target_directory Dir[source_directory+'*.yml'].each {|this_yaml_file| copy_file(this_yaml_file, target_directory) { :be_verbose } } else opne 'No directory exists at `'+sdir(source_directory)+'`.' end end
#¶ ↑
copy_headers_from
¶ ↑
This method will copy the registered headers from the given program at hand.
The first argument to this method is the path to the header files.
Invocation examples:
ry glibc --copy-headers-from=/usr/include ry glibc --copy-headers-to-pwd
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15343 def copy_headers_from(i) unless i.end_with? '/' i = i.dup if i.frozen? i << '/' end to = return_pwd headers = headers? unless headers.empty? headers.each {|this_header| from = "#{i}#{this_header}" if this_header.include? '/' # ================================================================= # # In this case we must create such a subdirectory. # ================================================================= # dirname = File.dirname(this_header) unless File.directory? File.dirname(dirname) mkdir(dirname) end end e 'Now trying to copy `'+sfile(from)+'` to `'+ sfile(to+this_header)+'`.' copy_file(from, to+this_header) } end end
#¶ ↑
copy_ruby
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 21997 def copy_ruby begin require 'roebe/toplevel_methods/setup.rb' Roebe.copy_setup_file_to_pwd rescue LoadError opne 'The method '+steelblue('Roebe.copy_setup_file_to_pwd()')+ ' is not available.' opne "Please install the #{slateblue('roebe')} project:" e e ' gem install roebe' e end end
#¶ ↑
copy_source_archive_of_this_program_into_the_current_directory
¶ ↑
This method can be used to copy the source archive of the given input program at hand, into the current working directory.
Invocation examples:
ry --copy-source=php ry --copy-source=ruby
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14582 def copy_source_archive_of_this_program_into_the_current_directory(i) _ = load_yaml_dataset_for_this_program(i) stored_where = _.program_path? opne "#{steelblue('=>')} Copying "\ "#{sfile(stored_where)} to "\ "#{sdir(return_pwd)}#{mediumpurple(File.basename(stored_where))}" copy_file(stored_where, return_pwd) end
#¶ ↑
copy_these_archives
¶ ↑
This method will copy the selected applications into the current working directory.
To invoke this method from the commandline, try:
rbt --copy-archives=kde5_plasma rbt --copy-archives=ruby
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15381 def copy_these_archives( i = :kde5_plasma ) if i.is_a? String i = i.split(',') if i.include? ',' end case i when :kde5_plasma, 'kde5_plasma' i = return_kde_plasma_components end i = [i].flatten.compact.reject {|entry| entry.strip.empty? }.map {|entry| try_to_find_an_alias_to_this_input_unless_the_program_exists(entry) } if i.empty? opne 'Please provide at the least one argument - the '\ 'directory that is to be copied.' else opne "Now copying #{i.size.to_s} entries into the local "\ "working directory:" i.each {|this_program| target_directory = source_dir?+this_program.downcase+'/' if File.directory? target_directory copy_directory(target_directory, :be_verbose) else opne "No directory exists at `#{sdir(target_directory)}`." end } end end
#¶ ↑
copy_this_yaml_file
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 1638 def copy_this_yaml_file( i = compile_which_program? ) if is_registered? i opne "#{rev}Now copying the .yml file for #{steelblue(i)}" opne "into the current working directory." target_file = cookbook_directory?+i+'.yml' if File.exist? target_file opnn; copy_file(target_file) { :be_verbose } end else opne "Not a registered program: #{i}" end end
#¶ ↑
create_dependencies_file
¶ ↑
This method will create a Gobolinux
dependencies file.
To invoke it, do something like:
ry htop create_dependencies_file
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12709 def create_dependencies_file( create_where = rbt_log_directory? ) _ = RBT::Linux::Gobolinux::CreateDependenciesFile.new( create_where, required_deps_on?, :dont_run_yet ) _.allow_creation_of_resources _.run # Finally, run. end
#¶ ↑
create_description_file
¶ ↑
Creates a Description file, for use in Gobolinux
systems.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15007 def create_description_file(create_where) if create_where.include? programs_directory? create_where = create_where.delete('-') end file_location = create_where+'Resources/Description' remove_file(file_location) if File.exist? file_location # Remove it if it already exists. append_what_into( dataset?.description?, file_location ) end
========================================================================= # === create_ebuild_recipe Use this to create an ebuild file.
This is done by the specialized class CreateBuild.
If you want to test this method, do something such as this here: ry htop ebuild ========================================================================= #
# File lib/rbt/compile/compile.rb, line 24758 def create_ebuild_recipe( dataset_to_use = cookbook_dataset? ) RBT::Cookbooks::CreateEbuild.new(dataset_to_use) end
#¶ ↑
create_shell_scripts
(bash tag bashrc tag)¶ ↑
This method will convert the yaml dataset to bash scripts, so that the bash shell can make use this information as well.
To invoke this method, do something such as this:
ry --bash
To get the array content do this (after sourcing the file):
echo ${programs[*]}
#¶ ↑
cat /System/Settings/bash_programs_rc
#¶ ↑
cd /System/Settings/
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27628 def create_shell_scripts RBT::CreateBashScripts.new # bl $RBT/create_bash_scripts.rb end
#¶ ↑
create_shellscript
(shell tag, script tag)¶ ↑
This is a wrapper over the class GenerateShellscript
.
It will return a string, which contains all the information to create a specific shell script.
The first argument to this method is the name of the program in question.
To invoke this method, do:
ry htop create_shellscript ry php cshell
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27597 def create_shellscript( program = compile_which_program?, save_into_a_file = true, display_result = false ) _ = GenerateShellscript.new( program, save_into_a_file, display_result ) return _.string? end
#¶ ↑
create_standalone_yaml_file
¶ ↑
This will create standalone yaml files.
Usage example:
ry htop --csyf
#¶ ↑
# File lib/rbt/compile/compile.rb, line 10754 def create_standalone_yaml_file require 'rbt/cookbooks/create_cookbook_yaml_file/create_cookbook_yaml_file.rb' cliner { opne 'Dumping all available recipes next.' } store_here = RBT.configuration?.recipes_directory all_programs.each { |this_program| e sfancy("This program is: `")+simp(this_program)+sfancy('`.') initialize_cookbook_dataset_for(this_program) _ = RBT::Cookbooks::CreateCookbookYamlFile.new(this_program, :do_not_run_yet) _.store_where(store_here) _.run } cliner { opne sfancy('Finished dumping all Recipes into ')+sdir(store_here) opne "#{N}There were: #{sfancy(all_programs.size.to_s)} of them.#{N}" } end
#¶ ↑
create_the_build_directory_then_cd_into_it
¶ ↑
Note that we will only cd into the directory if we actually use a build directory.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14402 def create_the_build_directory_then_cd_into_it( i = DEFAULT_NAME_FOR_THE_BUILD_DIRECTORY ) if use_build_directory? create_the_build_directory cd i end end
#¶ ↑
create_yaml_file_for_this_program
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15320 def create_yaml_file_for_this_program( i = compile_which_program? ) require 'rbt/utility_scripts/expand_cookbooks.rb' e opnn; RBT.expand_this_cookbook(i) e end
#¶ ↑
dataset_from_the_file_cookbook_chained_programs?¶ ↑
This query-method obtains the dataset from the yaml file containing all chained-programs.
The alias-name .chained_programs?() makes accessing this information even simpler.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26292 def dataset_from_the_file_cookbook_chained_programs? @internal_hash[:dataset_from_the_file_cookbook_chained_programs] end
#¶ ↑
dataset_program_name_and_program_version?¶ ↑
This method will always return the program name and the associated program version of any given program, such as:
"htop-2.0.2"
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26914 def dataset_program_name_and_program_version? if cookbook_dataset? cookbook_dataset?.program_name_and_program_version? # Delegate to cookbook_dataset? here. else nil end end
#¶ ↑
decide_whether_to_invoke_autogen
¶ ↑
Invoke autogen.sh if specified so, and only if the file autogen.sh actually exists.
There may be some situations where it does not make sense to invoke autogen, such as when the build type specifically tells us to use meson.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 25630 def decide_whether_to_invoke_autogen( _ = FILE_AUTOGEN ) if use_autogen? if uses_the_meson_build_system? opne crimson('The value for autogen is set to ')+ royalblue('true')+ crimson(', meaning "do use autogen".') opne crimson('The .yml file specifies to use the meson-build system, though.') opne crimson('Autogen is only useful for GNU configure based system, so') opne crimson('autogen is set to false for this run - thus, not making '\ 'use of autogen.') e opne crimson('If you need autogen, consider changing '\ 'the information in the') opne crimson('.yml file ')+ sfile("#{compile_which_program?}.yml")+ crimson('.') e opne 'Do note that this behaviour may be changed at a later time.' disable_autogen end if File.exist?(_) do_use_autogen # This is the do-action that invokes autogen.sh end end end
#¶ ↑
decide_whether_to_invoke_the_autoconf_command
¶ ↑
Whether to run “autoconf” or whether we will not. Only very few programs will need this.
Note that the invocation of autoconf must happen AFTER the pre-installation step has finished, and after checking whether sed must be used or whether sed is not needed. Afterwards, we can then check whether we will use a build directory, and whether we must use another prefix.
A program that may require this is “bridgeutils”.
Invocation example:
ry bridgeutils
#¶ ↑
# File lib/rbt/compile/compile.rb, line 25749 def decide_whether_to_invoke_the_autoconf_command if use_autoconf? cmd = 'autoconf' # " #{SHELL_ERROR_CODE}" cliner { opne "Doing `#{teal(cmd)}` in directory #{sdir_return_pwd}" opne 'using this command next:' opne sfancy(" #{cmd}") } `#{cmd}` end end
#¶ ↑
delete¶ ↑
This method is similar to the method .delete() for class Hash. The method here will only return the value, though, and NOT delete anything - while this behaviour is, strictly speaking, not the same as for class Hash, there does not seem to be a big reason as to why the information should be deleted from an instance of class RBT::Compile
.
In other words: .delete() here is mostly a compatibility method, in order to “fake-simulate” behaviour that a Hash would normally show.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13535 def delete(this_key) case this_key # ======================================================================= # # === :prefix # ======================================================================= # when :prefix prefix?.to_s # ======================================================================= # # === :program_version # ======================================================================= # when :program_version program_version?.to_s # ======================================================================= # # === :description # # This is actually a pointer towards the short description, since # it is used primarily for autogenerating pkgconfig files. # ======================================================================= # when :description short_description?.to_s end end
#¶ ↑
delete_libtool_files?¶ ↑
Query whether we will delete .la files or whether we will not. If we will not, then any installed .la files will be removed.
Note that this will ONLY be honoured if compilation was a success AND we use an AppDir path as prefix - so .la files that are installed under /usr/lib/ will not be removed, ever.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 22310 def delete_libtool_files? if @internal_hash[:keep_la_files] !@internal_hash[:keep_la_files] else RBT.configuration?.delete_libtool_files end end
#¶ ↑
depends_on_cmake?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12680 def depends_on_cmake? RBT.depends_on_cmake?(required_deps_on?) end
#¶ ↑
deregistering_from_the_status_file
¶ ↑
De-register the program that we are currently compiling from the status file again.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27076 def deregistering_from_the_status_file into = RBT.file_status dataset = {} if File.exist? into dataset.merge!(YAML.load_file(into)) end if dataset.has_key? 'currently_compiling_these_programs' _ = dataset['currently_compiling_these_programs'] if _.include? compile_which_program? dataset['currently_compiling_these_programs'] = dataset['currently_compiling_these_programs'].reject {|line| line == compile_which_program? } what = YAML.dump(dataset) write_what_into(what, into) end end end
#¶ ↑
determine_the_build_system_in_use_and_consider_syncing_this_back_onto_the_cookbook_dataset
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14414 def determine_the_build_system_in_use_and_consider_syncing_this_back_onto_the_cookbook_dataset _ = build_system? case _ when :infer_automatically _ = RBT.infer_build_system end cookbook_dataset?.set_build_system(_) end
#¶ ↑
determine_the_configure_base_directory_to_use
¶ ↑
This method can be used to determine the full path to the configure base directory to be used.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 10883 def determine_the_configure_base_directory_to_use( target = extract_to_this_dir?.dup+ yaml_dataset?.program_name_and_program_version?+ '/'+ cookbook_dataset_configure_base_directory?.to_s ) set_configure_base_directory(target) end
#¶ ↑
determine_the_program_path
¶ ↑
This method will determine the (internal) program path that is to be used, that is - the path to finding the program on the local harddisc.
A word about the variable use_this_as_short_name:
Since as of September 2019 we will also remove ‘.’ characters, so that programs such as “ruamel.yaml” can reside in a directory called “ruamelyaml”.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13444 def determine_the_program_path use_this_as_short_name = yaml_dataset?.program_short_name?.dup.downcase. delete('-.') use_this_as_short_name.delete!('_') value = source_directory?+ use_this_as_short_name+ '/'+ yaml_dataset?.program_name_and_program_version?+ yaml_dataset?.archive_type? set_program_path(value) end
#¶ ↑
determine_which_programs_to_compile
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 20415 def determine_which_programs_to_compile( first_argument = first_argument? ) if first_argument set_handle_this_program(first_argument) # ===================================================================== # # We may not replace anything in this case, as otherwise # "--lxqt" may become "--lxqtconfig" or just "lxqtconfig" # which is not desirable. But sometimes this is useful, # so ... # ===================================================================== # replace_or_dont_replace = :honour_user_settings if first_argument.start_with? '--' replace_or_dont_replace = :do_not_replace end set_array_compile_these_programs(first_argument, replace_or_dont_replace) end # ======================================================================= # # Next, look for chained-programs. # ======================================================================= # _ = dataset_from_the_file_cookbook_chained_programs? if _.has_key?(first_argument) and !does_include?(first_argument) set_compile_these_programs(_[first_argument]) end end
#¶ ↑
disable_ccache
¶ ↑
Use this method to temporarily disable ccache, that is - for the current run. If you do not want to use ccache at all, simply set the content of the corresponding .yml file to false.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 22916 def disable_ccache @internal_hash[:use_ccache] = false end
#¶ ↑
disable_colours
(colours tag)¶ ↑
Disable colours with this method. This will not be permanent, it will be valid only for the running instance (this object). If you want to permanently disable colours, use:
rbt_config --disable-colours
To use this specific method here, do something like this:
ry htop disablecolours
Remember that you can chain together instructions, so:
ry htop disablecolours ntrad
Would compile in an appdir-like fashion, without using any colours.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12543 def disable_colours( be_verbose = true ) RBT.disable_colours # ← Defined in rbt/colours/colours.rb disable_colours # This one is defined in base.rb. if be_verbose opne 'We will not use any colours.' end end
#¶ ↑
disable_md5sum_calculation
¶ ↑
This method here can be used to disable the md5sum calculation altogether.
Invocation example:
ry htop --no-md5sum
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13890 def disable_md5sum_calculation opne 'We will not calculate the md5sum of an archive. This '\ 'should speed up' opne 'things a little bit, in particular for very large files.' RBT::Cookbooks::SanitizeCookbook.disable_md5sum_calculation # Cookbooks::Cookbook must provide this method. end
#¶ ↑
disable_opn
¶ ↑
Use this method to stop reporting any program names.
To trigger this, try one of these usage examples:
ry php noopn ry htop nonames
#¶ ↑
# File lib/rbt/compile/compile.rb, line 1881 def disable_opn e 'We will not use Opn (class name output, aka output-program-name)' RBT.do_not_show_the_classname @internal_hash[:use_opn] = false end
#¶ ↑
disable_static_compilation
¶ ↑
Use this method to disable static compilation.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 29269 def disable_static_compilation( be_verbose = :be_verbose ) case be_verbose when :be_verbose be_verbose = true when :do_not_be_verbose be_verbose = false end if be_verbose opne 'Disabling static compilation.' end @internal_hash[:build_static] = false if cflags?.include? '-static' set_cflags(cflags?.dup.sub(/-static/,'')) end end
#¶ ↑
display_postinstall_dataset
¶ ↑
This method will display the postinstall actions that will be done for the given program at hand.
Invocation examples:
ry perl p? ry docbookxsl --display_postinstall ry libraw1394 --postinstallation_steps? ry bash --postinstallation_steps? ry vte --postinstallation_steps?
#¶ ↑
# File lib/rbt/compile/compile.rb, line 23353 def display_postinstall_dataset result = cookbook_dataset_postinstall? unless result.empty? opne "The postinstall instructions for `#{royalblue(program?)}` are:" result = [result].flatten.compact # <- We need an Array past this point. result.each {|entry| e e " #{yellowgreen(entry)}" # Display with a slight padding. e } opne 'Also assigning the above result to the xorg buffer.' set_xorg_buffer(result.join(N)) end end
#¶ ↑
do_check_for_binary_duplicates
¶ ↑
If you wish to check for binary-duplicates under /usr/bin/, then this method may be helpful to you.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14666 def do_check_for_binary_duplicates target_dir = :default # ======================================================================= # # The next line of code handles the situation when we are in the # directory /usr/sbin/, and when we are on a roebe-system (aka at home). # ======================================================================= # if is_on_roebe? and (return_pwd == '/usr/sbin/') target_dir = '/usr/sbin/' end array = RBT.array_binary_duplicates(:default, target_dir) if array.empty? target_dir = '/usr/bin/' if target_dir == :default opne "No duplicates appear to exist under the "\ "#{sdir(target_dir)} hierarchy." else opne 'The following duplicates were found:' e array.each {|entry| e " #{sfile(entry.ljust(40))}" } end end
#¶ ↑
do_compile_all_available_local_version_of_this_program
¶ ↑
Invocation example:
ry libsigc++ --compile-all-available-local-versions
#¶ ↑
# File lib/rbt/compile/compile.rb, line 1385 def do_compile_all_available_local_version_of_this_program( i = compile_which_program? ) opne 'Checking for the locally available '\ 'versions of the program '+sfancy(i)+' next.' target_directory = source_dir?+i.downcase+'/' e opne "We will check at the directory `#{sdir(target_directory)}`." e matches = Dir[target_directory+'*'] if matches.empty? opne 'No result was found at the directory `'+sdir(target_directory)+'`.' opne 'This usually indicates that the '\ 'directory does not exist - or is empty.' else matches.each {|entry| opne 'Working on the entry `'+sfancy(entry)+'` next.' entry = remove_archive_at_the_end(entry) basename = File.basename(entry) program_name = program_information_return_program_name(basename) program_version = program_information_return_version(basename) reset set_compile_this_program(program_name) initialize_dataset_for_this_program(program_name) set_program_version(program_version) do_compile_this_program(program_name) { :do_not_initialize_the_dataset } } end end
#¶ ↑
do_compile_in_a_non_traditional_way
¶ ↑
We enable Gobolinux-style compilation here, as in AppDir-like compilation.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 21212 def do_compile_in_a_non_traditional_way( program_name_and_program_version = program_name_and_program_version?, be_verbose = true ) if can_we_continue? case program_name_and_program_version when :be_silent, :be_quiet be_verbose = false program_name_and_program_version = program_name_and_program_version? end case be_verbose when :be_silent, :be_quiet be_verbose = false end if be_verbose opne 'Overruling any potential traditional setting.' end @internal_hash[:counter_called_traditional_or_non_traditional_compilation] += 1 ensure_that_a_cookbook_object_has_been_instantiated set_user_prefix :ntrad opne 'Enabling AppDir prefix.' enable_non_traditional_compilation( program_name_and_program_version ) end end
#¶ ↑
do_compile_in_a_traditional_way
¶ ↑
Use this method when you want to use ‘/usr/’ as the main prefix of compilation.
Usage example:
ry php --trad
#¶ ↑
# File lib/rbt/compile/compile.rb, line 21258 def do_compile_in_a_traditional_way( be_verbose = true, can_we_continue = can_we_continue? ) if can_we_continue @internal_hash[:we_tried_to_compile_this_program_n_times] += 1 if be_verbose opne 'Using a "'+sfancy(:traditional)+'" strategy for compilation '\ '(which means prefix '+sdir('/usr/')+').' end set_user_prefix '/usr/' # Specify a user-prefix here. end end
#¶ ↑
do_compile_in_both_traditional_and_non_traditional_manner
¶ ↑
This method combines both main strategies for compilation - first, into the /usr/ prefix, and then into the appdir prefix.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 21531 def do_compile_in_both_traditional_and_non_traditional_manner opne 'We will first compile in the traditional way, and then after that' opne 'we will compile in the non-traditional (appdir) way.' do_compile_in_a_traditional_way # First, compile in a traditional way. @internal_hash[:extra_compilation] = true end
#¶ ↑
do_compile_libstdc_plus_plus
¶ ↑
This method will compile/install libstdc++, which is part of GCC.
To invoke this method try:
ry --install-libstdc++
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13970 def do_compile_libstdc_plus_plus set_compile_these_programs :gcc opne steelblue('libstdc++')+', from GCC, will be installed next.' opne royalblue('1')+') The GCC-archive of GCC will be extracted first.' dataset = return_dataset_for_this_program(compile_which_program?) path = dataset.path? gcc_version = dataset.program_version? if File.exist? path opne 'Extracting '+sfile(path)+' to '+sdir(log_dir?)+'.' extract_what_to(path, log_dir?) # ===================================================================== # # cd into the right target: # ===================================================================== # target = log_dir?+cookbook_dataset_program_name_and_program_version?+'/libstdc++-v3/' opne royalblue('2')+') cd to the target directory at '+sdir(target)+' next.' cd(target) opne royalblue('3')+') create the build directory, then cd into it next.' mkdir 'BUILD_DIRECTORY' cd 'BUILD_DIRECTORY' opne royalblue('4')+') Running configure, then "make", then "make install" next.' # ===================================================================== # # Find out the prefix that we wish to use (required for a cd-action # lateron. # ===================================================================== # use_this_prefix = rds( programs_dir?+'Libstdc++/'+gcc_version+'/' ) cmd = ( '../configure '\ '--prefix='+use_this_prefix+' --disable-multilib --disable-nls --disable-libstdcxx-threads --disable-libstdcxx-pch' ).squeeze(' ').gsub(/\n/,' ').squeeze(' ') e e steelblue(cmd) e esystem cmd run_make_then_make_install RBT.to_current(use_this_prefix) cd use_this_prefix rnsymc end end
#¶ ↑
do_compile_the_perl_addons
¶ ↑
s====================================== #¶ ↑
# File lib/rbt/compile/compile.rb, line 12695 def do_compile_the_perl_addons array = chained_programs?['perl_addons'].reject {|entry| entry == 'perl' } opne "Installing various registered perl-addons (#{array.size}) next." set_compile_these_programs(array) end
#¶ ↑
do_compile_this_program
(real compile tag)¶ ↑
This method can be used to compile a given program. It is the main “workhorse” for class RBT::Compile
.
To not initialize the dataset, use :do_not_initialize_the_dataset as block-argument.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 20621 def do_compile_this_program(i) return unless can_we_continue? # ======================================================================= # # First check if the user wants to ensure a specific licence: # ======================================================================= # if check_for_this_licence? unless licence? == check_for_this_licence? opne tomato('The licences do not match. ')+ 'Expected licence' opne 'was: '+ steelblue( RBT.sanitize_this_licence(check_for_this_licence?) )+', specified licence was: '+ steelblue(licence?) return end end i = i.to_s.dup # We need a String. i.delete!('_') if i.include? '_' # ======================================================================= # # Handle the * argument. We will show to the user what programs # exist that start with this name. # # To trigger this method, do: # # ry a* # ry e* # # ======================================================================= # if i.respond_to?(:include?) and i.include?('*') verbose_find_all_keys_starting_with(i) exit_program end # ======================================================================= # # === Check whether ccache exists # # Query for the use and availability of ccache. This should come # after any special environment was set. # ======================================================================= # if use_ccache? and !is_ccache_available? notify_the_user_that_ccache_is_not_available end # ======================================================================= # # Note that the next clause will return and thus break from this # method. Subsequent method calls will not be triggered. # ======================================================================= # if do_we_check_whether_the_program_exists? and !is_this_program_included?(i) opne "The program #{steelblue(i)} is #{tomato('not')} registered "\ "as part of the RBT project." opne 'Thus, it could not be found and, subsequently, it can not be' opne 'compiled or installed.' return :the_program_is_not_registered_in_the_rbt_project end # ======================================================================= # # cd into the main log directory: # ======================================================================= # if cd_into_the_rbt_log_directory? cd rbt_log_directory?, :be_quiet end # ======================================================================= # # === Register the program for compilation # # Next, we have to register the name of the program somewhere, # which is to be done through a method-call. But first we will # try to sanitize it a little bit, if it includes at the least # one '/' character. # ======================================================================= # i = i.to_s unless i.is_a? String i = File.basename(i) if i.include? '/' i = set_handle_this_program(i) # ======================================================================= # # Next, we will typically initialize a new cookbok instance. # ======================================================================= # if block_given? if yield == :do_not_initialize_the_dataset else initialize_a_new_cookbook_instance(i) # ← Instantiate a new cookbook instance here. end end determine_which_compiler_will_be_used program_path = program_path? if program_path.nil? # ===================================================================== # # This is a safeguard - but it is also the default, actually. The # cookbook-dataset is much more likely to contain the local "URL" # to the program at hand. # ===================================================================== # program_path = cookbook_dataset_program_path? end # ======================================================================= # # Sometimes we must re-write the program path, e. g. if we take # another program version. The following method does that for us. # ======================================================================= # # consider_sanitizing_the_program_path # determine_the_configure_base_directory_to_use if program_path unless File.exist? program_path # ===================================================================== # # === Download the program if it does not yet exist locally # # Download the program if it does not exist here. This functionality # must come before we try to extract the program. # # Obtain the program path first, though. # ===================================================================== # download_program unicode_middle_cliner # Looks better with cliner, I think. end end # ======================================================================= # # === Set special environment variables # # Next, ensure that if the cookbooks file at hand is using any special # environment variable, that this will also be used. For example, # the program called "htop" will use these LDFLAGS: -ltinfow, # so this has to be enabled. # This should come before we will check for ccache. # ======================================================================= # considering_setting_any_special_environment_variable # ======================================================================= # # === (1) Consider changing the tab title: # # Changing the name of the tab title should happen only after the # program name was set. The method will check whether we will actually # do any tab-change action or not. Note that when we refer to "tab", # we really mean KDE konsole tabs primarily. # # The variable called `use_this_as_tab_title` will keep track of the # tab-title that is to be used for the KDE konsole tab title. # ======================================================================= # use_this_as_tab_title = :default if check_whether_the_given_input_is_a_file_and_does_exist? and does_this_file_exist_and_is_it_a_file?(i) # This may be the case when the user supplied a path. use_this_as_tab_title = remove_archive_at_the_end(File.basename(i)) end # ======================================================================= # # === Honour the "do_not_download" settings if it exists. # ======================================================================= # do_not_download if cookbook_dataset? and cookbook_dataset?.do_not_download? consider_changing_the_tab_title(use_this_as_tab_title) # ======================================================================= # # Keep track of the base-directory onto which we will extract. # ======================================================================= # set_extract_to_this_directory( TEMP_DIR_FOR_RBT+ program_name_and_program_version?.to_s ) # ======================================================================= # # Also reset the compiled n-times counter next. # ======================================================================= # reset_compiled_n_times_counter program_path = program_path? # ======================================================================= # # Notify the user which program will be compiled/installed next. This # requires the name of the program, as well as the assumed program # path. # ======================================================================= # notify_the_user_as_to_which_program_will_be_compiled_or_installed_next( i, program_path ) # ======================================================================= # # === Consider showing the Flexbox next (flexbox tag, infobox tag) # # Consider showing the fluxbox next. The flexbox may also show # the required dependencies of the given program at hand, which # should always come before the archive at hand is extracted. # # A configuration showing the dependencies, within the file called # "always_show_dependencies.yml". # # Note that since as of Nov 2017, the default is to not always show # the dependencies, so the user has to specifically enable this # option if he/she wants to have that. # # In the old code, we used to call the method # feedback_dependencies_of_the_program() rather than # show the flexbox at hand. # ======================================================================= # consider_showing_the_flexbox # ======================================================================= # # First, check whether we have to extract the archive at hand. We do # not have to extract .gem files, since "gem" does this for us. # ======================================================================= # skip_extracting_if_it_is_a_gem_file we_can_not_continue if an_error_has_occurred? if is_a_gem_file?(program_path) install_ruby_gem(program_path) # Install this rubygem. else # ===================================================================== # # Check whether the archive exists. If not then notify the user about # it. This has to happen before we consider removing the old # extracted archive directory. # ===================================================================== # unless File.exist? program_path opne "No archive exists at `#{sfile(program_path)}`." opne 'As it was specified to extract the archive in this '\ 'case, yet this' opne 'archive could not be found at the above reported path, '\ 'we will exit' opne 'now. You may consider downloading the source archive, '\ 'should' opne 'it exist.' exit_program end unless skip_extracting? consider_removing_the_old_extracted_directory_if_it_exists end # ===================================================================== # # === (2) Set the CFLAGS next. # # This should come before we extract the program. We will also # honour the build_static variable. # # We will do this only for programs that have to be compiled, though. # ===================================================================== # if has_to_be_compiled? if build_static? # ================================================================= # # Honour static compilation settings in the ymal file. # ================================================================= # opne 'The yaml file specifies that this program is to '\ 'be '+steelblue('compiled statically')+'.' opne "Thus, we will use these CFLAGS: "\ "#{lightblue(default_cflags?)}" # ================================================================= # # We also have to scan the configure command string. If that string # contains an instruction such as "--disable-static", then we will # get rid of it, and notify the user. The reason is that, quite # obviously, we can not have conflicting options passed. # Note that this may be changed at a later time in the future, if # we decide that only user-supplied options to RBT may change this # behaviour. For now, we simply add a way to check the logic on # it, which is an improvement over the old code which did not # do any logic-checking at all whatsoever. # ================================================================= # configure_options = configure_options? if configure_options.include? '--disable-static' opne 'The configure option to '+sfancy(compile_which_program?)+ ' is using the option called '+simp('--disable-static')+'.' opne "As this #{steelblue('would contradict')} with our goal "\ "to enable static compilation," opne 'this option was replaced with --enable-static, from '\ 'the configure command string.' cookbook_dataset?.configure_options = configure_options?.sub( /-?-?disable-?static/, '--enable-static' ) end set_cflags(:build_static) end end return unless can_we_continue? # This should come before we extract anything. if File.exist? program_path extract_the_program(program_path?) end # ===================================================================== # # Next, exit if this was specified that way. # ===================================================================== # exit_program if extract_only? ensure_that_the_configure_options_are_consistent_in_regards_to_static_compilation if program_path and File.exist?(program_path) consider_creating_the_appdir_skeleton # ===================================================================== # # Next, change to the extracted directory. We will also have to # honour the configure_base_dir setting. # ===================================================================== # cd_into_this_directory = rds( TEMP_DIR_FOR_RBT+ program_name_and_program_version?+'/'+ configure_base_dir?.to_s ) cd cd_into_this_directory opne "We are in the directory #{sdir(return_pwd)}." # ===================================================================== # # === Handle patches # # Consider applying a patch next - this should come before the # preinstall action and before the sed-action, but after the # optional start message. # ===================================================================== # consider_applying_a_patch # ===================================================================== # # === Optional start messages # # Display optional start message here, right before we continue # to the preinstall? stage and other stages. # ===================================================================== # consider_displaying_the_start_message # ===================================================================== # # (4) Reset any possible error message at this point. # ===================================================================== # RBT.reset_error_message # ===================================================================== # # === Check for sed-action # # Next, we check whether we must apply sed. It must come before any # preinstall-action, and after we have cd-ed to the correct directory. # This also means after we have extracted the archive at hand. # ===================================================================== # check_for_sed_action # ===================================================================== # # === Pre-install actions # # Next, handle pre-install actions first, should they exist. These # should come after we have checked for sed-related actions. # ===================================================================== # run_preinstall_actions # ===================================================================== # # Next register that we are compiling a program. # ===================================================================== # register_that_this_program_is_currently_being_compiled run_pre_configure_steps_if_requested_to_do_so decide_whether_to_build_statically # ===================================================================== # # === The (optional) autogen-step # # Consider running "autogen" next. # # This should come after the archive was already extracted, and # after pre-installation steps were performed - but it should come # BEFORE we invoke "autoconf" (the latter one is an optional step # as well, though). # ===================================================================== # decide_whether_to_invoke_autogen # (autogen tag) decide_whether_to_invoke_the_autoconf_command # This must occur after the pre-installation step. run_configure_like_stage check_for_common_problems_and_common_errors # ===================================================================== # # Consider symlinking glib-schema files into the /usr/ hierarchy. # ===================================================================== # consider_symlinking_glib_schema_files_into_the_usr_share_hierarchy # ===================================================================== # # Make our instance of SymlinkProgram behave properly - this should # come before we perform postinstallation actions, and after the # glib schema files were symlinked. # ===================================================================== # prepare_symlink_program_instance else opne 'No file was found at `'+program_path?.to_s+'`.' end end if has_an_error_occurred? opne swarn('An error has occurred in the directory ')+ sdir(return_pwd)+ swarn('.') opne swarn('We will most likely not be able to continue.') we_can_not_continue end # ======================================================================= # # === Handle empty subdirectories # # Next we will consider removing empty subdirectories. This has to # happen here again, after the postinstall step, because the installation # may have failed. The method will also do a more general clean-up # step in the respective AppDir prefix. # ======================================================================= # consider_removing_empty_subdirectories store_time_snapshot # ======================================================================= # # Report to the user how long it took us to compile/install the program # at hand. # ======================================================================= # consider_reporting_the_time_it_took_to_compile_this_program # ======================================================================= # # Next, compare the installed libraries versus the assumed # libraries. This can then be used to updated the dataset. # ======================================================================= # if ignore_errors_anyway? or successfully_compiled? # ===================================================================== # # Next, consider performing postinstallation steps: # ===================================================================== # consider_performing_postinstallation_actions # ← Postinstallation step # ===================================================================== # # Consider stripping the compiled binaries. # ===================================================================== # if had_to_be_compiled? # ===================================================================== # # Next check whether we have to strip the compiled binaries or # whether we do not have to strip them. The checks are done # with the method itself, so we don't have to do any conditional # checks here at this point. # ===================================================================== # do_strip_the_compiled_binaries # ===================================================================== # # Next, we will consider creating and populating the subdirectory # called "lib/pkgconfig/". This may be necessary for programs that # install into "share/pkgconfig/" rather than "lib/pkgconfig". # # This step has to be done before we call the method # consider_symlinking_the_pkgconfig_files(). # ===================================================================== # consider_creating_and_populating_the_pkgconfig_directory # ===================================================================== # # Next register the configure-line into the configure "database", # unless a problem or error has occurred. # ===================================================================== # if no_problem_was_encountered? and no_error_was_encountered? # ================================================================= # # Register the configure-line that was used into the "global" # configure database next: # ================================================================= # register_configure_line_into_configure_database # ================================================================= # # If the cookbook file at hand has symlinking_pkgconfig_files # enabled, and if the program is compiled, as AppDir, then we # will symlink .pc iles into /usr/lib/pkgconfig/, if the # latter one exists. # # This should actually be part of the post-installation actions, # but before running ldconfig. # ================================================================= # consider_symlinking_the_pkgconfig_files if did_we_use_an_appdir_prefix? # ============================================================= # # And store this into the app-dir prefix. # ============================================================= # do_store_the_configure_options_that_were_used_into_a_markdown_file # ============================================================= # # === Handle .gir files since as of 22.02.2020. # ============================================================= # if has_gir_files? and symlink_gir_files? target_directory = '/usr/share/gir-1.0/' symlink_the_available_gir_files_into_this_target_directory(target_directory) end end # ================================================================= # # Also register it to the file that keeps track of which # programs were compiled successfully. # ================================================================= # register_last_compiled_program end end # ===================================================================== # # Make sure that the registered binaries are already registered, if # the program has been compiled successfully. This will only be run # on my home setup, though. # ===================================================================== # consider_checking_whether_the_compiled_binaries_are_already_registered # ===================================================================== # # Consider running "ldconfig" next. # ===================================================================== # consider_running_ldconfig else # ===================================================================== # # Else a problem or an error may have occurred. We will thus check # for that. The error will be re-set more on the beginning of # this method rather than its end. # ===================================================================== # check_for_common_problems_and_common_errors end consider_comparing_the_installed_libraries_versus_the_assumed_libraries # ======================================================================= # # === Go back to the temp-directory again # # Return to the temp-directory as start again. This has to happen # because the underlying directory may have been removed, so we # need to go to a "stable" directory instead. # # The second argument exists so that we are silent about this. # ======================================================================= # change_directory(temp_directory?, :do_not_report_anything) unless keep_extracted? # ======================================================================= # # === Remove the extracted archive / directory # # We have to clean-up again, by removing the extracted archive. This # behaviour can be changed by the user, though. Additionally, the # individual .yml file may decide for us whether we will remove the # extracted directory or whether we will keep that directory. User # instructions overrule the settings in the .yml file, though. # ======================================================================= # do_remove_the_extracted_archive end # ======================================================================= # # Ensure that the expanded cookbook .yml file exists: # # Note that this has been disabled on 10.10.2019, because it is a # bit buggy. We may have to re-enable this at a later time, but # this requires that we first fix the code that would generate # the expanded cookbook dataset. # ======================================================================= # if is_on_roebe? and !does_the_expanded_cookbook_file_exist_for_this_program?(i) expand_this_cookbook(i) end # ======================================================================= # # Also store the prefix that we used on the toplevel namespace. # ======================================================================= # RBT.set_last_prefix_used(use_which_prefix?) consider_changing_the_tab_title :clear # ======================================================================= # # Show success or failure - this should come last. # ======================================================================= # show_success_or_failure_status end
#¶ ↑
do_create_a_slackware_package
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 1739 def do_create_a_slackware_package( i = return_pwd ) require 'rbt/linux/slackware/create_slackware_package.rb' this_program = File.basename(i) if this_program.include? '-' this_program = program_information_return_name(this_program) end RBT::CreateSlackwarePackage.new(this_program) { :do_not_autoinstall } end
#¶ ↑
do_create_this_appdir_skeleton
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 19474 def do_create_this_appdir_skeleton(i) RBT::CreateAppDirSkeleton.new(i.dup) {{ use_colours: use_colours?, use_opn: use_opn? }} end
#¶ ↑
do_enable_static_compilation
¶ ↑
Enable static compilations.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 29292 def do_enable_static_compilation @internal_hash[:build_static] = true end
#¶ ↑
do_extensively_report_the_build_statistics
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28728 def do_extensively_report_the_build_statistics report_the_compile_strategies unless RBT.respond_to? :show_how_many_files_are_tracked require 'rbt/statistics/show_how_many_files_are_tracked.rb' end # ======================================================================= # # Since as of July 2020 we will also show how many files are tracked. # ======================================================================= # RBT.show_how_many_files_are_tracked end
#¶ ↑
do_include_clang_for_the_llvm_compilation
¶ ↑
Here we have to do four steps in particular - extract two programs into the extracted directory of LLVM.
The code below is not very elegant and quite hackish; I simply wanted to finish this on the same day as I had this idea, which was on 09.09.2020. At a later point this should be cleaned up.
Invocation examples:
ry llvm --include-clang-for-compilation ry llvm --compile-clang
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14343 def do_include_clang_for_the_llvm_compilation # ======================================================================= # # First, we must extract LLVM. # ======================================================================= # initialize_dataset_for(:llvm) extracted_to = extract(cookbook_dataset_program_path?)+ cookbook_dataset_program_name_and_program_version? cd extracted_to # cd into that directory. initialize_dataset_for(:clang) extract_what_to(cookbook_dataset_program_path?, return_pwd+'tools') rename( 'tools/'+cookbook_dataset_program_name_and_program_version?, 'tools/clang' ) initialize_dataset_for(:compilerrt) extract_what_to(cookbook_dataset_program_path?, return_pwd+'compiler-rt') # ======================================================================= # # First, we must extract LLVM. # ======================================================================= # initialize_dataset_for(:llvm) create_build_directory_then_cd_into_it set_this_env_variable 'CC=gcc' set_this_env_variable 'CXX=g++' # ======================================================================= # # The next cmake-line is a hack - at a later point we should clean this # up. # ======================================================================= # cmd = 'cmake -DCMAKE_INSTALL_PREFIX='+appdir_prefix?(:llvm)+' -DLLVM_ENABLE_FFI=ON -DCMAKE_BUILD_TYPE=Release -DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON -DLLVM_ENABLE_RTTI=ON -DLLVM_TARGETS_TO_BUILD="host;AMDGPU;BPF" -DLLVM_BUILD_TESTS=ON -Wno-dev -G Ninja ..'.delete(N). squeeze(' ') esystem cmd do_run_ninja do_run_ninja_install rnsymc(appdir_prefix?(:llvm)) exit_program end
#¶ ↑
do_initiate_batch_compilation
(compile tag, main tag, run tag)¶ ↑
This method is the general entry-point in order to batch-compile the programs. The programs are typically stored as an Array, in the variable called @array_compile_these_programs.
The logic for this task will be handled internally, on a per-program basis.
The argument to this method should be an Array which holds the programs that we wish to compile. This is normally set elsewhere in class RBT::Compile
.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 20270 def do_initiate_batch_compilation( i = @array_compile_these_programs ) i.each {|this_program| # reset_the_internal_hash # ← This must come before the update-method. do_compile_this_program(this_program) } end
#¶ ↑
do_install_only_the_headers
¶ ↑
This method will only intall the headers of a program. You must call the method action_install_only_headers
() for real action.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 21577 def do_install_only_the_headers( of_this_program = compile_these_programs?.first ) do_not_compile do_not_run_configure disable_logging # We dont want to log. opne "Installing only headers for the program `"\ "#{sfancy(of_this_program)}` now." @internal_hash[:install_only_the_headers] = true end
#¶ ↑
do_install_via_cmake
¶ ↑
This method, after running “cmake”, does the equivalent of:
- premake - make - make install
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12612 def do_install_via_cmake # ======================================================================= # # We should check whether cmake exists on the host system or whether # it does not. # ======================================================================= # if cmake_exists? create_the_build_directory_then_cd_into_it run_the_cmake_command run_premake_make_then_make_install run_through_the_registered_problems_registered_errors_and_behaviour_changes reset_error_map_line_to_a_specific_error else # The user should be informed that "cmake" could not be found. notify_the_user_that_cmake_could_not_be_found we_can_not_continue end end
#¶ ↑
do_install_via_meson
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 24992 def do_install_via_meson create_the_build_directory use_this_prefix = prefix?.dup use_this_prefix << '/' unless use_this_prefix.end_with? '/' set_configure_command(:meson) _ = 'meson'.dup if do_we_use_any_prefix? _ << ' --prefix='+use_this_prefix+' --libdir='+use_this_prefix+ 'lib' end # ======================================================================= # # Obtain the meson-configure options next, but only if the user # has allowed us to do so. # ======================================================================= # if use_meson_configure_options? meson_configure_options = return_meson_configure_options.to_s.strip if meson_configure_options and !meson_configure_options.empty? # ===================================================================== # # Append the meson-configure options in this case. # ===================================================================== # opne "Making use of the #{royalblue('meson_configure_options')}, "\ "as specified by the #{slateblue('.yml')} file." opne "The working directory is: #{sdir(return_pwd)}" _ << " #{meson_configure_options}" end end # ======================================================================= # # Add the build-directory if we make use of a build directory. # ======================================================================= # if use_build_directory? _ << " #{build_directory?}" end _.squeeze!(' ') set_full_configure_command(_) e e colourize_this_important_system_command(_) e run_this_sys_command _ cd DEFAULT_NAME_FOR_THE_BUILD_DIRECTORY # ======================================================================= # # === Run "ninja" next: # ======================================================================= # _ = 'ninja' ecolourize_this_important_system_command(_) run_this_sys_command _ # ======================================================================= # # === Run "ninja install" next: # ======================================================================= # _ = 'ninja install' ecolourize_this_important_system_command(_) run_this_sys_command _ end
#¶ ↑
do_not_check_whether_the_program_exists
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 1656 def do_not_check_whether_the_program_exists @internal_hash[:check_whether_the_given_input_is_a_file_and_does_exist] = false end
#¶ ↑
do_not_compile
¶ ↑
This method can be invoked to set the :continue_after_configure_step entry in the internal hash to false.
If set to false then we will NOT compile a program. Instead, we will run the configure script and quit after having done so.
# ¶ ↑
# File lib/rbt/compile/compile.rb, line 11270 def do_not_compile( be_verbose = true ) case be_verbose when :be_quiet be_verbose = false end if be_verbose opne 'We will not continue after configure phase.' end @internal_hash[:continue_after_configure_step] = false @internal_hash[:do_not_compile] = true set_do_not_symlink(:be_verbose) # So we don't run advanced symlink. end
#¶ ↑
do_not_display_the_flexbox
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 22185 def do_not_display_the_flexbox @internal_hash[:show_the_flexbox] = false end
#¶ ↑
do_not_run_configure
¶ ↑
Do not run the configure script. Since Jan 2012 we also disable running ldconfig in this method.
# ¶ ↑
# File lib/rbt/compile/compile.rb, line 18371 def do_not_run_configure( be_verbose = true ) if be_verbose opne 'We will not compile - or run any configure script.' end do_not_run_the_configure_script do_not_use_ldconfig no_postinstall_actions end
#¶ ↑
do_not_run_configure_script
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18385 def do_not_run_configure_script @internal_hash[:run_configure_script] = false end
#¶ ↑
do_not_run_make_install
¶ ↑
Use this method if you wish to specifically skipping the “make install” step.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 11800 def do_not_run_make_install( be_verbose = false ) @internal_hash[:run_make_install] = false if be_verbose opne 'We will not run the "'+slateblue('make install')+'" command.' end # ======================================================================= # # Running ldconfig seems pointless, so it is also disabled (silently). # ======================================================================= # do_not_use_ldconfig(:do_not_be_verbose) end
#¶ ↑
do_not_strip_binaries
¶ ↑
This is the non-verbose variant to disable stripping of binaries.
If you need the verbose variant, use the method called verbose_do_not_strip_the_binaries
() instead.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 24621 def do_not_strip_binaries @internal_hash[:strip_binaries] = false end
#¶ ↑
do_not_strip_binaries
?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 24635 def do_not_strip_binaries? !strip_binaries? end
#¶ ↑
do_not_symlink_header_files
¶ ↑
This will disable symlinking the header files. By default, we will not be verbose and thus do not output anything to the user.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 24343 def do_not_symlink_header_files @internal_hash[:symlink_headers] = false end
#¶ ↑
do_not_symlink_in_general_and_also_do_not_symlink_header_files
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 24303 def do_not_symlink_in_general_and_also_do_not_symlink_header_files set_do_not_symlink do_not_symlink_header_files end
#¶ ↑
do_not_use_a_prefix
¶ ↑
Do not use any prefix in general, no matter whether we will use GNU configure, meson/ninja, cmake or any other build system..
#¶ ↑
# File lib/rbt/compile/compile.rb, line 23733 def do_not_use_a_prefix opne 'No '+steelblue('--prefix')+' option will be used.' @internal_hash[:use_a_prefix] = false end
#¶ ↑
do_not_use_any_compile_time_flags
¶ ↑
If you do not want to use any compile-time flags, aka CFLAGS, then you can use this method here.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13087 def do_not_use_any_compile_time_flags opne 'Setting compile-time flags ('+ royalblue('CFLAGS')+', '+ royalblue('LDFLAGS')+ ') to empty.' set_cflags('') end
#¶ ↑
do_not_use_any_configure_option
¶ ↑
This option allows us to avoid using any configure option.
Invocation example from the commandline:
ry htop --dont-use-configure-options
#¶ ↑
# File lib/rbt/compile/compile.rb, line 1670 def do_not_use_any_configure_option( be_verbose = be_verbose?, &block ) if block_given? be_verbose = yield end case be_verbose when :be_verbose, true # ===================================================================== # # Be verbose in this case. # ===================================================================== # opne 'No configure options will be used for this run.' end @internal_hash[:try_to_use_configure_options] = false end
#¶ ↑
do_not_use_ldconfig
¶ ↑
Use only this method when you wish to disable running ldconfig.
To set this, do something like:
ry htop do_not_use_ldconfig
#¶ ↑
# File lib/rbt/compile/compile.rb, line 20156 def do_not_use_ldconfig( be_verbose = be_verbose? ) case be_verbose when :do_not_be_verbose, :be_silent be_verbose = false end if be_verbose opne "We will not run `#{teal('ldconfig')}`." end RBT.configuration?.run_ldconfig = false end
#¶ ↑
do_not_use_sed
¶ ↑
Disable the use of sed through this method.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27255 def do_not_use_sed( be_verbose = false ) case be_verbose when :be_verbose be_verbose = true end if be_verbose opne "We will not be using #{lightgreen('sed')}." end @internal_hash[:sed] = false end
#¶ ↑
do_perform_an_intelligent_bootstrap
¶ ↑
Usage example:
rbt --intelligent-bootstrap
#¶ ↑
# File lib/rbt/compile/compile.rb, line 16419 def do_perform_an_intelligent_bootstrap begin require 'environment_information' rescue LoadError; end opne 'Attempting to perform an '+ steelblue('intelligent bootstrap operation next')+'.' if Object.const_defined? :EnvironmentInformation EnvironmentInformation.initialize array_of_outdated_programs = EnvironmentInformation.return_array_of_outdated_programs # ===================================================================== # # Now that we have these programs, we must sort them based on # filesize. # ===================================================================== # array_of_outdated_programs = array_of_outdated_programs.sort_by {|this_program| result = 1_000_000 # Use a bogus entry here, to sort it towards the bottom. target_yaml_file = ::RBT.path_to_expanded_directory?+this_program.to_s+'.yml' if File.exist? target_yaml_file dataset = YAML.load_file(target_yaml_file) if dataset.has_key? 'archive_size' result = dataset['archive_size'] end end result } array_of_outdated_programs.each {|this_program| opne "Now compiling #{steelblue(this_program)}." ::RBT::Compile.new(this_program) } end end
#¶ ↑
do_permanently_disable_ccache
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 22976 def do_permanently_disable_ccache( into = FILE_CCACHE, what = "false\n" ) write_what_into(what, into) opne "Permanently disabling the use of ccache "\ "(Stored into this file: `#{sfile(into)}`)." if is_on_roebe? into = "#{RUBY_SRC_DIRECTORY}rbt/lib/rbt/yaml/configuration/"\ "#{File.basename(into)}" write_what_into(what, into) opne "Permanently disabling the use of ccache "\ "(Stored into this file: `#{sfile(into)}`)." end end
#¶ ↑
do_permanently_disable_the_colours
¶ ↑
This method can be used to permanently disable the colours.
Invoke this method by issuing:
ry --permanent-no-colours
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12269 def do_permanently_disable_the_colours opne 'Now permanently disabling the colours.' configuration?.use_colours = false what = false into = RBT.file_use_colours write_what_into(what, into) if is_on_roebe? into = RUBY_SRC_DIR_RBT_YAML_AT_HOME+'configuration/'+ File.basename(into) opne "Also storing in `#{sfile(into)}`." write_what_into(what, into) end end
#¶ ↑
do_permanently_enable_ccache
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 22957 def do_permanently_enable_ccache( into = FILE_CCACHE, what = "true\n" ) write_what_into(what, into) opne "Permanently enabling the use of ccache "\ "(Stored into this file: `#{sfile(into)}`)." if is_on_roebe? into = "#{RUBY_SRC_DIRECTORY}rbt/lib/rbt/yaml/configuration/"\ "#{File.basename(into)}" write_what_into(what, into) opne "Permanently enabling the use of ccache "\ "(Stored into this file: `#{sfile(into)}`)." end end
#¶ ↑
do_permanently_enable_the_colours
¶ ↑
This method can be used to permanently enable the colours.
Invoke this method by issuing:
ry --permanent-enable-colours
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12247 def do_permanently_enable_the_colours opne 'Now permanently enable the colours.' configuration?.use_colours = true write_what_into(false, RBT.file_use_colours) if is_on_roebe? into = RUBY_SRC_DIR_RBT_YAML_AT_HOME+'configuration/'+ File.basename(into) opne "Also storing in `#{sfile(into)}`." write_what_into(what, into) end end
#¶ ↑
do_permanently_use_clang
¶ ↑
This method will permanently enable clang, the compiler, on a project-wide default.
Invocation example:
ry --do-permanently-use-clang
#¶ ↑
# File lib/rbt/compile/compile.rb, line 22806 def do_permanently_use_clang configuration?.use_this_compiler = :clang configuration?.do_save end
#¶ ↑
do_permanently_use_psych
¶ ↑
Use this method if you wish to permanently use psych, rather than syck.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14452 def do_permanently_use_psych opne 'We will use the psych module for yaml-datasets from now on.' opne 'This will be stored in the file '+sfile(FILE_USE_PSYCH_OR_SYCK) write_what_into(YAML.dump(:psych), FILE_USE_PSYCH_OR_SYCK) if is_on_roebe? write_what_into(YAML.dump(:psych), ROEBE_PATH_TO_COOKBOOKS+'yaml/configuration/'+ File.basename(FILE_USE_PSYCH_OR_SYCK) ) end end
#¶ ↑
do_permanently_use_syck
¶ ↑
Use this method if you wish to permanently use syck, rather than psych.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14470 def do_permanently_use_syck opne 'We will use the syck module for yaml-datasets from now on.' opne 'This will be stored in the file '+sfile(FILE_USE_PSYCH_OR_SYCK) write_what_into(YAML.dump(:syck), FILE_USE_PSYCH_OR_SYCK) if is_on_roebe? write_what_into(YAML.dump(:syck), ROEBE_PATH_TO_COOKBOOKS+'yaml/configuration/'+ File.basename(FILE_USE_PSYCH_OR_SYCK) ) end end
#¶ ↑
do_remove_the_extracted_archive
¶ ↑
This is the method that will remove the extracted archive again. Only invoke it when we are absolutely certain that the archive has to be extracted.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 19212 def do_remove_the_extracted_archive _ = remove_archive_stuff_from_the_end( extract_where_to?+ File.basename(program_path?.to_s) ) if File.directory?(_) and remove_the_extracted_archive? opne "Next, the directory at `#{sdir(_)}` will be removed." remove_directory(_) end end
#¶ ↑
do_run_GNU_configure_then_make_then_make_install
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 20445 def do_run_GNU_configure_then_make_then_make_install( use_this_configure_command = use_this_build_system? ) run_the_configure_command run_premake_make_then_make_install if run_make? end
#¶ ↑
do_set_keep_extracted
¶ ↑
This delegates towards the method set_keep_the_extracted_archive
and may also report to the end-user as to what is being done.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18842 def do_set_keep_extracted( be_verbose = true ) case be_verbose when :be_silent, :be_quiet be_verbose = false end if be_verbose opne 'The extracted directory will not be removed '\ 'after compilation / installation has finished.' end set_keep_the_extracted_archive end
#¶ ↑
do_show_a_deprecation_notice
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 17499 def do_show_a_deprecation_notice opne "#{tomato('Take notice that class RBT::Compile is mildly deprecated')}" opne "#{tomato('past 2022. The old functionality should still work fine, as-is,')}" opne "#{tomato('but eventually class RBT::Compile will be removed.')}" opne "#{tomato('Consider using RBT::Installer instead.')}" end
#¶ ↑
do_store_the_configure_options_that_were_used_into_a_markdown_file
¶ ↑
This method is only invoked for an AppDir program. It will store the configure options, but not the full configure command; for that another .md file is used.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18004 def do_store_the_configure_options_that_were_used_into_a_markdown_file store_this = configure_options?.dup unless store_this.empty? # ===================================================================== # # We will remove some stuff from it before storing: # ===================================================================== # if store_this.include? rbt_temp_dir? store_this.sub!( /#{Regexp.quote(rbt_temp_dir?)}/, '' ) _ = program_name_and_program_version? if store_this.include? _ store_this.sub!(/#{_}/, '.') end end into = "#{prefix?}Resources/configure_options.md" opne 'Storing the configure options that were used '\ 'into the file:' e e " #{sfile(into)}" e write_what_into("#{store_this}\n", into) end end
#¶ ↑
do_strip_the_compiled_binaries
¶ ↑
This method will strip the compiled binaries, but only if we install them in an AppDir-prefix, that is, a path such as:
/Programs/Htop/2.0.2/ /home/Programs/Htop/2.0.2/
This stripping-operation will be done by the program called “strip”, which is part of the binutils suite.
There are three major ways how to use the strip functionality essentially:
(1) --strip-unneeded (2) --strip-debug (3) --strip-all
“strip –strip-unneeded” will remove all symbols that are not needed for relocation processing.
“strip –strip-debug” will only remove the debugging symbols.
“strip –strip-all” will remove all symbols.
Note that you can also strip the symbol table, from an object file, by using the “-s option” of the strip command.
When I tested different strip variants, in particular –strip-debug and –strip-unneeded, the latter one was producing significantly smaller binary files. When I used –strip-all and compared it to –strip-unneeded, the results were the same - so based on this, I am setting “–strip-unneeded” as the default.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 24505 def do_strip_the_compiled_binaries( # ===================================================================== # # Determine which strip-variant to use next: # strip_how = '--strip-debug' # strip_how = '--strip-all' # ===================================================================== # strip_how = '--strip-unneeded' # ← This is the current default. ) # ======================================================================= # # Do not strip the binaries if an error has occurred or if the user # has not enabled this option. # ======================================================================= # return unless can_we_continue? return if an_error_has_occurred? return if do_not_strip_the_binaries? # ======================================================================= # # First, we must determine whether we will use the strip command or # whether we will not. Presently, we will use the strip command if # the user_prefix either includes the programs directory - or if # we use a path that is NOT using /usr as part of its prefix. # # As of January 2019, the above has been changed - we will only use # this if the real prefix includes the programs directory. Any other # prefixes will be ignored. # # As of December 2019, the method also has to check whether # real_prefix? returns a value other than nil (or false). The # reason for this is because RBT::Compile is able to respond # to --no-prefix again, so this requires more checks. # ======================================================================= # if real_prefix? and real_prefix?.include?(programs_dir?) # or # !real_prefix?.include?('/usr') _ = rds(real_prefix?.to_s+'/bin/') # ===================================================================== # # Next obtain all entries in the bin/ subdirectory there. This may # lead to wrong results, though, as it may also include other files # if we are not careful. # ===================================================================== # all_files_in_the_bin_subdirectory = Dir["#{_}*"] # ===================================================================== # # Since as of 01.02.2019 we will only keep entries that are also # registered under "binaries:" in the corresponding .yml file. # This was specifically done to prevent running strip on e. g. # /usr/bin/* or /root/bin/*. # ===================================================================== # binaries = binaries? all_files_in_the_bin_subdirectory.select! {|entry| binaries.include?(File.basename(entry)) } strip_command = "strip #{strip_how.lstrip}" unless all_files_in_the_bin_subdirectory.empty? how_many = sfancy(all_files_in_the_bin_subdirectory.size.to_s) # =================================================================== # # Notify the user how many executables will be modified # through strip next. # =================================================================== # text = "Next running \"#{sfancy(strip_command)}\" on".dup if all_files_in_the_bin_subdirectory.size > 1 text << ' all' end text << ' '+how_many # Add the number here. if all_files_in_the_bin_subdirectory.size > 1 text << ' binaries.' else text << ' binary.' end # =================================================================== # # Display our findings to the user next: # =================================================================== # opne text all_files_in_the_bin_subdirectory.each {|this_file| # ================================================================= # # The following command will usually run: # "strip --strip-unneeded *" # ================================================================= # cmd = "#{strip_command} #{this_file}" opne " #{sfancy(cmd)}" system(cmd) } end end end
#¶ ↑
do_the_dependencies_include_this_program?¶ ↑
This method can be used to check whether the dependencies include a given program at hand (the input).
Keep in mind that dependencies can be written in either “name” or “name >= 1.2.3” style. So we also have to check for the second possibility there.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26789 def do_the_dependencies_include_this_program?( i = compile_which_program? ) dependencies = required_dependencies_on? # ======================================================================= # # Simplify the dependencies next. # ======================================================================= # dependencies.map! {|entry| if entry.include?(' >') or entry.include?(' <') entry = entry.split(' ').first.strip end entry } dependencies.include? i end
#¶ ↑
do_these_logic_steps
(logic tag)¶ ↑
This is a “meta”-method - it bundles different logic-steps together.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 10629 def do_these_logic_steps(*array) flattened = array.flatten flattened.each {|this_entry| case this_entry # ===================================================================== # # === :consider_applying_a_patch # ===================================================================== # when :consider_applying_a_patch consider_applying_a_patch # ===================================================================== # # === :consider_creating_the_appdir # ===================================================================== # when :consider_creating_the_appdir consider_creating_the_appdir_skeleton else # else assume a method-call as-is. send(this_entry.to_sym) end } end
#¶ ↑
do_upgrade_from_this_file
¶ ↑
This method can be used to read input from a file, in order to determine which programs are to be compiled.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14045 def do_upgrade_from_this_file(i) case i # case tag when :default, :def i = 'these_programs_can_be_upgraded.yml' end if File.exist? i if i.end_with? '.yml' dataset_to_use = load_yaml(i) else dataset_to_use = File.readlines(i).map {|line| line.strip } end _ = dataset_to_use _ = _.join(', ') if _.is_a? Array opne "We will use this dataset: #{slateblue(_)}" set_compile_these_programs(dataset_to_use) else opne "No file called #{sfile(i)} appears to exists." end end
#¶ ↑
do_upload_ruby_binary
¶ ↑
To invoke this, try:
rbt --upload-ruby-binary
#¶ ↑
# File lib/rbt/compile/compile.rb, line 22244 def do_upload_ruby_binary ensure_that_the_log_directory_exists # ======================================================================= # # Obtain the path to the local ruby version in use: # ======================================================================= # path_to_ruby = "#{programs_dir?}Ruby/" base_directory_to_upload = "#{path_to_ruby}Current" # This is a symlink. ruby_version = File.readlink(base_directory_to_upload) cd log_dir? _ = path_to_ruby+ruby_version+'/' # This is the full, real path. # ======================================================================= # # Next, use tar to create an archive. # ======================================================================= # readelf_command_to_use = "readelf -h #{_}bin/ruby" binary_32_bit_or_64_bit = `#{readelf_command_to_use}` binary_32_bit_or_64_bit = binary_32_bit_or_64_bit.split(N).select {|line| line.include? 'Class:' } binary_32_bit_or_64_bit = binary_32_bit_or_64_bit.to_s.dup binary_32_bit_or_64_bit =~ /(\d+)/ binary_32_bit_or_64_bit = $1.to_s.dup+'-bit' e "We will put this archive into `#{sdir(return_pwd)}`." name_of_the_ruby_archive = 'ruby-'+ruby_version+'-'+binary_32_bit_or_64_bit+'.tar.xz' _ = 'tar cfJv '+name_of_the_ruby_archive+' '+_ esystem _ _ = (return_pwd+name_of_the_ruby_archive).squeeze '/' if File.exist? _ e 'The file now resides at `'+sfile(_)+'`.' do_binary_upload_of_this_file(_) # Here we finally upload the archive. else e 'Some error appears to have happened - no archive at '+sfile(_) e ' could be found.' end end
#¶ ↑
do_use_a_white_background
¶ ↑
We will silently assume that the user has a white background, and will re-assign to use a green font colour in this case, on KDE Konsole.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12490 def do_use_a_white_background ::Colours.table_colour_methods_to_specific_colour[:simp] = :seagreen end
#¶ ↑
do_use_appdir_prefix
¶ ↑
This method will call do_compile_in_a_non_traditional_way
, but it will always be quiet.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 23514 def do_use_appdir_prefix do_compile_in_a_non_traditional_way(:be_quiet) end
#¶ ↑
do_use_autogen
¶ ↑
This invokes the autogen script, by using ‘sh’.
In oldschool shell script code, this means that we will run the following command:
sh autogen.sh
#¶ ↑
# File lib/rbt/compile/compile.rb, line 25707 def do_use_autogen( use_this_cmd = "sh #{FILE_AUTOGEN}" # " #{SHELL_ERROR_CODE}" ) cliner { _ = return_pwd opne simp('Doing `')+sfancy(use_this_cmd)+simp('` from ')+sdir(_) opne simp('using the following command:') opn; efancy " #{use_this_cmd}" } `#{use_this_cmd}` end
#¶ ↑
do_use_build_directory
¶ ↑
Use this method to specifcally “tell” a program to do use a build directory. For cmake-based projects it is recommended to use a build directory.
Usage example:
ry htop build
#¶ ↑
# File lib/rbt/compile/compile.rb, line 23090 def do_use_build_directory( be_verbose = true ) case be_verbose when :be_verbose be_verbose = true when :be_quiet be_verbose = false end if be_verbose opne 'A build directory will be used.' end @internal_hash[:use_build_directory] = true end
#¶ ↑
do_use_cmake
¶ ↑
If you wish to use cmake, you can do so via this method here.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12672 def do_use_cmake opne "We will use #{steelblue('cmake')} rather than make." set_use_this_make_command 'cmake' end
#¶ ↑
do_use_gobolinux_symlinkprogram
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12046 def do_use_gobolinux_symlinkprogram(be_verbose = true) if be_verbose opne 'Using the GoboLinux SymlinkProgram rather than '\ 'the internal RBT::SymlinkProgram script.' end @internal_hash[:use_gobolinux_symlinkprogram] = true end
#¶ ↑
do_use_meson
¶ ↑
This method will allow us to use meson. It will, on roebe systems, also try to use Python 3 if it is not the main one in use.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 29487 def do_use_meson use_utf8_encoding_in_env set_use_this_configure_command(:meson) set_use_this_build_directory('build') consider_enabling_python3 end
#¶ ↑
do_use_random_build_directory
¶ ↑
This method can be used to use an ad-hoc random build directory.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 23131 def do_use_random_build_directory( be_verbose = true ) use_this_as_the_new_name = ''.dup n_times = (8..16).to_a.sample n_times.times { use_this_as_the_new_name << ALPHABET.sample } if be_verbose opne "We will use a #{lightgreen('random directory')} as "\ "build directory (#{sfancy(use_this_as_the_new_name)})." end do_use_build_directory :be_quiet set_name_for_the_build_directory(use_this_as_the_new_name) end
#¶ ↑
do_use_random_version
¶ ↑
Use a random version of a program.
Usage example:
ry gcc --use-random-version
#¶ ↑
# File lib/rbt/compile/compile.rb, line 17334 def do_use_random_version( this_program = compile_which_program? ) require 'rbt/utility_scripts/check_for_available_versions.rb' cfav = RBT::Cookbooks::CheckForAvailableVersions.new(this_program) available_programs = cfav.programs?.map {|entry| File.basename(entry) } _ = available_programs.sample opne "We will use another version (for program #{simp(_)})" dataset?.set_complex_program_version(_) # This here sets the new version. end
#¶ ↑
do_use_the_blfs_instructions_for_compiling_this_program
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 25564 def do_use_the_blfs_instructions_for_compiling_this_program( this_program = compile_which_program? ) require 'rbt/linux/linux_from_scratch/parse_blfs_webpage.rb' _ = return_dataset_from_this_remote_blfs_page(this_program) _ = RBT::Linux::ParseBlfsWebpage.new(_).shell_commands? initialize_dataset_for(this_program) program_path = yaml_dataset?.program_path? if File.exist? program_path extract_what_to(program_path, :default) # ===================================================================== # # Next we must cd to the correct target, before making use of # the BLFS instructions. # ===================================================================== # cd_target = extracted_directory?+program_name_and_program_version? cd cd_target opne "We are in the directory #{sdir(return_pwd)}." e opne 'Next, the '+steelblue('BLFS instructions')+ ' acquired will be run as-is:' e esystem _ else opnn; no_file_exists_at(program_path) end end
#¶ ↑
do_use_the_clang_compiler
¶ ↑
Use this method if you wish to make use of the (LLVM) clang compiler rather than gcc.
Do note that you can also use special arguments or combine clang with ccache, such as shown in the following examples:
export CC='ccache clang -fcolor-diagnostics -Qunused-arguments -fcatch-undefined-behavior -ftrapv' export CXX='ccache clang++ -fcolor-diagnostics -Qunused-arguments -fcatch-undefined-behavior -ftrapv'
Invocation example:
ry htop --clang
#¶ ↑
# File lib/rbt/compile/compile.rb, line 29584 def do_use_the_clang_compiler( shall_we_notify_the_user = :notify_the_user ) case shall_we_notify_the_user # ======================================================================= # # === :notify_the_user # ======================================================================= # when :notify_the_user, :and_notify_the_user opne "We will attempt to use (#{teal('LLVM')}) #{slateblue('clang')} "\ "to compile the code at hand." end set_this_env_variable 'CC=clang', :be_quiet set_this_env_variable 'CXX=clang++', :be_quiet @internal_hash[:compiler_to_use] = :clang # Keep track of the compiler here. end
#¶ ↑
do_use_the_gcc_compiler
¶ ↑
Use this method if you wish to make use of the GCC compiler.
Invocation example:
ry htop --use-gcc
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13504 def do_use_the_gcc_compiler( shall_we_notify_the_user = :notify_the_user ) case shall_we_notify_the_user # ======================================================================= # # === :notify_the_user # ======================================================================= # when :notify_the_user, :and_notify_the_user opne "We will attempt to use #{teal('gcc')} to compile the "\ "code at hand." end set_this_env_variable 'CC=gcc', :be_quiet set_this_env_variable 'CXX=g++', :be_quiet @internal_hash[:compiler_to_use] = :gcc # Keep track of the compiler here. end
#¶ ↑
do_we_use_python3?¶ ↑
This method will return true if we use python version 3 or higher, and false otherwise.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 25304 def do_we_use_python3? version = `python -V #{SHELL_ERROR_CODE}`.chomp if version.include? ' ' version = version.split(' ').last end version.start_with? '3' # ← This check has to suffice for now. end
#¶ ↑
does_a_python_binary_exist?¶ ↑
This method will return true if a “python” binary can be found in the PATH variable - and it will return false otherwise.
# ¶ ↑
# File lib/rbt/compile/compile.rb, line 25159 def does_a_python_binary_exist? _ = false check_these_directories = query_path? if check_these_directories.is_a?(String) and check_these_directories.include?(':') splitted = check_these_directories.split(':') splitted.each {|this_path| target = rds(this_path+'/python') if File.exist?(target) _ = true end } end _ end
#¶ ↑
does_this_file_exist?¶ ↑
This method checks whether the given-input argument, an assumed path to a file, exists.
The reason why this method exists is because it was necessary to do a “does this file exist” check in other directories rather than the current working directory.
#¶ ↑
RBT::Base#does_this_file_exist?
# File lib/rbt/compile/compile.rb, line 26076 def does_this_file_exist?( this_file = FILE_SCONS ) this_file = this_file.dup # ← We must always work on a copy. # ======================================================================= # # We have to check whether the cookbook_dataset has been initialized. # If it has not been initialized yet, we will not query whether we # ought to use a build directory or not. # ======================================================================= # if cookbook_dataset? and use_build_directory? this_file.prepend('../') end super(this_file) end
#¶ ↑
download_program
(download tag, download archive, wget tag)¶ ↑
The method ‘download_program` will attempt to download the given program, which is the first argument passed to this method.
An# URL is expected as argument here, a String, such as
'http://hisham.hm/htop/releases/2.2.0/htop-2.2.0.tar.gz'
An Array can also be used as argument. Internally the method will make use of an Array anyway.
For this download-related activity, we will either use a plain system() call to “wget” or we may use a ruby wget-wrapper. On Linux
or BSD-based systems ‘wget’ may be simpler to use. On windows we may have to use a ruby-variant of ‘wget’ instead.
Do note that the method download_program
() will always assume that the first argument given is an Array - that is, an Array of multiple urls. It will download all passed remote programs in a batch-like operation. This allows the user to, for example, download the whole KDE stack, in principle, by simply passing the Array of remote entries that constitute that KDE stack.
Please keep in mind that we will change_directory() in this method too, so you don’t have to call that on your own.
As of 05 September 2014 the method will also honour the “do_not_download” setting, if it was defined. This can be overruled in the arguments passed to this method.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 17621 def download_program( url_for_program = url1?, may_we_download = may_we_download?, change_to_this_directory = cookbook_dataset_base_dir?, shall_we_update_the_dataset = true ) url_for_program = [url_for_program].flatten.compact # ======================================================================= # # We will handle some special Symbols next: # ======================================================================= # case shall_we_update_the_dataset when :do_not_update_the_dataset shall_we_update_the_dataset = false end case may_we_download when :do_download, :we_may_download may_we_download = true end case change_to_this_directory # ======================================================================= # # === :default # ======================================================================= # when :default change_to_this_directory = cookbook_dataset_base_dir? end change_to_this_directory = change_to_this_directory.to_s if is_on_roebe? unless change_to_this_directory.start_with? '/home/x/' this_file = RBT.file_source_directory? if File.exist? this_file if File.read(this_file).start_with? '$' # This is a small safeguard for my home system. opne 'The base directory does not seem to refer to '+ sdir('/home/x/') opne 'as a base. Has the environment been properly set up?' return end else opnn; no_file_exists_at(this_file) end end end url_for_program.each {|use_this_remote_url| if may_we_download url_for_program = use_this_remote_url url_for_program = url1? if url_for_program == :def # ======================================================================= # # Since Jul 2011 we use pure wget for this. Something is odd with # RubyWget and until we have fixed this, plain wget has to be used. # ======================================================================= # use_svn = dataset?.svn_url? # ======================================================================= # # Check whether the base directory exists. # ======================================================================= # if !File.exist?(change_to_this_directory) opne simp('Creating the directory `')+ sdir(change_to_this_directory)+ simp('` next.') create_directory(change_to_this_directory) end # ======================================================================= # # Change into the base directory first, before continuing to try # to download the archive in question. # ======================================================================= # change_directory(change_to_this_directory) # cd into the archive. # ======================================================================= # # Change into the archive. Be verbose about it. # ======================================================================= # cliner { opne "#{simp('Downloading ')}#{sfile(url_for_program)}" opne simp('into the directory ')+sdir(change_to_this_directory)+ simp(' now.') } if url_for_program.to_s.include? 'tar.gz' # overrule here for .tar.gz files. _ = cookbook_dataset? #.data _.set_archive_type('.tar.gz') _.set_program_full_name _.assemble_program_path @data = cookbook_dataset?.return_dataset end if use_svn.nil? or use_svn.empty? # Assume no SVN was given. bl rubywget do_download_this_program(url_for_program) # RubyWget.new(url_for_program) else # Else, we should use svn perhaps? Hmm or not. if _ do_download_this_program(_) else do_download_this_program(url_for_program) end # RubyWget.new(_) end if shall_we_update_the_dataset # ================================================================= # # We will update the dataset as well. # ================================================================= # yaml_dataset = load_yaml_dataset_for_this_program( program_information_return_name(url_for_program), :return_flat_datastructure ) assign_to_the_main_dataset( yaml_dataset ) end end } end
#¶ ↑
download_the_latest_source_code_of_this_program
¶ ↑
This method can be used to do a git clone checkout.
To try this method, invoke it like this:
ry mpv --git-download
#¶ ↑
# File lib/rbt/compile/compile.rb, line 17515 def download_the_latest_source_code_of_this_program( i = compile_which_program? ) old_directory_content = Dir['*'].select {|entry| File.directory? entry } if compile_which_program?.nil? initialize_dataset_for(i) end _ = git_url? if _.nil? or _.empty? opne tomato('No remote git-URL is known for `'+i.to_s+'`.') opne tomato('Consider adding such an entry to the .yml '\ 'file at hand.') return end # ======================================================================= # # Notify the user that we are about to download a remote package next: # ======================================================================= # opne "#{rev}Next trying to #{royalblue('download')} from #{steelblue(_)}." # ======================================================================= # # Invoke the git-command next: # ======================================================================= # e esystem "git clone #{_}" e new_directory_content = Dir['*'].select {|entry| File.directory? entry } difference = new_directory_content - old_directory_content unless difference.empty? case difference.size when 1 # =================================================================== # # Currently we only handle one entry here. # =================================================================== # this_directory = difference.first opne 'A directory was found at '+ sdir(File.absolute_path(this_directory))+'.' new_name = this_directory+'-'+return_current_time opne 'It will be renamed next, to '+sdir(new_name)+'.' opne 'Finally, it will be made into a .tar.xz file.' rename(this_directory, new_name) to_tar_xz(new_name) if is_on_roebe? opne 'You may be able to remove the directory at '+ sdir(File.absolute_path(new_name))+' now.' end end end end
#¶ ↑
download_the_remote_documentation_of_the_RBT_project
¶ ↑
This method will download the documentation of the RBT
project for local use.
Usage example:
rbt --download-docu
#¶ ↑
# File lib/rbt/compile/compile.rb, line 10613 def download_the_remote_documentation_of_the_RBT_project remote_URL = 'https://www.rubydoc.info/gems/rbt/' opne 'Now downlading from the remote URL at '+steelblue(remote_URL)+'.' dataset = URI.open(remote_URL).read into = File.absolute_path('rbt_documentation.html') write_what_into(dataset, into) if File.exist? into opne 'Storing into the local file at '+sfile(into)+'.' end end
#¶ ↑
download_this_remote_url_into_that_local_directory
¶ ↑
The first argument should be the remote URL to the program at hand.
The second argument should be a local directory.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 17571 def download_this_remote_url_into_that_local_directory( url = url1?, local_directory = '/home/Temp/downloads/' ) local_directory = local_directory.dup if local_directory.frozen? local_directory << '/' unless local_directory.end_with? '/' unless File.directory? local_directory create_directory(local_directory) { :be_verbose } end cd local_directory # change directory into that target download_program( url, :we_may_download, local_directory, :do_not_update_the_dataset ) end
#¶ ↑
download_using_svn
¶ ↑
Use this method here to download/checkout from svn. In order for this to properly work, you need to define a svn_url in the yaml file for the respective program at hand.
To try out this method, do:
ry dosbox svn
#¶ ↑
# File lib/rbt/compile/compile.rb, line 17782 def download_using_svn( i = compile_which_program? ) dataset = dataset? if dataset.nil? dataset = initialize_dataset_for(i) end _ = "svn co #{dataset.svn_url?}" working_directory = sdir(return_current_pwd) opne "Now trying to use svn to download the source directly "\ "(working directory is: #{working_directory}." opnn; print ' ' e _ _result = `#{_}` # We may want to use this return-value at a later time. # ======================================================================= # # === Rename the trunk directory next # ======================================================================= # if File.directory? 'trunk' _ = "#{i}-#{today?}" opne "Now renaming directory `#{sdir('trunk')}` to `#{simp(_)}`." rename('trunk', _) if Object.const_defined? :ToTarXz opne 'Now trying to package the directory `'+sdir(_)+'`.' to_tar_xz(_) package_name = Dir["#{_}.tar.xz"] unless package_name.empty? opne 'All should be done now. You can move this .tar.xz '\ 'package ('+simp(package_name.first)+').' end end end end
#¶ ↑
edit_the_yaml_file_via_the_main_editor
¶ ↑
Invocation example:
rbt --edit-file=nano
#¶ ↑
# File lib/rbt/compile/compile.rb, line 17466 def edit_the_yaml_file_via_the_main_editor( this_yaml_file = compile_which_program?, use_this_editor = ENV['EDITOR'] ) this_yaml_file = this_yaml_file.to_s.dup this_yaml_file = 'nano' if this_yaml_file.empty? _ = nil # Default. # ======================================================================= # # Determine which editor to use next: # ======================================================================= # _ = use_this_editor.to_s.dup+' ' if use_this_editor # ======================================================================= # # Overrule on my home system. # ======================================================================= # if is_on_roebe? or _.nil? _ = "#{editor?} " end unless File.exist? this_yaml_file unless this_yaml_file.include? '/' this_yaml_file = return_location_to_this_programs_yaml_file(this_yaml_file) end end if File.exist? this_yaml_file _ << this_yaml_file else _ << find_this_yaml_file(this_yaml_file) end esystem _ end
#¶ ↑
either_report_the_total_amount_of_binaries_or_how_many_binaries_this_program_will_install
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27745 def either_report_the_total_amount_of_binaries_or_how_many_binaries_this_program_will_install if a_program_has_been_initialized? report_the_amount_of_binaries else RBT.report_how_many_binaries_are_registered end end
#¶ ↑
enable_everything_for_the_current_compilation_run
¶ ↑
Note that currently we will only work on the “–enable*” entries.
Invocation example:
ry ncurses ntrad --enable-everything --dontsymlink
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14091 def enable_everything_for_the_current_compilation_run default_extract_step( use_this_local_path: cookbook_dataset?.program_path? ) cd_to_the_extracted_archive e 'running ./configure help ...' cmd = './configure --help' result = `#{cmd}` array = result.split(N) # ======================================================================= # # Entries may look like this: # # --enable-symlinks make tic use symbolic links not hard links\n" + # --with-x11-rgb=FILE file containing X11 rgb information (EPREFIX/lib/X11/rgb.txt)\n" + # # ======================================================================= # selection = array.select {|line| splitted = line.split(' ') line.start_with?(' --enable-') and (splitted[0].downcase == splitted[0]) # <- This checks for all-downcase. # ^^^ exclude entries such as "--enable-FEATURE[=ARG]" } selection = selection.map {|entry| entry.split(' ').first.to_s }.join(' ').strip clear_configure_options append_this_to_the_configure_options(selection) end
#¶ ↑
enable_is_on_gobolinux
¶ ↑
This method can be used to default to a GoboLinux behaviour.
We should closely follow the behaviour of GoboLinux via the RBT
scripts, 1:1 - no need to create incompatibilities at this point.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 11959 def enable_is_on_gobolinux # ENV['IS_ON_GOBOLINUX'] = '1' # ← Disabled as of 25.09.2018; we probably no longer need to do this. @internal_hash[:is_on_gobolinux] = true use_non_traditional_prefix do_not_symlink_headers do_not_symlink_pkgconfig_files do_use_gobolinux_symlinkprogram # ← Trying this as of Oct 2017. do_not_register_into_the_yaml_database end
#¶ ↑
enable_non_traditional_compilation
¶ ↑
This will essentially switch to app-dir prefix.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 16564 def enable_non_traditional_compilation( optional_use_this_as_program_name_and_program_version = program_name_and_program_version? ) if optional_use_this_as_program_name_and_program_version @internal_hash[:prefix].set_program( optional_use_this_as_program_name_and_program_version ) end @internal_hash[:prefix].enable_non_traditional_compilation end
#¶ ↑
enable_simulation
¶ ↑
Enable to run in simulation mode. The first argument is an optional message we give, in which case we will output that message.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 11243 def enable_simulation( optional_message = '' ) unless optional_message.empty? opne optional_message end do_run_simulation end
#¶ ↑
ensure_that_the_configure_options_are_consistent_in_regards_to_static_compilation
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 29213 def ensure_that_the_configure_options_are_consistent_in_regards_to_static_compilation _ = configure_options?.dup if compile_statically? unless _.include? '--enable-static' _ << ' --enable-static' # Just to be safe. end if _.include?('--enable-static') and not (_.include?('--disable-shared')) _ << ' --disable-shared' unless _.include?('--enable-shared') end if _.include?('--enable-shared') and _.include?('--enable-static') set_configure_options( _.sub(/--enable-shared/, '--disable-shared') ) sort_configure_options_alphabetically end end end
#¶ ↑
ensure_that_the_program_exists
¶ ↑
This method will control whether we can continue to run. We can continue to run if the program exists as part of the cookbooks project. One exception to this rule is when the last character is a ‘*’ token. In this case we assume that he user wants to simply get a list of available programs instead, starting with that specific name, e. g. “e*” should yield a list of all programs starting with the character “e”.
You can try this out by doing:
ry e*
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18514 def ensure_that_the_program_exists( i ) i = i.to_s if honour_check_to_ensure_that_the_program_exists? unless cookbooks_include_this_program?(i) # =================================================================== # # Handle not-registered programs next: # =================================================================== # opne "#{crimson('The program `')}#{seagreen(i)}"\ "#{crimson('` could not be found. It thus can not be compiled')}" opne crimson('and hence, RBT::Compile can not continue. If this '\ 'file should exist,') opne crimson('it can be found at:') e e " #{sfile(return_location_to_this_programs_yaml_file(i))}" e we_can_not_continue end unless i.end_with? '*' end return can_we_continue? end
#¶ ↑
error_is
(error_is
tag)¶ ↑
This registered an error. An error is always a problem, but some problems allow us to continue the installation steps. An error on the other hand will end the installation procedure.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 19554 def error_is( this_error = :meson_could_not_be_found ) problem_is(this_error) an_error_has_occurred # ======================================================================= # # Register the error on the main RBT namespace as well. # ======================================================================= # RBT.append_error_message( this_error ) end
#¶ ↑
error_message?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 19587 def error_message? RBT.error_message? end
#¶ ↑
extract_the_linux_kernel_archive
¶ ↑
To tap into this method from the commandline, do:
ry --extract-linux
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15738 def extract_the_linux_kernel_archive result = initialize_cookbook_dataset_for(:linux) target = result.extract_to? if File.symlink? '/usr/src/linux' delete_symlink('/usr/src/linux') end extract_what_to( result.path?, target, :do_keep_the_old_directory_if_it_exists ) e "Finished extracting the linux kernel to #{sdir(target)}." end
#¶ ↑
extract_this_program_if_it_exists
(extract tag, extracter tag)¶ ↑
This method will extract the given archive directory, by delegating towards class Extracter.
This method ought to be invoked quite early, logically; the method “consider_extracting_this_program()” may be used to invoke this method.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 19258 def extract_this_program_if_it_exists( i = cookbook_dataset_program_path?, extract_to_this_location = extract_to?, shall_we_report_to_the_user_if_the_archive_does_not_exist = true ) if File.exist? i if run_simulation? opne "We would normally extract `#{sfile(i)}` "\ "to #{sdir(extract_to_this_location)} next," opne 'but since we run in simulation-mode, we will not '\ 'extract anything.' else invoke_extracter( # ← Delegate to invoke_extracter() here. i, extract_to_this_location # Second argument is the location. ) end # ===================================================================== # # Next we will exit if the user told us that he/she is only # interested in extracting the program. # ===================================================================== # exit_program if extract_only? else if shall_we_report_to_the_user_if_the_archive_does_not_exist opne swarn('No file could be found at `')+ sfile(i)+ swarn('` - thus,') opne swarn('we can not extract anything.') # =================================================================== # # Also set a specific error, so that we won't continue. # =================================================================== # error_is 'We can not continue. Has the archive '\ 'been properly extracted?' end end return extract_to_this_location # And return it too, in case downstream code needs it. end
#¶ ↑
extract_to_default_directory
¶ ↑
By default, we will extract to this directory - but the value is lateron refined to the full path instead; so the assignment done here is just so that we have a starting value we can work with.
This method will be called from within the method reset().
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18889 def extract_to_default_directory( i = RBT.log_directory? ) @internal_hash[:extract_to_this_directory] = i end
#¶ ↑
extract_to_this_directory?¶ ↑
This query-method tells us where we will extract (our archive) to.
The temp-directory is initially the same as RBT.rbt_log_directory?.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18902 def extract_to_this_directory? _ = @internal_hash[:extract_to_this_directory] # ======================================================================= # # Allow the user to overrule this value. # ======================================================================= # if @internal_hash[:extract_to_this_directory_as_specified_by_the_user] _ = @internal_hash[:extract_to_this_directory_as_specified_by_the_user] end _ end
#¶ ↑
extracted_base_directory?¶ ↑
If you need to query the value for the path to the extracted directory, then make use of the method extract_to_this_directory? rather than the method here.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18982 def extracted_base_directory? @internal_hash[:extracted_base_directory] end
#¶ ↑
feedback_all_libraries_and_all_binaries
¶ ↑
Invoke this method by issuing:
ry htop installs_what?
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28504 def feedback_all_libraries_and_all_binaries( of_this_program = compile_which_program? ) feedback_all_binaries(of_this_program) feedback_all_libraries(of_this_program) end
#¶ ↑
feedback_all_registered_binaries_of_all_programs
¶ ↑
This method will show, on the commandline, all registered binaries of all the programs together.
Invocation example:
rbt --all-binaries
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27772 def feedback_all_registered_binaries_of_all_programs _ = RBT.registered_binaries? opne 'These '+royalblue(_.size.to_s)+' binaries are registered:' e _.each_with_index {|this_binary, index| index += 1 padded_index = (index.to_s+') ').rjust(5) e " #{lightgreen(padded_index)}"\ "#{slateblue(this_binary)}" } e end
#¶ ↑
feedback_configure_options
¶ ↑
To test this method, try something like this:
ry htop configure_options? ry gcc configure_options?
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28471 def feedback_configure_options(i = compile_this_program?) opne 'The configure options for the program '+sfancy(i)+' are:' if dataset?.nil? ensure_that_we_have_a_dataset(i) end _ = configure_options? e e " #{sfancy(_)}" e end
#¶ ↑
feedback_default_values_of_the_internal_hash
¶ ↑
Invocation example from the commandline:
ry --feedback-the-default-values-of-the-internal-hash
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28530 def feedback_default_values_of_the_internal_hash dataset = return_default_internal_hash e e "The following #{lightblue(dataset.keys.size.to_s)} entries are known:" e dataset.each_pair {|key, value| if value.nil? value = 'nil' end e " #{slateblue(key)}: #{lightgreen(value)}" }; e end
#¶ ↑
feedback_dependencies_of_this_program
¶ ↑
Feedback the dependencies of a given program through this method.
Invocation example:
ry pango --feedback_dependencies_of_this_program
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28669 def feedback_dependencies_of_this_program( i = compile_which_program? ) if dataset?.nil? ensure_proper_dataset(i) end dependencies = dataset?.deps_on? unless dependencies.empty? cliner opne 'The following dependencies were found for `'+sfancy(i)+'`:' e # =================================================================== # # We will next assume that dependencies is an Array. # =================================================================== # dependencies.each {|dep| e " A dependency on: #{olivedrab(dep)}" } e cliner else opne "No dependency was found for `#{sfancy(i)}`." end end
#¶ ↑
feedback_expanded_dependencies_of_this_program
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28825 def feedback_expanded_dependencies_of_this_program( i = compile_which_program? ) e rev+'The expanded dependencies for '+steelblue(i)+' are:' e RBT::ReverseDependencies.dependencies?(i).each {|entry| e " #{entry}" } e end
#¶ ↑
feedback_last_compiled
¶ ↑
There are several ways how to invoke this method. We thus need to be rather flexible about feedbacking this to the user.
One of the first distinctions will be whether we have a ‘=’ token in the input or whether we do not.
Examples:
rbt --last-compiled? rbt --last-5-compiled? rbt --last-five-compiled? rbt --last-compiled?=5 rbt --last-compiled?=6
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28597 def feedback_last_compiled( i = :all_of_them ) i = i.first if i.is_a? Array # Grab the first entry. # ======================================================================= # # Next, we determine the dataset of which programs have been compiled. # ======================================================================= # dataset = compiled_programs? dataset = dataset.keys if dataset.respond_to? :keys case i when :all_of_them i = dataset.size end unless dataset opne 'No dataset was found in this file: '+sfile(file_compiled_programs?) return end show_n_programs = 1 # This is the default. if i.to_s =~ /^\d+$/ show_n_programs = i.to_i end if i and i.to_s.include?('=') splitted = i.split('=') show_n_programs = splitted.last.to_i elsif (show_n_programs > 1) # pass through in this case else # Else it does not include a '='. regex_to_use = /--last(-\d+-)compiled\?/ i =~ regex_to_use show_n_programs = $1.to_s.dup.delete('-').to_i if $1 array = HASH_ENGLISH_NUMBERS.keys if array.any? {|entry| i.include? entry } result = array.select {|entry| i.include? entry } result = result.first unless result.empty? # =================================================================== # # Now we must convert this: # =================================================================== # result = HASH_ENGLISH_NUMBERS[result] show_n_programs = result.to_i end end # ======================================================================= # # Narrow our dataset down. # ======================================================================= # if show_n_programs > dataset.size opne 'We have not kept track of that many ('+ sfancy(show_n_programs.to_s)+') registered programs, so' opne "only #{dataset.size.to_s} programs will be shown instead." show_n_programs = dataset.size end dataset = dataset.reverse[0 .. (show_n_programs - 1)].reverse e opne "The last #{simp(show_n_programs.to_s)} compiled "\ "programs (most recent one comes first) were:" # ======================================================================= # # Now we can report this dataset, which contains our programs. # ======================================================================= # e; dataset.reverse.each {|key| e " #{sfancy(key)}" }; e end
#¶ ↑
feedback_licenses
¶ ↑
This will feedback all licenses, or apply a filter.
Usage example:
ry htop flicenses
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28305 def feedback_licenses( filter_for_licenses = '*' ) RBT::Cookbooks::FeedbackLicenses.new(filter_for_licenses) # bl $RUBY_COOKBOOKS/lib/cookbooks/feedback_licenses.rb end
#¶ ↑
feedback_main_config
¶ ↑
In order to invoke this method, do:
rbt config?
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28406 def feedback_main_config opne 'We will show the configuration options set for the '\ 'RBT project next.' cliner { hash = RBT.configuration?._ # Delegate to the config. hash.each_pair {|key, value| case key.to_s.strip when 'email' value = crimson(value.to_s.ljust(10)) else value = slateblue(value.to_s.ljust(10)) end key = lightgoldenrodyellow( ((key.to_s+':').ljust(46)) ) e ' '+key+' '+value } } end
#¶ ↑
feedback_prefix_in_use
?¶ ↑
Use this method to feedback which prefix is in use.
Usage examples:
ry allegro --prefix? ry openmpi --prefix? ry htop prefix?
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27729 def feedback_prefix_in_use?( shall_we_exit = true ) program_name = compile_which_program?.dup if cookbook_dataset?.nil? ensure_proper_dataset_for(program_name) end e "#{rev}The prefix in use for #{lightgreen(program_name)} will be:" e " #{sfancy(prefix?)}" exit_program if shall_we_exit end
#¶ ↑
feedback_program_description
¶ ↑
We feedback the description here, by tapping into the method feedback_description
() from class Cookbooks
.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27790 def feedback_program_description( i = program_name? ) e RBT.feedback_description_of(i) e end
#¶ ↑
feedback_url
¶ ↑
Wrapper around Cookbooks
functionality.
Usage example:
rbt htop url?
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28805 def feedback_url( i = compile_which_program? ) RBT::Cookbooks::Url.new(i) # ======================================================================= # # The next line of code has been commented out at 21.09.2018: # ======================================================================= # # ::RBT::Cookbooks::DisplayCookbookDataset.feedback_url.feedback_url(compile_which_program?) # ======================================================================= # # The next part may be controversial, as it sets the xorg buffer. # As of May 2014 it was disabled. # ======================================================================= # # result = @cookbooks.feedback_url # set_xorg_buffer(result) end
#¶ ↑
feedback_various_versions
¶ ↑
This actually will only feedback the RBT
version in use, since we have merged the different projects together in September 2018.
To invoke this method, do:
ry htop feedback_version
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28365 def feedback_various_versions( optional_use_opn = true, ljust = 45 ) case optional_use_opn when :do_not_use_opn optional_use_opn = false end feedback_rbt_version(ljust, optional_use_opn) end
#¶ ↑
feedback_what_we_are_currently_compiling?¶ ↑
This method will feedback what we are currently compiling.
To invoke this method, do:
rbt --what-are-we-currently-compiling?
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28442 def feedback_what_we_are_currently_compiling?( status_file = FILE_STATUS ) if File.exist? status_file dataset = YAML.load_file(status_file) end this_key = 'currently_compiling_these_programs' if dataset.has_key?(this_key) and !dataset[this_key].empty? # This should work because it is an Array. these_programs_are_currently_compiled = dataset[this_key] opne 'The following programs are currently compiled:' e these_programs_are_currently_compiled.each {|this_program| e " #{sfancy(this_program)}" }; e else opne 'No program is being currently compiled.' end end
#¶ ↑
feedback_whether_the_cookbook_will_modify_env_variables
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28704 def feedback_whether_the_cookbook_will_modify_env_variables( compile_this_program = compile_which_program? ) _ = set_env_variables? if is_this_program_registered?(compile_this_program) if _.nil? opne "The program #{sfancy(compile_this_program)} does not "\ "set any ENV variable." else opne 'The program '+sfancy(compile_this_program)+' will '\ 'modify at the least one ENV variable.' opne 'Displaying these next:' e set_these_env_variables(_, :report_only) e end else opne 'No program with that name is known.' end end
#¶ ↑
feedback_whether_we_will_strip_or_whether_we_will_not
¶ ↑
Feedback whether we will run the “strip” binary or whether we will not.
Invocation example:
ry --strip?
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28260 def feedback_whether_we_will_strip_or_whether_we_will_not _ = strip_binaries? case _ when true opne 'Yes, we will run "'+slateblue('strip')+'" on the resulting '\ 'binaries of' opne 'the given program at hand.' when false opne "No, we will #{swarn('NOT')} run \"strip\" on the "\ "resulting binaries of" opne 'the given program at hand.' else e 'Unknown value: '+steelblue(_.class.to_s) end end
#¶ ↑
find_all_keys_starting_with
¶ ↑
This method will find all keys starting with a specific character.
Currently we will always exist when we use this method, so returning something is not hugely important.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26261 def find_all_keys_starting_with( i ) i.delete!('*') # Get rid of '*' since we no longer need it past this point. all_matches = all_programs?.select {|key| key =~ /^#{i}/ } e all_matches.sort.join(', ').split(N).map {|entry| ' '+entry }.join(N) e opne 'Found a total of '+ royalblue(all_matches.size.to_s)+ ' matches.' return all_matches end
#¶ ↑
first_argument?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12463 def first_argument? @internal_hash[:commandline_arguments].first end
#¶ ↑
full_configure_command?¶ ↑
The @full_configure_command contains the full configure command that we will use. The advantage in using this is that we can easily copy/paste this at a later time, should we need to do so.
We can also store this into a local file, such as a .md file. In fact, this was the primary reason why it was added.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18075 def full_configure_command? @internal_hash[:full_configure_command] end
#¶ ↑
generate_all_gobolinux_recipes
¶ ↑
This method can be used to auto-generate all GoboLinux recipes.
Invocation example:
ry --generate-all-gobolinux-recipes
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12064 def generate_all_gobolinux_recipes # ======================================================================= # # Must first change into an appropriate directory. # ======================================================================= # target_dir = "#{rbt_log_directory?}gobolinux/" if File.directory? target_dir # ===================================================================== # # Always remove the old directory should it exist. # ===================================================================== # remove_directory(target_dir) end mkdir(target_dir) if File.directory? target_dir opnn; cd target_dir, :be_verbose # ===================================================================== # # Next, create the subdirectories but be silent about it. # ===================================================================== # array = ('a'..'z').to_a # ===================================================================== # # Add two exceptions. # ===================================================================== # array[0,0] = '3' array[0,0] = '0' array.each {|entry| mkdir(entry, :be_quiet) } else opne "The target directory `#{sdir(target_dir)}` does not exist." opne 'Please create it before we can create GoboLinux recipes.' return end available_programs?.each {|this_program| opne "Now generating a GoboLinux recipe for "\ "the program `#{sfancy(this_program)}`." create_gobolinux_recipe_for(this_program) } # ======================================================================= # # Now that we have generated all these recipes, let's create a tarball # of the directory. # ======================================================================= # cd rbt_log_directory?, :be_quiet begin require 'totarxz' gobolinux_recipes_archive = "gobolinux-recipes-#{return_current_date}" mv 'gobolinux', gobolinux_recipes_archive to_tar_xz(gobolinux_recipes_archive) target_archive = "#{gobolinux_recipes_archive.dup}.tar.xz" if File.exist? target_archive opne "Everything has been packaged up into `"\ "#{sfancy(target_archive)}` (cwd: #{sdir_return_pwd})." # =================================================================== # # Rename the directory again. # =================================================================== # opnn; mv gobolinux_recipes_archive, 'gobolinux' # =================================================================== # # FTP upload if we are on Roebe. # =================================================================== # if is_on_roebe? require 'ftp_paradise' if File.exist? target_archive FtpParadise.upload_this_binary_file(target_archive) else opne 'Can not upload the file '+sfile(target_archive) opne 'as it does not exist.' end # ================================================================= # # Next, connect and upload all the individual directories to # my remote FTP host. # ================================================================= # end # =================================================================== # # Next, upload the individual directories to the remote FTP host. # Unfortunately this has a problem so we have disabled this for now. # =================================================================== # # =========================================================================== # # DISABLED FOR NOW. MUST BE FIXED ONE DAY. # =========================================================================== # if false _ = FtpParadise.new(:shevy) _.remote_mkdir 'gobolinux' _.remote_cd 'gobolinux' opnn; cd 'gobolinux', :be_verbose array.each {|this_directory| _.remote_mkdir(this_directory) _.rcd(this_directory) # ================================================================= # # Ok, we can obtain the local directories and then upload them # all. # ================================================================= # local_target = this_directory+'/*' all_local_directories = Dir[local_target].select {|entry| File.directory? entry } if all_local_directories.empty? opne 'Nothing found under '+sfancy(local_target)+'.' else all_local_directories.each {|this_entry| opne 'Now uploading the directory `'+sdir(this_entry)+'`.' _.upload_this_directory(this_entry) } end _.rcd '..' # Return to the base directory again. } end # end false clause (DEBUG - FIXME!!!) end rescue LoadError opne 'Please install the gem totarxz, in order to create '\ 'a '+sorange('.tar.xz')+' archive.' end end
#¶ ↑
generate_gobolinux_recipe
¶ ↑
This will delegate towards Cookbooks
and generate gobolinux recipe for the given program.
Invocation example:
ry zenity --gobolinux-recipe
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12861 def generate_gobolinux_recipe(i = compile_which_program?) RBT.create_gobolinux_recipe(i) { :store_in_alphanumeric_subdirectory } end
#¶ ↑
generate_homepage
¶ ↑
Generate a LFS-like homepage, which is part of the RBT
project, within the Cookbooks
namespace.
Invocation example:
ry --generate-homepage
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15534 def generate_homepage require 'rbt/cookbooks/generate_homepage/generate_homepage.rb' RBT::Cookbooks::GenerateHomepage[] end
#¶ ↑
generate_machomebrew_formula
¶ ↑
This method will generate a (hopefully valid) Homebrew script.
Commandline-invocation example:
ry htop --generate_homebrew_script
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15149 def generate_machomebrew_formula( i = compile_which_program? ) RBT::GenerateMachomebrewFormula.new(i) end
#¶ ↑
generate_new_cookbook
¶ ↑
This method can be used to generate a new cookbook file. It is no longer that useful, but retained mostly for legacy reasons.
To generate a new cookbook, do:
ry htop ---generate_new_cookbook Installer libxml2 ---generate_new_cookbook
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15309 def generate_new_cookbook( shall_we_exit = true ) opne 'Will generate a new cookbook file, as instructed.' action(:create_a_new_cookbook, program_name?.to_s) exit_program if shall_we_exit end
#¶ ↑
generate_shell_completion
¶ ↑
Generates shell completion code. Right now it will only work for Bash.
Invocation example:
ry --generate_shell_completion
#¶ ↑
# File lib/rbt/compile/compile.rb, line 29397 def generate_shell_completion( for_this_shell = :all ) if Object.const_defined?(:RBT) and RBT.const_defined?(:GenerateShellCompletion) RBT::GenerateShellCompletion.new( for_this_shell ) # bl GenerateShellCompletion end end
#¶ ↑
generate_slack_desc_file_for_this_program
¶ ↑
Trigger like so:
rbt htop --gsc
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15051 def generate_slack_desc_file_for_this_program( i = compile_which_program? ) path_to_this_file = RBT.generate_slackware_description_file(i) return path_to_this_file end
#¶ ↑
get_packages
¶ ↑
Get all packages from the directory /Depot/Packages and compare them to our given request.
I am no longer making heavy use of Packages but perhaps one day I may extend it, so this is one reason why it is kept.
Invoke it like so:
ry php pgk?
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13712 def get_packages( this_program = compile_which_program? ) this_program = this_program.first if this_program.is_a? Array packages_dir = packages_directory? # This constant is defined in Configuration.rb opnn e "Searching for matching packages to `#{simp(this_program)}`, "\ "inside of the directory #{sdir(packages_dir)}." _ = get_files_from(packages_dir) if _ and !_.empty? result = _.grep(/#{this_program}/i) pp result return result else opne "Unfortunately no match was found in `#{sdir(packages_dir)}`." end end
#¶ ↑
guess_build_type
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15624 def guess_build_type RBT.build_type? end
#¶ ↑
handle_the_postinstallation_step
¶ ↑
This will delegate towards class RBT::ToCurrent
, to set the Current symlink.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15829 def handle_the_postinstallation_step if uses_appdir_prefix? _ = prefix? opne "Setting a symlink next, for #{steelblue(_)}:" # ===================================================================== # # Delegate onto class RBT::ToCurrent next. # ===================================================================== # RBT::ToCurrent.new(_) end end
#¶ ↑
handle_this_program?¶ ↑
This is the variable that will keep track of the program that the user wants to install or compile next.
It has to be set anew whenever a new program is compiled.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 21187 def handle_this_program? @handle_this_program end
#¶ ↑
has_a_problem_occurred?¶ ↑
Query-method over as to whether a problem has occurred or whether it has not.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 19902 def has_a_problem_occurred? problem? end
#¶ ↑
has_key?¶ ↑
This is a substitute method, to enable hash-like behaviour for some keys. Right now (December 2019) this is a hardcoded Array, but in the future the code may be changed - let’s see.
Do note that this method is specifically synced (closely) with class RBT::CreatePkgconfigFile.new
.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13568 def has_key?(i) %i( description prefix program_version ).include? i end
#¶ ↑
ignore_errors?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 19580 def ignore_errors? @internal_hash[:ignore_errors] end
#¶ ↑
increment_compiled_this_program_n_times_counter
¶ ↑
By default this method will increment by +1.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 11378 def increment_compiled_this_program_n_times_counter( by_plus_n = 1 ) @internal_hash[:we_tried_to_compile_this_program_n_times] += by_plus_n end
#¶ ↑
infer_information_from_this_archive
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15870 def infer_information_from_this_archive(i) _ = remove_archive_at_the_end( File.basename(i) ) _ = ProgramInformation.new(_) use_this_as_program_name = _.program_name? use_this_as_program_version = _.program_version? # ======================================================================= # # Obtain a dummy-cookbook dataset first. # ======================================================================= # cookbook_dataset = load_yaml_dataset_for_this_program( use_this_as_program_name ) # ======================================================================= # # Update the program_path next: # ======================================================================= # cookbook_dataset.program_path = i set_compile_this_program(use_this_as_program_name) cookbook_dataset.set_program_version(use_this_as_program_version) set_on_ihash(cookbook_dataset) cd :log_dir invoke_extracter( cookbook_dataset.program_path, log_dir?, true ) cd log_dir?+remove_archive_stuff_from_the_end(File.basename(i)) run_configure_like_stage exit_program end
#¶ ↑
initialize_a_new_cookbook_instance
¶ ↑
The first argument to this method should be the program that the user wants to wish to compile or install, as a String, such as “php” or “ruby” or something like that.
Since as of January 2018, whenever you need an instance from class RBT::Cookbooks::SanitizeCookbook
, this method here should be used.
The reason is simple:
-
This method will do all the required invocations needed to properly instantiate a new Cookbook instance.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 21454 def initialize_a_new_cookbook_instance( i = @array_compile_these_programs.first, simple_or_complex = simple_or_complex? ) @cookbook = RBT::Cookbooks::SanitizeCookbook.new(i) {{ make_use_of_aliases_kept_in_the_file_cookbook_aliases: make_use_of_cookbook_aliases?, simple_or_complex: simple_or_complex }} return @cookbook # Always return the dataset as well here. end
#¶ ↑
initialize_cookbook_dataset_for
¶ ↑
This method is different to load_yaml_dataset_for_this_program
() in that we will also assign to the main internal Hash.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13361 def initialize_cookbook_dataset_for( this_program = @handle_this_program, optional_arguments = nil ) yaml_dataset = load_yaml_dataset_for_this_program( this_program, optional_arguments ) # ======================================================================= # # Next, assign to the internal Hash: # ======================================================================= # assign_to_the_main_dataset( yaml_dataset ) end
#¶ ↑
install_only_headers?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 21567 def install_only_headers? @internal_hash[:install_only_the_headers] end
#¶ ↑
install_palemoon
¶ ↑
To invoke this ad-hoc method, try:
rbt --install-palemoon
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13169 def install_palemoon( path = '/home/x/src/palemoon/palemoon-'\ '28.5.2-64bit.tar.xz' ) if File.exist? path _ = remove_archive_from_the_end( File.basename(path) ).sub(/-64bit$/, '') program_name = program_information_return_name(_) program_version = program_information_return_version(_) target = program_dir?+program_name.capitalize+'/'+program_version+'/' create_app_skeleton(target) cd target extract_to = target extract_what_to(path, extract_to) e 'Done!' else opnn; no_file_at(path) end end
#¶ ↑
install_ruby_gem
(install gem, gem install, gem tag)¶ ↑
Use this method to install a ruby gem, then exit.
The input argument should be the path towards the .gem file in question.
Right now we will always exit when we use this method, by default. This behaviour can be changed through the variable ‘shall_we_exit’.
Invocation example:
ry /home/x/src/ruby/gems/wirble-0.1.3.gem ry $MY_SRC/ruby/gems/unf-0.0.5.gem ry thor
# ¶ ↑
# File lib/rbt/compile/compile.rb, line 21926 def install_ruby_gem( this_gem = program_path?, shall_we_exit = exit_after_a_rubygem_has_been_installed? ) do_not_display_the_flexbox do_not_symlink :be_quiet case this_gem when :default this_gem = program_path? end case shall_we_exit when :then_exit, :do_exit shall_we_exit = true when :do_not_exit shall_we_exit = false end # ======================================================================= # # === Download the gem # # If the path to a gem includes a "http" string, then we will assume # that we will first have to download it. # ======================================================================= # if this_gem and this_gem.include? 'http' go_to_base_dir do_download(this_gem) end # ======================================================================= # # Next, install the gem via a system() call. There are several ways # how to install a gem through, most importantly, with or without # dependency management by gem. # ======================================================================= # _ = ("gem install #{return_gem_install_options} #{this_gem}").squeeze(' ') opne _ system _ exit_program if shall_we_exit end
#¶ ↑
install_the_dependencies_of_this_program
¶ ↑
Invocation example:
ry rails --install-its-dependencies
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14128 def install_the_dependencies_of_this_program( this_program = compile_which_program? ) # ======================================================================= # # First obtain the direct-dependencies of the given program at hand. # ======================================================================= # dependencies = required_deps_on? e opne 'Next, installing the '+orange(dependencies.size.to_s)+ ' dependencies of the program `'+ sfancy(this_program)+'`.' e opne 'These programs are:' e dependencies.each {|this_entry| e slateblue(" #{this_entry}") } e dependencies.each {|this_entry| install_that_program = true # ===================================================================== # # Consider skipping a few of these programs. # ===================================================================== # case this_entry when 'python' target = "#{programs_directory?}Python/Current/bin/python" if File.exist? target install_that_program = false e "Skipping python as it is already installed at #{sfancy(target)}." end when 'ruby' target = "#{programs_directory?}Ruby/Current/bin/ruby" if File.exist? target install_that_program = false e "Skipping ruby as it is already installed at #{sfancy(target)}." end end if install_that_program # =================================================================== # # We ought to not quit after a rubygem has been installed. # =================================================================== # _ = RBT::Compile.new(this_entry, :do_not_run_yet) _.do_not_exit_after_a_rubygem_has_been_installed _.run end } end
#¶ ↑
install_the_linux_kernel_header_files_via_appdir_prefix
¶ ↑
This method essentially does what is described here:
http://www.linuxfromscratch.org/lfs/view/development/chapter05/linux-headers.html
The main difference is that we will use a proper appdir prefix.
Invocation examples:
ry --install-kernel-headers ry --install-linux-headers
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15726 def install_the_linux_kernel_header_files_via_appdir_prefix install_the_linux_kernel_header_files_via_this_prefix(:appdir_prefix) end
#¶ ↑
install_the_linux_kernel_header_files_via_this_prefix
¶ ↑
The argument to this method is the prefix to be used. For example, the default AppDir prefix on my system for the linux kernel is “/home/Programs/Linux/5.7/”.
This method can also be used to specify a prefix for “home” which refers to the “home directory”.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13596 def install_the_linux_kernel_header_files_via_this_prefix( use_this_prefix = :appdir_prefix ) _ = initialize_cookbook_dataset_for(:linux) # ======================================================================= # # Get the local path to the latest linux kernel next. # ======================================================================= # program_path = _.program_path? # ======================================================================= # # Designate which prefix is to be used next: # ======================================================================= # case use_this_prefix when :appdir_prefix, :default use_this_prefix = _.prefix? end extract_to = _.extract_to? extract_what_to(program_path, extract_to) { :keep_the_old_directory_if_it_exists } rcp _.program_name_and_program_version? target = extract_to+_.program_name_and_program_version? opne 'Now changing into '+sdir(target)+'.' cd target esystem 'make mrproper' esystem 'make headers' if File.exist? 'usr/include/Makefile' remove_file 'usr/include/Makefile' end opne 'We are in the directory '+sdir(target)+'.' opne 'Doing a '+steelblue('recursive copy action')+rev+' next.' cpr('usr/include/', use_this_prefix) opne 'Done! The target was at '+sdir(use_this_prefix+'include/') end
#¶ ↑
install_this_flatpak
¶ ↑
This method can be used to install a flatpak from the official flatpak-URL.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13462 def install_this_flatpak( this_program ) # ======================================================================= # # We must first check whether this program has a flatpak-entry. But # before that, we must initialize the dataset for the given program # at hand. # ======================================================================= # initialize_dataset_for(this_program) if has_flatpak_url? cmd = "flatpak install --user #{flatpak_url?}" e esystem cmd e else opne "The program #{sfancy(this_program)} does not "\ "have a registered flatpak-URL." end end
#¶ ↑
invoke_extracter
¶ ↑
Delegate towards class Extracter next.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 19310 def invoke_extracter( i = program_path?, extract_to_this_directory = rbt_log_dir?, keep_the_old_directory_if_it_exists = false ) append_to_the_commandline = ''.dup case extract_to_this_directory when nil extract_to_this_directory = will_be_extracted_towards? @internal_hash[:extract_to_this_directory_as_specified_by_the_user] = extract_to_this_directory set_extract_to_this_directory(extract_to_this_directory) end # ======================================================================= # # === Handle Hashes next # ======================================================================= # if i.is_a? Hash if i.has_key? :use_this_local_path i = i.delete(:use_this_local_path) end end yielded = nil case keep_the_old_directory_if_it_exists # case tag. when :do_keep_the_old_directory_if_it_exists, :keep_the_old_directory_if_it_exists keep_the_old_directory_if_it_exists = true end # ======================================================================= # # === Handle blocks given to this method next: # ======================================================================= # if block_given? yielded = yield case yielded # ===================================================================== # # === :keep_the_old_directory_if_it_exists # ===================================================================== # when :keep_the_old_directory_if_it_exists keep_the_old_directory_if_it_exists = true else # =================================================================== # # === Handle Hashes next # =================================================================== # if yielded.is_a? Hash # ================================================================= # # === :append_to_the_commandline # ================================================================= # if yielded.has_key? :append_to_the_commandline append_to_the_commandline << yielded[:append_to_the_commandline] end end end end unless skip_extracting? case extract_to_this_directory # ===================================================================== # # === :default # ===================================================================== # when :default extract_to_this_directory = will_be_extracted_towards? end # ===================================================================== # # Remove the extracted directory if it exists next. This will, # however had, NOT be done if we extract to another target # directory, such as when issuing a command like # "ry htop --extract-to=/opt/test". # ===================================================================== # # possibly_existing_old_extracted_archive = cookbooks_dataset_extracted_towards? # unless possibly_existing_old_extracted_archive.include? extract_to? # =================================================================== # # In this case we reasonably assume that the user has NOT given # a --extract-to value. # # Keep in mind that the user may specify another temp-directory, # which explains the check for user-input. # =================================================================== # if cookbooks_dataset? and !keep_the_old_directory_if_it_exists _ = will_be_extracted_towards? if @internal_hash.has_key?(:extract_to_this_directory_as_specified_by_the_user) and @internal_hash[:extract_to_this_directory_as_specified_by_the_user] _ = @internal_hash[:extract_to_this_directory_as_specified_by_the_user] end unless (_.squeeze('/').strip == '/') if File.directory?(_) _ = _.dup if _.frozen? _.strip! _.squeeze!('/') # ============================================================= # # Notify the user that we will remove the old directory next. # ============================================================= # opne tomato('Removing')+' the '+seagreen('old directory')+' at `'+sdir(_)+'`.' remove_directory(_) end end end # end if i and File.exist?(i) if are_we_on_windows? and i.include?('.tar.') # =================================================================== # # Windows has to be handled in a special way. # =================================================================== # cmd = '7z x "'.dup cmd << i cmd << '" -so | 7z x -aoa -si -ttar -o"'+program_name_and_program_version?.to_s+'"' esystem cmd else # =================================================================== # # Delegate towards class Extracter next. The second argument is a # Hash which will typically carry a lot of information. This is # necessary because we want to "fine-tune" Extracter at this # step. # =================================================================== # ::Extracter.extract_this( i, extract_to: extract_to_this_directory, # ← Extract to this directory. prepend_this_namespace: 'RBT→', # ← Use this modifier. use_colours: use_colours?, verbosity: :be_verbose, run_simulation: run_simulation?, pad_opn_with_n_tokens: RBT.n_padding_to_use_for_opn?, use_opn: show_the_classname?, append_this_to_the_commandline: append_to_the_commandline ) { :show_the_full_name_of_the_archive } end else e 'No file exists at '+steelblue(i.to_s)+'.' end end end
#¶ ↑
is_a_gem_file?¶ ↑
Query whether we have a .gem file at hand here.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 22097 def is_a_gem_file?( i = program_path? ) i.to_s.end_with? '.gem' end
#¶ ↑
is_meson_build_type?¶ ↑
This method will return true if we can use meson in the current directory; and false otherwise.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 29477 def is_meson_build_type? RBT.build_type? == :meson end
#¶ ↑
is_on_gobolinux
?¶ ↑
Query whether we are on GoboLinux or whether we are not.
In the past this was only a check for an environment variable.
Since we will allow commandline options to change this, we also had to use a proper variable to keep track of this.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 11996 def is_on_gobolinux? @internal_hash[:is_on_gobolinux] end
#¶ ↑
is_registered?¶ ↑
Determine whether a given program is registered or whether it is not.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 29429 def is_registered?(i) return RBT.is_available? i end
#¶ ↑
keep_the_extracted_archive?¶ ↑
This is a query method towards a setting kept in the internal Hash variable.
A boolean value will be returned. This boolean value determines whether the archive will be kept after it was extracted, or whether it will be removed again after it was extracted.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 19233 def keep_the_extracted_archive? _ = cookbook_dataset_keep_extracted? # ← The default. unless @internal_hash[:keep_the_extracted_archive].nil? _ = @internal_hash[:keep_the_extracted_archive] end return _ end
#¶ ↑
kill_the_main_pid
¶ ↑
This will kill the process that was spawned via IO.popen. Use with care.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12391 def kill_the_main_pid( main_pid = internal_pid? ) if main_pid begin Process.kill('KILL', main_pid) set_internal_pid(nil) rescue Errno::ESRCH end end end
#¶ ↑
last_system_command_was_a_success?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 24733 def last_system_command_was_a_success? $CHILD_STATUS.success? end
#¶ ↑
load_data_from_this_gobolinux_recipe
¶ ↑
This method will allow us to load the dataset from a local GoboLinux recipe, as a drop-in replacement.
The most important setting there will be to use:
url="http://ftp.gnome.org/pub/gnome/sources/GConf/3.2/GConf-3.2.6.tar.xz"
which is part of the file called “Recipe”.
The other settings are also useful but not as important.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12735 def load_data_from_this_gobolinux_recipe(i) i = i.to_s.dup # Always work on a new String-copy anyway. case i when 'Dir.pwd' i = return_pwd end # ======================================================================= # # === Handle GoboLinux Recipes past that point # ======================================================================= # if i.include? '/' the_program_is_included # Enable the fact that the program is "included": # ===================================================================== # # Assume the input to be something like '/Depot/jjjjj/GConf/3.2.6-r3/'. # ===================================================================== # if i.count('/') > 1 # At the least two '/'. splitted = i.split('/') program_name = splitted[-2] program_version = splitted[-1] set_program_name(program_name) initialize_yaml_dataset(program_name, :bypass_check) set_program_version(program_version) chop_off_revision_number set_base_dir(i) # =================================================================== # # The position of the Description file. # =================================================================== # description_file = 'Resources/Description' dataset_from_the_description_file = nil assume_default_archive_type # =================================================================== # # Next, read in the information from the file 'Recipe'. # =================================================================== # this_file = 'Recipe' if File.exist? this_file recipe_dataset = File.read(this_file) use_this_regex = /^url="(.+)"/ use_this_url = recipe_dataset.scan(use_this_regex).flatten.first set_url(use_this_url) set_this_archive(File.basename(use_this_url)) else opne 'Something appears to be incorrect - no file '\ 'called '+sfile(this_file)+' could be found.' exit_program end if File.exist? description_file dataset_from_the_description_file = File.read(description_file) # ================================================================= # # Next, use some regexes to properly interprete the dataset. # ================================================================= # regex_for_url1 = /\[Homepage\] (.+)/ regex_for_license = /\[License\] (.+)/ regex_for_description = /\[Description\] (.+)/ regex_for_short_description = /\[Summary\] (.+)/ _regex_for_name = /\[Name\] (.+)/ # ================================================================= # # Next determine some values here. # ================================================================= # dataset_from_the_description_file =~ regex_for_url1 set_url2($1.to_s.dup) # Here we change the "homepage" URL. dataset_from_the_description_file =~ regex_for_license set_license($1.to_s.dup) dataset_from_the_description_file =~ regex_for_description set_description($1.to_s.dup) dataset_from_the_description_file =~ regex_for_short_description set_short_desc($1.to_s.dup) set_short_name(program_name) # ================================================================= # # The following code is probably no longer needed, but we can # keep it for now - maybe one day we have to use it. # dataset_from_the_description_file =~ regex_for_name # this_program = $1.to_s.dup.downcase # set_this_program(this_program) # ================================================================= # attach_program_name_and_program_version determine_program_full_name # This is like: 'gnome-mahjonng-5.08.tar.xz' assemble_program_path unless File.exist?(File.basename(program_full_name?)) e 'As the program does not exist locally, we will download it from:' e e ' '+sfancy(url?.to_s) e download_this_remote_program(url1) end # ================================================================= # # Now we assume that the program must exist locally. # ================================================================= # opne 'The following information is known about this program:' cliner e main_eight? # Show some more information. cliner target = File.basename(program_full_name?) extract_this_archive(target, return_pwd) new_target = dataset_program_name? opnn; cd new_target, :be_verbose do_use_appdir_prefix(:be_quiet) use_default_configure_command # ================================================================= # # Determine the configure options. # ================================================================= # use_this_regex = /^configure_options=\(([\s\S]+)\)$/ # See: http://rubular.com/r/Zy29SMPvLm set_configure_options( recipe_dataset.scan(use_this_regex).flatten.first ) set_configure_base_dir('') set_use_this_build_directory('') do_not_remove_the_extracted_archive # ================================================================= # # Run "configure" next. # ================================================================= # run_configure_via_system(nil, :do_not_change_the_directory) run_premake_make_then_make_install run_all_actions_after_the_make_install_step end end end end
#¶ ↑
load_last_compiled_program
¶ ↑
This essentially does the following:
x = load_yaml('/Depot/Temp/rbt_logs/last_compiled_programs.yml')
To obtain this information from the commandline, try:
rbt --last-compiled-program?
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12889 def load_last_compiled_program _ = RBT.file_compiled_programs if File.exist? _ @last_compiled_program = load_yaml(_) result = @last_compiled_program # ===================================================================== # # If we store it as an Array, the last compiled program is the # one that comes last in that Array, too. # ===================================================================== # result = result.last if result.is_a? Array # ===================================================================== # # It may include a '#' character, in which case we will treat this # as a comment: # ===================================================================== # if result.include? '#' result = result[0, result.index('#')].strip end return result # ← And return the result here. else opne "No file exists at `#{sfile(_)}`." opne 'Thus, we can not load anything.' exit_program end end
#¶ ↑
make_file_exists?¶ ↑
Determine whether a “Makefile” exists or whether it does not exist.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 11866 def make_file_exists? File.exist? 'Makefile' end
#¶ ↑
meson_build_file_exists?¶ ↑
When we check for the file called “meson.build”, we must also keep in mind that we may use a build directory. This is the reason why the following code uses a variable.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 25407 def meson_build_file_exists?( at_this_location = return_pwd ) if File.exist?(at_this_location) and File.file?(at_this_location) return true else # ===================================================================== # # Next check whether we do use a build directory or whether we do not. # ===================================================================== # if use_build_directory? target_file = File.absolute_path("#{at_this_location}../meson.build") check_for_this_file = target_file else check_for_this_file = "#{at_this_location}meson.build" end File.exist?(check_for_this_file) end end
#¶ ↑
name_for_the_build_directory?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 23013 def name_for_the_build_directory? @internal_hash[:name_for_the_build_directory] end
#¶ ↑
ninja_install
(ninja tag)¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 25368 def ninja_install this_file = 'build.ninja' if may_we_run_ninja? if File.exist?(this_file) or File.exist?(File.absolute_path(this_file)) # =================================================================== # # === ninja # =================================================================== # e teal('ninja') reset_error_map_line_to_a_specific_error run_this_system_command 'ninja' # <- Run the sys-command here. run_through_the_registered_problems_registered_errors_and_behaviour_changes reset_error_map_line_to_a_specific_error # =================================================================== # # === ninja install # =================================================================== # e teal('ninja install') reset_error_map_line_to_a_specific_error run_this_system_command 'ninja install' # <- Run the sys-command here. run_through_the_registered_problems_registered_errors_and_behaviour_changes reset_error_map_line_to_a_specific_error else opne "No file called #{sfile(this_file)} could be found - thus," opne "the build tool called #{orange('ninja')} can not be run." # =================================================================== # # Register this error as well: # =================================================================== # error_is :could_not_find_file_called_build_ninja end end end
#¶ ↑
no_error_was_encountered?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 20051 def no_error_was_encountered? !an_error_has_occurred? end
#¶ ↑
no_problem_has_occurred?¶ ↑
This method will return true if no problem has occurred - otherwise it will return false.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 19892 def no_problem_has_occurred? !problem? end
#¶ ↑
notify_the_user_as_to_which_program_will_be_compiled_or_installed_next
¶ ↑
Notify the user which program will be compiled/installed next through this method.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 16546 def notify_the_user_as_to_which_program_will_be_compiled_or_installed_next( i = compile_which_program?, _ = program_path? ) opne "#{rev}The program `#{steelblue(i)}` "\ "will be #{compile_or_install_string?} next, in "\ "#{lightgreen(mode?.to_s)} mode." opne "The #{steelblue('assumed local path')} is:" e e " #{sfile(_)}" e end
#¶ ↑
notify_the_user_that_ccache_is_not_available
¶ ↑
Provide some information to the user about the use of ccache.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 22925 def notify_the_user_that_ccache_is_not_available opne swarn('You are trying to use ')+ steelblue('ccache')+ swarn(', as specified by the configuration') opnwarn 'file, but ccache could not be found. Please install ccache if' opnwarn 'you wish to use it. The URL to the latest source would be:' e efancy " #{::RBT.return_url1_of_this_program(:ccache)}" e opnwarn 'If you do not want to use ccache, you can '\ 'disable ccache, via' opnwarn 'either of the following two options:' e efancy ' rbt --permanently-disable-ccache' e efancy ' rbt --disable-ccache # this variant will avoid '\ 'ccache just for this run' e opnwarn 'This class will now continue without ccache.' end
#¶ ↑
notify_the_user_that_cmake_could_not_be_found
¶ ↑
Do note that this method is solely here for notifying/reporting - it may presently not do anything else but to report to the user.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12647 def notify_the_user_that_cmake_could_not_be_found opne "#{swarn('The program ')}#{sfancy('cmake')} #{swarn('could not')} "\ "#{swarn('be found - thus, ')}#{tomato(compile_which_program?)}" opnewarn 'can not be compiled.' opnewarn 'Consider installing cmake if you wish to compile programs' opnewarn 'that require cmake for their compilation.' end
#¶ ↑
notify_the_user_that_porg_is_not_available
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 29539 def notify_the_user_that_porg_is_not_available opne 'You are trying to use porg, but porg is not installed.' opne 'Please either install porg - or disable the configuration ' opne "option use_porg in the #{slateblue('configuration setting')}." end
#¶ ↑
notify_the_user_that_this_program_is_missing
¶ ↑
The first argument to this method should be the program that is missing, such as ‘ruby’ or ‘htop’ or ‘glib’.
The method will also notify the user how to install the program via the RBT
scripts, if this is applicable - aka, if this program is registered.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 19848 def notify_the_user_that_this_program_is_missing( i = :jam ) i = i.to_s unless i.is_a? String e; cliner(use_colour: :konsole_slateblue) { e "#{rev}#{sfancy(i)} was not found on your system." e e 'As you are running via the RBT scripts, you can possibly '\ 'install '+simp(i) e 'by issuing the following command:' e e ' '+sfancy("rbt #{i}") e # ===================================================================== # # Extra options can be passed into the block to this method. # ===================================================================== # if block_given? yield end }; e end
#¶ ↑
operating_system_in_use?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 10717 def operating_system_in_use?( i = RUBY_PLATFORM ) case i # ======================================================================= # # === linux # ======================================================================= # when /linux$/ # e. g. "x86_64-linux" 'Linux' # ======================================================================= # # === win # ======================================================================= # when /win/, /mingw/ 'Windows' else 'Undetermined (as of yet - please report it upstream)' end end
#¶ ↑
opnn (opnn tag)¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 1935 def opnn( optional_i = { namespace: namespace? } ) if use_opn? ::RBT::Compile.opnn(optional_i) end end
#¶ ↑
original_input?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 25954 def original_input? @internal_hash[:original_input] end
#¶ ↑
output_all_urls
¶ ↑
This method will output all URLs of every registered program.
Invocation example:
ry --output_all_urls
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15801 def output_all_urls dataset = RBT.all_urls(:no_opn).result? # Tap into this method here, without outputting the namespace. dataset = dataset.map {|entry| entry[0] = ' '+(entry[0]+' ').ljust(30) entry.join }.join("\n") store_where = rbt_log_dir?+'all_program_urls.md' File.delete(store_where) if File.exist? store_where # Let's get rid of the old file first. opne "Storing into #{sfile(store_where)}" save_file(dataset, store_where) end
#¶ ↑
package_rbt_scripts
(package tag, release tag)¶ ↑
You can use this method to package the RBT
scripts.
A specialized class will do this for us, class PackageRbtScripts
.
Invocation examples:
ry --package_rbt_scripts ry --release
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13667 def package_rbt_scripts( also_exit = false ) unless RBT.const_defined? :PackageRbtScripts require 'rbt/utility_scripts/package_rbt_scripts.rb' end RBT::PackageRbtScripts.new also_exit = true if also_exit == :then_exit exit_program if also_exit end
#¶ ↑
package_this_appdir
¶ ↑
Invocation example:
ry --package-appdir=htop
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13637 def package_this_appdir(i) target = programs_dir?+i.capitalize+'/Current' if File.exist?(target) and File.symlink?(target) old_pwd = return_pwd initialize_dataset_for(i) cd target use_this_as_the_archive_name = i.downcase+'-'+program_version? to_tar_xz("#{target}*") {{ use_this_archive_name: use_this_as_the_archive_name }} full_target = target+use_this_as_the_archive_name if File.exist? full_target mv(full_target, old_pwd) end end end
#¶ ↑
parameters_to_make?¶ ↑
The aliased method to this method, called make_options?, is mildly discouraged after 12.04.2019. The primary reason for this is that the name parameters_to_make? is more explicit, and thus better in the long run (less confusing).
#¶ ↑
# File lib/rbt/compile/compile.rb, line 11786 def parameters_to_make? _ = @internal_hash[:parameters_to_make] if _.nil? _ = cookbook_dataset_parameters_to_make? end _ end
#¶ ↑
parse_this_line_obtained_via_io_popen
¶ ↑
This method is used to parse all output generated via IO.popen().
#¶ ↑
# File lib/rbt/compile/compile.rb, line 24038 def parse_this_line_obtained_via_io_popen( line, use_colours = use_colours? ) # ======================================================================= # # Delegate towards class ColourizeParser next. # ======================================================================= # cparser = @internal_hash[:colourize_parser] unless use_colours cparser.disable_colours end line.chomp! # ======================================================================= # # Feed towards module RBT::Errors::MapLineToASpecificError next: # ======================================================================= # RBT::Errors::MapLineToASpecificError.parse_this_line(line) # ======================================================================= # # Next, put the line towards ColourizeParser. The reason why this is # done after the error checking above is to simply keep the output # as it was originally, before changing it via colours and the like. # ======================================================================= # cparser.grab_this_line(line) line = cparser.line?.dup if line.include?('A required package was not found') and !RBT::Errors::MapLineToASpecificError.required_packages?.empty? name_of_the_package = RBT::Errors::MapLineToASpecificError.required_packages?.first.to_s line << ' '+crimson("( → #{name_of_the_package} is missing)") line << N+N+'You can try to install it via:'+N line << N+slateblue(' rbt '+name_of_the_package)+N+N end # ======================================================================= # # The reason we output the line here is so that we can still do # modifications to it, if we have to. This is the case e. g. for # when we wish to display which package is missing. # ======================================================================= # e line # Output here. if line.include?('configure: No such file or directory') opne 'The '+crimson('above error message')+' most likely means '\ 'that no configure script could be found.' end @internal_hash[:array_sys_command_string] << line # We could also store the lines here. end
#¶ ↑
permanently_add_this_global_flag
¶ ↑
Use this method in order to permanently add a new global flag, into the file called “global_flags.yml”.
To test this method, try:
rbt --add-global-flag=--disable-static
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12308 def permanently_add_this_global_flag(i) i = i.to_s.dup into = RBT.file_global_flags opne "Now appending the flag `#{sfancy(i)}` into the "\ "file `#{sfile(into)}`." old_file_content = ''.dup if File.exist? into old_file_content << File.read(into).strip end old_file_content << " #{i}" what = old_file_content write_what_into(what, into) if is_on_roebe? into = ROEBE_FILE_GLOBAL_FLAGS opne 'Now appending the flag `'+sfancy(i)+'` into the '\ 'file `'+sfile(into)+'`.' write_what_into(what, into) end end
#¶ ↑
permanently_disable_porg
¶ ↑
Permanently disable porg via this method.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 23175 def permanently_disable_porg if use_porg? opne 'Disabling porg.' if configuration?.respond_to? :use_porg= configuration?.use_porg = false if configuration?.respond_to? :save_config configuration?.save_config else what = false into = FILE_USE_PORG opne "Storing into `#{sfile(into)}`." write_what_into(what, into) end else opne 'The configuration-object is not functional - it does not' opne 'respond to the method called .use_porg=' end else opne 'Porg is already disabled.' end end
#¶ ↑
permanently_enable_is_on_gobolinux
¶ ↑
Use this method to “enable” the GoboLinux file layout.
To call this method from the commandline, do:
rbt --permanently-enable-is-on-gobolinux
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12023 def permanently_enable_is_on_gobolinux( be_verbose = :be_verbose ) case be_verbose when :be_verbose be_verbose = true end _ = RBT.file_is_on_gobolinux if File.exist? _ opne "The file at `#{sfile(_)}` already exists." else if be_verbose opne "Enabling GoboLinux layout now via the file `#{sfile(_)}`." end opne "Now creating the file #{sfile(_)}." create_file(_) enable_is_on_gobolinux # And also enable the GoboLinux behaviour. end end
#¶ ↑
permanently_remove_this_global_flag
¶ ↑
Use this method in order to permanently remove a new global flag, into the file called “global_flags.yml”.
To test this method, try:
rbt --remove-global-flag=--disable-static
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12339 def permanently_remove_this_global_flag(i) i = i.to_s.dup into = RBT.file_global_flags old_file_content = ''.dup if File.exist? into old_file_content << File.read(into).strip end if old_file_content.include? i opne 'Now removing the flag `'+sfancy(i)+'` from the '\ 'file `'+sfile(into)+'`.' old_file_content.gsub!(/#{i}/,'') else opne "The flag `#{sfancy(i)}` can not be removed from "\ "the file `#{sfile(into)}`." opne 'because this file does not have that flag.' end what = old_file_content write_what_into(what, into) if is_on_roebe? into = ROEBE_FILE_GLOBAL_FLAGS opne 'Now removing the flag `'+sfancy(i)+'` from the '\ 'file `'+sfile(into)+'`.' write_what_into(what, into) end end
#¶ ↑
permanently_set_programs_dir
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12286 def permanently_set_programs_dir( what, into = FILE_PROGRAMS_DIRECTORY ) opne 'Storing '+sfancy(what)+' into the file `'+sfile(into)+'`.' write_what_into(what, into) if is_on_roebe? into = RUBY_SRC_DIR_RBT_YAML+'configuration/programs_directory.yml' opne 'Storing '+sfancy(what)+' into the file `'+sfile(into)+'`.' write_what_into(what, into) end end
#¶ ↑
pkgconfig_files?¶ ↑
Query method over the registered .pc files of a particular program.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26745 def pkgconfig_files? cookbook_dataset?.pkgconfig_files? end
#¶ ↑
postinstallation?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 23292 def postinstallation? _ = cookbook_dataset_postinstall? # ======================================================================= # # The following part is, as of January 2019, only added when we have # modified this variable through the method set_user_prefix(). The # user can (currently) not modify this variable on his/her own. # ======================================================================= # unless @internal_hash[:postinstallation].nil? _ = @internal_hash[:postinstallation] end _ # Return it here. end
#¶ ↑
pre_make_install_sed
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26837 def pre_make_install_sed? cookbook_dataset?.pre_make_install_sed? end
#¶ ↑
prefix?¶ ↑
This will properly handle the prefix in use. It is the general getter-method which should be used whenever we wish to obtain the prefix in use.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 23810 def prefix? # ======================================================================= # # Note that cookbook_prefix? could also be used. # ======================================================================= # _ = @internal_hash[:prefix].to_s # This is the default. if @internal_hash.has_key?(:user_prefix) and @internal_hash[:user_prefix] # ===================================================================== # # This is valid when the user has given a commandline option to # use another prefix. # ===================================================================== # case @internal_hash[:user_prefix].to_s when 'ntrad', 'appdir', 'appdir_prefix' _ = return_appdir_prefix else _ = @internal_hash[:user_prefix].to_s end end # ======================================================================= # # Ensure a trailing '/'. # ======================================================================= # unless _.end_with? '/' _ = _.dup _ << '/' end if _.is_a? String unless @internal_hash[:use_a_prefix] _ = nil # Respect the user not wishing to use any prefix at all. end return _ end
#¶ ↑
prepare_for_gcc
¶ ↑
This method can be used to aid in the preparation of compiling a new GCC from source.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 1693 def prepare_for_gcc # ======================================================================= # # === gmp # ======================================================================= # initialize_cookbook_dataset_for(:gmp) cp(cookbook_dataset_program_path?, return_pwd) { :be_verbose } extract_what_to(File.basename(cookbook_dataset_program_path?), return_pwd, :keep_the_old_directory_if_it_exists) rename( remove_archive_at_the_end( File.basename(cookbook_dataset_program_path?) ), 'gmp' ) # ======================================================================= # # === mpc # ======================================================================= # initialize_cookbook_dataset_for(:mpc) cp(cookbook_dataset_program_path?, return_pwd) { :be_verbose } extract_what_to(File.basename(cookbook_dataset_program_path?), return_pwd, :keep_the_old_directory_if_it_exists) rename( remove_archive_at_the_end( File.basename(cookbook_dataset_program_path?) ), 'mpc' ) # ======================================================================= # # === mpfr # ======================================================================= # initialize_cookbook_dataset_for(:mpfr) cp(cookbook_dataset_program_path?, return_pwd) { :be_verbose } extract_what_to(File.basename(cookbook_dataset_program_path?), return_pwd, :keep_the_old_directory_if_it_exists) rename( remove_archive_at_the_end( File.basename(cookbook_dataset_program_path?) ), 'mpfr' ) end
#¶ ↑
prepare_symlink_program_instance
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 24232 def prepare_symlink_program_instance symlink_program = symlink_program? # ======================================================================= # # Assign the prefix to SymlinkProgram next: # ======================================================================= # symlink_program?.set_use_this_program( prefix? ) symlink_program.disable_colours unless use_colours? symlink_program.do_not_symlink = do_not_symlink? # Honour configure option here. symlink_program.use_opn = RBT::Compile.show_the_classname? # ======================================================================= # # Next, prevent auto-registering into the local yaml database. # This part is already handled via register_program() in # the file postinstall.rb # ======================================================================= # symlink_program.do_not_register_into_the_local_yaml_database end
#¶ ↑
problem_is
¶ ↑
Keep in mind that not every problem is an error. An error will indicate that copilationg will (or already has) fail(ed).
An example for an error may be :missing_headers, which indicates that some .h files may be missing (or could not be found, anyway).
An example for a problem may be some add-on failing, without this being a “critical problem” (aka an error).
#¶ ↑
# File lib/rbt/compile/compile.rb, line 19603 def problem_is( i = nil, optional_extra_information = nil ) case i when :default, :no_problem # This is the default too. The nil value will be used in these cases. i = nil end if i.is_a? Array i = i.first # Only use the first Array entry. end if optional_extra_information @internal_hash[:problem] = [i, optional_extra_information] else # This here is the default - it is a LOT more common. @internal_hash[:problem] = i end end
#¶ ↑
program_has_to_be_compiled?¶ ↑
The query-method program_has_to_be_compiled? determines whether our program has to be compiled or whether it does not have to be compiled.
For example, ruby .gem files typically do not have to be compiled, whereas C/C++ projects have to be compiled.
Note that this requires a setting in the .yml file. While it could probably be automatically determined whether a program has to be compiled, for the time being (November 2019) we will simply define this manually.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26439 def program_has_to_be_compiled? cookbook_dataset? and cookbook_dataset_program_has_to_be_compiled? end
#¶ ↑
program_information_return_name
¶ ↑
This method can be used to specifically return the short name of a given input-String. That input-String usually is a remote URL to some program.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 24969 def program_information_return_name(i) program_information_return_short_name(File.basename(i)) end
#¶ ↑
program_information_return_version
¶ ↑
This “substitutes” calls to ProgramInformation.return_version().
#¶ ↑
# File lib/rbt/compile/compile.rb, line 24940 def program_information_return_version(i) ProgramInformation.return_version(File.basename(i)) end
#¶ ↑
program_version
?¶ ↑
This method will return the program version in use. The default will be to simply use the version stored in the cookbook dataset, but we also allow for the user to supply commandline-flags to use any other program version that he/she desires to use.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 1329 def program_version? _ = cookbook_dataset_program_version? # ← Default value. if @internal_hash[:use_this_specific_program_version] _ = @internal_hash[:use_this_specific_program_version] end _.delete('/') if _ # A bit hackish, since it is a workaround, but necessary for now (Jan 2019). end
#¶ ↑
purge_all_man_files_in_the_programs_hierarchy
¶ ↑
Invoke this method by issuing something like this:
ry --nomanpage
#¶ ↑
# File lib/rbt/compile/compile.rb, line 11189 def purge_all_man_files_in_the_programs_hierarchy target = programs_directory? opne "Now purging all man-pages in `#{sdir(target)}`." opne '(Note that we will only work on entries pointed at '\ 'with a Current symlink.)' Dir[target+'*'].each {|entry| entry << '/' unless entry.end_with? '/' current = entry + 'Current' if File.symlink? current # =================================================================== # # Ok, the Current → symlink exists, thus we can continue. # =================================================================== # manpage = "#{File.readlink(current)}/share/man/" manpage = rds(manpage) if File.exist? manpage and File.directory? manpage opne "Now #{tomato('removing')} the directory `#{sdir(manpage)}`." remove_directory(manpage) unless manpage.squeeze('/') == '/' # Trivial "safeguard". end end } end
#¶ ↑
purge_all_settings_directories
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15542 def purge_all_settings_directories # ======================================================================= # # We need to avoid entries such as: # # /home/Programs/Qt/5.14.0/qml/QtQuick/VirtualKeyboard/Settings # # This explains the .count('/') action in the code below. # ======================================================================= # all_settings_directories = Dir[programs_dir?+'**/Settings'].select {|entry| File.directory?(entry) and entry.end_with?('Settings') and (entry.count('/') == 4) }.sort opne 'Next removing '+sfancy(all_settings_directories.size)+' directories.' remove_these_directories(all_settings_directories) { :be_verbose } end
#¶ ↑
purge_fhs_binaries_of_this_program
¶ ↑
This method will purge binaries that may reside at the /usr/bin/ hierarchy. Be careful when using this - only use it when you are sure that you want this functionality.
Invocation examples:
ry littleutils --purge-fhs-binaries ry --purge-traditional-binaries-from=xscreensaver
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15604 def purge_fhs_binaries_of_this_program( i = compile_which_program? ) if i.nil? opne 'Please provide a valid program name to this method.' return end PurgeBinariesOfThisProgram.new(i.downcase) end
#¶ ↑
purge_fhs_libraries_of_this_program
¶ ↑
Get rid of all /usr/lib/ libraries of the respective program at hand.
Invocation example:
ry --fhs-purge-libraries=libgc
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14723 def purge_fhs_libraries_of_this_program( i = compile_which_program? ) if i.nil? opne 'Please provide a valid program name to this method.' return end PurgeLibrariesOfThisProgram.new(i) end
#¶ ↑
purge_these_binaries
¶ ↑
This method can be used to purge binaries.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14851 def purge_these_binaries( i = binaries? ) removed_n_binaries = 0 opne "Now attempting to remove #{sfancy(i.size.to_s)} binaries:" e i.each {|this_binary| target = "/usr/bin/#{this_binary}" ftype = nil begin ftype = File.ftype(target) rescue Errno::ENOENT; end if File.exist? target e "Deleting the file `#{sfile(target)}` next." remove_file(target) removed_n_binaries += 1 else if ftype == 'link' e "Deleting the stray symlink at `#{sfile(target)}` next." remove_symlink(target) end end } e if removed_n_binaries == 0 opne 'None of these binaries could be '\ 'found at '+sdir('/usr/bin/')+'.' end end
#¶ ↑
query_configuration_options
¶ ↑
This method will query the configuration option of a given program.
Invocation example:
ry glibc qco
#¶ ↑
# File lib/rbt/compile/compile.rb, line 29443 def query_configuration_options( i = compile_this_program? ) action(:show_configuration_options, i) exit_program end
#¶ ↑
query_for
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 25867 def query_for(i) case i.to_s # ======================================================================= # # === "Assumed Operating System:" # ======================================================================= # when /^Assumed Operating System:?$/i operating_system_in_use? # ======================================================================= # # === "Prefix:" # ======================================================================= # when /^Prefix:?$/i prefix? # ======================================================================= # # === "Will be extracted towards" # ======================================================================= # when /^Will(-|_| )?be(-|_| )?extracted(-|_| )?towards:?$/i, /^extract(-|_| )?to(-|_| )?this(-|_| )?directory\??$/i will_be_extracted_towards? # ======================================================================= # # === "Required dependencies on:" # ======================================================================= # when /^Required(-|_| )?dependencies(-|_| )?on:?$/i required_dependencies_on? # ======================================================================= # # === "Host architecture in use:" # ======================================================================= # when /^Host(-|_| )?architecture(-|_| )?in(-|_| )?use:?$/i host_achiteture_in_use? # ======================================================================= # # === "CFLAGS in use:" # ======================================================================= # when /^CFLAGS(-|_| )?in(-|_| )?use:?$/i verbose_cflags_in_use? # Use a more verbose variant for the CFLAGs in use. # ======================================================================= # # === "Build system to be used" # ======================================================================= # when /^Build(-|_| )?system(-|_| )?to(-|_| )?be(-|_| )?used:?$/i build_system_to_be_used? # ======================================================================= # # === "Use a build directory:" # ======================================================================= # when /^Use(-|_| )?a(-|_| )?build(-|_| )?directory:?$/i use_a_build_directory? # ======================================================================= # # === "Compiler to be used:" # ======================================================================= # when /^Compiler(-|_| )?to(-|_| )?be(-|_| )?used:?$/i compiler_to_be_used? # ======================================================================= # # === "Will ccache be used:" # ======================================================================= # when /^Will(-|_| )?ccache(-|_| )?be(-|_| )?used:?$/i will_ccache_be_used? else # ===================================================================== # # Otherwise we will query the cookbook-dataset. This may sometimes # lead to problems, so it is better to define every query-related # method in the case-when menu above. # ===================================================================== # cookbook_dataset?.query_for(i) end end
#¶ ↑
query_for_configure_options_or_meson_options_or_cmake_options
¶ ↑
Return either cmake or meson or configure options accordingly.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26362 def query_for_configure_options_or_meson_options_or_cmake_options( i = 'configure-options:' ) case i # ======================================================================= # # === configure options: # ======================================================================= # when /^configure(-|_| )?options:?$/i case build_system? when 'cmake' return_cmake_configure_options_while_considering_GNU_configure_options when 'meson' meson_configure_options?.to_s else configure_options? end end end
#¶ ↑
register_all_protos_for_compilation
¶ ↑
Invoke this method like so:
ry --protos
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12985 def register_all_protos_for_compilation proto_programs = available_programs?.select {|entry| entry.include?('proto') } proto_programs.reject! {|line| line.include? 'protobuf' } # ======================================================================= # # Reject those that are .gem files next - but this will only work if # the directory with expanded cookbooks is available: # ======================================================================= # if directory_expanded_cookbooks_exists? proto_programs.reject! {|name_of_the_program| this_file = directory_expanded_cookbooks+name_of_the_program+'.yml' if File.exist? this_file dataset = load_yaml(this_file) dataset['program_path'].end_with? '.gem' else e 'No file called '+sfile(this_file)+' was found.' nil end } end opne "We will next compile all "\ "#{sfancy(proto_programs.size.to_s)}"\ " proto-programs." set_compile_these_programs(proto_programs) end
#¶ ↑
register_configure_line_into_configure_database
¶ ↑
This method will register the complete configure-line used by the program at hand, into a yaml “database”. This is just a single .yml file that keeps track of all configure options used when compiling a program.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18213 def register_configure_line_into_configure_database compile_this_program = compile_which_program? store_this = full_configure_command?.dup unless store_this.empty? # ===================================================================== # # First load up the old "database" if it exists. # # This is a "global" database, in the sense that it may typically # reside at a location like this: # # /home/Temp/rbt/configure_command_database.yml # # Do note that the RBT project will also store this on a per-application # basis in the corresponding AppDir directory (under Resources/). # Since not every program is compiled via an AppDir, we need both # the global database, and a per-app specific entry. # ===================================================================== # into = RBT.file_configure_database? hash = {} # ===================================================================== # # Load the dataset from the file if it already exists. # ===================================================================== # if File.exist? into hash.update(YAML.load_file(into)) end # ===================================================================== # # We do not need to delete any old entry, because the following line # will overwrite the old content anyway, if it exists. # ===================================================================== # hash[compile_this_program] = store_this what = YAML.dump(hash) opne 'Storing the configure command' opne " #{sfancy(store_this)}" opne "into the file `#{sfile(into)}`." write_what_into(what, into) end end
#¶ ↑
register_last_compiled_program
¶ ↑
This method will try to store the last compiled program into the file determined via the method call RBT.file_compiled_program().
We will only store if the entry is DIFFERENT to the last one though.
This file is:
$RBT/yaml/last_compiled_program.yml
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26996 def register_last_compiled_program( i = compile_which_program? ) unless has_a_problem_occurred? unless do_not_compile? and !register_the_last_compiled_program? # Continue only if we do want to compile. file = RBT.file_compiled_programs base_dir = File.dirname(file) mkdir(base_dir) unless Dir.exist? base_dir if File.exist?(file) and !File.empty?(file) # Must check whether the file exists first. array_dataset = YAML.load_file(file) else array_dataset = [] end if array_dataset.respond_to? :uniq! array_dataset.uniq! # else # opne swarn('Some minor problem occurred:') end unless (array_dataset.last == i) and !array_dataset.empty? # Storing only if it is different. opne 'Trying to register the last compiled program '\ '(`'+springgreen(i)+'`) into the file:' opne " #{sfile(file)}" # ================================================================= # # Remove any old entries, if they exist. # ================================================================= # if array_dataset.include? i array_dataset.reject! {|entry| entry == i } end # ================================================================= # # And next, add that entry: # ================================================================= # array_dataset << i what = YAML.dump(array_dataset) # ================================================================= # # Simply append to the dataset (aka file) at hand. # ================================================================= # write_what_into(what, file) end if array_dataset.respond_to? :last end end end
#¶ ↑
register_sigint
¶ ↑
We have to register the siginterrupts, so as to gracefully handle user-interrupts via Ctrl-C.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 29357 def register_sigint Signal.trap('SIGINT') { do_set_keep_extracted(:be_silent) do_not_run_ldconfig remove_compiling_is_in_progress opne 'Exiting now at once.' exit_program } end
#¶ ↑
register_that_this_program_is_currently_being_compiled
¶ ↑
This method will register that a given program is currently being compiled.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27100 def register_that_this_program_is_currently_being_compiled( into = RBT.file_status # ← This may be e. g. "/Depot/Temp/rbt/status.yml". ) dataset = {} if File.exist? into dataset.merge!(YAML.load_file(into)) end unless dataset.has_key? 'currently_compiling_these_programs' dataset['currently_compiling_these_programs'] = [] end dataset['currently_compiling_these_programs'] << compile_this_program? what = YAML.dump(dataset) # ======================================================================= # # We must sure that the base directory exists. # ======================================================================= # unless File.directory?(File.dirname(into)) mkdir(File.dirname(into)) end write_what_into(what, into) end
#¶ ↑
registered_erroneous_libtool_entries?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 22390 def registered_erroneous_libtool_entries? RBT::Errors::MapLineToASpecificError.erroneous_libtool_entries? end
#¶ ↑
remove_all_symlinks
¶ ↑
Delegate to RBT::RemoveAllSymlinks
for this action.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 24432 def remove_all_symlinks RBT::RemoveAllSymlinks.new end
#¶ ↑
remove_all_temp_directories
¶ ↑
This method will remove all directories in the /Depot/Temp hierarchy. It was added since it is sometimes easier to just remove all extracted archives via batch-process.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14524 def remove_all_temp_directories _ = rbt_log_dir? # ======================================================================= # # Select all directories in that directory next: # ======================================================================= # all_directories_there = Dir["#{_}*"].select {|entry| File.directory? entry } opne "All #{sfancy(all_directories_there.size.to_s)}"\ " directories in the #{sdir(_)} hierarchy will be removed." remove_these_directories(all_directories_there) end
#¶ ↑
remove_empty_directories
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14508 def remove_empty_directories( i = return_pwd ) opne "Now trying to remove all empty directories from the directory "\ "#{sdir(i)}." require 'rbt/utility_scripts/remove_empty_directories.rb' RBT.remove_empty_directories(i) end
#¶ ↑
remove_extracted_archive
¶ ↑
This method simply removes the extracted archive. If @keep_extracted was set to true we will not run it, but this is decided in another method called consider_removing_extracted_archive
().
Note that the invocation of this method must happen last, as otherwise we may run into problems such as:
in `pwd': No such file or directory - getcwd (Errno::ENOENT)
We can not use the string returned by the method extract_to_this_directory? because this will refer to the rbt/ base directory.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 19107 def remove_extracted_archive( where = :build_anew ) case where # ======================================================================= # # === :default # ======================================================================= # when :default, :build_anew where = rds(will_be_extracted_towards?) end if run_simulation? # Run in simulation mode here. opne sfancy('We run in simulation mode right now. Normally the directory ') opne sdir(where)+sfancy('would next be removed.') elsif is_a_gem_file? # ===================================================================== # # Ruby .gem files are no longer considered "removable" since as of # 17.06.2020. # ===================================================================== # elsif where == log_dir? opne 'Can not remove '+sdir(log_dir?)+'.' else # ================================================================== # # We must honour the keep_extracted setting. We also will not # remove the log directory. # ================================================================== # if keep_the_extracted_archive? or (where == RBT.log_directory?) # =================================================================== # # In this case we do not have to do anything. # =================================================================== # else opne "Removing the extracted archive at `#{sdir(where)}`." unless File.directory? where _ = 'However had, no such directory exists. Perhaps '\ 'it was' opne _ opne 'already removed, or it has never existed.' end # =================================================================== # # We must check whether the directory exists, before trying to # remove it. # =================================================================== # if File.directory? where remove_directory(where) else # No directory exists there. end end end end
#¶ ↑
replace_symlinks
¶ ↑
Delegate towards RBT::ReplaceSymlinks
here. We will work on the current working directory.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 24442 def replace_symlinks( from_where = return_pwd ) RBT::ReplaceSymlinks.new(from_where) # bl $RBT/replace_symlinks.rb end
#¶ ↑
report_all_programs_that_make_use_of_a_build_directory
¶ ↑
This method can report all programs that make use of a build directory. Note that this presently depends on the existance of the directory expanded_cookbooks.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27647 def report_all_programs_that_make_use_of_a_build_directory opne 'Trying to determine all programs that use '\ 'a build-directory ...' opne 'This may take a moment ...' use_this_key = :use_build_directory # It is stored as a Symbol. if expanded_directory_exists? # ===================================================================== # # Find all cookbooks in the expanded-cookbook-directory next: # ===================================================================== # target = directory_expanded_cookbooks? all_files = Dir["#{target}*.yml"] all_files.select! {|entry| dataset = YAML.load_file(entry) dataset[use_this_key] and (dataset[use_this_key] == true) # Obtain all entries with this key here. } all_files.map! {|entry| File.basename(entry).sub(/\.yml$/,'') } if all_files.empty? opne 'No cookbook recipe makes use of a build directory.' else opne "The following #{slateblue(all_files.size.to_s)} programs "\ "make use of a build directory:" all_files.each_with_index {|this_program, index| index += 1 padded_index = index.to_s.rjust(4).ljust(6) colourized_and_padded_index = royalblue(padded_index) e colourized_and_padded_index+ lightblue(this_program) } end else # ===================================================================== # # else notify the user how to create the relevant directory. # ===================================================================== # opne 'The expanded directory does not exist. You can (re)create it' opne 'by issuing:' e e ' rbt --create-expanded-directory' e end end
#¶ ↑
report_finished_installing_this_program
¶ ↑
Report that we have finished compiling the program.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 29098 def report_finished_installing_this_program( i = compile_this_program? ) unless do_not_compile? unless problem? || an_error_has_occurred? opne "Finished installing the program `#{sfancy(i)}`." end end end
#¶ ↑
report_rbt_version
¶ ↑
This method will report the version in use by the RBT
project.
Invocation examples:
ry --version rbt version?
#¶ ↑
# File lib/rbt/compile/compile.rb, line 17308 def report_rbt_version( optional_shall_we_exit = false ) case optional_shall_we_exit when :also_exit, :then_exit optional_shall_we_exit = true end # ======================================================================= # # We will show the version of the RBT scripts, and we will also # display when the project was last updated. # ======================================================================= # RBT.report_rbt_version(:also_show_when_the_project_was_last_updated) exit if optional_shall_we_exit end
#¶ ↑
report_size_of_these_programs
¶ ↑
This method will report the size of the issued programs.
The programs are to be given as the first argument to this method, ideally as an Array.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28915 def report_size_of_these_programs( i, size_of_the_programs = 0 ) if i.is_a? String and i.include?('=') i = i.to_s.dup if i.frozen? i.gsub!(/--size=/,'') i = i.split(',') if i.include? ',' end i = [i] unless i.is_a? Array i.each {|entry| dataset = self.new(entry) unless use_colours? dataset.disable_colours end size = dataset.size?.to_i opne "Now working on #{sfancy(entry.rjust(8))}"\ " (Size: #{size.to_s.rjust(8)} bytes)" size_of_the_programs += size } e opne 'The size of the programs '+sfancy(i.join(','))+' is:' e if Object.const_defined?(:Roebe) and Roebe.const_defined?(:HumanReadable) size_of_the_programs = Roebe::HumanReadable[size_of_the_programs] end result = " #{simp(size_of_the_programs.to_s)}".dup result << ' bytes' unless size_of_the_programs.to_s.strip.end_with? 'B' opne result e end
#¶ ↑
report_status_information
¶ ↑
Invocation example:
rbt --report-status
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27902 def report_status_information e e 'The source directory is at: '+sdir(RBT.source_dir?) e 'The temp directory is at: '+sdir(RBT.temp_dir?) report_where_archives_will_be_extracted_into e end
#¶ ↑
report_the_amount_of_binaries
¶ ↑
Invocation example:
ry glib --n-binaries?
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28145 def report_the_amount_of_binaries( i = compile_which_program? ) ensure_proper_dataset_for(i) if cookbook_dataset?.nil? _ = binaries? opne 'The program '+sfancy(i)+' will '\ 'install '+sfancy(_.size.to_s)+' binaries.' end
#¶ ↑
report_the_kde_status
¶ ↑
This method will report the “status” of the KDE project, as far as the cookbooks project is concerned.
What is meant here is that this method will simply report the main constants that handle the remote URL to kde projects.
To invoke this method, do this on the commandline:
rbt --report-the-kde-status
#¶ ↑
# File lib/rbt/compile/compile.rb, line 21666 def report_the_kde_status require 'rbt/utility_scripts/report_the_kde_status.rb' RBT.report_the_kde_status end
#¶ ↑
report_where_we_will_store_logs
¶ ↑
This will ask where we store our BT-Related files. The Config object defines that.
To trigger this, do:
ry --store_where?
#¶ ↑
# File lib/rbt/compile/compile.rb, line 29119 def report_where_we_will_store_logs opne "Log-files will be stored into the directory `"\ "#{sdir(log_dir?)}`." end
#¶ ↑
report_whether_a_build_directory_will_be_used_for_this_program
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28157 def report_whether_a_build_directory_will_be_used_for_this_program opne 'Will a '+teal('build directory')+' be used for the program '+ sfancy(compile_which_program?)+'? '+ simp( verbose_truth(use_build_directory?).delete('.') )+'.' end
#¶ ↑
report_whether_this_program_is_included_or_whether_it_is_not
¶ ↑
This method will notify the user as to whether the given program passed into this method is registered, as part of the RBT
project, or whether it is not.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28029 def report_whether_this_program_is_included_or_whether_it_is_not( i = program? ) e teal("Is #{program} included in the RBT project?: ")+ verbose_truth( is_this_program_included?(i, :be_quiet) ) end
#¶ ↑
report_whether_we_are_on_gobolinux
¶ ↑
To invoke this method, do:
rbt --is-on-gobolinux?
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12008 def report_whether_we_are_on_gobolinux opne 'Are we on GoboLinux: '+ royalblue( verbose_truth(is_on_gobolinux?.to_s) ) end
#¶ ↑
report_which_programs_can_be_compiled_statically
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27964 def report_which_programs_can_be_compiled_statically use_this_key = :can_be_compiled_statically selection = available_programs?.select {|this_program| if does_this_expanded_cookbook_file_exist_for_this_program?(this_program) dataset = load_dataset_from_this_expanded_cookbook(this_program) _ = dataset[use_this_key] (_ == 'yes') or (_.to_s == 'true') else false end } if selection.empty? opne 'No program that can be compiled statically was found.' opne 'This is an incorrect result, though. Have you expanded' opne 'your local dataset already?' opne 'If not, run:' e e ' rbt --expand-dataset' e else opne 'The following programs can be compiled statically:' e selection.each_with_index {|this_program, index| index += 1 e royalblue(" #{index.to_s.rjust(3)}) ")+ steelblue("#{this_program}") } e end end
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
RBT::CompileBase#reset
# File lib/rbt/compile/compile.rb, line 16579 def reset super() RBT::Errors::MapLineToASpecificError.reset infer_the_namespace # ======================================================================= # # === @internal_hash # # Following comes the main Hash that keeps internal data. This should # come quite early, as some other variables may be stored in that Hash. # # This is no longer necessary in the method here, as the "upstream" # base class does this for us already - hence the call to super() # shown above. # ======================================================================= # # @internal_hash = {} # ======================================================================= # # === @array_compile_these_programs # ======================================================================= # @array_compile_these_programs = [] # ======================================================================= # # === @simple_or_complex # ======================================================================= # @simple_or_complex = :use_expanded_dataset # :simple # ======================================================================= # # === Clear problems # # Next, prepare the stage for recording-problems. No problems are # known initially, on startup. That method call must come after # the internal Hash has been created. # ======================================================================= # clear_problems add_the_default_dataset_to_the_internal_hash add_the_invariant_dataset_to_the_internal_hash disable_colours unless RBT.use_colours? set_program_path(nil) extract_to_default_directory set_cflags { :be_silent } # ← Initialize the CLFAGS here. end
#¶ ↑
reset_the_status_file
¶ ↑
This method will clear the status.yml file, aka re-set it to zero.
To invoke this method, do:
rbt --reset-the-status-file
#¶ ↑
# File lib/rbt/compile/compile.rb, line 11314 def reset_the_status_file this_file = FILE_STATUS dataset = {} dataset['currently_compiling_these_programs'] = [] write_what_into(YAML.dump(dataset), this_file) end
#¶ ↑
return_append_this_to_the_configure_options
¶ ↑
This method will always at the least return an empty String.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14650 def return_append_this_to_the_configure_options _ = '' if @internal_hash[:append_this_to_the_configure_options] _ = _.dup if _.frozen? _ << @internal_hash[:append_this_to_the_configure_options] end return _ end
#¶ ↑
return_cmake_configure_options_while_considering_GNU_configure_options
¶ ↑
This method will return the cmake_configure_options, or configure options. One day this should be changed to ONLY return the cmake_configure_options, but for the time being we need to retain compatibility to GNU configure options.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14631 def return_cmake_configure_options_while_considering_GNU_configure_options _ = cmake_configure_options? unless _ # ===================================================================== # # We default to the configure options for legacy reasons. At # some later point we may have to change all cookbook files, # but for now we won't. # ===================================================================== # _ = configure_options? end _ << return_append_this_to_the_configure_options return _.strip.squeeze(' ') end
#¶ ↑
return_dataset_for_this_program
¶ ↑
This method will be used to return the dataset, that is a new cookbook instance, from the given program at hand.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13488 def return_dataset_for_this_program( i = compile_which_program? ) load_yaml_dataset_for_this_program(i) end
#¶ ↑
return_default_hash_to_be_passed_into_colour_make
¶ ↑
This method will return a static hash. This can be overruled, though, by providing an argument (another hash) to this method.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14740 def return_default_hash_to_be_passed_into_colour_make( optional_input = nil ) hash = { use_this_make_command: use_which_make_command?, append_these_options: parameters_to_make?, run_make: run_make?, run_make_install: run_make_install?, use_porg: use_porg?, program_name_and_program_version: program_name_and_program_version? } if optional_input hash.update(optional_input) end hash end
#¶ ↑
return_games_components
¶ ↑
This method will conveniently return the Array holding all programs that belong to the KDE5 Application pool.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 22286 def return_games_components RBT.return_games_components end
#¶ ↑
return_hash_for_the_postinstallation_step
¶ ↑
This method will return a Hash that can be used as the main initializer for class RBT::PostinstallationStep
.
The method accepts an argument (optional). That argument should be an instance of RBT::Compile
, if it is provided. If provided we will fetch our information from that instance, rather than from the default internal one.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 23420 def return_hash_for_the_postinstallation_step( optional_rbt_compile_object = nil ) # ======================================================================= # # First we will setup some local variables that will be returned # via the Hash. # ======================================================================= # register_the_program_or_do_not_register_the_program = false shall_we_run_fetch_all_m4_macros = true shall_we_invoke_symlink_program = false shall_we_symlink_the_header_files_into_the_usr_include_hierarchy = false if optional_rbt_compile_object if optional_rbt_compile_object.continue_after_make_step? and optional_rbt_compile_object.make_install_stage_was_a_success? and optional_rbt_compile_object.no_error_has_occurred? register_the_program_or_do_not_register_the_program = true end if optional_rbt_compile_object.do_not_symlink? shall_we_run_fetch_all_m4_macros = false elsif !optional_rbt_compile_object.continue_after_make_step? shall_we_run_fetch_all_m4_macros = false end if optional_rbt_compile_object.continue_after_make_step? and optional_rbt_compile_object.make_install_stage_was_a_success? # ===================================================================== # # if i.include? '-' # Added this as of Jul 2014. # i = i.to_s.delete('-') # end # ^^^ Disabled as of Sep 2017. We would have to go about # this via some central configuration option in RBT, rather # than an ad-hoc hack such as the above. # ===================================================================== # shall_we_invoke_symlink_program = true end unless optional_rbt_compile_object.do_not_symlink? if optional_rbt_compile_object.symlink_headers_into_usr_include_hierarchy? and optional_rbt_compile_object.uses_an_appdir_prefix? and File.directory?(optional_rbt_compile_object.real_prefix?.to_s+'include/') and !Dir["#{optional_rbt_compile_object.real_prefix?}include/**.h"].empty? shall_we_symlink_the_header_files_into_the_usr_include_hierarchy = true end else if continue_after_make_step? and make_install_stage_was_a_success? and no_error_has_occurred? register_the_program_or_do_not_register_the_program = true end if do_not_symlink? shall_we_run_fetch_all_m4_macros = false elsif !continue_after_make_step? shall_we_run_fetch_all_m4_macros = false end if continue_after_make_step? and make_install_stage_was_a_success? # ===================================================================== # # if i.include? '-' # Added this as of Jul 2014. # i = i.to_s.delete('-') # end # ^^^ Disabled as of Sep 2017. We would have to go about # this via some central configuration option in RBT, rather # than an ad-hoc hack such as the above. # ===================================================================== # shall_we_invoke_symlink_program = true end unless do_not_symlink? if symlink_headers_into_usr_include_hierarchy? and uses_an_appdir_prefix? and File.directory?(real_prefix?.to_s+'include/') and !Dir["#{real_prefix?}include/**.h"].empty? shall_we_symlink_the_header_files_into_the_usr_include_hierarchy = true end end hash = { compile_which_program: compile_which_program?, use_this_prefix: real_prefix?.to_s, dataset_to_use: cookbook_dataset?, use_tags: use_tags?, full_configure_command: full_configure_command?, do_register_the_program: register_the_program_or_do_not_register_the_program, do_run_fetch_all_m4_macros: shall_we_run_fetch_all_m4_macros, shall_we_invoke_symlink_program: shall_we_invoke_symlink_program, install_only_binaries: install_only_binaries?, use_gobolinux_symlinkprogram: use_gobolinux_symlinkprogram?, delete_libtool_files: delete_libtool_files?, symlink_into_usr_lib_dir: symlink_into_usr_lib_dir?, postinstall: postinstall?, shall_we_symlink_the_header_files_into_the_usr_include_hierarchy: shall_we_symlink_the_header_files_into_the_usr_include_hierarchy } return hash end
#¶ ↑
return_kde5_porting_aids
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 21756 def return_kde5_porting_aids RBT.return_kde5_porting_aids end
#¶ ↑
return_last_configure_command
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18254 def return_last_configure_command hash = compiled_programs? # The full dataset is assigned here. last_key = hash.keys.last # Grab the last key. dataset = hash[last_key] # Now we have obtained the dataset. full_configure_command = dataset['full_configure_command'] return full_configure_command end
#¶ ↑
return_lxqt_components
¶ ↑
This method will conveniently return the Array holding all programs that belong to the LX-QT pool.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 21867 def return_lxqt_components RBT.return_lxqt_components end
#¶ ↑
return_mate_desktop_components
¶ ↑
This method will conveniently return the Array holding all programs that belong to the KDE5 Application pool.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12180 def return_mate_desktop_components RBT.return_mate_desktop_components end
#¶ ↑
return_n_processors_of_this_computer
¶ ↑
This method will return how many processors this computer has. This can then be used to automatically determine the maximum option given to the “make” binary.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13291 def return_n_processors_of_this_computer( file_cpuinfo = FILE_CPUINFO ) if file_cpuinfo.is_a?(String) and File.exist?(file_cpuinfo) selected_dataset = File.readlines(file_cpuinfo).select {|line| line.start_with? 'processor' } selected_dataset.size else 1 # 1 is the minimum number. end end
#¶ ↑
return_path_to_the_archive_of_this_program
¶ ↑
This functionality depends on the expanded cookbooks dataset.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13581 def return_path_to_the_archive_of_this_program(i) dataset_from_expanded_cookbook = return_dataset_from_expanded_cookbook(i) dataset_from_expanded_cookbook[:program_path] end
#¶ ↑
return_possible_abbreviation_to_this_input
¶ ↑
This method will return an abbreviation to a given input.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 10778 def return_possible_abbreviation_to_this_input(i) if will_we_make_use_of_abbreviations? # ===================================================================== # # If the cookbooks-project already includes the given input at hand # then we do not have to do anything else. # ===================================================================== # is_the_program_included = cookbooks_include_this_program? i unless is_the_program_included # =================================================================== # # We have to do another check, this time including the abbreviations. # =================================================================== # is_the_program_included = cookbooks_include_this_program?( i, :with_abbreviations ) if is_the_program_included abbreviation_points_to = abbreviations?[i] unless abbreviation_points_to == i # =============================================================== # # Notify the user that we will "re-write" the original input # in this case. # =============================================================== # opne "#{rev}The given input #{sfancy(i)} could not be "\ "found, but an abbreviation" opne "was found, which is now used as the new name: "\ "#{mediumspringgreen(abbreviation_points_to)}" i = abbreviation_points_to.to_s.delete('_').dup set_is_an_abbreviation # =============================================================== # # We must also set the Hash to sync-back our findings, so that # we change input like "ry macro" to "ry marco". We avoid # using the setter method because the setter method does a # few additional checks as-is. # =============================================================== # set_handle_this_program(i) end end end end return i end
#¶ ↑
return_the_appropriate_configure_options
¶ ↑
This will return the configure options or meson option or cmake options. The guarantee is that we will return whatever is appropriate.
For now, the method will only consider configure options.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 10934 def return_the_appropriate_configure_options( build_type = return_build_type.to_s ) _ = nil # Tiny safeguard. build_type = build_type.to_sym unless build_type.is_a? Symbol case build_type # ======================================================================= # # === :meson # # This is for the meson-configure-options. # ======================================================================= # when :meson _ = @cookbook.meson_configure_options?.to_s # ======================================================================= # # === :configure # ======================================================================= # when :configure _ = @cookbook.configure_options?.to_s.dup # ======================================================================= # # === :unknown # # We currently don't handle this. # ======================================================================= # when :unknown, :infer, :infer_automatically return else return nil # opne 'Not yet handled: :'+build_type.to_s+'.' end if _ and !_.empty? splitted = _.split("\n").reject {|entry| entry.strip.empty? } first = splitted.first unless first.start_with?('--') splitted.map! {|entry| unless entry.start_with? '-' entry = "--#{entry}" end entry } end _ = splitted.join(' ') end _ = " #{_}" if _ return _ end
#¶ ↑
reuse_old_configure_options
¶ ↑
This method currently works only with the target program being GCC.
Perhaps it may be extended for other programs one day.
Invocation examples:
ry gcc --copy-old-version ry gcc --use-this-version=7.1.0 --use-old-configure-options
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13108 def reuse_old_configure_options( use_this_program = compile_which_program? ) _ = `#{use_this_program} -v #{SHELL_ERROR_CODE}` options = _.scan(/^Configured .+/).first. sub(/^Configured with:/,''). sub(/\.\.\/configure /,''). strip opne "Re-using the old configure option, which "\ "was `#{sfancy(options)}`." if options.include? programs_directory? # ===================================================================== # # Next, replace the oldprefix. # ===================================================================== # programs_dir = Regexp.quote(programs_directory?) if dataset?.nil? ensure_that_the_default_dataset_exists_for_this_program(use_this_program) end if @internal_hash[:use_this_specific_program_version] dataset?.set_program_version(@internal_hash[:use_this_specific_program_version]) dataset?.reassemble_program_path end regex_to_use = /(--prefix=#{programs_dir}Gcc\/\d{1,2}\.\d{1,2}\.\d{1,2})/ options.sub!(regex_to_use, '--prefix='+return_appdir_prefix) options.squeeze!('/') # ===================================================================== # # Now, simply use that as configure version. # ===================================================================== # extract_to_default_directory set_configure_base_directory cd_to_the_configure_base_directory run_preinstall_sed_and_currently_being_compiled consider_creating_the_build_directory e "These are the #{orange('options')} that will be used:" e e " #{simp(options)}" e set_configure_options(options) run_configure_make_and_make_install_with_this_configure_line(options) run_all_actions_after_the_make_install_step exit_program end end
#¶ ↑
run (run tag)¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27136 def run # ======================================================================= # # === The log directory must exist # # We must always ensure that the log_directory exists. # ======================================================================= # ensure_that_the_log_directory_exists determine_which_programs_to_compile menu # ======================================================================= # # === Initiate batch-compiltion next # # After the menu() interface has been called, we can proceed # to batch-compile every program. # ======================================================================= # do_initiate_batch_compilation(RBT.compile_which_programs?) # $stdout = @original_stdout if @original_stdout # ^^^ Have to re-think the above. end
#¶ ↑
run_configure_like_stage
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 21275 def run_configure_like_stage # use_this_build_system = cookbook_dataset_use_this_build_system? use_this_build_system = build_system? # ^^^ commented that out in July 2021. case use_this_build_system # ======================================================================= # # === cmake # ======================================================================= # when 'cmake' do_install_via_cmake # ======================================================================= # # === meson # ======================================================================= # when 'meson' do_install_via_meson # ======================================================================= # # === ninja # ======================================================================= # when 'ninja' # ===================================================================== # # Since as of 02.10.2018, we try to use ninja here automatically, # if the cookbook_dataset has a dependency on ninja. # ===================================================================== # set_use_this_make_command('ninja') # ======================================================================= # # === waf # ======================================================================= # when 'waf' run_waf_based_installation # ======================================================================= # # === scons # ======================================================================= # when 'scon' run_scons_based_installation else # this else-clause also covers :infer_automatically. # ===================================================================== # # === :infer_automatically # # This else clause will usually run GNU configure, aka # './configure'. # ===================================================================== # # ===================================================================== # # In this case we have to guess the build type, before we proceed, # since we have given the path to a file that exists. # # This code was disabled in April 2021. Let's see if we will need # it again one day. # ===================================================================== # # guessed_build_type = guess_build_type # opne "Guessing the build-type next ... the build type is: "\ # "#{slateblue(':'+guessed_build_type.to_s)}" # ===================================================================== # # === This entry clause is specifically for perl # ===================================================================== # if configure_command_to_use? and File.exist?(configure_command_to_use?) do_run_GNU_configure_then_make_then_make_install(configure_command_to_use?) # ===================================================================== # # === Handle 'configure' next, if such a file exists # ===================================================================== # elsif File.exist? 'configure' do_run_GNU_configure_then_make_then_make_install # ===================================================================== # # === Handle setup.py first # ===================================================================== # elsif File.exist?(RBT::FILE_SETUP_PY) run_python_installation # ===================================================================== # # === This is also for perl, if Makefile.PL exists # ===================================================================== # elsif File.exist?('Makefile.PL') esystem 'perl Makefile.PL' run_make_then_make_install # ===================================================================== # # === Handle meson next # ===================================================================== # elsif File.exist? RBT::FILE_MESON_BUILD do_install_via_meson # ===================================================================== # # === Handle cmake next # # This will be based on the file "CMakeLists.txt". # ===================================================================== # elsif cmake_file_exists? do_install_via_cmake # ===================================================================== # # === Handle plain Makefile next # ===================================================================== # elsif File.exist? 'Makefile' run_make_then_make_install # ===================================================================== # # === Handle ruby setup.rb next # ===================================================================== # elsif File.exist? 'setup.rb' esystem 'ruby setup.rb' else opne 'Nothing useful found in '+sdir(return_pwd)+'.' end end end
#¶ ↑
run_configure_script?¶ ↑
Determine whether we will invoke “./configure” or whether we will not.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18049 def run_configure_script? _ = @internal_hash[:run_configure_script] # ======================================================================= # # Next, fetch the entry that exists in the cookbook-dataset, and use # it in this case. # ======================================================================= # if _.nil? if cookbook_dataset_run_configure_script?.nil? _ = true # Safe-guard. else _ = cookbook_dataset_run_configure_script? end end _ end
#¶ ↑
run_make_command
(make tag, Makefile tag)¶ ↑
This is the wrapper method over “make”.
This method will, in the end, delegate towards RBT.colour_make
, which in turn runs the command/binary called “make”.
The specific command that will be used, in this case “make”, can also be a different one, as defined by the respective .yml file for the given program at hand. Not all programs require “make” for their compilation.
The method will also have to ensure that a Makefile-file exists, but only for installation types that do happen to require a Makefile.
Some build systems, such as meson/ninja, may use ‘make’, but may also skip it and do “ninja install” instead.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 11659 def run_make_command if exit_before_make? opne 'Exiting now as instructed before reaching '\ 'the "'+orange('make')+'" stage.' exit_program end # ======================================================================= # # === Determine whether the Makefile has to be modified or not. # ======================================================================= # if modify_the_makefile? opne 'The Makefile will be modified next ('+ steelblue('PREFIX')+' value will be changed).' do_use_this_makefile_here = return_pwd+'Makefile' # ===================================================================== # # Delegate towards RBT::ChangePrefix next. # ===================================================================== # RBT::ChangePrefix.new( use_this_makefile: do_use_this_makefile_here, use_this_as_the_new_prefix: prefix?.to_s.dup ) end if run_make? # ===================================================================== # # "make" is usually used, but we may also make use of "ninja" instead, # so we have to pass in this option towards RBT.colour_make. # ===================================================================== # if run_simulation? opne 'We are running a simulation, hence the following command' opne 'will not be run:' opn; efancy " #{make_command?}" else # =================================================================== # # Clear the old buffer first: # =================================================================== # reset_error_map_line_to_a_specific_error if has_to_be_compiled? consider_using_maximum_speed_for_compilation end # =================================================================== # # We will have to make a cd-operation to the configure base directory # if run_configure is no/false and if we use a build directory. # # This, however had, breaks cmake builds, so it was disabled in # February 2019. It may have to be changed at a later time # anyway. # =================================================================== # # if !run_configure? and use_build_directory? # cd_to_the_configure_base_directory # end # =================================================================== # # Next consider running pre-make commands - but this must come # AFTER running GNU configure and similar build-style runs. # =================================================================== # consider_running_premake_instructions unless installation_steps?.empty? installation_steps?.each {|this_step| opne "Next doing this step: #{sfancy(this_step)}" esystem this_step } end # =================================================================== # # Delegate towards RBT.colour_make next: # =================================================================== # _ = use_which_system_command? case _ # =================================================================== # # === :ioparser # # This is the more sophisticated ioparser variant. # =================================================================== # when :ioparser, :default RBT.colour_make { return_default_hash_to_be_passed_into_colour_make } # =================================================================== # # === :system # # This is the simple system-variant. # =================================================================== # when :system cmd = 'make'.dup hash = return_default_hash_to_be_passed_into_colour_make if hash.has_key? :append_these_options cmd << hash[:append_these_options].join(' ') end esystem cmd.strip.squeeze(' ') else e 'Unknown system-command: '+steelblue(_.to_s) end end run_through_the_registered_problems_registered_errors_and_behaviour_changes reset_error_map_line_to_a_specific_error if automatically_create_package? if is_on_slackware? # ================================================================= # # Create a slackware-package in this case. # ================================================================= # opne 'Next trying to create a package for `'+royalblue('slackware')+'`.' # The following subsection is incomplete. The path could be used # to find out whether things are put in their right position. # path = create_slackware_description_file RBT.run_makepkg_command(compile_which_program?, program_version?) end end end end
#¶ ↑
run_make_install
?¶ ↑
Query whether we will do the “make install” step or whether we will not. Will return a boolean value (true/false).
#¶ ↑
# File lib/rbt/compile/compile.rb, line 11774 def run_make_install? @internal_hash[:run_make_install] end
#¶ ↑
run_make_install_command
¶ ↑
This method will ultimately default to run something such as “make install”. Note that some programs do not use “make install” and instead use something such as “ninja install”.
The method here thus has to remain somewhat flexible, in order to install such programs as well.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 11534 def run_make_install_command # ======================================================================= # # Do not try to compile via make, if it does not have to be compiled. # ======================================================================= # return unless has_to_be_compiled? unless pre_make_install_sed.empty? pre_make_install_sed.each {|sed_instruction| run_this_sed_instruction(sed_instruction) } end if exit_before_make_install? opne 'Exiting now as instructed before reaching '\ 'the "'+orange('make install')+'" stage.' exit_program end # ======================================================================= # # === Check whether we may run make install or whether we may not. # ======================================================================= # if run_make_install? # ===================================================================== # # Clear the old buffer keeping track of our errors first: # ===================================================================== # reset_error_map_line_to_a_specific_error use_this_make_command = use_this_make_command? if use_this_make_install_command? # =================================================================== # # In this case we will use that make-install command instead. # =================================================================== # use_this_make_command = use_this_make_install_command? end use_this_make_command = use_this_make_command.dup use_porg = false if use_porg? if porg_is_available? use_porg = true else # ================================================================= # # Notify the user that porg is NOT available. We will continue # anyway, though. # ================================================================= # notify_the_user_that_porg_is_not_available end end # ===================================================================== # # If the user uses stow then the following clause is entered. # ===================================================================== # if use_stow? RBT.colour_make_install { return_default_hash_to_be_passed_into_colour_make( append: " DESTDIR=/stow/#{compile_which_program?} install", porg: use_porg, use_this_make_command: use_this_make_command ) } else RBT.colour_make_install { return_default_hash_to_be_passed_into_colour_make( porg: use_porg, use_this_make_command: use_this_make_command ) } end run_through_the_registered_problems_registered_errors_and_behaviour_changes reset_error_map_line_to_a_specific_error if an_error_has_occurred? # =================================================================== # # Register that this step led to an error in this case. # =================================================================== # @internal_hash[:make_install_stage_was_a_success] = false end end end
#¶ ↑
run_make_then_make_install
¶ ↑
Run “make” and then the “make install” command here.
This method is deliberately very simple.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 11515 def run_make_then_make_install unless an_error_has_occurred? run_make_command run_make_install_command end end
#¶ ↑
run_postinstall_actions?¶ ↑
We will default to the cookbook dataset - but this will be overruled if there is a corresponding entry in the @internal_hash variable.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 23318 def run_postinstall_actions? _ = cookbook_dataset_postinstall? unless @internal_hash[:run_postinstall_actions].nil? _ = @internal_hash[:run_postinstall_actions] end return _ end
#¶ ↑
run_pre_configure_steps_if_requested_to_do_so
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27123 def run_pre_configure_steps_if_requested_to_do_so _ = pre_configure_steps? if _ and !_.empty? and _.is_a?(Array) opne "#{rev}Doing a #{steelblue('pre-configure')} step next." _.each {|entry| esystem entry } end end
#¶ ↑
run_preinstall_actions
¶ ↑
These actions will be run before anything else, including “./configure”.
An example for such a preinstall action may be the following:
if is_on_32_bit_system? sed -r "/ifeq.*CompilerTargetArch/s#i386#i686#g" -i projects/compiler-rt/make/platform/clang_linux.mk
#¶ ↑
# File lib/rbt/compile/compile.rb, line 23917 def run_preinstall_actions _ = cookbook_dataset_preinstall? unless _.empty? # ===================================================================== # # Next we have to handle the preinstall-actions. This should # typically be an Array (and is guaranteed by class # RBT::SanitizeCookbook). # # We will output what we are doing pre-installation things, but # only do so IF we really want to so. # ===================================================================== # first = _.first unless first.start_with?('if ') and (first == 'if is_on_32_bit_system?') cliner { opne "Doing preinstallation actions next, from the directory " opne "`#{sdir(return_pwd)}`:" } end # ===================================================================== # # === Handle conditional cases in the preinstall clause next # ===================================================================== # if first.start_with? 'if ' # Ok, we assume this to be an if-conditional clause. case first # case tag when 'if is_on_32_bit_system?' if is_on_32_bit_system? # Ok, we are on a 32 bit system. _.shift unless _.empty? _ = _.first opne 'A pre-installation instruction was found, '\ 'which will be run next (from the '\ 'directory '+sdir(sdir_return_pwd)+').' opnesystem _ end end end else opnn if _.is_a? Array _.each {|entry| case entry # =============================================================== # # Note that most of the next steps may be handled by class # PostInstall already, such as create_directory(). # =============================================================== # # =============================================================== # # === copy_file STATIC_BUSYBOX_CONFIG # # Handle busybox's static configuration. This is stored # in the file called "static_busybox_config.md". # # On my home system this file is then found here: # # $RBT/misc/profiles/static_busybox_config.md # # =============================================================== # when /copy_file STATIC_BUSYBOX_CONFIG$/i source_location = "#{DIRECTORY_TO_THE_PROFILES}static_busybox_config.md" target_location = "#{cookbooks_dataset_extracted_towards?}.config" opne "Copying from #{sfile(source_location)}" opne "to #{sfile(target_location)}" copy_file(source_location, target_location) else if entry.end_with?('.new') case entry # =========================================================== # # === Handle ChangeLib64ToLib.new # =========================================================== # when /ChangeLib64ToLib.new$/ e "Delegating towards "\ "#{steelblue('RBT::ClassesForIndividualPrograms::Gcc::ChangeLib64ToLib')}"\ " next:" RBT::ClassesForIndividualPrograms::Gcc::ChangeLib64ToLib.new next end end end e sfancy(entry) system(entry) } else e sfancy(_) system(_) end end end end
#¶ ↑
run_premake_commands
¶ ↑
Here we try to run the premake commands, in case they exist.
If there are no pre_make_commands, then we will not do anything, as our array will be empty.
This method is normally run from do_compile_this_program
(), via a call to its alias name consider_running_premake_instruction().
#¶ ↑
# File lib/rbt/compile/compile.rb, line 11824 def run_premake_commands( array = cookbook_dataset_pre_make_commands? ) unless array.empty? opne "#{sfancy('Doing pre_make_commands next from ')}"\ "#{sdir_return_pwd}#{sfancy('.')}" array.each { |cmd| opnn e "In the directory #{sdir_return_pwd}, doing the following command next:" e e " #{slateblue(cmd)}" e e 'next.' custom_system(cmd) } end end
#¶ ↑
run_python_install1
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 25331 def run_python_install1 dataset = YAML.load_file(RBT.file_predefined_installation_instructions)['PINSTALL1'] if dataset.is_a?(String) and dataset.include?(';') dataset.split(';').each {|this_command| _ = this_command.strip e _ run_this_sys_command(_) } end end
#¶ ↑
run_python_install2
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 25345 def run_python_install2 dataset = YAML.load_file(RBT.file_predefined_installation_instructions)['PINSTALL2'] if dataset.is_a?(String) and dataset.include?(';') dataset.split(';').each {|this_command| _ = this_command.strip e _ run_this_sys_command(_) } end end
#¶ ↑
run_python_installation
¶ ↑
You should check whether setup.py exists prior to invoking this method here.
You can also pass in another file, such as configure.py. By default, the method will make use of a file called “setup.py”, though.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 25056 def run_python_installation( i = 'setup.py' ) if make_options?.nil? _ = cookbook_dataset_make_options? if _ and !_.empty? i = _ end end i = [i].flatten.compact # ======================================================================= # # We work on an Array here since some make_options entries also # specify an Array. # ======================================================================= # i.each {|do_this_action| case do_this_action when FILE_SETUP_PY # ← This is equivalent to "setup.py". # We could also use RBT::FILE_SETUP_PY. if does_a_python_binary_exist? esystem "python #{do_this_action} configure" esystem "python #{do_this_action} build" esystem "python #{do_this_action} install" else notify_the_user_that_no_binary_python_could_be_found end else run_this_command = "#{do_this_action}".dup if run_this_command.start_with?('python') and !run_this_command.include?('/') # ================================================================= # # This is valid for a command line such as: # "python setup.py config" # ================================================================= # splitted = run_this_command.split(' ') splitted[1].prepend(configure_base_dir?.dup) run_this_command = splitted.join(' ') end unless run_this_command.start_with? 'python' run_this_command.prepend('python ') end if does_a_python_binary_exist? esystem run_this_command else notify_the_user_that_no_binary_python_could_be_found end end } consider_renaming_the_kde_konsole_tab :clear, :do_rename end
#¶ ↑
run_scons
¶ ↑
Invoke this method here only when we wish to use scons in order to install a program.
Scons
is python-related, which is why it sits here in this file.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 25320 def run_scons _ = 'scons'.dup if use_build_directory? _.prepend('../') end esystem _ end
#¶ ↑
run_the_cmake_command
¶ ↑
Run the corresponding “cmake” command.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12557 def run_the_cmake_command _ = 'cmake'.dup if do_we_use_any_prefix? # Check whether the user wants to use a prefix at all. _ << " -DCMAKE_INSTALL_PREFIX=#{prefix?}" end _ << " #{cmake_configure_options?}" _ << ' .' _ << '.' if use_build_directory? _.squeeze!(' ') _.strip! # ======================================================================= # # === Check for more than one -DCMAKE_INSTALL_PREFIX entry next # # This should never be the case, so we will do some quality-control # and exit if this is the case so. # ======================================================================= # scanned_result = _.scan(/-DCMAKE_INSTALL_PREFIX=/) if scanned_result.size > 1 # ===================================================================== # # In this case, something must be wrong. Notify the user about it. # That way this can be corrected eventually. # ===================================================================== # opnewarn "There are at the least two definitions of "\ "#{royalblue('-DCMAKE_INSTALL_PREFIX=')}" opnewarn "in the .yml file at hand." opnewarn 'At the least one of these entries must be incorrect '\ 'and/or superfluous. Please ' opnewarn 'correct this logic-problem because RBT can continue to work.' e e 'See:' e e " #{sfancy(_)}" e exit_program end opne 'Next running' e e " #{colourize_this_important_system_command(_)}" e reset_error_map_line_to_a_specific_error set_full_configure_command(_) # system(_) run_this_sys_command(_) # Using this since as of 28.08.2022. end
#¶ ↑
run_the_configure_command
¶ ↑
This method will ultimately run the “./configure” command, with an appropriate prefix to be used.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 20458 def run_the_configure_command( use_this_configure_command = use_this_build_system? ) return unless run_configure_script? # ======================================================================= # # === configure_command_to_use # # Add the configure-command that is to be used next, if this is # specified in the cookbook .yml file at hand. For example, # 'bc' requires the command './configure.sh' rather than # 'configure'. # ======================================================================= # if cookbook_dataset_configure_command? use_this_configure_command = cookbook_dataset_configure_command?.dup else # This else-clause is the default. case use_this_configure_command # ===================================================================== # # === :infer_automatically # ===================================================================== # when :infer_automatically use_this_configure_command = return_build_type else use_this_configure_command = 'configure' end end create_the_build_directory_then_cd_into_it _ = ''.dup # ← We will start with this here. # ======================================================================= # # === Honour ccache # # Honour the CCACHE setting, if it has been provided. # ======================================================================= # if use_ccache? # ===================================================================== # # Find out whether ccache is available or whether it is not. If it # is we will use it, while also specifying which compiler to use. # ===================================================================== # if ccache_is_available? if will_gcc_be_used_for_compilation? _.prepend 'CC="ccache gcc" ' # In this case prepend it. end else # It must be available. notify_the_user_that_ccache_is_not_available end end _ << '.' if use_build_directory? # ======================================================================= # # The next line exists due to programs such as discount.yml needing # a configure-command like: ./configure.sh # ======================================================================= # _ << "." # unless use_this_configure_command.start_with?('./') # ======================================================================= # # Append the configure-base-directory value next. However had, I am # not sure whether this is correct in April 2021. We'll comment it # out for now; once we know more, we may re-add this again. # ======================================================================= # # _ << configure_base_directory?.dup _ << '/' _ << "#{use_this_configure_command}" # ======================================================================= # # The following _.include? check is valid for e. g. applications # such as "lsof". # ======================================================================= # if do_we_use_any_prefix? use_this_prefix = prefix?.to_s RBT.set_last_prefix_used(use_this_prefix) _ << " --prefix=#{use_this_prefix}" unless _.include? './Configure -n linux' end # ======================================================================= # # The following two checks are necessary, due to two reasons: # # - The user may not want to append any configure-options in # the first place. Hence, we must check for this via # use_configure_options?. # # - Second the user may also input a command such as "ry sed-4.5", # and in this case we have to work on an existing file, rather # than on the dataset in the cookbook-yaml file. # # ======================================================================= # if use_configure_options? and cookbooks_dataset? configure_options_to_use = return_the_appropriate_configure_options( use_this_configure_command ).to_s.dup.rstrip if configure_options_to_use and !configure_options_to_use.empty? # ===================================================================== # # Finally, append these additional commands to the # configure-string: # ===================================================================== # _ << " #{configure_options_to_use}" end end # ======================================================================= # # === Handle strange configuration options involving sysconfdir next # # This must come after we have appended the configure options in use. # ======================================================================= # if use_appdir_prefix? and _.include?('--sysconfdir=/etc') regexp_quoted_old_sysconfdir_prefix = Regexp.quote('--sysconfdir=/etc') rewritten_sysconfdir = '--sysconfdir='+rds(use_which_prefix?.to_s+'/etc') opne 'An '+salmon('AppDir prefix')+' is used, but also "'+ royalblue('--sysconfdir=/etc')+'". '\ 'This is not logical.' opne 'It is now assumed that the --sysconfdir=/etc is meant to target' opne "that #{salmon('AppDir prefix')}, so it will be rewritten to" opne "`#{royalblue(rewritten_sysconfdir)}`." _.sub!(/#{regexp_quoted_old_sysconfdir_prefix}/, rewritten_sysconfdir) end _ << " #{return_append_this_to_the_configure_options}" _.strip! # Just ensure that there are no trailing ' ' characters. # ======================================================================= # # === Handle the ERROR_LINE next # # Next, we will append the ERROR_LINE, but only if the user has # not overruled this on the commandline. # ======================================================================= # if @internal_hash[:append_shell_error_code] and !_.include?(ERROR_LINE) _ << ERROR_LINE end # ======================================================================= # # The next line is used to turn something like: # # "/Depot/Temp/rbt/discount-2.2.3a/./configure.sh" # # into: # # "/Depot/Temp/rbt/discount-2.2.3a/configure.sh" # # ======================================================================= # if _.include?('/./') _.sub!(/\/\.\//, '/') end set_full_configure_command(_.dup.squeeze(' ')) # ← Keep a copy too. use_this_colour = :konsole_dodgerblue # ← dodgerblue if use_colours? cliner(use_colour: use_this_colour) else cliner end e ecolourize_this_important_system_command(full_configure_command?) e if use_colours? cliner(use_colour: use_this_colour) else cliner end reset_error_map_line_to_a_specific_error # ← Must come before the sys-command. run_this_sys_command(full_configure_command?) # ← Run the sys-command here. run_through_the_registered_problems_registered_errors_and_behaviour_changes reset_error_map_line_to_a_specific_error end
#¶ ↑
run_this_sys_command
¶ ↑
This method will, by default, try to make use of IO.popen.
The alternatives, system() or backticks, are not as useful, in my opinion. However had, the user can use these variants too, since as of July 2020.
The current idea is to work on a line-by-line basis when IO.popen is used, and to also display what is done, so that the user has an idea what is happening.
There is also the possibility to use colours and colourize the input; this allows us to, for example, use specific colours for directories or for files or to indicate failures.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 24105 def run_this_sys_command( i ) set_pid(nil) # Reset it here. # ======================================================================= # # Determine whether we will make use of colours: # ======================================================================= # use_colours = use_colours? # ======================================================================= # # I still do not quite understand the second argument. Either way, # I have determined that this works better. # # ffmpeg = IO.popen(cmdline + " #{SHELL_ERROR_CODE}", "w+") # # ======================================================================= # if i.start_with? 'make' unless is_make_available? # =================================================================== # # We need to inform the user that the "make" binary is not available. # =================================================================== # opne "The program \"#{sfancy('make')}\" is "\ "#{swarn('not available')}, at the least not as "\ "part of the #{steelblue('$PATH')} variable." opne "RBT::Compile thus can not compile anything. You "\ "may want to check the #{orange('$PATH')} variable." do_not_continue_and_do_not_compile(:be_quiet) return end end i = i.dup if i.frozen? # ======================================================================= # # Next append shell-error-code, which is just ' 2>&1' really. # The user can disable this, though, via --do-not-append-no-error. # ======================================================================= # if append_shell_error_code? i << " #{SHELL_ERROR_CODE}" unless i.end_with? " #{SHELL_ERROR_CODE}" end case use_which_system_command? # ======================================================================= # # === :ioparser # ======================================================================= # when :ioparser io_object = IO.popen(i, {:err => [:child, :out]}) set_pid(io_object.pid) io_object.each { |line| # ===================================================================== # # The next line will also display what has happened. # ===================================================================== # parse_this_line_obtained_via_io_popen(line, use_colours) } io_object.close # ===================================================================== # # Right now only the io-parser above can handle the sys-command # strings. # ===================================================================== # # Next, we attempt to determine what some of the errors may be and # perhaps even how to resolve them. # ===================================================================== # # Handle "no configure file" next. # ===================================================================== # if array_sys_command_string? and array_sys_command_string?.any? {|line| line.include? 'sh: ./configure: No such file or directory' } problem_is :no_configure_file # ===================================================================== # # Handle missing headers next. # ===================================================================== # elsif array_sys_command_string?.any? {|line| line.include? 'headers are missing' } _ = array_sys_command_string?.select {|line| line.include? 'headers are missing' } problem_is _ end # ======================================================================= # # === :simple_system # # This entry point is for simple system() calls. # ======================================================================= # when :simple_system, :system esystem(i) end end
#¶ ↑
run_through_the_behaviour_changes
¶ ↑
We run through the module that keeps track of the behaviour changes that out to be run in class RBT::Compile
.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15218 def run_through_the_behaviour_changes RBT::Errors::MapLineToASpecificError.behaviour_changes?.each {|do_this_action| self.send(do_this_action) } end
#¶ ↑
run_through_the_erroneous_libtool_entries
¶ ↑
The first argument should be an Array; or an object that is able to respond to :each.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 22373 def run_through_the_erroneous_libtool_entries( i = erroneous_libtool_entries? ) i.each {|do_this_action| if is_on_roebe? and autofix? # =================================================================== # # Register this erroneous line for now - the fixing part will # happen at a later time. Only on roebe-systems for now, though. # =================================================================== # try_to_autocorrect_this_erroneous_libtool_entry_later(do_this_action) end } end
#¶ ↑
run_through_the_registered_errors
¶ ↑
Sync the errors towards class RBT::Compile
next.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 16405 def run_through_the_registered_errors RBT::Errors::MapLineToASpecificError.registered_errors?.each {|do_this_action| error_is do_this_action } end
#¶ ↑
run_through_the_registered_problems
¶ ↑
Sync the problems towards class RBT::Compile
next.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15206 def run_through_the_registered_problems RBT::Errors::MapLineToASpecificError.registered_problems?.each {|do_this_action| problem_is do_this_action } end
#¶ ↑
run_through_the_registered_problems_registered_errors_and_behaviour_changes
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15238 def run_through_the_registered_problems_registered_errors_and_behaviour_changes run_through_the_registered_problems run_through_the_registered_errors run_through_the_behaviour_changes run_through_the_erroneous_libtool_entries run_through_the_required_dependencies end
#¶ ↑
run_through_the_required_dependencies
¶ ↑
We have to sync the dependencies back into class RBT::Compile
.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15229 def run_through_the_required_dependencies RBT::Errors::MapLineToASpecificError.required_dependency?.each {|this_array| register_required_dependency(this_array.first, this_array.last) } end
#¶ ↑
run_waf
(waf tag)¶ ↑
This method can be used to install a project that uses “waf” as its build system.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 25111 def run_waf run_pre_make_commands _ = './waf'.dup if use_build_directory? _.prepend(configure_base_directory?) end opnn; report_working_directory # ======================================================================= # # Specify which subcommands to use, e. g. 'waf configure' followed by # 'waf build' and so forth. # ======================================================================= # run_these_subcommands = %w( configure build install ) run_these_subcommands.each {|this_subcommand| _ = "#{_} #{this_subcommand}" e e colourize_this_important_system_command(_) e system _ } end
#¶ ↑
save_into_compiled_programs
¶ ↑
This method will try to save a lot of useful data into a file called “compiled_programs.yml”.
That way we can try to figure out what happened at any moment in time (hopefully).
The variable full_configure_command will store the full configure command, whereas configure_options only shows the part afterwards, such as which parts to enable or disable and so forth.
This should also store ARCH info and such.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14226 def save_into_compiled_programs( store_into = FILE_COMPILED_PROGRAMS ) what = ''.dup # Need a non-frozen String. what << '# --- '+program_name?+N what << program_name?+':'+N what << ' CFLAGS: '+cflags?.to_s+N what << ' compiled_at: '+today?.to_s+', '+current_hour?+N what << ' prefix: '+real_prefix?.to_s+N what << ' full_configure_command: '+ full_configure_command?.to_s+N what << ' configure_options: '+configure_options?.to_s+N what << ' successfully_compiled: true/false'+N # This line here is obviously a stub. what << N # Extra newline - makes reading this file easier. append_what_into(what, store_into) end
#¶ ↑
scan_source_archive
¶ ↑
Scan the complete source archive.
Invocation example:
ry --scan_source_archive
#¶ ↑
# File lib/rbt/compile/compile.rb, line 11221 def scan_source_archive( shall_we_exit = true ) require 'rbt/cookbooks/scan_source_archive.rb' opne 'Scanning for source Archives now.' RBT::Cookbooks::ScanSourceArchive.new # bl ScanSourceArchive exit_program if shall_we_exit end
#¶ ↑
scons_file_exists?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 25186 def scons_file_exists? File.exist? 'SConstruct' end
#¶ ↑
search_for_tag
(search tag)¶ ↑
Use this to search for a tag.
Usage examples:
ry htop --tags pdf ry htop --tags term
#¶ ↑
# File lib/rbt/compile/compile.rb, line 17881 def search_for_tag( this_tag, shall_we_exit = true ) results = RBT::Cookbooks::SearchForTags.new(this_tag) exit_program if shall_we_exit return results end
#¶ ↑
sed?¶ ↑
Query as to whether we will use sed or not.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27170 def sed? _ = cookbook_dataset?.sed? if @internal_hash[:sed].nil? # ===================================================================== # # In this case we will use the sed-variant given by the cookbooks # dataset. # ===================================================================== # else _ = @internal_hash[:sed] end _ end
#¶ ↑
set_array_compile_these_programs
¶ ↑
This method will designate which programs are to be compiled, as an Array. It may look like this: [‘htop’,‘ruby’,‘php’]
Note that this method will remove all ‘-’ tokens from the given input at hand, if the second option allows this method to do so.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 20294 def set_array_compile_these_programs( i, consider_replacing_the_given_input = :honour_user_configuration_setting ) case consider_replacing_the_given_input # ======================================================================= # # === :default # ======================================================================= # when :default consider_replacing_the_given_input = true # ======================================================================= # # === :do_not_replace # # In this case we may not replace the given input. # ======================================================================= # when :do_not_replace consider_replacing_the_given_input = false # ======================================================================= # # === :honour_user_configuration_setting # ======================================================================= # when :honour_user_configuration_setting, :honour_user_settings if will_we_make_use_of_abbreviations? consider_replacing_the_given_input = @internal_hash[:make_use_of_the_cookbook_aliases] else consider_replacing_the_given_input = false end end i = [i].flatten.compact.reject {|entry| entry.start_with? '--' } i.map! {|entry| entry = entry.to_s.dup # ===================================================================== # # === Handle the possibility of replacing the given input at hand # # This clause is triggered when the user wishes to replace # the given input at hand. # # Invocation example: # # trad libx # # ===================================================================== # if consider_replacing_the_given_input # ===================================================================== # # First, check for .pc files directly. That way we can find the # real program at hand; and if not then the .pc suffix will be # dropped anyway. # ===================================================================== # if entry.end_with? '.pc' _ = RBT.return_the_associated_program_of_this_pkgconfig_file(entry) unless _ == entry opne 'This .pc file is registered and points to '\ 'the program called '+steelblue(_)+'.' opne 'It will be used as input next.' entry = _ end entry.delete_suffix!('.pc') if entry.end_with? '.pc' end entry.delete_suffix!('.yml') if entry.end_with? '.yml' entry.chop! if entry.end_with? ':','#' # Get rid of trailing ':' and '#'. entry = entry.delete('-').downcase # All gets downcased. \o/ unless File.exist? entry if is_an_archive?(entry) entry = remove_archive_at_the_end(entry) if entry.include?('-') and (entry =~ /\d+/) # ============================================================= # # Assume entries such as this one here: # mate-panel-1.21.3 # ============================================================= # program_name = ProgramInformation.return_name(entry) _program_version = ProgramInformation.return_version(entry) entry = program_name end end end entry = File.basename(entry) if entry.include? '/' unless RBT.is_this_program_registered?(entry) _ = RBT::MapThisInputToThatRegisteredProgram.new(entry) { :be_quiet } new_entry = _.return_possible_match if new_entry and (new_entry.to_s != entry.to_s) type = _.type? a_or_an = a_or_an?(type) opne 'Replacing '+steelblue(entry)+ ' with '+mediumslateblue(new_entry)+', as '\ 'input. It is '+a_or_an+' '+ mediumorchid(type.tr('_',' '))+'.' entry = new_entry end end unless entry.to_s.start_with? '--' # Exclude "--flag" options here. end entry } @array_compile_these_programs = i # ======================================================================= # # This will always be an Array, set on the toplevel: # ======================================================================= # RBT.set_compile_these_programs(i) # ======================================================================= # # We will also initialize the cookbook_dataset for the first program, # if possible. We will also delete '.' characters since as of September # 2019, as some programs may be called e. g. "ruamel.yaml". # ======================================================================= # original_first_program = RBT.compile_these_programs?.first.to_s first_program = File.basename( original_first_program.downcase.delete('/.') ) if first_program and RBT.is_this_program_included?(first_program) # ===================================================================== # # Set the initial seeds for the programs at hand. # ===================================================================== # set_compile_this_program(first_program) initialize_cookbook_dataset_for(first_program) end end
#¶ ↑
set_cflags
(cflags tag)¶ ↑
This method will enable you to set i.e. new cflags. This then also allows you to compile some programs in a different manner, such as if you wish to compile that particular program statically.
The default argument to this method will be a copy of ENV.
You can overrule this via a shortcut, if you want to, by passing true as argument, or even better, a Symol such as :static. This will then allow you to perform the static build, if the program at hand allows for this.
-static-libgcc may also be an option here.
The variable LDFLAGS may be important as well.
For instance:
make LDFLAGS=-all-static
#¶ ↑
# File lib/rbt/compile/compile.rb, line 22833 def set_cflags( i = default_cflags?, &block ) case i # case tag when :clear i = '' # ======================================================================= # # Enable static builds for the CFLAGS at hand # ======================================================================= # when :overrule_static_build, :static, :build_static, true i = old_cflags?+' -static -g' end # ======================================================================= # # Do the actual assignment next. # ======================================================================= # set_this_env_variable( "CFLAGS: #{i}", :do_set_these_variables, &block ) end
#¶ ↑
set_commandline_arguments
¶ ↑
This will be guaranteed to be an Array.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12407 def set_commandline_arguments(i = []) case i when nil i = [] end i = [i].flatten.compact # ======================================================================= # # Sanitize these commandline-arguments a little bit next. # ======================================================================= # if i and i.respond_to?(:any?) and i.any? {|entry| entry.to_s.start_with?('--') } possible_commandline_arguments = i.select {|inner_entry| inner_entry.to_s.start_with?('--') } # ===================================================================== # # We may still have input such as "--plasma1". The next code block # will account for that situation. # # Invocation example: # # ry --plasma1 # # ===================================================================== # i.map! {|entry| # =================================================================== # # Get the variant without any numbers or '-' hyphens next. # =================================================================== # entry_without_numbers_and_hyphen = entry.delete('-').gsub(/[0-9]/,'') if ARRAY_SPECIAL_COMPONENT_CONTAINING_MANY_SUBCOMPONENTS.include?(entry_without_numbers_and_hyphen) and (entry =~ /\d+$/) # ← This line was added April 2021 to distinguish between "-lxqt" and "-lxqt1". # ================================================================= # # We must also remove this option in that case from the # variable called possible_commandline_arguments. # ================================================================= # possible_commandline_arguments.reject! {|inner_entry| inner_entry == entry } # ================================================================= # # The next code should return a single entry. # ================================================================= # entry = try_to_return_a_special_compile_component(entry) determine_which_programs_to_compile(entry) entry = nil end entry } i = [i].flatten.compact end @internal_hash[:commandline_arguments] = i end
#¶ ↑
set_compile_these_programs_then_batch_compile_them
¶ ↑
This method can be used to start batch-compiling several programs in one go.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 21509 def set_compile_these_programs_then_batch_compile_them( i, consider_replacing_the_input = :default ) set_compile_these_programs(i, consider_replacing_the_input) batch_compile_these_programs(i) end
#¶ ↑
set_configure_base_directory
¶ ↑
This setter-method sets the @internal_hash, which is, for example, a directory such as:
/Depot/Temp/htop-1.0.0/
Some projects, such as “xvid” / “xvidcore”, may require a specific subdirectory, though.
Another example may be the program called “nspr”, which requires the following configure base directory:
/Depot/Temp/nspr-4.10.8/nspr/
class RBT::Compile
will store this in a separate variable so that it can be queried lateron.
Do note that the cookbook-dataset will also retain the original configure_base_directory.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27556 def set_configure_base_directory( i = :default ) case i # ======================================================================= # # === :default # ======================================================================= # when :default i = rds( "#{extract_to?.to_s}"\ "#{program_name_and_version?.to_s}/"\ "#{cookbook_dataset_configure_base_directory?.to_s}" ) end i = i.to_s.dup i = rds(i) # rds() is used here since as of Feb 2012. i << '/' unless i.end_with? '/' # It must always have a trailing '/'. i = i.to_s.dup @internal_hash[:configure_base_directory] = i # ← Finally, assign it. end
#¶ ↑
set_cookbook_dataset_program_version
¶ ↑
For this method to work, cookbook_dataset
? must have been instantiated before.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27463 def set_cookbook_dataset_program_version(i) cookbook_dataset?.set_program_version(i) end
#¶ ↑
set_description
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26502 def set_description(i) cookbook_dataset?.set_description(i) end
#¶ ↑
set_do_not_symlink
¶ ↑
Do not symlink after “make install” stage. This prevents the symlinking-step from e. g. /Programs/Htop/1.2.0/ into the /Systemd/Index/ hierarchy.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 24315 def set_do_not_symlink( be_verbose = true ) if block_given? yielded = yield case yielded when :be_verbose be_verbose = true end end case be_verbose when :be_verbose be_verbose = true when :be_quiet be_verbose = false end if be_verbose opne 'We will not symlink after compilation has finished.' end @internal_hash[:do_not_symlink] = true end
#¶ ↑
set_dont_keep_archive
¶ ↑
Use this method when you don’t want to keep the extracted archive.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 19041 def set_dont_keep_archive( be_verbose = true ) if be_verbose opne 'We will not keep our extracted archive.' end @internal_hash[:keep_the_extracted_archive] = false end
#¶ ↑
set_env_variables?¶ ↑
Determine whether we have to set any environment variable or not.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18683 def set_env_variables? _ = cookbook_dataset? if _ and _.respond_to?(:set_env_variables?) _.set_env_variables? else false end end
#¶ ↑
set_extract_to_this_directory
¶ ↑
This method can be used to keep track onto which directory archives will be extracted.
Within RBT
, the target is also known as the “homedir” variable.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18929 def set_extract_to_this_directory( i = RBT.log_directory?, be_verbose = false ) case be_verbose when :be_verbose be_verbose = true end i = i.to_s case i # ======================================================================= # # === pwd # ======================================================================= # when 'pwd','homedir' i = rds(return_pwd+'/') end unless File.exist? i unless i.end_with? '/' i = i.dup if i.frozen? i << '/' end # ======================================================================= # # Display some information to the user, if we operate in a verbose manner. # ======================================================================= # if be_verbose opne 'We will use '+sdir(i)+' as our directory into which '\ 'we will extract the source archive into.' end @internal_hash[:extract_to_this_directory] = i.dup end
#¶ ↑
set_extract_to_this_directory_as_specified_by_the_user
¶ ↑
This method can be used by the user to specify a certain directory.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18862 def set_extract_to_this_directory_as_specified_by_the_user( i = :random ) case i when :random # ===================================================================== # # In this case we will use a random subdirectory, but within the # temp directory still. # ===================================================================== # i = rbt_temp_dir?+return_n_random_characters(10) end unless i.end_with? '/' i = i.dup if i.frozen? i << '/' end @internal_hash[:extract_to_this_directory_as_specified_by_the_user] = i end
#¶ ↑
set_handle_this_program
¶ ↑
This method has to be used to register the name of the current program that is to be compiled or installed.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 21124 def set_handle_this_program( i, &block ) return if i and i.respond_to?(:start_with?) and i.start_with?('--') # Ignore '--' entries. if i.is_a? Array # Only consider the first input argument here. i = i.first end i = i.to_s.dup i = remove_archive_at_the_end( File.basename( i.to_s.dup.downcase.delete('/_-') # ← Get rid of '/', '_' and other characters. ) ) unless is_an_archive?(i) # ======================================================================= # # === Ad-hox fix libtool files if given to RBT::Compile next # # Invocation example: # # rbt libgdk-3.la # # ======================================================================= # if i.respond_to?(:end_with?) and i.end_with?('.la') and !File.exist?(i) do_not_try_to_autofix opne "Trying to autocorrect the libtool entry at "\ "#{royalblue(i)}" try_to_autocorrect_this_erroneous_libtool_entry( i ) return # And "exit" here. end # ======================================================================= # # Enable is-on-gobolinux if a certain .md file exists: # ======================================================================= # target_file = "#{log_dir?}is_on_gobolinux.md" if File.exist?(target_file) and !File.empty?(target_file) # ===================================================================== # # The above file must have been set on a GoboLinux system, when the # user did a rbt --auto before (or created the file manually). # ===================================================================== # enable_is_on_gobolinux end # ======================================================================= # # Keep track of the program we are compiling in the following variable; # after all that's the whole point of this method. :) # ======================================================================= # @handle_this_program = i.dup # Must be a String. return @handle_this_program end
#¶ ↑
set_internal_pid
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12375 def set_internal_pid(i = nil) @internal_hash[:pid] = i end
#¶ ↑
set_keep_the_extracted_archive
¶ ↑
This method will keep the source-archive extracted. Note that this is not the default - by default we will remove the extracted archive.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 19029 def set_keep_the_extracted_archive(i = true) @internal_hash[:keep_the_extracted_archive] = i end
#¶ ↑
set_name_for_the_build_directory
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 23110 def set_name_for_the_build_directory( i = DEFAULT_NAME_FOR_THE_BUILD_DIRECTORY, be_verbose = false ) case be_verbose when :report_back be_verbose = true end if be_verbose opne "The name of the build directory will be `#{royalblue(i)}`." end @internal_hash[:name_for_the_build_directory] = i end
#¶ ↑
set_on_ihash
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 21492 def set_on_ihash(i) @cookbook = i end
#¶ ↑
set_original_input
¶ ↑
This method can be used to keep track of the original input given to RBT::Compile
.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27350 def set_original_input(i = nil) @internal_hash[:original_input] = i end
#¶ ↑
set_parameters_to_make
¶ ↑
If we have to pass specials options to the program called “make”, then we can do so via this setter-method.
These are additional options that can be given to the program called “make”.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 29416 def set_parameters_to_make(i) # ======================================================================= # # The parameters must always be kept as an Array. # ======================================================================= # i = [i].flatten.compact @internal_hash[:parameters_to_make] = i # Do not change them to a String via .to_s end
#¶ ↑
set_permanently_extract_to
¶ ↑
This method will permanently set a new directory to which we will extract to.
To invoke this method, do something such as:
ry --permanently_extract_to=/Depot ry --permanently_extract_to=/opt ry --permanently_extract_to=$TEMP_DIR
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12225 def set_permanently_extract_to( i = nil ) if i target = RBT.permanently_set_temp_directory(i) opne "The RBT scripts will henceforthwith be extracted "\ "towards `#{sdir(target)}`." else opne 'Please provide an argument.' end end
#¶ ↑
set_pkgconfig_symlink
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 24703 def set_pkgconfig_symlink( i = true ) case i # Sanitize yes/no values. when 'yes','y' i = true when 'no','n' i = false end if block_given? case yielded when :be_verbose if i == true show_enable_pkgconfig_symlinking_message else opne "Disabling pkgconfig-symlinking of .pc files into `"\ "#{sdir('/usr/lib/pkgconfig/')}`." end end end if cookbook_dataset? cookbook_dataset?.symlink_pkgconfig_files = i else e 'No cookbook-dataset object could be found.' end end
#¶ ↑
set_postinstallation
¶ ↑
Note that the postinstallation steps will always be stored as an Array.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 23285 def set_postinstallation(i) @internal_hash[:postinstallation] = [i].flatten.compact end
#¶ ↑
set_preinstall_action
¶ ↑
This method can be used to set different pre-install actions.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27446 def set_preinstall_action(i) if i.is_a? String # Strings will become an Array here. if i.include? ',' i = i.split(',').map(&:strip) elsif i.include? ';' i = i.split(';').map(&:strip) end end cookbook_dataset?.preinstall = i end
#¶ ↑
set_program_version
¶ ↑
Use this method to assign to a new program version at hand.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 1343 def set_program_version(i) # ======================================================================= # # The program version is presently (December 2018) not allowed # to include a '/' character - possibly never allowed to have # this character. Thus, if we encounter such a character we # will apply File.basename() on this input. # ======================================================================= # if i.include? '/' i = File.basename(i).delete('/') end i.delete!('/') if i.include? '/' # ======================================================================= # # Keep track which specific program version we will use. # ======================================================================= # @internal_hash[:use_this_specific_program_version] = i # ======================================================================= # # The following code is semi-experimental - we will also sync onto # the cookbook dataset object if it exists. We do this primarily # so that class Flexbox can show the proper prefix in use. # ======================================================================= # if cookbook_dataset? cookbook_dataset?.set_program_version(i) if is_this_an_appdir_prefix? cookbook_dataset?.prefix? cookbook_dataset?.update_appdir_prefix end if use_appdir_prefix? # =================================================================== # # We know that we wish to use a special appdir prefix, so use it. # =================================================================== # set_user_prefix(return_appdir_prefix) end end end
#¶ ↑
set_short_name
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27437 def set_short_name(i) cookbook_dataset?.set_short_name(i) end
#¶ ↑
set_skip_extracting
¶ ↑
Use this method when we shall skip the extracting phase.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 19012 def set_skip_extracting( be_verbose = true ) if be_verbose opne 'We will not extract our source, thus we will skip '\ 'extracting the archive.' end @internal_hash[:skip_extracting] = true end
#¶ ↑
set_symlink_program
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 24212 def set_symlink_program( compile_this_program = compile_which_program?, use_this_program_version = program_version? ) # ======================================================================= # # We will delegate towards class RBT::SymlinkFromToCurrent next. # ======================================================================= # _ = RBT::SymlinkFromToCurrent.new( [ # Pass an Array here. compile_this_program, use_this_program_version ], :do_not_run_yet ) {{ use_opn: use_opn? }} @internal_hash[:symlink_program] = _ end
#¶ ↑
set_these_env_variables
¶ ↑
This method can be used to modify ENV variables.
The first input argument to this method should be the Hash, consisting of the key-value pairs in the form of key being the NAME of the shell variable that is to be modified; and the corresponding value being the new VALUE that you wish to set this variable to.
The third argument to this method determines whether we will output what we do to the user. By default this is true, but sometimes we may want to be able to quietly set these environment variables, such as when we attempt to use clang.
Legitimate usage examples for this method, in ruby, would be:
set_this_env_variable 'CFLAGS = -gcc' set_this_env_variable 'LIBS: -lpthread'
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18713 def set_these_env_variables( hash_or_string, # We allow Hash and String as input. But String must be in a special format. do_which_action = :report_only, be_verbose = true ) if block_given? yielded = yield if yielded.is_a? Symbol do_which_action = yielded end end unless @internal_hash[:do_not_use_special_flags] case do_which_action when :be_quiet, :be_silent be_verbose = false # =================================================================== # # Also change the do_which_action variable. # =================================================================== # do_which_action = :do_set_these_variables end case be_verbose when :be_verbose be_verbose = true when :be_quiet, :be_silent be_verbose = false end # ===================================================================== # # === Next, handle Strings # ===================================================================== # if hash_or_string.is_a? String if hash_or_string.include?('=') or hash_or_string.include?(':') if hash_or_string.include?('=') use_this_as_split_token = '=' elsif hash_or_string.include?(':') use_this_as_split_token = ':' end splitted = hash_or_string.sub(/^export /,'').split(use_this_as_split_token) this_key = splitted.first this_value = splitted.last hash_or_string = { this_key => this_value } end end # ===================================================================== # # === Next, handle Hashes # ===================================================================== # hash_or_string.each_pair {|key, value| value.strip! if value.is_a? String # =================================================================== # # Make some exceptions, e. g. for gems. # =================================================================== # return if is_a_gem? if be_verbose and is_compiled? and !extract_only? and not value.to_s.empty? # ================================================================= # # Notify the user as to the env-value modification. Since as of # November 2018 we will no longer use opnn() here. # ================================================================= # e " #{sfancy(key)} will be set to the "\ "value(s): #{lightblue(value.to_s)}" end if value.is_a? FalseClass or value.is_a? TrueClass or value.is_a? Integer value = value.to_s end case do_which_action when :do_set_these_variables # ================================================================= # # Next set the value to the environment variable. # ================================================================= # ENV[key] = value end } end end
#¶ ↑
set_url1
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27491 def set_url1(i) cookbook_dataset?.set_url1(i) end
#¶ ↑
set_use_these_configure_options
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18185 def set_use_these_configure_options(i) i.tr!(N,' ') if i.include? N i.squeeze!(' ') @internal_hash[:configure_options] = i end
#¶ ↑
set_use_this_build_system
¶ ↑
Consistently use this method when you modify the value at @internal_hash.
We need to ensure that it is a Symbol.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27414 def set_use_this_build_system(i) i = i.to_sym unless i.is_a? Symbol @internal_hash[:use_this_build_system] = i end
#¶ ↑
set_user_prefix
(set_prefix
tag, set prefix tag)¶ ↑
This method can be used by the user, to designate another prefix in use for the given program. This will be the target directory into which the program will be installed into.
A specialized class, called RBT::Prefix
, will handle the prefix.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 23527 def set_user_prefix( i = :appdir_prefix ) # ======================================================================= # # We must rewrite the program version in the following case. # # The input may look like this: # # "/Programs/Gobjectintrospection/1.53.4/" # # ======================================================================= # if i and use_this_specific_program_version? if i.is_a?(String) and i.include?(programs_directory?) use_this_regex = /(\d{1,2}\.?\d{1,2}\.?\d{1,2}\/)$/ # See: http://rubular.com/r/PPb2Y96XfF i.sub!(use_this_regex, use_this_specific_program_version?) i << '/' unless i.end_with? '/' elsif i.is_a?(Symbol) i = use_this_specific_program_version? end end if i.is_a? Symbol # ===================================================================== # # Next, perform some sanitize operations. # # This clause will handle Symbols such as :app_dir_like or # :use_ntrad_prefix_at_a_later_time. # ===================================================================== # case i.to_s # case tag # ===================================================================== # # === ULOCAL # # This refers to the commonly used /usr/local/ directory. # ===================================================================== # when 'ULOCAL' i = '/usr/local/' # ===================================================================== # # === trad # ===================================================================== # when /^trad$/ i = '/usr/' # ===================================================================== # # === --opt_prefix # ===================================================================== # when /^-?-?opt(_|-)?prefix$/, :opt i = '/opt/' # ===================================================================== # # === non_traditional # ===================================================================== # when /^app(_|-)?dir$/, /^app(_|-)?dir(_|-)?like$/, /^use(_|-)?appdir(_|-)?prefix$/i, /^use(_|-)?ntrad(_|-)?prefix(_|-)?at(_|-)?a(_|-)?later(_|-)?time$/i, 'non_traditional', 'gobolinux', 'ntrad', 'default', 'app_dir_like', 'appdir', 'return_appdir_path', 'false', 'f', 'appdir_prefix', '' i = return_non_traditional_prefix(handle_which_program?) # =================================================================== # # Since as of May 2014 we get rid of all '-' # =================================================================== # i.delete!('-') if i.include? '-' end # ===================================================================== # # === Convert environment variables, if given, and unfreeze frozen # Strings # ===================================================================== # if i.is_a?(String) # =================================================================== # # Unfreeze frozen Strings. # =================================================================== # if i.is_a? String and i.frozen? i = i.dup # "unfreeze" it. end # =================================================================== # # === Handle Strings that start with the ':' character # # Handle the situation when we input a String that starts with # the character ':'. This will be assumed to be a shortcut to # an environment variable. # =================================================================== # if i.start_with?(':') # ================================================================= # # Next, we must add the proper program_version. This is either the # program_version at hand - or it is an ENV variable if it exists. # We check for the ENV variable first. # ================================================================= # this_key = (i.delete(':').upcase+'_PREFIX').dup if ENV.has_key? this_key # =============================================================== # # The environment variables must be UPCASED and have appended # the string '_PREFIX'. # =============================================================== # i = ENV[this_key].dup.to_s else # =============================================================== # # Assume a special prefix variant targetting the /Programs/ # hierarchy. # =============================================================== # i = programs_directory?+i.to_s.delete(':').capitalize+'/' i << program_version?.dup.to_s end end if i.include?('$') i = convert_env_variable(i) # Replace ENV variables here. i << '/' unless i.end_with? '/' end if i.include? '--' if i.include? '--prefix=' # Input is assumed to be like '--prefix=/Depot/j' i = i.split('=').last # ← Obtain just the last part in this case. end end end # ===================================================================== # # === Ensure a trailing '/' for directories. # ===================================================================== # unless i.to_s.end_with? '/' # .to_s to protect against Symbols given. i << '/' if File.directory?(i.to_s) end end i = RBT::Prefix.new(i) # class RBT::Prefix will handle every prefix. # ======================================================================= # # Next, we must check for post-install actions and modify these, # if they exist. We only do so if we have an AppDir-prefix. # ======================================================================= # if is_an_appdir_prefix?(i.to_s) consider_modifying_postinstall end @internal_hash[:user_prefix] = i end
#¶ ↑
show_all_about
¶ ↑
This method will show the full content of a specific .yml file.
To invoke this method, do something like the following:
ry htop show_all
#¶ ↑
# File lib/rbt/compile/compile.rb, line 29189 def show_all_about( show_this_program = search_for_this_program? # or internal_program_name? ) require 'rbt/utility_scripts/show_all_about.rb' RBT::ShowAllAbout.new(show_this_program) end
#¶ ↑
show_all_binaries_of_this_program
¶ ↑
Use this method to show the registered binaries of the input-argument, the given program at hand. This will display these binaries in one line, as a “Hash”.
Invocation example:
rbt binutils --binaries-as-one-line?
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28751 def show_all_binaries_of_this_program( this_program = compile_which_program?, report_how = :one_line_per_program # The only other mode is :report_in_one_line ) case this_program # ======================================================================= # # === :default # ======================================================================= # when :default this_program = compile_which_program? end if dataset?.nil? ensure_that_a_dataset_exists_for_this_program(this_program) end _ = binaries? # Grab the registered binaries here. if _.empty? opne "No binaries/executables appear to be registered for "\ "the program `#{sfancy(this_program)}`." else case report_how when :one_line_per_program, :default e; _.each_with_index {|this_binary, index| index += 1 index = " #{slateblue((index.to_s+') ').rjust(5))}" e "#{index}#{sfancy(this_binary)}" }; e else # else we use another mode. result = '{'.dup result << _.join(',') result << '}' e result end end end
#¶ ↑
show_all_locally_available_programs
¶ ↑
Invocation example:
rbt --locally-available-programs?
#¶ ↑
# File lib/rbt/compile/compile.rb, line 29013 def show_all_locally_available_programs( slice_n_chunks = 3 ) programs_dir = programs_dir? all_dirs = Dir[programs_dir+'*'].select {|entry| File.directory? entry } all_dirs.map! {|entry| use_this_regex = /^#{programs_dir}/ entry = entry.sub(use_this_regex,'') entry # .downcase # To downcase or not to downcase. } n_programs = all_dirs.size.to_s opne "The locally available `#{orange(n_programs)}` programs are:" sliced = all_dirs.each_slice(slice_n_chunks) result = ' '.dup sliced.each {|inner_group_array| joined = inner_group_array.map {|entry| (entry+',').ljust(25) }.join result << ' '+sfancy(joined.strip).delete(',')+N } result = result.strip.chop.chomp.strip result.sub!(/,\e\[0;37$/, '.') # Reformat it. e e result e end
#¶ ↑
show_all_profiles_fitting_to_this_program
¶ ↑
This method can be used to show all profiles fitting to this program, such as gcc.
Invocation example:
ry --show-these-profiles=gcc
#¶ ↑
# File lib/rbt/compile/compile.rb, line 24014 def show_all_profiles_fitting_to_this_program(i = :gcc) all_available_profiles = return_files_from_the_profiles_directory selection = all_available_profiles.select {|entry| File.basename(entry).include? i.to_s } if selection.empty? opne 'No profiles were found for the program '\ 'called '+steelblue(i.to_s)+'.' else opne "#{rev}The following profiles were found for the program #{sfancy(i)}:" e selection.each_with_index {|this_file, index| index += 1 short_name_of_the_file = File.basename(this_file).sub(/.md$/,'') colourized_index = royalblue('[')+orangered(index)+royalblue(']') e " #{colourized_index} #{steelblue(short_name_of_the_file)}" } e end end
#¶ ↑
show_and_store_json_for
¶ ↑
This method will load the expanded cookbook dataset (a yaml file), and convert this into json, via the .to_json method.
Invocation example:
rbt htop --json
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15761 def show_and_store_json_for( this_program = compile_which_program? ) require 'json' hash = {} opne 'The json dataset for '+steelblue(this_program)+' is:' dataset = load_dataset_from_this_expanded_cookbook(this_program) hash[this_program.to_sym] = dataset e pp hash e opne 'This will be stored into the current directory as well.' what = hash.to_json # ======================================================================= # # Decide where to store the json-file. # ======================================================================= # into = "#{this_program}.json" opne 'Storing into the file `'+sfile(into)+'`.' write_what_into(what, into) end
#¶ ↑
show_available_aliases
¶ ↑
To invoke this method, do:
rbt --aliases?
#¶ ↑
# File lib/rbt/compile/compile.rb, line 10900 def show_available_aliases _ = RBT.cookbook_aliases? opne "The available #{sfancy(_.size.to_s)} aliases are:" index = 0 _.each_pair {|key, value| index += 1 colourized_index = slateblue((index.to_s+')').rjust(5)) e colourized_index+' '+sfancy(key.ljust(18))+ mediumseagreen(' → ')+simp(value) } end
#¶ ↑
show_available_batch_compile_options
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28122 def show_available_batch_compile_options( this_file = RBT.file_cookbook_chained_programs ) if File.exist? this_file dataset = YAML.load_file(this_file) keys = dataset.keys opne "These #{teal(keys.size)} entries exist:"; e keys.each {|this_entry_point| e " #{sfancy(this_entry_point)}" }; e else opnn; no_such_file_exists(this_file) end end
#¶ ↑
show_available_headers_of_this_program
¶ ↑
This method will show the available headers of the given program at hand.
Invocation example:
ry glibc --headers?
#¶ ↑
# File lib/rbt/compile/compile.rb, line 21548 def show_available_headers_of_this_program( i = compile_which_program? ) array_headers = cookbook_dataset_headers? if array_headers.empty? opne "The program `#{sfancy(i)}` will not install any .h files." else opne "The program `#{sfancy(i)}` will install these .h files:" e array_headers.each {|this_header_file| e " #{sfancy(this_header_file)}" } e end end
#¶ ↑
show_available_profiles
¶ ↑
This method will show the available (local) profiles.
To invoke this method try:
rbt --show-available-profiles
#¶ ↑
# File lib/rbt/compile/compile.rb, line 24774 def show_available_profiles( target_directory = DIRECTORY_RBT_PROFILES ) available_profiles = return_files_from_the_profiles_directory.map {|entry| File.basename(entry).sub(/.md$/,'') } if available_profiles.empty? opne "No profiles could be found in the directory "\ "#{sdir(target_directory)}." else e "#{rev}The following profiles are available:" e available_profiles.each_with_index {|entry, index| index += 1 result = " #{entry.ljust(45)}# #{seagreen(index.to_s.rjust(2))}" e slateblue(result) } e end end
#¶ ↑
show_build_systems_priorities
¶ ↑
Invocation example:
rbt --prioritize?
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27942 def show_build_systems_priorities array = return_build_systems_priorities e e lightgreen( 'The build system priority is the following '\ '(first one has higher priority):' ) e array.each_with_index {|content, index| index += 1 e slateblue(("(#{index}) ").rjust(6))+ orange(content) } e e 'Remember that the per-yaml setting "'+ steelblue('use_this_build_system')+'" cat' e 'overrule this.' e end
#¶ ↑
show_compile_chain
¶ ↑
Show all members of a particular compile-chain.
Invocation examples:
ry --show-chain=plasma ry --show-compile-chain-of=kde5_plasma ry --compile-chain-of=kde5_plasma ry --view=kde5_plasma ry --view=xfce
#¶ ↑
# File lib/rbt/compile/compile.rb, line 29382 def show_compile_chain(i) ShowCompileChain.of(i) end
#¶ ↑
show_compile_time_statistics
¶ ↑
This method will show compile-time statistics for all the programs that the user has compiled through RBT
.
Invocation example:
ry --show-compile-time-statistics
#¶ ↑
# File lib/rbt/compile/compile.rb, line 10991 def show_compile_time_statistics _ = RBT.file_storing_the_time_it_took_to_compile_programs if File.exist? _ dataset = YAML.load_file(_) if dataset.empty? opne 'The dataset is empty. Have there any programs been '\ 'compiled yet, through '+teal('rbt')+'?' else opne "Showing the compile-time statistics for the "\ "following #{sfancy(dataset.keys.size.to_s)} programs." e # =================================================================== # # Need to sort this dataset by size still. # =================================================================== # sorted_longest_compilation_comes_first = dataset.sort_by {|name_of_the_program, n_seconds| n_seconds }.reverse # =================================================================== # # Show a little header explaining what this is all about. # =================================================================== # e gray('-' * 80) # Next, properly name the header-entries e sfancy('Program name'.ljust(32))+ simp('Compile time [sec] ')+ orange('Compile time [min]')+ mediumslateblue(' Archive file size')+ mediumseagreen(' #') e gray('-' * 80) index = 0 sorted_longest_compilation_comes_first.each {|name_of_the_program, n_seconds| index += 1 left_padded = ("#{name_of_the_program.strip}:").ljust(26) right_padded_showing_n_seconds = ( '%.2f' % n_seconds.to_s.strip.to_f ).rjust(12) right_padded_showing_n_seconds << ' seconds' n_minutes = (n_seconds.to_f / 60.0).round(2) # Rounding to 2 is better. n_minutes = n_minutes.to_s.ljust(4,'0') # ================================================================= # # Next count the amount of numbers before the '.' point. If there # are at the least two numbers, we will .ljust(5,'0') rather than # .ljust(4,'0'). # ================================================================= # if n_minutes.include? '.' first_splitted = n_minutes.split('.').first if first_splitted.size > 1 n_minutes = n_minutes.to_s.ljust(5,'0') end end # ================================================================= # # The program name may be upcased; since we store only downcased # variants for the name of the .yml file at hand, we will also # .downcase() on the program name in the following code. # ================================================================= # archive_size = fast_return_file_size_of_this_program( name_of_the_program.downcase.delete('-') ) colourized_file_size = mediumslateblue( "#{archive_size.to_s.rjust(10)} Kb" ) result = ' '+sfancy(left_padded)+' '+ simp(right_padded_showing_n_seconds)+' '+ orange( ('('+n_minutes).rjust(6)+' minutes)' ) result << ' '+colourized_file_size result << mediumseagreen(" ##{index}") e result } e end else opne "No file exists at `#{sfile(_)}`." opne 'We thus can not show any statistics.' end end
#¶ ↑
show_components
¶ ↑
Invocation example:
ry --show-components=xfce
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28981 def show_components(i) i = i.to_s # Just in case. chained_programs = return_chained_programs if chained_programs.has_key? i _ = chained_programs[i] e e "#{rev}These components belong to #{steelblue(i)}:" e _.each_with_index {|this_program, index| index += 1 e lightgreen(" #{index}) ".rjust(6))+ steelblue(this_program) } e else opne 'No component with that name could be found.' opne 'Available keys are:' e e royalblue( chained_programs.keys.join(', ').strip.chop ) e end end
#¶ ↑
show_downloadable_programs
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15691 def show_downloadable_programs( i = available_programs?.sort ) chunked = i.each_slice(5) opne 'The following programs can be downloaded:' e chunked.each {|this_chunk| e " #{slateblue(this_chunk.join(', ').strip.chop)}" } e end
#¶ ↑
show_gobolinux_instructions
¶ ↑
To invoke this method do:
rbt --show-gobo-instructions
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28240 def show_gobolinux_instructions _ = RUBY_SRC_DIR+'rbt/doc/instructions_for_gobolinux.md' if File.exist? _ e File.read(_) else opnn; no_file_exists_at(_) end end
#¶ ↑
show_help_for_this_program
¶ ↑
Use this method if you wish to feedback how to use this class.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 20245 def show_help_for_this_program( i = '', be_silent = false ) be_silent = true if be_silent == :be_silent e simp(i)+' has these options available:' unless be_silent display_standard_help_options # This is stored in help.rb end
#¶ ↑
show_how_to_batch_compile
¶ ↑
This method will notify the user in how to batch-compile programs via RBT
.
Invocation example:
rbt --show_how_to_batch_compile
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28108 def show_how_to_batch_compile show_available_batch_compile_options e e 'In order to batch-compile one of these, issue a command such as:' e e ' rbt --batch-compile=mate' e ' rbt --batch-compile=vid_base' e ' rbt --batch-compile=terminals' e end
#¶ ↑
show_how_to_compile_kde
¶ ↑
This method will provide some hints on the commandline as to how to batch-compile the various KDE components.
Invocation example:
rbt --show-how-to-compile-kde
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28088 def show_how_to_compile_kde e e ' rbt --batch-compile=kde5_foundation' e ' rbt --batch-compile=kde5_plasma' e ' rbt --batch-compile=kde5_porting_aids' e ' rbt --batch-compile=kde5_applications' e end
#¶ ↑
show_information_about_blfs
¶ ↑
We show some information about BLFS webpages.
To invoke this method, you can issue a command such as this here:
rbt binutils --lfs
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27838 def show_information_about_blfs( use_this_key = :blfs ) ensure_that_this_key_has_a_dataset(use_this_key) dataset = cookbook_dataset? if dataset.has_key?(use_this_key) and !dataset?.blfs?.empty? # .empty? will assume this to be a String. url = dataset?.blfs? if url.is_a? Array url = url.first end e "Url is: #{sfancy(url)}" set_xorg_buffer(url) if is_roebe? else opne "The program #{royalblue(compile_which_program?)} has no blfs entry." end end
#¶ ↑
show_installation_procedure_file
¶ ↑
Show the content of the file called installation_procedure.yml
To invoke this method, try:
rbt --installation-procedure
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28183 def show_installation_procedure_file( this_file = BeautifulUrl['installation_procedere'] ) begin require 'beautiful_url' unless Object.const_defined? :BeautifulUrl rescue LoadError; end this_file = this_file.first if this_file.is_a? Array if File.exist? this_file e File.read(this_file) else opne 'No file called '+sfile(this_file)+' was found.' end end
#¶ ↑
show_last_compiled_program
¶ ↑
Use this method to show the last compiled program.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27861 def show_last_compiled_program( shall_we_exit = false ) shall_we_exit = true if shall_we_exit == :then_exit opne 'The last compiled program was `'+ sfancy(last_compiled_program?)+'` (as registered' opne "in the file #{sfile(RBT.file_compiled_programs)})." exit if shall_we_exit end
#¶ ↑
show_last_options
¶ ↑
Use this method to show the last configure options that were used in order to compile a program from source.
To grab this, try:
ry htop --last-options
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18400 def show_last_options( name_of_the_program = compile_which_program? ) full_configure_command = return_last_configure_command if full_configure_command opne "The last configure command for "\ "`#{simp(name_of_the_program)}` was:" opne " #{simp(full_configure_command)}" else opne "No configure command was used for `#{simp(name_of_the_program)}`." end end
#¶ ↑
show_last_updated
¶ ↑
This method will show the last updated programs.
Invocation example:
ry --last_update
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27709 def show_last_updated( shall_we_exit = true ) require 'rbt/cookbooks/show_last_updated.rb' RBT::Cookbooks::ShowLastUpdated.new # bl $RUBY_COOKBOOKS/lib/cookbooks/show_last_updated.rb exit_program if shall_we_exit end
#¶ ↑
show_minimal_gcc_configure_options
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 24912 def show_minimal_gcc_configure_options _ = directory_rbt_profiles?+'gcc_minimal_but_lots_of_languages_enabled.md' if File.exist? _ dataset = readlines(_).reject {|entry| begins_with_a_comment?(entry) }.join(N).tr(N,' ').squeeze(' ') e e " #{steelblue(dataset)}" e else opnn; no_file_exists_at(_) end end
#¶ ↑
show_n_largest_local_programs
¶ ↑
Show the largest local programs with this method.
Invocation example:
ry --show_highest
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28881 def show_n_largest_local_programs( i = :default ) require 'rbt/cookbooks/highest.rb' case i when :default i = 50 end RBT::Cookbooks::Highest.new(i) exit_program end
#¶ ↑
show_path_to_the_source_directory_yaml_file
¶ ↑
This method will simply show the path to the source_dir.yml file.
Usage example:
rbt --path_to_source_directory?
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28958 def show_path_to_the_source_directory_yaml_file _ = RBT.project_yaml_directory?+'configuration/source_dir.yml' e sfile(_) end
#¶ ↑
show_pc_files_installed_by_this_program
¶ ↑
Invocation example:
ry samba --pkgconfig-files?
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28856 def show_pc_files_installed_by_this_program( i = compile_which_program? ) _ = pc_files? if _.empty? opne 'The program '+simp(i)+' will not install any .pc file.' else opne "The program #{gold(i)} will install "\ "the following #{sfancy(_.size.to_s)} .pc file(s):" e; _.each {|this_pc_file| e " #{sfancy(this_pc_file)}" }; e end end
#¶ ↑
show_programs_with_a_blfs_entry
¶ ↑
Invocation example:
ry --show-all-blfs-entries
#¶ ↑
# File lib/rbt/compile/compile.rb, line 25599 def show_programs_with_a_blfs_entry _ = Dir["#{individual_cookbooks_dir?}*.yml"] matches = _.select {|file| dataset = File.read(file) dataset.include? ' blfs:' }.map {|entry| File.basename(entry).sub(/\.yml$/,'') } unless matches.empty? opne "The following #{sandybrown(matches.size.to_s)} programs "\ "have a #{sfancy('blfs')} entry:" e matches.each_with_index {|name_of_the_program, index| index += 1 index = (index.to_s+') ').rjust(5) remote_url = return_blfs_page_of_this_program(name_of_the_program) e royalblue(index)+slateblue(name_of_the_program.ljust(24))+ lightblue(remote_url.to_s) } e end end
#¶ ↑
show_programs_with_this_as_dependency
¶ ↑
Invocation example:
rbt --show-programs-with-this-as-dependency=cmake
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27806 def show_programs_with_this_as_dependency(i) use_this_key = :required_deps_on e rev+'Next trying to find all programs that depend on '+steelblue(i)+':' e array_these_programs_depend_on_the_given_input = [] available_programs?.each {|this_program| expanded_cookbook_dataset = return_dataset_from_this_expanded_cookbook(this_program) if expanded_cookbook_dataset required_deps_on = expanded_cookbook_dataset[use_this_key] if required_deps_on.include? i array_these_programs_depend_on_the_given_input << this_program e " - #{this_program}" end end } e e "#{rev}A total of "+ royalblue(array_these_programs_depend_on_the_given_input.size.to_s)+ rev+' registered programs depend on '+steelblue(i)+'.' e end
#¶ ↑
show_rbt_intro
¶ ↑
Invocation example:
ry --show-rbt-intro ry --intro
#¶ ↑
# File lib/rbt/compile/compile.rb, line 29049 def show_rbt_intro e e 'Here are some hints to get you started with RBT.' e e "You can compile a program by issuing #{orange('rbt <name>')}." e e 'Example:' e e sfancy(' rbt php') e e 'You can also compile into a standalone app-dir:' e e sfancy(' rbt php ntrad') e sfancy(' rbt php --app-dir') e e 'Both variants are synonymous. If in doubt, using the variants' e 'that start with '+teal('--')+' is recommended.' e e 'To speed-up looking for the dataset stored in the various .yml' e 'files you can also issue the following command:' e e sfancy(' rbt --expand') e e 'This command will expand the dataset into a "sanitized" variant' e 'that requires less pre-processing before it can be used for' e 'compiling/installing programs from source.' e end
#¶ ↑
show_success_or_failure_status
(success tag, failure tag, status tag)¶ ↑
This method will report some things, aka the success or failure status of a program.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 29130 def show_success_or_failure_status # ======================================================================= # # Report the following only if the program has been installed # successfully. # ======================================================================= # if has_the_program_been_installed_successfully? opne "The host system architecture was: "\ "#{slateblue(host_system?)}" if is_a_gem? # =================================================================== # # If it is a .gem file then we will not report as much information. # =================================================================== # opne teal('The program ')+ lightgreen(compile_which_program?)+ teal(' has been installed successfully.') else _ = return_full_configure_command if _.nil? or _.empty? # ================================================================= # # This entry-point is specifically for e. g. perl-addons and # similar programs. # ================================================================= # opne teal('The program ')+lightgreen(compile_which_program?)+ teal(' has been installed successfully.') else opne teal('The program ')+lightgreen(compile_which_program?)+ teal(' has been installed successfully, into the prefix') opne plum(prefix?.to_s)+ teal('. The full configure command was:') e e " #{slateblue(return_full_configure_command)}" e end end else # ===================================================================== # # Else the program has failed during compilation/installation. # ===================================================================== # opne crimson( return_unicode_warning_symbol_or_empty_string+' The program `' )+ teal(compile_which_program?)+ crimson( '` could not be installed. '+ return_unicode_warning_symbol_or_empty_string ) end end
#¶ ↑
show_the_available_gems
¶ ↑
To invoke this method from the commandline, try:
rbt --show-registered-gems
#¶ ↑
# File lib/rbt/compile/compile.rb, line 21879 def show_the_available_gems e opne 'These gems are currently available within the RBT project:' e RBT.array_all_rubygems.each_with_index {|this_gem, index| index += 1 e " #{lightgreen(index.to_s.rjust(4))} #{slateblue(this_gem)}" } e end
#¶ ↑
show_the_flexbox
¶ ↑
This will show the flexbox.
The first argument should be the dataset for the program that we are about to install/compile.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 22146 def show_the_flexbox( compile_this_program = compile_which_program? ) if show_the_flexbox? # =================================================================== # # Next determine whether we shall show the required dependencies # via the flexbox. Since as of November 2020 this is now the # default. At a later point we may disable it again, not sure # yet - but I think showing the dependencies is useful for # the end user, hence why it is now set to true by default. # =================================================================== # shall_we_show_the_required_dependencies_via_the_flexbox = always_show_dependencies? # =================================================================== # # Delegate into AsciiParadise::Flexbox next, if it is available: # =================================================================== # if Object.const_defined? :AsciiParadise e AsciiParadise::Flexbox.new(compile_this_program) {{ show_required_dependencies_on: shall_we_show_the_required_dependencies_via_the_flexbox, use_this_dataset: self, # sanitize_cookbook? use_colours: use_colours? }}.display e end end end
#¶ ↑
show_the_last_configure_option_for_this_program
¶ ↑
This method will make use of the file configure_command_database.yml. Obviously, the file has to exist in order for this to work.
Invocation example:
ry attica --show-last-configure-option-for-this-program
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28208 def show_the_last_configure_option_for_this_program( this_program = compile_which_program? ) _ = RBT.file_configure_database if File.exist? _ dataset = YAML.load_file(_) if dataset.has_key? this_program result = dataset[this_program] opne "The program #{sfancy(this_program)} has "\ "been compiled with this command:" e e " #{sfancy(result)}" # Display it without opnn. e else opne "The program #{sfancy(this_program)} has not "\ "been registered/compiled yet." end else opne "No file exists at `#{sfile(_)}` so we can not proceed." opne 'Nota bene: You should first compile some programs, before' opne 'making use of this method.' end end
#¶ ↑
show_where_the_base_directory_can_be_found
¶ ↑
To test this method, do:
ry htop base_dir?
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28054 def show_where_the_base_directory_can_be_found e opne 'The base directory is at: '.ljust(36)+ sfancy(temp_directory?) unless extract_to?.to_s.empty? opne "We will extract to this directory: "\ "#{sfancy(extract_to?.to_s)}" end e end
#¶ ↑
show_whether_we_are_using_ccache_or_whether_we_are_not
¶ ↑
To invoke this method from the commandline, try:
ry --use-ccache?
#¶ ↑
# File lib/rbt/compile/compile.rb, line 22903 def show_whether_we_are_using_ccache_or_whether_we_are_not _ = use_ccache? opne "Will the RBT project make use of ccache? "\ "#{sfancy(verbose_truth(_))}" end
#¶ ↑
show_which_colours_will_be_used
¶ ↑
To show which colours will be used for the RBT
project.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 12509 def show_which_colours_will_be_used opne 'These colours will be used:' e YAML.load_file(RBT_COLOURS_FILE).each_pair {|key, value| e " #{key.ljust(12)} → #{value}" }; e end
#¶ ↑
show_which_compiler_will_be_used
¶ ↑
This method will show which compiler will be used.
Commandline
invocation:
rbt --compiler?
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27881 def show_which_compiler_will_be_used opne "The compiler that will be used for compiling "\ "programs is `#{slateblue(use_which_compiler?)}`." end
#¶ ↑
show_which_files_will_be_installed
¶ ↑
This method will show to the user which files will be installed.
Invocation examples:
ry htop ifiles ry htop --installed-files ry ruby --installed-files
#¶ ↑
# File lib/rbt/compile/compile.rb, line 28006 def show_which_files_will_be_installed( i = compile_which_program? ) file = static_appdir_prefix?+'yaml/registered_files.yml' if File.exist? file opne 'The following files will be installed by '\ 'the program `'+simp(i)+'`:' dataset = YAML.load_file(file).sort e; dataset.each {|entry| e " #{entry}" }; e else opne "The file #{sfile('registered_files.yml')}"\ " could not be found," opne 'thus we can not show which files are installed.' end end
#¶ ↑
simple_or_complex?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26864 def simple_or_complex? @simple_or_complex end
#¶ ↑
skip_extracting
?¶ ↑
Query-method over as to whether we will skip extracting the archive at hand. This can usually only be done when the archive has already been extracted somehow.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18993 def skip_extracting? _ = @internal_hash[:skip_extracting] _ == true # This check prohibits nil and false. end
#¶ ↑
sort_configure_options_alphabetically
(sort tag)¶ ↑
This is simply a convenience method - we will quickly sort the Array of configure-options alphabetically here.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 29239 def sort_configure_options_alphabetically _ = configure_options? if _.include? ' ' splitted = _.split(' ') sorted = splitted.sort { |a, b| a.delete('-') <=> b.delete('-') }.reverse joined = sorted.join(' ') set_configure_options(joined) end end
#¶ ↑
speed_up_the_compilation
¶ ↑
We can speed up compilation via the -j option to “make”. Keep in mind that we have to avoid the number “0”, though, as make would complain when this is used.
See:
https://www.math-linux.com/linux/tip-of-the-day/article/speedup-gnu-make-build-and-compilation-process
#¶ ↑
# File lib/rbt/compile/compile.rb, line 16515 def speed_up_the_compilation use_n_processors = return_n_processors if use_n_processors <= 0 use_n_processors = 1 # ← 1 is always the minimum. "make -j0" would lead to errors. end append_parameters_to_make( " -j#{use_n_processors}" ) end
#¶ ↑
stop_on_error
¶ ↑
Method call to stop if the user wanted to.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 20091 def stop_on_error( be_verbose = true ) if be_verbose stderr return_opnn, :use_print stderr 'We will exit now because this behaviour is enabled' stderr return_opnn, :use_print stderr "in the configuration file (the entry: #{teal('stop_on_error')})." end exit_program if stop_on_error? end
#¶ ↑
store_this_as_last_libtool_file
¶ ↑
We will remove “‘ or unhandled argument” if it is part of the given input at hand.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 22418 def store_this_as_last_libtool_file(what) # ======================================================================= # # First sanitize the input a little bit: # ======================================================================= # if what.include? "' or unhandled argument" what = what.split(/' or unhandled argument/).first end unless what.empty? base_dir = "#{rbt_log_directory?}libtool/" mkdir(base_dir) unless File.directory? base_dir into = "#{base_dir}last_faulty_libtool_file.md" if is_on_roebe? if File.exist?(into) and File.read(into).strip.end_with? what # =================================================================== # # In this case, we will not store the same result again. # =================================================================== # return end opne "Also storing `#{royalblue(what)}` into `#{sfile(into)}`." end write_what_into(what, into) end end
#¶ ↑
strip_the_binaries_of_this_program
¶ ↑
Invocation example:
rbt --strip-binaries-of=htop
#¶ ↑
# File lib/rbt/compile/compile.rb, line 24596 def strip_the_binaries_of_this_program(i) [i].flatten.compact.each {|this_program| binaries_of_this_program = RBT.return_binaries_of_this_program(this_program) if binaries_of_this_program.empty? opne "The program #{sfancy(this_program)} has no associated binaries." opne 'Thus, "strip" can not be run on these binaries.' else opne 'Now running "strip" on '+ sfancy(binaries_of_this_program.size.to_s)+ ' programs:' binaries_of_this_program.each {|this_binary| run_the_strip_command_on_this_input(this_binary) } end } end
#¶ ↑
symlink_all_programs
¶ ↑
Use this method to symlink all programs in the $PROGRAMS directory.
Usage example to trigger this method:
ry htop symlink_all_programs
#¶ ↑
# File lib/rbt/compile/compile.rb, line 24282 def symlink_all_programs( may_we_symlink = !do_not_symlink? ) case may_we_symlink when :do_it may_we_symlink = true end # ======================================================================= # # @do_not_symlink = dataset?.do_not_symlink? if dataset?.do_not_symlink? # ======================================================================= # if may_we_symlink require 'rbt/utility_scripts/symlink_all_programs.rb' _ = RBT::SymlinkAllPrograms.new # bl $RBT/utility_scripts/symlink_all_programs.rb opne "We have finished symlinking all programs in "\ "#{sdir(_.programs_directory?)}." end end
#¶ ↑
symlink_glib_schema
¶ ↑
The default prefix, aka the first input argument, should be fine for this class.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 24383 def symlink_glib_schema( prefix_where_the_schema_files_reside = program_dir?+ internal_program_name?.capitalize+ '/Current/share/glib-2.0/schemas/' ) if File.directory? prefix_where_the_schema_files_reside RBT::SymlinkGlibSchema.new(prefix_where_the_schema_files_reside) { :do_not_report_when_anything_is_missing } end end
#¶ ↑
symlink_headers?¶ ↑
Use this method if you need to find out whether we shall symlink the .h files into the “/usr/include/” hierarchy or whether we should not.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 24368 def symlink_headers? _ = cookbook_dataset_symlink_headers? unless @internal_hash[:symlink_headers].nil? _ = @internal_hash[:symlink_headers] end _ end
#¶ ↑
symlink_the_available_gir_files_into_this_target_directory
¶ ↑
This is the “action” method, that is the method that will symlink all .gir files into the given target directory at hand.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15280 def symlink_the_available_gir_files_into_this_target_directory( target_directory = :default_target ) case target_directory when :default_target target_directory = '/usr/share/gir-1.0/' end gir_files?.each {|this_file| original_and_existing_gir_file = "#{prefix?}share/gir-1.0/#{this_file}" target_file = "#{target_directory}#{this_file}" if File.exist?(target_file) and target_file.end_with?('.gir') delete_file(target_file) end symlink(original_and_existing_gir_file, target_file) } end
#¶ ↑
to_tar_xz
¶ ↑
This method can be used to create a .tar.xz archive.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18966 def to_tar_xz(i, &block) if Object.const_defined? :ToTarXz ToTarXz.new(i, &block) else opne "ToTarXz is not available. It can be installed via: "\ "#{steelblue('gem install to_tar_xz')}" end end
#¶ ↑
try_to_autocorrect_this_erroneous_libtool_entry
¶ ↑
This method will delegate towards class RBT::Libtool
in order to fix a faulty .la file.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 22324 def try_to_autocorrect_this_erroneous_libtool_entry(i) require 'rbt/libtool/class_methods/autocorrect_this_file.rb' opne "Now delegating towards class #{slateblue('RBT::Libtool')}"\ " to attempt to autocorrect the problem:" opne " #{sfancy(i)}" RBT::Libtool.autocorrect_this_file(i) # ======================================================================= # # The next subsection can re-compile again. We do so at maximum # 5 times. # ======================================================================= # if is_on_roebe? and try_to_autofix? and compiled_n_times? < 5 increment_compiled_counter # Add +1 to the times we have tried to compile. clear_problems compile_this_program_again(program?) end end
#¶ ↑
try_to_autocorrect_this_erroneous_libtool_entry_later
¶ ↑
Use this method to register an erroneous libtool entry. It will be fixed at a later time during the regular compile-cycle.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 22354 def try_to_autocorrect_this_erroneous_libtool_entry_later(i) # ======================================================================= # # Store this faulty .la entry into a local file as well, next. This # was added in September 2018. # ======================================================================= # store_this_as_last_libtool_file(i) @internal_hash[:invalid_libtool_archive] = i # This is the libtool-entry that should go away. opne 'Note that you can try to correct this error via:' e e orange(' rbt --fix-libtool-from-file') e end
#¶ ↑
try_to_autofix?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26609 def try_to_autofix? @internal_hash[:try_to_autofix] end
#¶ ↑
try_to_automatically_setup_the_rbt_project
¶ ↑
This method could be used to automatically try and setup the project on a default GoboLinux system.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 16313 def try_to_automatically_setup_the_rbt_project if RBT.is_this_a_real_gobolinux_system? opne 'Found a local GoboLinux system.' opne 'Setting up some settings to make use of this as our host system.' target_file = log_dir?+'is_on_gobolinux.md' write_what_into('1', target_file) opne 'This will be stored into the file `'+sfile(target_file)+'`.' end end
#¶ ↑
try_to_batch_compile_this_stack
¶ ↑
This method can be used to batch-compile several applications.
Invocation examples:
rbt --batch-compile=autotools rbt --batch-compile=vid_suite rbt --batch-compile=mate rbt --batch-compile=kde5_porting_aids
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14893 def try_to_batch_compile_this_stack(i) # ======================================================================= # # === Do some sanitizing of the input first. # ======================================================================= # case i # ======================================================================= # # === rbt --batch-compile=phonon # ======================================================================= # when 'phonon', /^kde(_|-)?plasma/ i = 'kde5_plasma' # ======================================================================= # # === rbt --batch-compile=kde_apps # ======================================================================= # when /^kde(_|-)?apps/ i = 'kde5_applications' # ======================================================================= # # === rbt --batch-compile=protos # ======================================================================= # when 'protos' i = 'xorg_protos' end case i # case tag # ======================================================================= # # === rbt --batch-compile=kde5_porting_aids # ======================================================================= # when /^kde5?(_|-)?porting(_|-)?aids?$/i, /^porting(_|-)?aids?$/i i = return_kde5_porting_aids # ======================================================================= # # === rbt --batch-compile=mate # ======================================================================= # when 'mate', /^mate(-|_)?desktop$/ i = RBT.returned_chained_programs_of_the_mate_desktop opne "We will compile all #{sfancy(i.size.to_s)} programs "\ "of the mate-desktop." opne 'These include:' e; i.each {|entry| e ' - '+sfancy(entry) }; e else hash = return_chained_programs i = hash[i] end if i.is_a? String and i.include? ',' i = i.split(',').map(&:strip).flatten # Now it should be an Array. end if i.is_a? Array i.map! {|entry| entry.delete('-') } end return i end
#¶ ↑
try_to_compile_these_kde_programs
¶ ↑
This method has to remain flexible, because the input may be “first=20” or “last=20” and so forth.
Invocation example:
ry --kde1-first=10
#¶ ↑
# File lib/rbt/compile/compile.rb, line 21605 def try_to_compile_these_kde_programs(i) if i.frozen? i = i.dup end if i.start_with? '--' i.sub!(/^--/,'') end if i.include? '-' these_programs = [] splitted = i.split('-') # Like: "kde1-first=10" last = splitted.last first = splitted.first case first when 'kde1' these_programs = return_these_programs(:kde5_foundation) when 'kde2' these_programs = return_these_programs(:kde5_plasma) when 'kde3' these_programs = return_these_programs(:kde5_porting_aids) when 'kde4' these_programs = return_these_programs(:kde5_applications) end if last # May be like this: "first=10" if last.include? 'first=' n_programs = last.sub(/first=/,'').to_i these_programs = these_programs[0 .. (n_programs - 1)] end end set_compile_these_programs(these_programs) end end
#¶ ↑
try_to_find_an_alias_to_this_input_unless_the_program_exists
¶ ↑
This method will either return the original input unmodified; or it will modify the input in such a way that it points to a valid, registered program.
For example, the String “ph” may become “php”.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15637 def try_to_find_an_alias_to_this_input_unless_the_program_exists(i) unless cookbooks_include_this_program? i.downcase is_the_program_included = cookbooks_include_this_program?( i.downcase, :with_abbreviations ) if is_the_program_included i = abbreviations?[i.downcase] end end i end
#¶ ↑
try_to_fix_all_shebangs
¶ ↑
Use this to fix shebangs of the RBT
project.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13339 def try_to_fix_all_shebangs begin require 'roebe/classes/shebang_fixer.rb' cliner { opne 'Trying to fix all Shebangs now:' entries = Dir["#{base_directory?}**/**.rb"] entries.each { |file| file = ENV['RBT_DIR'].to_s+'/'+file Roebe::ShebangFixer.new(file) } } rescue LoadError e 'class Roebe::ShebangFixer is not available.' end end
#¶ ↑
try_to_output_how_many_processors_this_computer_has
¶ ↑
To try this method on the commandline, do:
rbt --n-cores?
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13270 def try_to_output_how_many_processors_this_computer_has( file_cpuinfo = FILE_CPUINFO ) if File.exist? file_cpuinfo opne 'This computer has '+ lightseagreen( return_n_processors_of_this_computer.to_s+' processors' )+'.' else opne 'Can not determine the number of processors as ' opne "there is no file at #{sfile(file_cpuinfo)}." end end
#¶ ↑
try_to_show_all_binary_duplicates_of_this_program
¶ ↑
Use this method to show which binary duplicates exist for the given input program.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15493 def try_to_show_all_binary_duplicates_of_this_program( i = compile_which_program? ) program_name = i if i.nil? opne 'A nil value has been found in '+orange(__method__.to_s)+'.' pp caller() end capitalized_program_name = program_name.capitalize target = programs_directory?+ capitalized_program_name+ program_name.capitalize+'/Current/bin/*' opne 'Obtaining all files at `'+sdir(target)+'`.' all_binaries = Dir[target] all_binaries.select! {|entry| File.exist? '/usr/bin/'+File.basename(entry) } if all_binaries.empty? opne 'The '+sdir('/usr/bin/')+' hierarchy does not contain '\ 'any of the binaries' opne "belonging to #{sfancy(program_name)}." else n_duplicates = all_binaries.size.to_s opne "Found #{sfancy(n_duplicates)} binary duplicates." all_binaries.each {|file| e "/usr/bin/#{File.basename(file)}" } end end
#¶ ↑
try_to_show_the_BLFS_content_of_this_program
¶ ↑
This method can be used to show the BLFS content of a program on the commandline.
The argument to this method should be the program that you wish to display on the commandline here.
Invocation examples:
ry gcc --paste-blfs-page ry libffi --paste-blfs-page ry php --paste-blfs-page
#¶ ↑
# File lib/rbt/compile/compile.rb, line 25469 def try_to_show_the_BLFS_content_of_this_program( i = compile_which_program? ) # ======================================================================= # # First, obtain the remove URL that points to the BLFS page. # ======================================================================= # remote_url = RBT.return_blfs_page_of_this_program(i) into_this_html_file = nil if remote_url what = ''.dup opne "A remote URL has been found, at `#{sfancy(remote_url)}`." opne 'We will next display the content of this remote page '\ 'on the commandline.' remote_dataset = URI.open(remote_url).read opne 'The data was obtained ('+steelblue('Encoding:')+ ' '+steelblue(remote_dataset.encoding.to_s)+')' store_here = "#{log_dir?}blfs_webpages/" mkdir(store_here) unless File.directory? store_here into_this_html_file = store_here+'blfs_page_for_'+i+'.html' opne 'It will be stored into the following file: ' e e " #{sfile(into_this_html_file)}" e write_what_into(remote_dataset, into_this_html_file) if into_this_html_file and File.exist? into_this_html_file remote_dataset = File.read(into_this_html_file, encoding: iso_encoding?) end opne 'Next, the content of that webpage will be shown as a '+ gold('STRING') opne 'on the commandline, but we will remove all HTML tags.' begin sanitized_dataset = remote_dataset.gsub(/<\/?[^>]*>/, '') sanitized_dataset = sanitized_dataset.split(N).reject {|line| line.strip.empty? } rescue ArgumentError => error pp error end # ===================================================================== # # Some HTML entities may have to be re-formatted, for display on the # commandline. For example, '&' is actually Ampersand aka '&' # token. # ===================================================================== # if sanitized_dataset.map! {|entry| if entry.include? '&' entry.gsub!(/&/,'&') end entry } end cliner { sanitized_dataset.each_with_index {|line, index| index += 1 line = to_unicode(line) e steelblue(index.to_s+') ')+ sfancy(line) what << "#{line}\n" } } if is_on_roebe? # =================================================================== # # On my home systems, we will also save this result into a # local file. # =================================================================== # target_directory = log_dir?+'blfs/' mkdir(target_directory) unless File.directory? target_directory into = target_directory+i+'.md' # <- Store it as a .md file. write_what_into_via_unicode(what, into) if into_this_html_file opne 'This dataset has also been stored into the '\ 'file `'+sfile(into)+'`.' end end opne "The web-page itself, as a .html page, is "\ "available at:" e e " #{sfile(into_this_html_file)}" e else opne "No BLFS entry is registered for the program `#{sfancy(i)}`." end end
#¶ ↑
try_to_use_configure_options?¶ ↑
Query whether we will make use of configure options.
Note that this is true by default.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26406 def try_to_use_configure_options? _ = true # ← True by default. unless @internal_hash[:try_to_use_configure_options].nil? _ = @internal_hash[:try_to_use_configure_options] end _ end
#¶ ↑
try_to_use_the_file_windows_cookbook
?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26004 def try_to_use_the_file_windows_cookbook? config?.try_to_use_the_file_windows_cookbook end
#¶ ↑
try_to_use_this_profile
¶ ↑
The .tr() operation in the method body is valid, because we will only store the filenames in a lowercased variant, such as “gcc_minimal.md” rather than “gcc-minimal.md”.
Usage examples:
ry gcc --profile=gcc_lfs_pass1 ry gcc --profile=gcc_minimal
#¶ ↑
# File lib/rbt/compile/compile.rb, line 24817 def try_to_use_this_profile(i) i = i.to_s.dup.tr('-','_') if i.start_with? '-' # This is always a mistake, for the time being, so remove it. i[/^-+/] = '' elsif i.start_with? '_' # This is always a mistake, for the time being, so remove it. i[/^_+/] = '' end case i # ======================================================================= # # === gcc-minimal-but-lots-of-languages # # To use this entry point, try: # # ry gcc trad --profile=gccp1 # ry gcc --ntrad --use-profile-minimal-gcc-but-lots-of-languages # # ======================================================================= # when /^gcc(-|_)?minimal(-|_)?but(-|_)?lots(-|_)?of(-|_)?languages$/i, /^gcc(-|_)?minimal(-|_)?but(-|_)?lots(-|_)?of(-|_)?languages(-|_)?enabled$/i, /^basic(-|_)?gcc(-|_)?but(-|_)?with(-|_)?lots(-|_)?of(-|_)?languages(-|_)?enabled$/i, /^-?-?basic(-|_)?gcc$/i, /^language(-|_)?rich$/i, 'gccp1', /:?gcc1$/i, :basic_gcc, :basic_gcc_but_with_lots_of_languages_enabled i = 'gcc_minimal_but_lots_of_languages_enabled' if no_cookbook_dataset? set_really_compile_this_program(:gcc) end # ======================================================================= # # === Use the LFS "recommended" version for GLIBC # # Invocation example: # # ry glibc ntrad --dont-symlink --use-glibc1-profile # # ======================================================================= # when /^default(-|_)?lfs(-|_)?glibc$/i, :glibc1 i = 'default_lfs_glibc' # ======================================================================= # # === qt # ======================================================================= # when 'qt' if no_cookbook_dataset? set_really_compile_this_program(:qt) end # ======================================================================= # # === gcc_lfs_pass_1 # ======================================================================= # when /^gcc(_|-)?lfs(_|-)?pass(_|-)?1$/ i = 'gcc_lfs_pass1.md' if no_cookbook_dataset? set_really_compile_this_program(:gcc) end end i = i.dup if i.frozen? # ======================================================================= # # First we will have to try to find the proper profile: # ======================================================================= # i << '.md' unless i.end_with? '.md' target = "#{DIRECTORY_RBT_PROFILES}#{i}" if File.exist? target opne 'Making use of the profile found at this location:' e opne " #{sfile(target)}" e # ===================================================================== # # The file exists, so we can load it. # ===================================================================== # dataset = File.readlines(target).reject {|line| line.strip.start_with? '#' # Get rid of comments. }.join(' ').delete("\n").strip.squeeze(' ') clear_old_configure_options # ===================================================================== # # Store it in the internal hash next: # ===================================================================== # set_configure_options_on_internal_hash(dataset) else opnn; no_file_exists_at(target) opne 'The current behaviour is that RBT will exit upon such an error -' opne 'only existing profiles may be used.' e e "The #{turquoise('available profiles')} are:" e show_the_available_profiles_for_configure_options e exit end end
#¶ ↑
update_all_gems
¶ ↑
This method allows us to update all gems.
To invoke this method from within RBT::Compile
, try this:
rbt --update-all-gems
Note that the constant ALSO_AUTOMATICALLY_INSTALL_THE_UPDATED_GEM
is used to automatically update a thus-downloaded gem.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 22079 def update_all_gems( also_automatically_install_the_updated_gem = ALSO_AUTOMATICALLY_INSTALL_THE_UPDATED_GEM ) require 'rbt/check_for_updates/check_for_new_release_on_rubygems.rb' opne 'Next '+ royalblue('updating all local gems')+'.' RBT.update_all_ruby_gems if also_automatically_install_the_updated_gem array_to_use = RBT.array_these_ruby_gems_were_updated? update_these_rubygems(array_to_use) end end
#¶ ↑
update_binaries_of_this_program
¶ ↑
Invocation examples:
rbt --update-binaries-of=poppler rbt --update-binaries-of=htop rbt --update-binaries-of=xinelib
#¶ ↑
# File lib/rbt/compile/compile.rb, line 11394 def update_binaries_of_this_program(i) these_binaries = RBT.infer_these_binaries_will_be_installed_by(i) # ======================================================================= # # Now that we have obtained the binaries we can add it to our # .yml file. Note that this will always overwrite any other existing # entry, so the first step is to get rid of any old entries, before # adding the new entries. # ======================================================================= # path = find_this_yaml_file(i) string = read_file_in_default_encoding(path) if is_on_roebe? opne 'Creating a backup of the file first.' backup_directory_at = log_dir?+'backup/' mkdir(backup_directory_at) unless File.directory?(backup_directory_at) # ===================================================================== # # We will copy the old file, so that we could re-use it if we need to. # ===================================================================== # opnn; copy_file( path, backup_directory_at+File.basename(path), :be_verbose ) end if string.include? ' binaries:' if is_on_roebe? # =================================================================== # # Notify only me on my home system in this case, as most users # won't need this information here really. # =================================================================== # opne "#{tomato('Removing')} the old #{slateblue('binaries:')} "\ "entries first." new_string = ''.dup state_is_open = false string.split(N).each {|line| if line.include? ' binaries:' state_is_open = true else # =============================================================== # # Toggle it unless the next line starts with a ' - '. # =============================================================== # unless line.start_with?(' - ') state_is_open = false end end unless state_is_open new_string << line << N end } string = new_string # And re-assign it here. end end # ======================================================================= # # Ok, now we can find the proper position and simply add the binaries. # We will first check for a "homepage:" String; then "url2:" and # then "url1:". These are our "anchors". # ======================================================================= # if these_binaries.empty? opne 'Can not store anything because no binaries could be found.' else append_this_string = ' binaries:'+N+' - '+these_binaries.join(N+' - ')+N splitted = string.split(N) array = [] if string.include? ' blfs: ' splitted.each {|line| if line.include? ' blfs: ' array << line+N+append_this_string else array << "#{line}#{N}" end } elsif string.include? 'configure_options: ' splitted.each {|line| if line.include? ' configure_options: ' array << line+N+append_this_string else array << "#{line}#{N}" end } elsif string.include? 'url2: ' splitted.each {|line| if line.include? ' url2: ' array << line+N+append_this_string else array << "#{line}#{N}" end } else opne 'Can not anchor it as no string '\ 'called '+slateblue('blfs:')+ ':, '+slateblue('configure_options:') opne 'or '+slateblue('url2:')+' could be found.' end what = array.join.chomp # ===================================================================== # # Next update the old content. # ===================================================================== # into = path opne 'Next overwriting the file `'+sfile(into)+'`.' write_what_into(what, into) if is_on_roebe? # =================================================================== # # Also auto-updating the rbt project. # =================================================================== # opne 'Since we are on roebe we will also auto-update the '\ 'rbt project next.' cd RUBY_SRC_DIR_AT_HOME+'rbt/' require 'roebe/toplevel_methods/rinstall2.rb' Roebe.rinstall2 end end end
#¶ ↑
update_binary_names
¶ ↑
To invoke this method, try:
ry htop update_binary_names ry --update-binary-names
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14986 def update_binary_names( also_exit = false ) also_exit = true if also_exit == :then_exit require 'rbt/registered/registered_binaries.rb' RBT::Cookbooks::RegisteredBinaries.new exit_program if also_exit end
#¶ ↑
update_kde_plasma
¶ ↑
Use this method, as delegation, in order to update the KDE5 plasma components.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 21677 def update_kde_plasma unless RBT::Cookbooks.const_defined? :UpdateKdePlasma require 'rbt/check_for_updates/update_kde_plasma.rb' end UpdateKdePlasma.new end
#¶ ↑
update_kde_porting_aids
¶ ↑
To invoke this, try:
rbt --update-kde-porting-aids
#¶ ↑
# File lib/rbt/compile/compile.rb, line 21645 def update_kde_porting_aids unless RBT::Cookbooks.const_defined? :UpdateKdePortingAids require 'rbt/check_for_updates/update_kde_porting_aids.rb' end RBT::Cookbooks::UpdateKdePortingAids.new end
#¶ ↑
update_libraries_of_this_program
¶ ↑
Invocation examples:
rbt --update-libraries-of=poppler rbt --update-libraries-of=htop rbt --update-libraries-of=xinelib
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13756 def update_libraries_of_this_program(i) these_libraries = RBT.infer_these_libraries_will_be_installed_by(i) # ======================================================================= # # Now that we have obtained the libraries we can add it to our # .yml file. Note that this will always overwrite any other existing # entry, so the first step is to get rid of any old entries, before # adding the new entries. # ======================================================================= # path = find_this_yaml_file(i) string = read_file_in_default_encoding(path) if is_on_roebe? opne 'Creating a backup of the file first.' backup_directory_at = log_dir?+'backup/' mkdir(backup_directory_at) unless File.directory?(backup_directory_at) # ===================================================================== # # We will copy the old file, so that we could re-use it if we need to. # ===================================================================== # opnn; copy_file( path, backup_directory_at+File.basename(path), :be_verbose ) end if string.include? ' libraries:' if is_on_roebe? # =================================================================== # # Notify only me on my home system in this case, as most users # won't need this information here really. # =================================================================== # opne "#{tomato('Removing')} the old #{slateblue('libraries:')} entries first." new_string = ''.dup state_is_open = false string.split(N).each {|line| if line.include? ' libraries:' state_is_open = true else # =============================================================== # # Toggle it unless the next line starts with a ' - '. # =============================================================== # unless line.start_with?(' - ') state_is_open = false end end unless state_is_open new_string << line << N end } string = new_string # And re-assign it here. end end # ======================================================================= # # Ok, now we can find the proper position and simply add the libraries. # We will first check for a "homepage:" String; then "url2:" and # then "url1:". These are our "anchors". # ======================================================================= # if these_libraries.empty? opne 'Can not store anything because no libraries could be found.' else append_this_string = ' libraries:'+N+' - '+these_libraries.join(N+' - ')+N splitted = string.split(N) array = [] if string.include? ' homepage: ' splitted.each {|line| if line.include? ' homepage: ' array << line+N+append_this_string else array << "#{line}#{N}" end } elsif string.include? 'url2: ' splitted.each {|line| if line.include? ' url2: ' array << line+N+append_this_string else array << "#{line}#{N}" end } elsif string.include? 'url1: ' splitted.each {|line| if line.include? ' url1: ' array << line+N+append_this_string else array << "#{line}#{N}" end } else opne 'Can not anchor it as no string '\ 'called '+slateblue('homepage:')+ ':, '+slateblue('url2:') opne 'or '+slateblue('url1:')+' could be found.' end what = array.join.chomp # ===================================================================== # # Next update the old content. # ===================================================================== # into = path opne 'Next overwriting the file `'+sfile(into)+'`.' write_what_into(what, into) if is_on_roebe? # =================================================================== # # Also auto-updating the rbt project. # =================================================================== # opne 'Since we are on roebe we will also auto-update the '\ 'rbt project next.' cd RUBY_SRC_DIR_AT_HOME+'rbt/' require 'roebe/toplevel_methods/rinstall2.rb' Roebe.rinstall2 end end end
#¶ ↑
update_mate_desktop_components
¶ ↑
Update mate-desktop via this method.
Invocation example:
rbt --update-mate
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15681 def update_mate_desktop_components unless RBT::Cookbooks.const_defined? :CheckForMateDesktopUpdates require 'rbt/check_for_updates/check_for_mate_desktop_updates.rb' end RBT::Cookbooks::CheckForMateDesktopUpdates.new end
#¶ ↑
update_program_path
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14304 def update_program_path cookbook_dataset?.update_program_path end
#¶ ↑
update_these_rubygems
¶ ↑
This method can be used to specifically update the input-array rubygems.
By default we will feed in all registered rubygems, that is - all .gem files that are registered within the RBT
project.
If you want to use another array of programs, pass in the Array of .gem files that you wish to use, into this method.
To invoke this method from the commandline, issue something like this:
rbt --install-all-rubygems
#¶ ↑
# File lib/rbt/compile/compile.rb, line 22055 def update_these_rubygems( array_to_use = RBT.array_all_rubygems ) unless array_to_use.empty? initialize_default_values array_to_use.each {|this_program| opne "Now installing the ruby gem called #{slateblue(this_program)}:" RBT.install_this_rubygem(this_program) } end end
#¶ ↑
upload_to
¶ ↑
This can be used to upload a RBT
file (or any other file) to a remote host, via FTP.
We will make use of the FTP-Paradise project for this.
Usage examples:
ry php upload /tmp/python-3.1.1.recipe ry php upload
#¶ ↑
# File lib/rbt/compile/compile.rb, line 22206 def upload_to( upload_this_file = '/Depot/Temp/xchat.desktop', this_url = 'shevegen.square7.ch', optional_cd_into_this_directory = nil ) case this_url when :default this_url = 'shevegen.square7.ch' end this_recipe = '/home/Temp/xchat.desktop' if this_recipe.nil? ftp = FtpParadise::Connection.new ftp.login_name = 'shevegen' ftp.password = ENV['MY_FTP_PASSWORD'] ftp.url = this_url if optional_cd_into_this_directory ftp.change_directory(optional_cd_into_this_directory) end ftp.upload(upload_this_file) end
#¶ ↑
use_a_random_extracted_directory
¶ ↑
Use a random name for the extracted directory. That way we can compile the same program concurrently, for whatever the reason (such as when you want to use different options for the compile-run as such).
Usage example:
ry htop --random-extracted-dir
#¶ ↑
# File lib/rbt/compile/compile.rb, line 10662 def use_a_random_extracted_directory # ======================================================================= # # First build up the gibberish name. # ======================================================================= # gibberish_name = ''.dup possibilities = ('A'..'Z').to_a+ ('a'..'z').to_a+ ('0'..'9').to_a 10.times { gibberish_name << possibilities.sample } gibberish_name << '_' # And the last one is a separator-character. # ======================================================================= # # Next, create that directory - it must end with the assumed # extracted-directory name: # ======================================================================= # target = rbt_log_directory?+ gibberish_name+ program_name_and_program_version?+ '/' set_extract_to_this_directory_as_specified_by_the_user(target) do_show_the_infobox cd(target) extract_what_to(program_path?, target) {{ append_to_the_commandline: '--strip-components=1' }} cd(target) do_these_logic_steps( :consider_creating_the_appdir, :consider_applying_a_patch, :check_for_sed_action, :run_preinstall_actions, :register_that_this_program_is_currently_being_compiled, :run_pre_configure_steps_if_requested_to_do_so, :decide_whether_to_build_statically, :decide_whether_to_invoke_autogen, :decide_whether_to_invoke_the_autoconf_command, :run_configure_like_stage, :check_for_common_problems_and_common_errors, :consider_symlinking_glib_schema_files_into_the_usr_share_hierarchy, :prepare_symlink_program_instance, :consider_removing_empty_subdirectories, :store_time_snapshot, :consider_reporting_the_time_it_took_to_compile_this_program, :consider_performing_postinstallation_actions, :do_strip_the_compiled_binaries, :consider_creating_and_populating_the_pkgconfig_directory, :register_configure_line_into_configure_database, :consider_symlinking_the_pkgconfig_files, :consider_checking_whether_the_compiled_binaries_are_already_registered, :consider_running_ldconfig ) end
#¶ ↑
use_a_specific_program_version
¶ ↑
Use this method to set to a specific program version.
Currently we will act on –version= and on –use-version=.
To check the regex, look here:
http://rubular.com/r/Wnq91wy8Nx
To test this, try any of the following:
ry gcc --version=4.5.3.tar.xz ry gcc --use-version=4.5.3.tar.xz ry nano --v=2.4.3 ry mesa --use-this-version=mesa-18.2.6
#¶ ↑
# File lib/rbt/compile/compile.rb, line 1769 def use_a_specific_program_version(i) i = i.dup # ======================================================================= # # We don't want file-extensions here. # ======================================================================= # i = remove_file_extension(i) if i.include?('=') splitted = i.split('=') # Get the last part, e. g. "11.3.0". i = splitted.last end # ======================================================================= # # Now we have e. g. input such as "mesa-18.2.6". Or just # "11.3.0". In the latter case we have to modify the input # a bit. # ======================================================================= # if i.include?('-') or i.include?('_') set_program_name( program_information_return_program_name(i) ) set_program_short_name( program_information_return_program_name(i) ) i = program_information_return_version(i).dup else # Else we will just use it directly as version. end # ======================================================================= # # In the past we used a regex, like shown here: # # https://rubular.com/r/Z6LP2FCENzPj # # But we probably don't have to do so since January 2019. # ======================================================================= # set_program_version(i) opne "Setting to the specific version `#{royalblue(i)}` "\ "now (for the program #{orange(compile_which_program?)})." # ======================================================================= # # Set it in the internal Hash - it will be synced lateron, see the # file sync.rb for this. # ======================================================================= # new_target_prefix = rds( "#{programs_directory?}/#{compile_which_program?.capitalize}/#{i}/" ) # ======================================================================= # # We will also modify the original program_path. # ======================================================================= # set_user_prefix( new_target_prefix ) unless archive_type?.empty? empty_archive_type end update_program_name set_program_full_name( cookbooks_program_name? ) update_program_path cookbook_dataset?.rebuild_program_path # ======================================================================= # # We must also change url1 in the cookbook dataset. We will apply # a regex for this job - see here: https://rubular.com/r/JZKjmx413E3uXI # ======================================================================= # use_this_regex = /(\d{1,2}\.\d{1,2}\.\d{1,2})/ cookbook_dataset?.set_url1( url1?.gsub( use_this_regex, ProgramInformation.return_version(program_name_and_program_version?) ) ) end
#¶ ↑
use_autoconf?¶ ↑
This method determines as to whether we will use autoconf or whether we will not. By default the value of @internal_hash is nil. If a user modifies this value from the commandline, to either true or false, then we will use that value; otherwise we will use the value defined in the cookbook-dataset for this particular program at hand.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 25772 def use_autoconf? _ = cookbook_dataset?.use_autoconf? # ← This is the default. unless @internal_hash[:use_autoconf].nil? _ = @internal_hash[:use_autoconf] end return _ end
#¶ ↑
use_build_directory
?¶ ↑
Query-method over as to whether we will use a build directory or not.
This method will return a Boolean value (true or false).
#¶ ↑
# File lib/rbt/compile/compile.rb, line 23154 def use_build_directory? _ = cookbooks_dataset?.use_build_directory? unless @internal_hash[:use_build_directory].nil? _ = @internal_hash[:use_build_directory] end _ end
#¶ ↑
use_ccache?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 29548 def use_ccache? @internal_hash[:use_ccache] end
#¶ ↑
use_maximum_speed_for_compilation?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13252 def use_maximum_speed_for_compilation?( use_maximum_speed_for_compilation = config?.use_maximum_speed_for_compilation ) result = false if use_maximum_speed_for_compilation result = use_maximum_speed_for_compilation end return result end
#¶ ↑
use_porg?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 23166 def use_porg? @internal_hash[:use_porg] end
#¶ ↑
use_the_internal_sed_wrapper?¶ ↑
Whether we will use the internal sed wrapper, aka class SedWrapper
.
Since as of February 2018, we will not do so.
You can query this via the commandline like so:
rbt use-the-internal-sed-wrapper?
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27220 def use_the_internal_sed_wrapper? @internal_hash[:use_the_internal_sed_wrapper] end
#¶ ↑
use_this_as_programs_dir
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 16346 def use_this_as_programs_dir( i = programs_directory? ) i = convert_end_variable # Sanitize it. i << '/' unless i.end_with? '/' opne "Assigning a new Programs directory at: #{simp(i)}" RBT.configuration?.programs_directory = i # ======================================================================= # # Next we also must sync towards the main dataset. # ======================================================================= # cookbook_dataset?.programs_directory = i cookbook_dataset?.sanitize_prefix :appdir_path end
#¶ ↑
use_this_build_directory
?¶ ↑
Ask the dataset for the proper build directory to use.
This may not always be true though.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 23000 def use_this_build_directory? _ = name_for_the_build_directory? # _ = _.path?.to_s if _ # Should be equal to: .path? # ^^^ uncommented as of April 2021. _ end
#¶ ↑
use_this_environment_variable
¶ ↑
This method will use a specific environment variable as the new prefix. An example follows next.
To use this, try a command invocation such as:
--use-this-environment-variable=XFCE_PREFIX --use-this-environment-variable=MATE_DESKTOP_PREFIX
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18639 def use_this_environment_variable(i) i = i.to_s.dup # We only want to work on unfrozen Strings. if i.include? '--' i.gsub!(/--/,'') # Only get rid of '--', not '-'. end if i.include? '$' i.delete!('$') end if i.include? '=' i = i.split('=').last # ======================================================================= # # Now we assume this to be an environment variable. # ======================================================================= # if ENV.has_key? i i = ENV[i] end else i = ENV[i] if ENV.has_key? i end # ======================================================================= # # Finally, set the user-prefix next. # ======================================================================= # set_user_prefix(i) end
#¶ ↑
use_this_make_command?¶ ↑
This is most commonly just “make” - but it may also be “ninja” or another build system.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 11939 def use_this_make_command? _ = 'make' # Just some default. _ = cookbook_dataset_make_command? if cookbook_dataset_make_command? unless @internal_hash[:use_this_make_command].nil? _ = @internal_hash[:use_this_make_command] end _ # And return it here. end
#¶ ↑
use_which_build_system?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26385 def use_which_build_system? # ======================================================================= # # We default to the cookbook dataset when it comes to a specific # build system. # ======================================================================= # _ = cookbookset_dataset_use_which_build_system? unless @internal_hash[:use_this_build_system].nil? _ = @internal_hash[:use_this_build_system] end _ end
#¶ ↑
use_which_compiler?¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26871 def use_which_compiler? config?.use_this_compiler end
#¶ ↑
uses_appdir_prefix?¶ ↑
This method will return true if the given input is an AppDir-prefix; and false otherwise.
An AppDir prefix is one that may include the programs directory as a String - for example the string “/Programs/” or “/home/Programs/”.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 23755 def uses_appdir_prefix?( i = prefix?.to_s ) return false if i.nil? case i when 'ntrad', 'appdir', 'appdir_prefix' return true else # ===================================================================== # # We may also have to check on the number, e. g. # (i.to_s =~ /\d+/) # And "has a number". # ===================================================================== # return i.include?(programs_directory?) end end
#¶ ↑
uses_the_meson_build_system?¶ ↑
This method will query whether the meson-build system is used or not.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 25361 def uses_the_meson_build_system? use_this_build_system? == 'meson' end
#¶ ↑
verbose_do_not_strip_the_binaries
¶ ↑
This will notify the user what we will do, and also toggle the flag that keeps track over as to whether we will run “strip” on the compiled binaries or whether we will not.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 24646 def verbose_do_not_strip_the_binaries opne "We will not strip the binaries (in the "\ "#{sdir('bin/')} subdirectory)." do_not_strip_binaries end
#¶ ↑
verbose_do_not_use_special_environment_flags
¶ ↑
If we do not want to use any ENV variable, this entry point will help us.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 18670 def verbose_do_not_use_special_environment_flags opne 'We will not use any '+teal('special environmental flag')+' (ENV).' path = query_path? ENV.clear set_path(path) # Must re-enable PATH environment as it was. @internal_hash[do_not_use_special_environment_flags] = true end
#¶ ↑
verbose_do_symlink_headers_into_usr_include_hierarchy
¶ ↑
This method can be called from the commandline. As a consequence, we must modify the @internal_hash rather than the dataset stored in the cookbooks.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 24258 def verbose_do_symlink_headers_into_usr_include_hierarchy opne 'We will try to symlink '+orange('.h')+' files into '\ 'the '+sdir('/usr/include/')+' hierarchy.' @internal_hash[:symlink_headers] = true end
#¶ ↑
verbose_enable_static
¶ ↑
This method can be used to enable static compilation of the program. The user can tap into this method by issuing –static on the commandline, for instance.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 29258 def verbose_enable_static opne "Trying to #{steelblue('compile statically')} (no shared libraries)." do_enable_static_compilation append_static_onto_the_cflags end
#¶ ↑
verbose_find_all_keys_starting_with
¶ ↑
This method will feedback all programs that start with a given (input) letter.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 16291 def verbose_find_all_keys_starting_with(i) opne 'Finding all matches starting with the letter `'+ sfancy(i.delete('*'))+'` now:' e find_all_keys_starting_with(i) e end
#¶ ↑
verbose_md5_checking
¶ ↑
Use this method to do md5-checksum checking.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13872 def verbose_md5_checking _ = program_path? opne sfancy('The md5sum of `')+simp(program_name?)+ sfancy('` in `')+sfile(_)+sfancy('` is:') opne simp(' '+return_md5(_)) # This method is defined here. end
#¶ ↑
verbose_purge_fhs_binaries_of_this_program
¶ ↑
This method will notify the user as to what will be done, then delegate towards purge_fhs_binaries_of_this_program
().
#¶ ↑
# File lib/rbt/compile/compile.rb, line 15580 def verbose_purge_fhs_binaries_of_this_program(i) i = [i].flatten.compact i.each {|entry| entry.downcase! opne "Now purging all #{mediumspringgreen('binaries')} of "\ "the program `#{sfancy(entry)}`, at the #{sdir('/usr/bin/')}"\ " hierarchy." purge_fhs_binaries_of_this_program(entry) } end
#¶ ↑
verbose_purge_fhs_libraries_of_this_program
¶ ↑
This method will notify the user as to what will be done, then delegate towards purge_fhs_libraries_of_this_program
().
#¶ ↑
# File lib/rbt/compile/compile.rb, line 14703 def verbose_purge_fhs_libraries_of_this_program(i) i = RBT.return_alias_program_name_for(i) opne "Now purging all #{mediumspringgreen('lib/')} programs "\ "of `#{sfancy(i)}` at the #{sdir('/usr/lib/')}"\ " hierarchy." purge_fhs_libraries_of_this_program(i) end
#¶ ↑
verbose_query_whether_this_program_can_be_compiled_statically
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 29299 def verbose_query_whether_this_program_can_be_compiled_statically( this_program = compile_which_program? ) _ = cookbook_dataset? opne 'Can the program '+sfancy(this_program)+' be compiled statically: '+ lightgreen(verbose_truth(_.can_be_compiled_statically?)) end
#¶ ↑
verbose_query_whether_we_will_use_the_internal_sed_wrapper
¶ ↑
Query whether the internal sed-wrapper will be used.
Invocation example:
rbt --use-the-internal-sed-wrapper?
#¶ ↑
# File lib/rbt/compile/compile.rb, line 27193 def verbose_query_whether_we_will_use_the_internal_sed_wrapper( shall_we_exit = :do_not_exit ) if use_the_internal_sed_wrapper? opne 'Yes, the internal sed-wrapper will be used ('+ slateblue('class SedWrapper')+').' else opne 'No, the internal sed-wrapper will '+ orange('NOT')+ ' be used (class SedWrapper).' end case shall_we_exit when :and_exit, :and_then_exit exit_program end end
#¶ ↑
verbose_report_will_we_use_autogen
¶ ↑
This method will output, in a verbose manner, whether we will use autogen or whether we will not.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 25677 def verbose_report_will_we_use_autogen( i = compile_which_program? ) if cookbook_dataset?.nil? initialize_dataset_for(i) end will_we_use_autogen = use_autogen? if will_we_use_autogen.nil? and cookbook_dataset_use_autogen? will_we_use_autogen = true end if will_we_use_autogen opne "Yes, autogen will be used for the "\ "program `#{sfancy(i)}`." else opne "No, autogen will #{swarn('NOT')} be used for "\ "the program #{sfancy(i)}." end end
#¶ ↑
waf_file_exists?¶ ↑
This boolean query method will determine whether a waf-file exists.
The input-argument is used primarily so that we can use another target-directory for where the ‘waf’ file may exist.
The method resides in this file here because waf ultimately depends on python.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 25147 def waf_file_exists?( this_file = 'waf' ) File.exist? this_file end
#¶ ↑
warning_argument_was_not_found
¶ ↑
Call this method when an argument was not found.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 20108 def warning_argument_was_not_found(i) cliner { opnn ewarn "Attention: The argument `#{sfancy(i.to_s)}#{swarn('` was not found.')}" opnn ewarn 'Have a look at the spelling. Should this argument exist?' opne N opnn ewarn "If you are convinced that this may be a bug or a missing feature," opnn ewarn "feel free to report this to the lead developer(s)." opne report_to_developers } # Finish here, so we display a nice coloured line still. stop_on_error end
#¶ ↑
we_can_not_continue
¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 13024 def we_can_not_continue(be_verbose = false) case be_verbose when :be_quiet be_verbose = false end if be_verbose opne 'The RBT scripts can not continue.' end @internal_hash[:can_we_continue] = false end
#¶ ↑
we_tried_to_compile_this_program_n_times¶ ↑
#¶ ↑
# File lib/rbt/compile/compile.rb, line 26018 def we_tried_to_compile_this_program_n_times? @internal_hash[:we_tried_to_compile_this_program_n_times] end
#¶ ↑
will_be_extracted_towards?¶ ↑
This method will tell us the full path of the extracted directory for the program at hand.
A trailing ‘/’ is required for the result of this method.
Returns: a String.
#¶ ↑
# File lib/rbt/compile/compile.rb, line 19201 def will_be_extracted_towards? "#{log_directory?}#{program_name_and_program_version?}/" end