class RBT::Action::Cookbooks::SanitizeCookbook
Constants
- ARRAY_ARRAY_ENTRIES
#¶ ↑
ARRAY_ARRAY_ENTRIES
(array tag)¶ ↑These entries should be kept as an Array at all time. They will all allow us to run .each on them.
In “pure” ruby code, these would all be set to e. g. “xyz = []”, so really just an Array of Arrays.
#¶ ↑
- ARRAY_EMPTY_VALUES
#¶ ↑
ARRAY_EMPTY_VALUES
¶ ↑All values that will be initialized by default to an empty string, aka ”, have to be registered here.
#¶ ↑
- ARRAY_FALSE_VALUES
#¶ ↑
ARRAY_FALSE_VALUES
(false tag)¶ ↑This constant collects all values that must be explicitely set to false on startup.
#¶ ↑
- ARRAY_MAIN_PROGRAM_ENTRIES
#¶ ↑
ARRAY_MAIN_PROGRAM_ENTRIES
¶ ↑We need the following 8 entries defined here, so that we do not forget them lateron.
These are the only entries we care about and describe the most important components of a program.
#¶ ↑
- ARRAY_NIL_ENTRIES
#¶ ↑
ARRAY_NIL_ENTRIES
(nil tag)¶ ↑All entries that are nil by default.
These are entries where a default value is not absolutely necessary.
#¶ ↑
- ARRAY_TRUE_VALUES
#¶ ↑
ARRAY_TRUE_VALUES
(true tag)¶ ↑Only a few variables are true for now, by default - prefix, run_ldconfig and
has_to_be_compiled
at the very least.#¶ ↑
- DEFAULT_PROGRAM_VERSION
#¶ ↑
DEFAULT_PROGRAM_VERSION
¶ ↑#¶ ↑
- HOW_TO_INVOKE_THE_PROGRAM
#¶ ↑
HOW_TO_INVOKE_THE_PROGRAM
¶ ↑#¶ ↑
- REPLACE_PLUS_WITH_LONG_NAME
#¶ ↑
REPLACE_PLUS_WITH_LONG_NAME
¶ ↑If this constant is true then we will replace ‘+’ with ‘plus’ if they are part of a program name.
#¶ ↑
Public Class Methods
#¶ ↑
RBT::Action::Cookbooks::SanitizeCookbook.feedback_all_available_formats
¶ ↑
To invoke this method from the commandline, try:
rbt --feedback_all_available_formats
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4458 def self.feedback_all_available_formats( i = ::RBT.return_file_specification_of_registered_cookbook_entries ) dataset = YAML.load_file(i) dataset.each_pair {|key, value| if Object.const_defined? :Colours separator = ::RBT.slateblue(': ') else separator = simp(': ') end ::RBT.e( key.ljust(30)+separator+value.rjust(10) ) } end
#¶ ↑
RBT::Action::Cookbooks::SanitizeCookbook.feedback_format_specification_of
¶ ↑
This is the method that will tell us whether an entry in the cookbooks settings is an Array or a String or a Hash or a Boolean value.
Usage example:
RBT::Action::Cookbooks::SanitizeCookbook.feedback_format_specification_of :headers
From the commandline:
rbt --format-specification-of=extract_to rbt --format-specification-of=extract_to
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 6188 def self.feedback_format_specification_of( i = 'extract_to' ) i = i.to_s unless i.is_a? String # We need a String here. # ======================================================================= # # First, load the YAML file that has our dataset. # ======================================================================= # dataset = YAML.load_file( ::RBT.return_file_specification_of_registered_cookbook_entries # We need this method. ) if dataset.has_key? i format_type = dataset[i] RBT.opnn; e "The format type for the key `#{Colours.simp(i)}` is:" e e " #{Colours.sfancy(format_type)}" e else RBT.opnn; e "No format called `#{Colours.simp(i)}` is known." end end
#¶ ↑
initialize¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 247 def initialize( i = ARGV, run_already = true, &block ) reset case i # ======================================================================= # # === :do_not_run_yet # ======================================================================= # when :do_not_run_yet run_already = false i = [] end set_commandline_arguments(i) # ======================================================================= # # === Handle blocks next # ======================================================================= # if block_given? yielded = yield # ===================================================================== # # === Handle Symbols first # ===================================================================== # if yielded.is_a? Symbol case yielded # =================================================================== # # === :do_not_instantiate_a_new_raw_cookbook # =================================================================== # when :do_not_instantiate_a_new_raw_cookbook set_simple do_not_instantiate_a_new_raw_cookbook # =================================================================== # # === :do_not_run_yet # =================================================================== # when :do_not_run_yet, :dont_run_yet run_already = false # =================================================================== # # === :be_quiet_and_bypass_menu # =================================================================== # when :be_quiet_and_bypass_menu, :be_quiet be_quiet # =================================================================== # # === fast_and_be_verbose # =================================================================== # when :fast_and_be_verbose be_verbose set_simple_or_complex(:complex) # =================================================================== # # === :be_fast_and_be_quiet # =================================================================== # when :be_fast_and_be_quiet, :complex, :use_expanded_dataset, :expanded, :default set_be_quiet set_simple_or_complex(:complex) # =================================================================== # # === :be_fast # =================================================================== # when :be_fast, :fast set_simple_or_complex(:complex) # =================================================================== # # === :simple # # Note that :return_flat_datastructure is an alias, since as of # April 2021. # =================================================================== # when :simple, :simple_cookbook, :return_flat_datastructure set_simple_or_complex(:simple) else # ================================================================= # # === Handle unknown Symbols # # This may be disabled one day - not sure yet. For now it will # remain, though. # ================================================================= # if yielded.is_a? Symbol orev "Unknown symbol called "\ "#{sfancy(':')}#{sfancy(yielded.to_s)} #{rev}passed." orev 'Showing the very important '+tomato('caller()')+ "#{rev} backtrace next:" e cliner; pp caller(); cliner e end set_simple_or_complex(yielded) end # ===================================================================== # # === Handle Hashes next # ===================================================================== # elsif yielded.is_a? Hash # =================================================================== # # === :make_use_of_aliases_kept_in_the_file_cookbook_aliases # =================================================================== # if yielded.has_key? :make_use_of_aliases_kept_in_the_file_cookbook_aliases _ = yielded[:make_use_of_aliases_kept_in_the_file_cookbook_aliases] set_make_use_of_aliases_kept_in_the_file_cookbook_aliases(_) end # =================================================================== # # === :simple_or_complex # =================================================================== # if yielded.has_key? :simple_or_complex set_simple_or_complex( yielded[:simple_or_complex] ) end end end run if run_already end
#¶ ↑
RBT::Action::Cookbooks::SanitizeCookbook.return_dataset
¶ ↑
This method will return the whole dataset for a given program at hand (if it is registered). You can then use this dataset in other programs.
As input it is preferred to provide a symbol, such as :htop or :lua; a String should work fine as well, though.
Returns: a Hash
Usage examples:
htop_dataset = RBT::Action::Cookbooks::SanitizeCookbook.return_dataset(:htop) ruby_dataset = RBT::Action::Cookbooks::SanitizeCookbook.return_dataset(:ruby)
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 6137 def self.return_dataset( of_this_program = :htop ) dataset = RBT::Action::Cookbooks::SanitizeCookbook.new(of_this_program).yaml_dataset? return dataset end
Public Instance Methods
#¶ ↑
add_the_array_entries_to_the_dataset_variable
(array tag)¶ ↑
This method will ensure that all specified Array entries are part of the internal yaml dataset when a new class is instantiated.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3294 def add_the_array_entries_to_the_dataset_variable( i = ARRAY_ARRAY_ENTRIES ) i.each {|entry| set(entry.to_sym, []) } end
#¶ ↑
add_the_empty_entries_to_the_dataset_variable
(empty tag)¶ ↑
We must ensure that the empty values are also properly set to “” on startup, in a mandatory fashion.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3277 def add_the_empty_entries_to_the_dataset_variable( i = ARRAY_EMPTY_VALUES ) i.each {|entry| # ===================================================================== # # Store the keys as a Symbol. # ===================================================================== # dataset?[entry.to_sym] = '' } end
#¶ ↑
add_the_false_entries_to_the_dataset_variable
(false tag)¶ ↑
Here we will set all false values into our main dataset.
We do this only if we do not yet have such a value in our dataset though.
# ¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3224 def add_the_false_entries_to_the_dataset_variable(i = ARRAY_FALSE_VALUES) # ======================================================================= # # Set the false values to false next. # ======================================================================= # i.each {|this_false_value| if has_key? this_false_value # =================================================================== # # If that key already exists in the dataset then we have to ensure # that it will be a boolean value. # =================================================================== # sanitize_boolean_value(this_false_value) else set(this_false_value, false) end } end
#¶ ↑
add_the_nil_entries_to_the_dataset_variable
(nil tag)¶ ↑
This will set entries, such as “homepage”, to nil initially.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3307 def add_the_nil_entries_to_the_dataset_variable( i = ARRAY_NIL_ENTRIES ) i.each {|entry| dataset?[entry.to_sym] = nil } end
#¶ ↑
add_the_remaining_entries_to_the_dataset_variable
¶ ↑
This will add the remaining entries into the main dataset.
These entries will default to an empty String. If you need another default for any of the missing entry then you should modify the corresponding value in the file ‘constants.rb’ and specify to which group it belongs.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3210 def add_the_remaining_entries_to_the_dataset_variable registered_cookbook_entries?.each {|key| dataset?[key.to_sym] unless has_key? key.to_sym } end
#¶ ↑
add_the_true_entries_to_the_dataset_variable
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3244 def add_the_true_entries_to_the_dataset_variable( i = ARRAY_TRUE_VALUES ) # ======================================================================= # # Set the false values to false next. # ======================================================================= # i.each {|this_false_value| if has_key? this_false_value # =================================================================== # # If that key already exists in the dataset then we have to ensure # that it will be a boolean value. # =================================================================== # sanitize_then_set_boolean_value(this_false_value) else set(this_false_value, true) end } end
#¶ ↑
append_this_to_the_configure_options
¶ ↑
This method can be used to append something to the (stored) configure options in use.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3647 def append_this_to_the_configure_options(i = '') _ = configure_options?.to_s _ << " #{i}" set_configure_options(_) end
#¶ ↑
append_to_array_show_these_entries
¶ ↑
Use this method when you wish to append to the main Array keeping track of which entries are to be shown.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 2747 def append_to_array_show_these_entries(i) array_show_these_entries? << i end
#¶ ↑
archive_size
?¶ ↑
This method keeps track of the size of the program tarball in question.
For this to work, we should have initialized the program size at 0.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5747 def archive_size? obtain(__method__.to_s.delete('?').to_sym) end
#¶ ↑
archive_type
?¶ ↑
Simply query the archive type here. The archive_type
is something such as “.tar.gz” or “.tar.bz2”.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1422 def archive_type? obtain(__method__.to_s.delete('?').to_sym) end
#¶ ↑
assemble_program_full_name
¶ ↑
This method will build-up a valid “program_full_name” setting.
In order to achieve this, it will make use of the method called return_default_program_full_name
, which itself is a combination of program_name
?+archive_type?.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4026 def assemble_program_full_name( i = return_default_program_full_name ) set_program_full_name(i) end
#¶ ↑
assemble_the_default_program_name_and_program_version
¶ ↑
This method will assemble the program_name
(6) variable, which is derived directly from:
program_name? and '-' and program_version?
For example it could look like this:
"gnome-mahjongg-5.08"
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3076 def assemble_the_default_program_name_and_program_version( i = :default ) case i # ======================================================================= # # === :default # ======================================================================= # when :default i = program_name?+ token?+ program_version? end set_program_name_and_program_version(i) end
#¶ ↑
autosymlink_lib64
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5202 def autosymlink_lib64? obtain __method__.to_s.delete('?').to_sym end
#¶ ↑
base_dir
?¶ ↑
This is entry (5), a simple query method. It will give us back the base directory of our program in question, such as ‘/home/x/src/htop/’.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1463 def base_dir? obtain(__method__.to_s.delete('?').to_sym) end
#¶ ↑
build_static
?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1231 def build_static? obtain(__method__.to_s.delete('?').to_sym) end
#¶ ↑
calculate_archive_size
¶ ↑
This method can be used to determine the size of the target archive in question. The corresponding entry will be set in the main Hash, called ‘archive_size’.
In order for this to work, we need the content of program_path
defined before, however. Whenever we set program_path
, we can re-calculate the filesize anew.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4424 def calculate_archive_size( i = program_path? ) set_archive_size(0) # First set it to 0 always, as default. if found_result? and File.exist?(i.to_s) size = File.size?(i.to_s) set_archive_size(size) end end
#¶ ↑
check_for_outdated_entries
¶ ↑
This method will check for outdated/obsolete entries and notify the user about this. Tha way we can get rid of such obsolete entries.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3443 def check_for_outdated_entries( _ = dataset? ) use_this_key = 'github' if !_.has_key?(use_this_key) and _.has_key?(use_this_key.to_sym) use_this_key = use_this_key.to_sym end if _.has_key?(use_this_key) and !_[use_this_key].nil? and !_[use_this_key].empty? opne crimson('This file contains an obsolete entry called ')+ royalblue('github') opne crimson('This entry could be replaced with the '\ 'entry called ')+ steelblue('git_url')+ crimson('.') opne crimson('It should be possible to get rid of this entry in ')+ crimson('the yaml file ') e e " #{sfile(yaml_file?)}" e end end
#¶ ↑
chop_off_revision_number
¶ ↑
This method will check if a program version ends with a String such as “-r8”. If so then this part will be chopped off.
Usually this trailing part denotes an internal revision rather than an external program version.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3988 def chop_off_revision_number _ = program_version? use_this_regex = /(-r\d{1,2})$/ if _ =~ use_this_regex _.sub!(use_this_regex,'') set_program_version(_) end end
#¶ ↑
clear_configure_options
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3111 def clear_configure_options set_configure_options nil end
#¶ ↑
cmake_configure_options
?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1522 def cmake_configure_options? obtain(__method__.to_s.delete('?').to_sym) end
#¶ ↑
completely_infer_the_program_name_and_the_program_version_from_this_input
¶ ↑
This will honour macros in program_name_and_program_version.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3576 def completely_infer_the_program_name_and_the_program_version_from_this_input(i) set_program_name_and_program_version( return_sanitized_program_name_and_program_version( i ) ) set_program_name( ProgramInformation.return_name(program_name_and_program_version?).dup ) set_program_version( ProgramInformation.return_version(program_name_and_program_version?).dup ) end
#¶ ↑
configure_base_dir?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1246 def configure_base_dir? obtain(__method__.to_s.delete('?').to_sym) end
#¶ ↑
configure_command_to_use?¶ ↑
The specific configure command that we will use.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1255 def configure_command_to_use? obtain(__method__.to_s.delete('?').to_sym) end
#¶ ↑
copy_the_data_from_the_raw_cookbook_onto_the_main_hash
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 2653 def copy_the_data_from_the_raw_cookbook_onto_the_main_hash hash = dataset? raw_cookbook_dataset?.each_pair {|key, value| hash[key] = value # Only copy, do not modify anything. } end
#¶ ↑
dataset_of_the_program?¶ ↑
Note that specifically the method hash? should return the FULL, sanitized dataset, because other programs may rely on that dataset, and because this information may then easily be dumped into a local .yml file as well.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4489 def dataset_of_the_program? @internal_hash[:dataset] end
#¶ ↑
decompose_program_name
¶ ↑
This method will set short_name
and program_version
, by making use of the content stored in program_name
? by default.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3897 def decompose_program_name( i = program_name? ) _ = ::ProgramInformation.return_short_name_and_program_version(i) set_short_name(_.short_name?, :propagate_towards_real_short_name) set_program_version(_.program_version?) end
#¶ ↑
deduce_everything_from_the_program_name_and_program_version_downwards
¶ ↑
This method will deduce - and set - everything starting from the program_name_and_program_version
entry downwards.
It will NOT set other aggregate methods, such as set_program_path
(). The reason for this is that this method here shall work downwards what it can deduce on its own, without depending on other methods.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3500 def deduce_everything_from_the_program_name_and_program_version_downwards( i = program_name_and_program_version? ) program_information = ProgramInformation.new(i) set_short_name(program_information.short_name?) set_program_name(program_information.program_name?) set_program_version(program_information.program_version?) end
#¶ ↑
description?¶ ↑
In the past raw_description
? was guaranteed to return the unmodified description, including newlines.
During the rewrite in April 2021, this no longer seemed necessary, as the sanitization-logic was changed.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1357 def description? obtain(__method__.to_s.delete('?').to_sym) end
#¶ ↑
determine_all_relevant_values_for_the_dataset_variable
¶ ↑
This method will copy some important values from the raw-cookbook to the main @dataset variable.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 6060 def determine_all_relevant_values_for_the_dataset_variable # ======================================================================= # # Some variables are still missing, such as program_path. The # specification does not include these, but we need them for # class RBT::Compile, so add these next. # # Perhaps in the future we may also add these variables, but for # the time being, these variables have to be defined next. # ======================================================================= # dataset?[:program_path] = base_dir?.to_s+ program_name_and_program_version?.to_s+ archive_type?.to_s if dataset?[:program_path].nil? dataset?[:program_path] = raw_cookbook?.program_path? end if dataset?[:program_version].nil? dataset?[:program_version] = return_program_version_from_the_raw_cookbook end if dataset?[:program_full_name].nil? dataset?[:program_full_name] = return_default_program_full_name end if dataset?[:program_name].nil? dataset?[:program_name] = return_program_name_from_the_raw_cookbook end if dataset?[:program_name_and_program_version].nil? dataset?[:program_name_and_program_version] = raw_cookbook?.program_name_and_program_version? end if dataset?[:keep_extracted].nil? set_keep_extracted(raw_cookbook?.keep_extracted?) end end
#¶ ↑
determine_everything
(determine tag)¶ ↑
This method will essentially determine all the other dependent variables, and set them onto the main (internal) dataset - the cookbook dataset.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3676 def determine_everything determine_the_program_name_and_the_program_version_from_url1_while_respecting_existing_values determine_the_base_dir determine_the_archive_type determine_the_full_program_name determine_the_full_program_path determine_the_file_size # ← can happen only after the program path was determined. end
#¶ ↑
determine_program_name_and_program_version
¶ ↑
This method will automatically determine the program name and the program version, based on two other settings in the main cookbook-dataset. This means that this method will ONLY succeed if these two settings have been determined PRIOR to invoking this method here.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3431 def determine_program_name_and_program_version set_program_name_and_program_version( :default ) end
#¶ ↑
determine_the_base_dir
¶ ↑
This is like ‘/home/x/src/gnomemahjongg/’, so combining src_dir?+short_name?. We will use :default, though, as argument to set_base_dir
() since that already does the above for us.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3724 def determine_the_base_dir if short_name?.nil? if program_name? set_short_name(program_name?) end end set_base_dir(:default) end
#¶ ↑
determine_the_full_program_name
¶ ↑
program_full_name
is like ‘gnome-mahjonng-5.08.tar.xz’, so this is program_name_and_program_version
?+archive_type?
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3712 def determine_the_full_program_name set_program_full_name(:default) end
#¶ ↑
determine_the_full_program_path
¶ ↑
This refers to program_path
, which may look like ‘/home/x/src/gnomemahjongg/gnome-mahjonng-5.08.tar.xz’.
In other words, it combines base_dir
?+program_full_name?.
In June 2020 this was changed, to more adjust towards the needs of class RBT::Compile
.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3664 def determine_the_full_program_path set_program_path(:try_to_rebuild_it_from_smaller_components) end
#¶ ↑
determine_the_program_name_and_the_program_version
¶ ↑
This method will determine:
(1) the "program_name" (2) the "program_version"
setting.
We will not use .downcase because some program names may include upcased characters, such as “libX11”.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3856 def determine_the_program_name_and_the_program_version( i = dataset?[:url1] ) if ihash?.has_key?(:program_name) # ===================================================================== # # If we already have set a program_name value, and this one includes # a '-' character, then we assume here that the original cookbook # file already contains a "foobar-1.0" entry, which we will simply # use next. # ===================================================================== # if ihash?[:program_name].include? '-' i = ihash?[:program_name] end end # ======================================================================= # # First, if the input contains a '/' then we split towards the last # part. # ======================================================================= # if i.include? '/' i = File.basename(i) end i = remove_archive_at_the_end(i) # Get rid of e. g. '.tar.xz' if i.include? '-' program_name = ProgramInformation.return_name(i) program_version = ProgramInformation.return_version(i) else program_name = i.dup program_version = DEFAULT_PROGRAM_VERSION end set_program_name(program_name) set_program_version(program_version) set_program_name_and_program_version(:default) set_short_name(program_name) end
#¶ ↑
determine_the_program_name_and_the_program_version_from_url1
¶ ↑
Do note that this method will respect program_name_and_program_version
entries.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3017 def determine_the_program_name_and_the_program_version_from_url1( url1 = url1? ) i = remove_archive_from_the_end( File.basename(url1) ).dup _ = program_name_and_program_version? if _ and _.is_a?(String) and !_.empty? # ===================================================================== # # This clause is entered when the .yml file at hand has both an # url1 entry but also a specific program_name_and_program_version # entry. In this case we simply grab the # program_name_and_program_version entry instead. # ===================================================================== # i = _ end if i.include?(token?) completely_infer_the_program_name_and_the_program_version_from_this_input(i) elsif i.include?(opposite_token?) set_separator_token(opposite_token?) completely_infer_the_program_name_and_the_program_version_from_this_input(i) else if is_a_github_url? and (i =~ /^v\d+/) require 'rbt/toplevel_methods/return_program_name_and_program_version_from_this_github_url.rb' i = RBT.return_program_name_and_program_version_from_this_github_url(url1?) end # ===================================================================== # # Alright - we have not found a separator token, such as '-' or # '_'. What to do in such a case? # One strategy is to notify the user about it, but this does not # really resolve the issue at hand. Since as of 27.05.2020 # I decided to "fake-simulate" the proper program name and program # version based on ProgramInformation. That also means that the # old notification was disabled, but it will be kept in the source # code here, in the event that we may wish to re-attach it one day. # ===================================================================== # completely_infer_the_program_name_and_the_program_version_from_this_input( ProgramInformation.return_name(i)+ '-'+ ProgramInformation.return_version(i) ) # opne 'No separator token found: '+steelblue(token?.to_s) # opne tomato('The URL was: ')+steelblue(url1) end end
#¶ ↑
do_convert_the_dataset
¶ ↑
This method will convert the raw-dataset into the sanitized dataset.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 6252 def do_convert_the_dataset( url1 = :default, url2 = :default ) set_archive_type parse_url1_and_set_all_associated_values(url1) check_for_outdated_entries(dataset?) sanitize_everything(url1, url2) determine_all_relevant_values_for_the_dataset_variable end
#¶ ↑
do_extract
¶ ↑
You can use this method, if you have class Extracter available, to force class Extracter to extract this program.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 2973 def do_extract( i = program_path? ) begin require 'extracter' unless Object.const_defined? :Extracter rescue LoadError; end if Object.const_defined? :Extracter # ======================================================================= # # Ok, extracter is available so we can continue. # ======================================================================= # Extracter.new(i?).extracted_path? # Specify the path. else opne 'class Extracter is not available. Consider installing it via:' e opne orange(' gem install extracter') e end end
#¶ ↑
do_not_make_use_of_aliases_kept_in_the_file_cookbook_aliases
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4409 def do_not_make_use_of_aliases_kept_in_the_file_cookbook_aliases @internal_hash[:make_use_of_aliases_kept_in_the_file_cookbook_aliases] = false end
#¶ ↑
do_show_full_description
¶ ↑
This method will allow us to show the full description of a given program.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4326 def do_show_full_description # ======================================================================= # # The following method-call will toggle the proper behaviour. # ======================================================================= # RBT::Action::Cookbooks::SanitizeCookbook.do_not_honour_threshold_value end
#¶ ↑
do_use_this_program_version
¶ ↑
Use this method specifically to set (and use) another program version.
The difference towards set_program_version
is that we will also re-assemble the default program path.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3613 def do_use_this_program_version(i = '1.52.1') set_program_version(i) reassemble_program_path end
#¶ ↑
does_include?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5017 def does_include?( this_program, honour_aliases = make_use_of_aliases_kept_in_the_file_cookbook_aliases? ) # ======================================================================= # # Delegate towards the toplevel-method next. # ======================================================================= # ::RBT.does_include?( this_program, honour_aliases ) end
#¶ ↑
ensure_that_this_hash_has_only_valid_keys
¶ ↑
The input to this method must be a Hash.
This method will ensure that the given Hash has only valid keys.
In the past, we could use it to convert it into Symbols but this is no longer in use. We now make no further modifications to the original dataset.
If all keys are valid then we won’t have to notify the user about it at all.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3919 def ensure_that_this_hash_has_only_valid_keys( i = raw_cookbook.hash? ) registered_cookbook_entries = registered_cookbook_entries? # ======================================================================= # # Check whether all is fine with the raw-dataset. # ======================================================================= # if i.nil? cliner opne sfancy('nil')+' was passed into the method '+ orange('ensure_that_this_hash_has_only_valid_keys()') opne steelblue('This can not be right. Program name was: ')+ sfancy(program_name?.to_s)+'.' pp caller() pp self cliner else i.each_pair {|key, value| key = key.to_s # We will only deal with Strings past this point. case key # =================================================================== # # === Add some ad-hoc exceptions next # =================================================================== # when 'program_full_name','md5sum', # Ad-hoc exceptions. 'program_name', 'program_path', 'program_version', 'set_env_variables' next end unless registered_cookbook_entries.include?(key) seek_this_yaml_file = "#{seek_this_program?}" seek_this_yaml_file << '.yml' unless seek_this_yaml_file.end_with? '.yml' opne "#{swarn('Warning')}#{rev} - the cookbook-file for `"\ "#{sfancy(seek_this_yaml_file)}#{rev}`" opne "(path: #{sfile(raw_cookbook?.file?)}#{rev})" opne "#{rev}contains a key that was #{swarn('NOT')} #{rev}"\ "registered. The name of that" opne "#{rev}(invalid / ignored) key is: `#{sfancy(key.to_s)}#{rev}`." opne "#{rev}This is defined in the file "\ "#{Colours.sfile('registered_cookbook_entries.yml')}" # ================================================================= # # Next, also try to find a name that is similar. # ================================================================= # if registered_cookbook_entries.any? {|entry| entry.include? key.to_s } select_this_entry = registered_cookbook_entries.select {|entry| entry.include? key.to_s }.first opne "#{rev}Did you mean this entry instead? "\ "#{sfancy(select_this_entry)}" end opne 'This is currently discouraged.' # exit end } end end
#¶ ↑
extract_to?¶ ↑
This must return a String.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1403 def extract_to? obtain(__method__.to_s.delete('?').to_sym) end
#¶ ↑
extracted_towards?¶ ↑
Determine where the archive will be extracted towards. This will also specifically include the name of the program at hand and the corresponding version, such as ‘gnome-mahjonng-5.08’.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4974 def extracted_towards? # ======================================================================= # # We include the program name and the program version. # ======================================================================= # result = "#{extract_to?}#{program_name_and_program_version?}" unless result.end_with? '/' result = result.dup if result.frozen? result << '/' end return result end
#¶ ↑
feedback_available_cookbooks
¶ ↑
Feedback which cookbooks are available.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3141 def feedback_available_cookbooks(i = available_programs?) e 'These cookbooks are available:'; print ' ' e i.join(', ') end
#¶ ↑
find_in_the_raw_cookbook
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 2663 def find_in_the_raw_cookbook( i = search_for_this_program?, raw_cookbook = raw_cookbook? ) if debug? opne "#{rev}Loading the dataset from the file "\ "`#{sfile(raw_cookbook?.file?)}#{rev}`." end if raw_cookbook result = raw_cookbook.find(i) return result end end
#¶ ↑
find_this_program
(find tag)¶ ↑
This method will also keep track which program we are trying to find.
Note that .find() is an alias to this method.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 2585 def find_this_program( i = first? ) determine_which_program_is_sought(i) # (1) seek this new program if may_we_instantiate_a_new_raw_cookbook? instantiate_raw_cookbook(i) # (2) finally, instantiate a new raw cookbook end populate_the_dataset_variable # (4) initialize the main hash properly if raw_cookbook? if in_simple_mode? # (5) in this case, sync a lot of stuff. # =================================================================== # # We use this method call because the program we are trying to find # may have been modified, such as from "x11" to "libx11". # =================================================================== # find_in_the_raw_cookbook(seek_this_program?) ensure_that_this_hash_has_only_valid_keys( raw_cookbook?.dataset? ) # =================================================================== # # :archive_type can be set early because we can scan for the real # value lateron anyway. # =================================================================== # dataset?[:archive_type] = '.tar.xz' # (6) archive_type # =================================================================== # # In this case we have to do additional parsing. However had, when # the .yml file contains a set-entry called program_name_and_program_version # then this entry will be used rather than using url1. # =================================================================== # _ = program_name_and_program_version? if _ and _.is_a?(String) and !_.empty? _ = ::RBT.sanitize_url1_entry(_, dataset?.merge(url1: raw_cookbook?.url1?)).dup # ================================================================= # # In this case program_name_and_program_version exists, so we will # set these parts first. # ================================================================= # set_program_name_and_program_version(_) deduce_everything_from_the_program_name_and_program_version_downwards set_program_full_name(:default) set_short_name(:default) set_base_dir(:default) set_program_path(:default) set_program_version(:infer_from_the_program_name_and_program_version) else parse_url1_and_set_all_associated_values end check_for_outdated_entries(dataset?) sanitize_everything # (7) sanitize everything determine_all_relevant_values_for_the_dataset_variable else # =================================================================== # # else we are in complex-mode. # =================================================================== # copy_the_data_from_the_raw_cookbook_onto_the_main_hash end end end
#¶ ↑
find_this_program_and_then_set_the_internal_cookbook_dataset_then_determine_everything
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 2754 def find_this_program_and_then_set_the_internal_cookbook_dataset_then_determine_everything( compile_this_program = first_argument? ) if does_include?(compile_this_program) the_program_was_found # The program was found - so continue. find_this_program_and_then_set_the_internal_cookbook_dataset( compile_this_program ) determine_everything else this_program_was_not_found(compile_this_program) end end
#¶ ↑
flatpak_url
?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5600 def flatpak_url? obtain __method__.to_s.delete('?').to_sym end
#¶ ↑
guess_short_name
¶ ↑
This method can be used to guess the short name of a program.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3624 def guess_short_name( i = program_name? ) _ = ::ProgramInformation.return_short_name(i) set_short_name(_) end
#¶ ↑
has_a_dependency_on_meson?¶ ↑
This method will return a boolean value, indicating whether the given program at hand has a dependency on the build system called meson or whether it has not.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4567 def has_a_dependency_on_meson? required_deps_on? and required_deps_on?.include?('meson') end
#¶ ↑
has_key?¶ ↑
This query method will delegate towards the yaml dataset, whether it has a given key or whether it does not.
The key should ideally be a Symbol - keep this in mind.
Since as of April 2021 there will be no modifications made; the input argument will be the key. Prior to that we converted it to a String via .to_s.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4045 def has_key?(i = :blfs) dataset?.has_key?(i) end
#¶ ↑
has_to_be_compiled
?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1238 def has_to_be_compiled? obtain(__method__.to_s.delete('?').to_sym) end
#¶ ↑
headers?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1446 def headers? obtain(__method__.to_s.delete('?').to_sym) end
#¶ ↑
initialize_the_internal_hash
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 380 def initialize_the_internal_hash # ======================================================================= # # === @internal_hash # # The internal hash contains lots of entries that are important for # this class to work properly. # # Since as of August we inherit the "parent" Hash, so we don't # re-assign it here. # ======================================================================= # # @internal_hash = {} # ======================================================================= # # === :dataset # # This entry will contain the dataset that refers to the program at # hand. If you want to clear it then you can use the method # .reset_the_dataset(). # ======================================================================= # @internal_hash[:dataset] = nil # ======================================================================= # # === :original_unmodified_name # # This variable will keep track of which program we are searching for. # ======================================================================= # @internal_hash[:original_unmodified_name] = nil # ======================================================================= # # === raw_cookbook # # This is initially set to nil, simply to not forget it. # ======================================================================= # @internal_hash[:raw_cookbook] = nil # ======================================================================= # # === :use_this_connective_token # # Some programs, such as artemis, have a '_' rather than a '-'. So # we need to be able to keep track of this as well. The default is # '-' though. # ======================================================================= # @internal_hash[:use_this_connective_token] = '-' # ======================================================================= # # === :wrap_result # # By default, we will word-wrap too long text lines. # ======================================================================= # @internal_hash[:wrap_result] = true # ======================================================================= # # === :replace_plus_with_long_name # ======================================================================= # @internal_hash[:replace_plus_with_long_name] = REPLACE_PLUS_WITH_LONG_NAME # ======================================================================= # # === :try_to_truncate_too_long_output # ======================================================================= # @internal_hash[:try_to_truncate_too_long_output] = true # ======================================================================= # # === :seek_this_program # ======================================================================= # @internal_hash[:seek_this_program] = nil # ======================================================================= # # === :found # # This variable keeps track as to whether the input has been found # or not. # ======================================================================= # @internal_hash[:found] = false # ======================================================================= # # === :autogenerate_expanded_dataset # ======================================================================= # @internal_hash[:autogenerate_expanded_dataset] = false # ======================================================================= # # === :make_use_of_aliases_kept_in_the_file_cookbook_aliases # # Next, determine whether to use cookbook-internal aliases or whether # we shall not. # ======================================================================= # @internal_hash[:make_use_of_aliases_kept_in_the_file_cookbook_aliases] = true # ======================================================================= # # === :shall_we_display_the_md5sum # ======================================================================= # @internal_hash[:shall_we_display_the_md5sum] = RBT.display_md5sum? # ======================================================================= # # === :report_how_many_programs_are_registered # ======================================================================= # @internal_hash[:report_how_many_programs_are_registered] = false # ======================================================================= # # === :array_show_these_entries # ======================================================================= # @internal_hash[:array_show_these_entries] = [] # ======================================================================= # # === :may_we_instantiate_a_new_raw_cookbook # # This variable can be used to instantiate a new raw-cookbook. This # is the default behaviour, but sometimes we may not want to do so, # and instead supply our own dataset, which is why this variable # exists. # ======================================================================= # @internal_hash[:may_we_instantiate_a_new_raw_cookbook] = true # ======================================================================= # # === :simple_or_complex # ======================================================================= # # @internal_hash[:simple_or_complex] = :simple set_simple_or_complex(:default) # Set it once on startup. end
#¶ ↑
initialize_the_main_hash_with_default_values
¶ ↑
This method is necessary so that our main hash contains all necessary values initially.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 2905 def initialize_the_main_hash_with_default_values reset_the_dataset # This will make @internal_hash[:dataset] an empty Hash. # ======================================================================= # # Add the emptry-entries to the dataset next: # ======================================================================= # add_the_empty_entries_to_the_dataset_variable add_the_nil_entries_to_the_dataset_variable add_the_array_entries_to_the_dataset_variable add_the_true_entries_to_the_dataset_variable add_the_false_entries_to_the_dataset_variable # ======================================================================= # # Last but not least, add the remaining entries to the dataset variable. # ======================================================================= # add_the_remaining_entries_to_the_dataset_variable end
#¶ ↑
instantiate_raw_cookbook
(raw tag)¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 6102 def instantiate_raw_cookbook( i = seek_this_program? ) # ===================================================================== # # We also have to sync the variable @simple_or_complex down onto the # raw-cookbooks loader. # ===================================================================== # # @internal_hash[:raw_cookbook] = RBT.raw_cookbook(i) { simple_or_complex? } @internal_hash[:raw_cookbook] = action( :raw_cookbook, i, { autogenerate_expanded_dataset: @internal_hash[:autogenerate_expanded_dataset] } ) { simple_or_complex? } end
#¶ ↑
is_a_boolean_configuration_value?¶ ↑
Query method to determine whether the input is a boolean configuration value. For example, the String “use_glib_schema”, would be a boolean configuration value and thus this method would return true.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4896 def is_a_boolean_configuration_value?(i) ( ARRAY_FALSE_VALUES + ARRAY_TRUE_VALUES ).flatten.include? i end
#¶ ↑
is_a_game?¶ ↑
This method will simply return true if the program in question is a game, and false if it is not a game. That way we can quickly find out whether the input is a game or whether it is not.
Usage example:
ProgramInformation.return_name @program_name ProgramInformation.return_name 'supertux-0.1.1'
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4062 def is_a_game? return true if tags?.to_s.include? 'game' return false # Else return false here. end
#¶ ↑
is_an_active_project?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1411 def is_an_active_project? obtain(__method__.to_s.delete('?').to_sym) end
#¶ ↑
is_another_archive_used_locally?¶ ↑
This method depends on program_path
? having been properly set BEFORE the method is invoked.
The method will return true or false.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3748 def is_another_archive_used_locally?( i = archive_type? ) result = false program_path = program_path? if program_path unless File.exist?(program_path) target = base_dir?+program_name_and_program_version?+'*' entries = Dir[target] if entries.nil? or entries.first.nil? or entries.first.include?(archive_type?) e 'An error happened. The target was:' e e tomato(target) e e 'The program at hand was assumed to be '+steelblue(i)+' and' e 'the program_path was assumed to be: '+lightgreen(program_path.to_s) if is_on_roebe? and !target.end_with?('-*') # =============================================================== # # This here looks like so: '/home/x/src/-*' # palemoon may show this error. # =============================================================== # exit end else result = true end end end return result end
#¶ ↑
is_the_build_system_meson?¶ ↑
Query-method to determine whether the build system makes use of meson or whether it does not.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5096 def is_the_build_system_meson? use_this_build_system? == 'meson' end
#¶ ↑
keep_extracted
?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5592 def keep_extracted? obtain __method__.to_s.delete('?').to_sym end
#¶ ↑
last_update
?¶ ↑
The last_update
tag keeps track over as to when that particular program was last updated.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1316 def last_update? obtain(__method__.to_s.delete('?').to_sym) end
#¶ ↑
licence?¶ ↑
This is the query method over licence.
Do note that while the specification allows for both a String value, or an Array value alternatively, it only really makes sense to assume that tag to be a String.
The reason why an Array is used as an alternative is twofold:
(1) That way we can also respect programs that have more than one licence. (2) It may sometimes be more convenient to use an Array in the corresponding .yml file.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5175 def licence? _ = obtain(__method__.to_s.delete('?').to_sym).to_s _ = _.first if _.is_a? Array return _ end
#¶ ↑
m4_files
?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1323 def m4_files? obtain(:m4_files) end
#¶ ↑
main_seven?¶ ↑
This method will return the main 7 entries that are the most important ones for any given program at hand.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4594 def main_seven?( use_padded_output = true ) _ = ''.dup one = 'short_name: '.dup two = 'program_version: '.dup three = 'archive_type: '.dup four = 'base_dir: '.dup five = 'program_name: '.dup six = 'program_full_name: '.dup seven = 'program_path: '.dup # ======================================================================= # # Next make sure to pad the output, if the user requested this. # ======================================================================= # if use_padded_output n_ljust = 19 one = one.ljust(n_ljust) two = two.ljust(n_ljust) three = three.ljust(n_ljust) four = four.ljust(n_ljust) five = five.ljust(n_ljust) six = six.ljust(n_ljust) seven = seven.ljust(n_ljust) end _ << "#{one}#{short_name?}#{N}" _ << "#{two}#{program_version?}#{N}" _ << "#{three}#{archive_type?}#{N}" _ << "#{four}#{base_dir?}#{N}" _ << "#{five}#{program_name?}#{N}" _ << "#{six}#{program_full_name?}#{N}" _ << "#{seven}#{program_path?}#{N}" return _ end
#¶ ↑
make_use_of_aliases_kept_in_the_file_cookbook_aliases?¶ ↑
This method can be used to query whether we will make use of aliases kept in the cookbook_aliases.yml file or whether we will not.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4963 def make_use_of_aliases_kept_in_the_file_cookbook_aliases? @internal_hash[:make_use_of_aliases_kept_in_the_file_cookbook_aliases] end
#¶ ↑
may_we_modify_the_configure_options
?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5246 def may_we_modify_the_configure_options? obtain __method__.to_s.delete('?').to_sym end
#¶ ↑
md5sum?¶ ↑
Conditionally use md5sum.
This method must accomodate three different possibilities:
(1) We have generated a .yml file in a special directory. We will preferentially use that one, if it exists. This requires of the user to have generated these values already. If the user did so then we will use these values rather than calculate them anew again. The advantage of this way is that it will significantly speed up the process. (2) IF we do not have such a file as described in (1), then we will first try to use the ruby Md5sum class, specifically its Md5sum[] class method. Note that the ruby Md5sum class is fairly slow for large programs, which is why option (1) is the default since as of April 2016. (3) The other two options (1) and (2) not being available, we will try to use the unix coreutils "md5sum" instead, which is a binary, and should be pretty fast.
Note that as of May 2016, we also make available a way to AVOID calculating the md5sum at all. Not everyone will need the md5sum information after all.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3357 def md5sum?( use_this_path = program_path? ) # ======================================================================= # # === Try to use yaml files first # # The expanded directory on my system will be here: # # /Depot/Temp/CookbookDirectory/expanded_cookbooks/ # # ======================================================================= # if File.directory?(RBT.base_dir_to_store_expanded_cookbooks?) and File.exist?(use_this_path.to_s) and use_this_path.end_with?('.yml') begin dataset = YAML.load_file(use_this_path) return dataset['md5sum'].to_s rescue ArgumentError => error opne 'An error happened for the path `'+sfile(use_this_path)+ '`. We will exit as a consequence.' pp error exit end # ======================================================================= # # === Use the pure ruby way next # ======================================================================= # elsif Object.const_defined? :Md5sum Md5sum[use_this_path].md5sum? # Calculate it anew via Md5sum[]. # ======================================================================= # # === Try to use md5sum binary directly next # # This entry point depends on a binary that is part of the # coreutils package. # ======================================================================= # elsif (result = `md5sum bogus 2>&1`) and !result.include?('command not found') if File.directory? use_this_path # A workaround for now. return '0' else # =================================================================== # # Delegate to the system tool here, part of coreutils. # =================================================================== # result = `md5sum #{use_this_path}`.split(' ').first result.strip! if result return result end else '0' # Return 0 then. But that should not ever happen. end end
#¶ ↑
merge_in_this_dataset
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 6235 def merge_in_this_dataset(dataset) # ======================================================================= # # Next "copy" the dataset onto the main Hash. # ======================================================================= # if dataset dataset.each_pair {|key, value| key = key.to_sym @internal_hash[:dataset][key] = value } end end
#¶ ↑
meson_configure_options
?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5195 def meson_configure_options? obtain __method__.to_s.delete('?').to_sym end
#¶ ↑
meson_or_cmake_or_configure_options?¶ ↑
This is similar to the method called .meson_or_configure_options?() but we will also check whether cmake is in use.
The optional argument must be a Symbol. If provided then this method will simply return the corresponding configure-options.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5823 def meson_or_cmake_or_configure_options?( optional_use_this_build_system = nil ) if optional_use_this_build_system case optional_use_this_build_system # ===================================================================== # # === :meson # ===================================================================== # when :meson meson_configure_options? # ===================================================================== # # === :cmake # ===================================================================== # when :cmake cmake_configure_options? # ===================================================================== # # === :configure # ===================================================================== # when :configure configure_options? end else if is_the_build_system_meson? meson_configure_options? elsif is_the_build_system_cmake? cmake_configure_options? else configure_options? end end end
#¶ ↑
meson_or_configure_options?¶ ↑
This method will either return the meson-configure options or the GNU configure options. The checks are in order, so first we will check for meson, and then default to configure if meson is NOT used.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4637 def meson_or_configure_options? if is_the_build_system_meson? meson_configure_options? else configure_options? end end
#¶ ↑
modify_the_makefile
?¶ ↑
This method will query whether RBT
will modify the Makefile at hand or whether it will not. Some Makefiles have hardcoded paths which do not respect the given –prefix variant, not even DESTDIR, as far as I know. Hence, for these .yml files, we need to have a way to modify that Makefile and correct it.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1161 def modify_the_makefile? obtain(__method__.to_s.delete('?').to_sym) end
#¶ ↑
obtain (obtain tag, o tag)¶ ↑
This getter-method can be used to obtain elements from the main yaml dataset, which is stored in:
@internal_hash[:dataset]
The main reason why a method is used here is because the keys can be either Symbols or Strings. If we ever wish to change to another format, we can do so thanks to the flexibility of this setup.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5671 def obtain(this_key) result = nil # ======================================================================= # # Next, we need to decide whether we use a Symbol, or a String. # ======================================================================= # unless this_key.is_a? Symbol this_key = this_key.to_sym if complex_mode? end dataset = dataset? if dataset if dataset.has_key? this_key result = dataset[this_key] # [] is better than .fetch() here. # elsif raw_cookbook_dataset?.has_key?(what.to_s) # result = raw_cookbook_dataset?[what.to_s] #else # e rev+'DEBUG: TODO, remove me -> No key called '+ # steelblue(this_key.to_s)+' (class: '+this_key.class.to_s+ # ') could be found.' end end return result end
#¶ ↑
opposite_token?¶ ↑
This method will return the “opposite” token, e. g. ‘_’ is the “opposite to ‘-’ and vice versa.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5046 def opposite_token?( i = @internal_hash[:use_this_connective_token] ) case i when '-' '_' when '_' '-' end end
#¶ ↑
optional_start_message
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5431 def optional_start_message? obtain __method__.to_s.delete('?').to_sym end
#¶ ↑
parameters_to_make?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5217 def parameters_to_make? obtain __method__.to_s.delete('?').to_sym end
#¶ ↑
parse_url1_and_set_all_associated_values
¶ ↑
We will make various changes depending on the url1 entry.
If this entry exists, various data points will be set on the main dataset of this class.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 2777 def parse_url1_and_set_all_associated_values( url1 = raw_cookbook?.url1? ) # ======================================================================= # # url1 may look like this: # # https://www.python.org/ftp/python/3.9.4/Python-3.9.4.tgz # # ======================================================================= # if url1 # ===================================================================== # # Fix .js files. # ===================================================================== # if url1.end_with? '.js' set_archive('.js') elsif url1.end_with? '.gem' set_archive(url1) end if url1.include? '%2B' # This means '+'. url1.gsub!(/%2B/,'+') end if url1.include? '-trunk' url1 = remove_file_extension(url1) end if url1.include? '-release.tar' url1 = chop_off_archive(url1) url1.sub!(/-release/,'') end # ===================================================================== # # === Handle github URLs next # # Next, check if it is a github url and if it may not have a # "-" and if it consists only of numbers; in this case we know # we have to determine the program name in a different manner. # ===================================================================== # if is_github_url?(url1) and !File.basename(url1).include?('-') and (url1 =~ /\d{0,2}\.\d{0,2}\.?\d{0,2}/) # ================================================================== # # In this case we will re-write this URL; and also modify the # variable called url1. # # The current content of url1 may be a String such as: # # 'https://github.com/opencv/opencv/archive/3.4.5.tar.gz' # # ================================================================== # use_this_regex = /\/v?(\d{0,2}\.\d{0,2}\.?\d{0,2})\./ # See: https://rubular.com/r/dvCdVJWbtUhJaJ # ================================================================== # # We must use the unmodified input-name here because that name may # still include '-' characters, which may be important for some # programs. Unfortunately this is not always available, such as # for: # # https://github.com/kdave/btrfs-progs/archive/refs/tags/v5.11.1.tar.gz # # Thus, we will default to original_unmodified_name?, but we # will try to determine whether the "/"-splitted third part # contains a '-' character. If so then this name is used # instead. The explanation can be seen by the text # given above. # ================================================================== # replacement_name = original_unmodified_name?.to_s.dup if url1.include? '/' splitted = url1.split('/') if splitted[4] and splitted[4].include?('-') replacement_name = splitted[4] end end url1.sub!( use_this_regex, '/'+replacement_name+'-\1.' ) end end # ======================================================================= # # Note that url1 may also be invalid, such as by having this as # content: # # cmake@3.22.4 # # In this case we will simply rewrite this towards cmake-3.22.4. # ======================================================================= # if url1 and url1.include?('@') url1.tr!('@','-') end if url1 url1 = remove_archive_at_the_end(File.basename(url1)) end program_information = ProgramInformation.new(url1) set_short_name(program_information.short_name?) # (1) short_name, such as 'gnomemahjongg' set_program_name(program_information.program_name?) # (2) program_name, such as 'gnome-mahjongg' set_program_version(program_information.program_version?) # (3) program_version set_program_name_and_program_version("#{program_name?}-#{program_version?}") # (4) program_name_and_program_version set_program_full_name(program_name_and_program_version?+archive_type?) # (6) program_full_name, such as 'gnome-mahjonng-5.08.tar.xz' set_base_dir(:default) # (7) base_dir _ = base_dir?.to_s+ program_name?.to_s+'-'+ program_version?.to_s+ archive_type?.to_s set_program_path(_) # (8) program_path unless File.exist? _ try_to_find_another_local_file(_) set_program_path end end
#¶ ↑
pkgconfig_files
?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1394 def pkgconfig_files? obtain(__method__.to_s.delete('?').to_sym) end
#¶ ↑
populate_the_dataset_variable
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 2699 def populate_the_dataset_variable( i = simple_or_complex? ) initialize_the_main_hash_with_default_values # First, fill the dataset with default values. case i # ======================================================================= # # === :simple # # If we make use of the simple dataset then we do not have to sync the # value back onto RawCookbook. # ======================================================================= # when :simple # ===================================================================== # # In this case we have to do sanitizing stuff. # ===================================================================== # merge_in_the_dataset_derived_from_the_raw_cookbook # must come after we instantiated the raw cookbook # ======================================================================= # # === :complex # # In this case we can simply query from the raw-cookbook dataset. # ======================================================================= # when :complex raw_cookbook?.set_complex # Pass the info to the raw-cookbook as well. allowed_cookbook_entries?.each {|this_entry| _ = ("#{this_entry.to_s}?").to_sym if raw_cookbook?.respond_to? _ dataset?[this_entry.to_sym] = raw_cookbook?.send(_) else # e ' Notice: the object does not respond to '+steelblue(_)+'.' end } determine_all_relevant_values_for_the_dataset_variable end end
#¶ ↑
postinstall?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1344 def postinstall? obtain(__method__.to_s.delete('?').to_sym) end
#¶ ↑
pre_make_commands
?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1365 def pre_make_commands? obtain(__method__.to_s.delete('?').to_sym) end
#¶ ↑
pre_make_install_sed
?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5438 def pre_make_install_sed? obtain __method__.to_s.delete('?').to_sym end
#¶ ↑
prefix?¶ ↑
Query the prefix in use by our sought program.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5654 def prefix? obtain __method__.to_s.delete('?').to_sym end
#¶ ↑
program_full_name
?¶ ↑
This entry will have everything except the leading PATH.
For instance:
"gpm-1.20.1.tar.xz"
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5614 def program_full_name? obtain __method__.to_s.delete('?').to_sym end
#¶ ↑
program_name
?¶ ↑
This method is a reader-method over e. g. ‘gnome-mahjongg’.
It does NOT have the version of the program included, which is a different behaviour enabled during May 2020.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5476 def program_name? obtain __method__.to_s.delete('?').to_sym end
#¶ ↑
program_name_and_program_version
?¶ ↑
Note that the connective token in use is usually ‘-’, but there are programs such as ‘artemis_v16.0.11.jar’ that have no ‘-’ at all whatsoever. To also honour such programs, we have to use this connective token - it will be re-defined towards ‘_’ specifically for programs that have no ‘-’ token, such as artemis.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5335 def program_name_and_program_version? obtain __method__.to_s.delete('?').to_sym end
#¶ ↑
program_path
?¶ ↑
This method will return the ‘program_path’ value, through the reader method obtain().
The program_path
variable has the FULL path to the archive in question, for instance:
/home/x/src/gnomemahjonng/gnome-mahjonng-5.08.tar.xz /home/x/src/gpm/gpm-1.20.1.tar.bz2 /home/x/src/gambas3/gambas3-3.10.0.tar.xz base_dir? ^^^^^^^^^ program_full_name? ^^^
It consists of base_dir
?+program_full_name?.
Do note that the program_path
value is the most important entry, as ALL the other information can be derived from the information stored in this variable alone.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1287 def program_path? obtain(__method__.to_s.delete('?').to_sym) end
#¶ ↑
program_version
?¶ ↑
This method must always return a String.
We use it to query the program version of the specific program at hand.
For instance, if the program name is “python-2.4” then this method will return the version string part, i.e. “2.4”.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5406 def program_version? obtain __method__.to_s.delete('?').to_sym end
#¶ ↑
properly_pad_and_colourize_this_help_option
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4437 def properly_pad_and_colourize_this_help_option( key_to_invoke_the_method, text_that_is_to_be_displayed ) left_padding = ' ' # A bit of left-padding here. n_left_pad_value = 38 n_left_pad_value -= key_to_invoke_the_method.size left_padding+HOW_TO_INVOKE_THE_PROGRAM+ skyblue(' '+key_to_invoke_the_method)+ (' ' * n_left_pad_value)+' # '+ text_that_is_to_be_displayed end
#¶ ↑
query_for
¶ ↑
This method is a more general query-method for certain data stored in the Cookbook
class.
For example: the input String ‘Compiling this program:’ will yield the name of the program that the cookbook class currently holds.
The primary use case is for the Flexbox class.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4247 def query_for(i) _ = i.to_s.dup _.chop! if _.end_with? ':' case _ # ======================================================================= # # === "Homepage" # ======================================================================= # when /^Homepage$/i homepage_url? # ======================================================================= # # === program_name_and_program_version? # ======================================================================= # when /^program(-|_| )?name(-|_| )?and(-|_| )?program(-|_| )?version\??$/i program_name_and_program_version? # ======================================================================= # # === extract_to? # ======================================================================= # when /^extract(-|_| )?to\??$/i extract_to? # ======================================================================= # # === "Build system to be used:" # ======================================================================= # when /^Build(-|_| )?system(-|_| )?to(-|_| )?be(-|_| )?used$/i use_this_build_system? # ======================================================================= # # === "configure options" # ======================================================================= # when /^configure(-|_| )?options\??$/i configure_options? # ======================================================================= # # === "URL to the source archive" # ======================================================================= # when /^URL(-|_| )?to(-|_| )?the(-|_| )?source(-|_| )?archive$/i url_to_the_source_archive? # ======================================================================= # # === "Keep the archive extracted" # ======================================================================= # when /^Keep(-|_| )?the(-|_| )?archive(-|_| )?extracted$/i keep_the_archive_extracted? # ======================================================================= # # === "Program path" # ======================================================================= # when /^Program(-|_| )?path$/i program_path? # ======================================================================= # # === "Program version" # ======================================================================= # when /^Program(-|_| )?version$/i program_version? # ======================================================================= # # === "Compiling this program" # ======================================================================= # when /^Compiling(-|_| )?this(-|_| )?program$/i, /^Installing(-|_| )?this(-|_| )?program$/i, /^Extracting(-|_| )?this(-|_| )?program$/i short_name? # ======================================================================= # # === "Prefix" # ======================================================================= # when /^Prefix$/i prefix? else e crimson("Unhandled input to #{__method__}: #{_}") end end
#¶ ↑
quiet_down
¶ ↑
This method will cause the cookbook to be silent and not report how many programs are registered.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3131 def quiet_down set_be_silent # This is defined in the parent class. @internal_hash[:report_how_many_programs_are_registered] = false end
#¶ ↑
raw_cookbook_dataset?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4953 def raw_cookbook_dataset? @internal_hash[:raw_cookbook] and raw_cookbook?.dataset? end
#¶ ↑
reassemble_the_program_path
¶ ↑
This method will always ultimate attempt to set the program path, if possible.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 2891 def reassemble_the_program_path( i = return_default_program_path ) assemble_the_default_program_name_and_program_version # Assign to something such as: "gnome-mahjongg-0.1.3" set_program_path(i) end
#¶ ↑
rebuild_program_full_name
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3097 def rebuild_program_full_name set_program_full_name(:default) end
#¶ ↑
report¶ ↑
This is just a general-purpose method that will output some values.
It will output useful information about a program.
For a full report system, use the specialized class DisplayCookbookDataset.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 2060 def report program_name = seek_which_program? return if program_name.to_s.empty? array_show_these_entries?.clear append_to_array_show_these_entries(:mode_in_use) # ======================================================================= # # === short_description # ======================================================================= # unless short_description?.empty? append_to_array_show_these_entries(:short_description) end if short_description? # ======================================================================= # # Add a bunch of symbols to the main array here. # ======================================================================= # append_to_array_show_these_entries(%i( description )) unless extra_information?.empty? append_to_array_show_these_entries(:extra_information) end if extra_information? append_to_array_show_these_entries(%i( program_path base_dir program_full_name program_name_and_program_version program_version archive_type short_name program_name url1 url2 )) # ======================================================================= # # === Show the main homepage if it exists # ======================================================================= # if homepage? append_to_array_show_these_entries(:homepage) end if flatpak_url? and !flatpak_url?.empty? append_to_array_show_these_entries(:flatpak_url) end # ======================================================================= # # Unless the pkgconfig_files Array is empty, we will display the # .pc files of the given program. # ======================================================================= # if pkgconfig_files? unless pkgconfig_files?.empty? append_to_array_show_these_entries(:pkgconfig_files) end end # ======================================================================= # # === Display installation_steps if they are not empty # ======================================================================= # if installation_steps? and !installation_steps?.empty? append_to_array_show_these_entries(:installation_steps) end # ======================================================================= # # === Display the configure command to use next # ======================================================================= # if configure_command_to_use? unless configure_command_to_use?.empty? unless configure_command_to_use? == 'configure' append_to_array_show_these_entries(:configure_command_to_use) end end end # ======================================================================= # # === Add the .gir-files, if they exist # ======================================================================= # if gir_files? unless gir_files?.empty? append_to_array_show_these_entries(:gir_files) end end if program_compile_name? and !program_compile_name?.empty? append_to_array_show_these_entries(:program_compile_name) end # ======================================================================= # # === Add the headers, if they exist # ======================================================================= # if headers? unless headers?.empty? append_to_array_show_these_entries(:headers) end end if binaries? append_to_array_show_these_entries(:binaries) unless binaries?.empty? end if libraries? append_to_array_show_these_entries(:libraries) unless libraries?.empty? end append_to_array_show_these_entries(%i( prefix )) if configure_base_dir? and !configure_base_dir?.to_s.empty? append_to_array_show_these_entries(:configure_base_dir) end append_to_array_show_these_entries( %i( extract_to configure_options meson_configure_options md5sum file_size keep_extracted ) ) if build_static? == true append_to_array_show_these_entries(:build_static) end unless use_this_make_command?.to_s == 'make' append_to_array_show_these_entries(:use_this_make_command) end if sed? and sed?.is_a?(Array) and !sed?.empty? append_to_array_show_these_entries(:sed) end append_to_array_show_these_entries(:do_not_download) if do_not_download? append_to_array_show_these_entries(:apply_patch) if apply_patch? if deps? append_to_array_show_these_entries(:required_deps_on) unless deps?.empty? end if make_options? unless make_options?.empty? # Only show the make_options if they are not empty. append_to_array_show_these_entries(:make_options) end end append_to_array_show_these_entries(:enable_shared) # if enable_shared? if preinstall? append_to_array_show_these_entries(:preinstall) unless preinstall?.empty? end if postinstall? append_to_array_show_these_entries(:postinstall) unless postinstall?.empty? end append_to_array_show_these_entries(:tags) unless tags?.empty? append_to_array_show_these_entries(:svn_url) if svn_url? and !svn_url?.empty? append_to_array_show_these_entries(:git_url) if git_url? and !git_url?.empty? append_to_array_show_these_entries(:pre_make_commands) unless pre_make_commands?.empty? append_to_array_show_these_entries(:use_build_directory) if use_build_directory? append_to_array_show_these_entries(:manual_steps) if manual_steps? and !manual_steps?.empty? append_to_array_show_these_entries(:licence) # ← Mandatory entry. # ======================================================================= # # === use_this_build_system will always be shown # ======================================================================= # append_to_array_show_these_entries(:use_this_build_system) # ← Mandatory entry. # ======================================================================= # # === Use autogen will always be shown. # ======================================================================= # append_to_array_show_these_entries(:use_autogen) append_to_array_show_these_entries(:has_to_be_compiled) append_to_array_show_these_entries(:last_update) append_to_array_show_these_entries(:do_not_symlink) if do_not_symlink? append_to_array_show_these_entries(:md5sum) if show_md5sum? append_to_array_show_these_entries(:use_this_make_install_command) if use_this_make_install_command? # ======================================================================= # # Show whether we will run "configure" or whether we will not: # ======================================================================= # append_to_array_show_these_entries(:run_configure) if run_configure? # ======================================================================= # # Display the BLFS entry fairly close to the bottom. # ======================================================================= # append_to_array_show_these_entries(:blfs) unless blfs?.empty? # ======================================================================= # # Next, display it with a coloured "border". # ======================================================================= # use_this_colour_or_no_colour = :lightblue unless use_colours? use_this_colour_or_no_colour = :do_not_use_colours end array_show_these_entries?.flatten! array_display_these_entries = array_show_these_entries? cliner(use_this_colour_or_no_colour) { e "#{rev}Feedbacking all about the program "\ "`#{mediumslateblue(program_name)}#{rev}`, "\ "#{rev}taken from the file" e "`#{sfile(which_file?)}#{rev}`." e # ===================================================================== # # Next, use a dedicated method to display all the individual # components: # ===================================================================== # show_this_dataset_containing_which_entries_should_be_displayed( array_display_these_entries ) # ===================================================================== # # Show important URLs next. # ===================================================================== # if urls?.first e; e ' Important URLs:' _ = urls?.map {|entry| entry.to_s.chomp }.reject {|x| x.empty?} if _ e; _.each_with_index {|line, index| e "#{grey(' (')}#{seagreen(index+1).to_s}#{grey(') ')}#{grey(line)}" }; e end end } e end
#¶ ↑
report_binary_or_library_program_name
¶ ↑
Only call this method when we have found an alias.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 2926 def report_binary_or_library_program_name( i, new_program_name, binary_or_library = 'binary' ) if i and !i.empty? case binary_or_library # ===================================================================== # # === :binary # ===================================================================== # when :binary binary_or_library = 'binary' # ===================================================================== # # === :library # ===================================================================== # when :library binary_or_library = 'library' end opne '`'+simp(i)+rev+'` was found as name of a '+ simp(binary_or_library)+rev+' file.' opne 'We will now assume that you want to get this '\ 'whole package instead and will' opne 'thus set the name to this program now, which belongs to '\ 'the package `'+sfancy(new_program_name)+rev+'`.'+N end end
#¶ ↑
required_deps_on?¶ ↑
This method will list the required dependencies of a given program and returns them, at least those that are defined in the ‘required_deps_on:’ entry of the respective yaml file.
Please keep in mind that our dependencies must be kept in Array form.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5564 def required_deps_on? obtain __method__.to_s.delete('?').to_sym end
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
RBT::Action#reset
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 367 def reset super() infer_the_namespace initialize_the_internal_hash # ======================================================================= # # === :use_colours # ======================================================================= # set_use_colours end
#¶ ↑
reset_the_dataset
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 539 def reset_the_dataset # ======================================================================= # # === :dataset # ======================================================================= # @internal_hash[:dataset] = {} end
#¶ ↑
return_appdir_prefix
¶ ↑
This method will return an App-Dir like path of the given program at hand, such as “ffmpeg” or “php”.
It is typically called from within the method called .sanitize_the_prefix(). In other words, whenever we need to sanitize the prefix passed this method will be called.
This method requires that short_name
? and program_version
? were already defined prior to its invocation.
The appdir components would be like this:
/home//Programs/Ruby/2.4.1/ programs_dir?+short_name?.capitalize+'/'+program_version?
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5518 def return_appdir_prefix( programs_dir_to_use = programs_dir?, short_name_to_use = short_name?.capitalize, program_version_to_use = program_version? ) _ = programs_dir_to_use.dup if are_we_on_gobolinux? _ << program_compile_name?.dup else _ << short_name_to_use.dup end _ << "/#{program_version_to_use.dup}/" return _ end
#¶ ↑
return_default_location_of_this_cookbook
¶ ↑
This will use the default location based on the search_term.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4991 def return_default_location_of_this_cookbook( i = search_which_program? ) "#{individual_cookbooks_directory?}#{i}.yml" end
#¶ ↑
return_default_program_full_name
¶ ↑
program_full_name
(entry 6) is something like:
'gnome-mahjonng-5.08.tar.xz'
so this is program_name_and_program_version
?+archive_type?
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4526 def return_default_program_full_name( i = program_name_and_program_version?.to_s+ archive_type?.to_s ) return i end
#¶ ↑
return_default_program_path
¶ ↑
This is entry number (8), program_path
, which will look like:
'/home/x/src/gnomemahjongg/gnome-mahjonng-5.08.tar.xz' # base_dir?+program_full_name? '/home/x/src/gnomemahjongg/' + 'gnome-mahjonng-5.08.tar.xz'
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4666 def return_default_program_path base_dir?+ program_full_name? end
#¶ ↑
return_first_dot_as_hyphen_from_this_url
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4860 def return_first_dot_as_hyphen_from_this_url(i = url1?) new_url = File.basename(i).dup # Obtain the URL here. new_url.sub!(/\./,'-') # This replaces only the first '.' found. return new_url end
#¶ ↑
return_first_underscore_as_hyphen_and_other_undscores_as_dots
¶ ↑
This method exists specifically for input such as ‘boost_1_61_0’.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5034 def return_first_underscore_as_hyphen_and_other_undscores_as_dots(i = url?) i = return_first_underscore_as_hyphen_from_this_url(i).dup i.tr!('_','.') return i end
#¶ ↑
return_first_underscore_as_hyphen_from_this_url
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4648 def return_first_underscore_as_hyphen_from_this_url( i = url1? ) new_url = File.basename(i).dup # Obtain the URL here. new_url.sub!(/_/,'-') # This replaces only the first '_' found. new_url = remove_archive_from_the_end(new_url) return new_url end
#¶ ↑
return_middle_part_of_the_program_version
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4550 def return_middle_part_of_the_program_version( program_version = program_version? ) result = program_version.dup if result.include? '.' result = result.split('.')[1] end return result end
#¶ ↑
return_proper_type¶ ↑
This will return the proper default time, such as [] or ” and so forth.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3472 def return_proper_type_for(i = :required_deps_on) file = ::RBT.file_specification_of_registered_cookbook_entries if File.exist? file _ = YAML.load_file(file) if _.include? i.to_s assumed_type = _[i.to_s] case assumed_type when 'Array' return [] else e tomato('Unhandled type: ')+ steelblue(assumed_type.to_s) end end end return nil end
#¶ ↑
return_sanitize_url1
¶ ↑
This can be considered almost equaly to the old “sanitize_url1” method.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4928 def return_sanitize_url1( i = url1? ) i = i.dup # ======================================================================= # # === Handle "llvm-10.0.0.src.tar.xz" and similar cases next # ======================================================================= # if i i.sub!(/\.src\./,'') if i.include? '.src.' # For doxygen.yml i.sub!(/-src/,'') if i.include? '-src' # For zatacka.yml i.delete_suffix!('/download') if i.end_with? '/download' end return i end
#¶ ↑
return_sanitized_program_name_and_program_version
¶ ↑
This method will also get rid of archives.
A full program_name_and_program_version
would be something like:
'gnome-mahjonng-5.08' (2) program_name like 'gnome-mahjongg'
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4684 def return_sanitized_program_name_and_program_version( i = program_name_and_program_version?.dup, url = url1?.dup ) case i # case tag # ======================================================================= # # === USE_URL_DOWNCASE # # Use the URL as program name but downcase it. # ======================================================================= # when 'USE_URL_DOWNCASE', 'USE_DOWNCASED' i = File.basename(url.downcase) # ======================================================================= # # === FIRST_UNDERSCORE_AS_HYPHEN # # This will convert input such as 'boost_1_61_0' into 'boost-1_61_0'. # ======================================================================= # when 'FIRST_UNDERSCORE_AS_HYPHEN', 'FIRST_UNDERSCORE_IS_HYPHEN', 'USE_URL_REPLACE_UNDERSCORE' i = return_first_underscore_as_hyphen_from_this_url(url) # ======================================================================= # # === PROGRAM_NAME_AND_PROGRAM_VERSION_WITHOUT_ALPHABET # # This entry point has been specifically added for the program "brotli", # but also other programs that would fall into that scheme. # # Brotli has an URL like this: # # https://github.com/google/brotli/archive/v1.0.7/brotli-v1.0.7.tar.gz # # The annoying part is the very last 'v'. If you extract this archive # then the resulting directory name is "brotli-1.0.7", so the folks # who packaged this archive evidently are very clueless. But even # aside from this, the issue is that the RBT project may have to guess # and infer the correct program version, which should not include the # 'v' character anyway. The following when-entry ensures precisely # this: all alphabet-characters will be dropped from the program # version. # # This entry point has been added on 30.11.2019. # # Note that PROGRAM_VERSION is not exactly the same, since it will # ONLY modify the program version; it will NOT change the name of # the program at hand. # # Keep in mind that the input may be incomplete, such as in the # String "ninja-PROGRAM_VERSION". # ======================================================================= # when /^PROGRAM_NAME_AND_PROGRAM_VERSION_WITHOUT_ALPHABET$/, /^PROGRAM_VERSION$/, /-PROGRAM_VERSION$/ program_version = program_version? if program_version.nil? or program_version.empty? _ = remove_archive_from_the_end(File.basename(url1?.dup)) _.delete!('a-z') _[0,1] = '' if _.start_with? '-' program_version = _ end if i.include? 'PROGRAM_NAME_AND_PROGRAM_VERSION_WITHOUT_ALPHABET' use_this_as_program_short_name = program_short_name? if use_this_as_program_short_name.nil? or use_this_as_program_short_name.empty? use_this_as_program_short_name = ProgramInformation.return_short_name( remove_archive_from_the_end( File.basename(url1?.dup) ) ) end i.sub!(/PROGRAM_NAME_AND_PROGRAM_VERSION_WITHOUT_ALPHABET/, use_this_as_program_short_name+'-'+program_version) elsif i.include? 'PROGRAM_VERSION' i.sub!(/PROGRAM_VERSION/, program_version) end i.squeeze!('.') # ======================================================================= # # === USE_URL_LAST_HYPHEN_IS_DOT # # This entry point will convert the last hyphen, aka '-', into a '.' # dot. The input may be 'ImageMagick-7.0.8-27' and it will then # become 'ImageMagick-7.0.8.27'. # ======================================================================= # when /^USE_URL_LAST_HYPHEN_IS_DOT$/ _ = File.basename(url1?) i = remove_archive_from_the_end(_) i = i.reverse.sub(/-/,'.').reverse # ======================================================================= # # === FIRST_UNDERSCORE_AS_HYPHEN_AND_OTHER_UNDERSCORES_AS_DOTS # # This is due to boost again - apparnetly the boost developers make # use of a very strange packaging schemata. # # So this entry point will convert input such as 'boost_1_61_0' into # 'boost-1.61.0'. # ======================================================================= # when 'FIRST_UNDERSCORE_AS_HYPHEN_AND_OTHER_UNDERSCORES_AS_DOTS' i = return_first_underscore_as_hyphen_and_other_undscores_as_dots(url) # ======================================================================= # # === FIRST_DOT_AS_HYPHEN # # The following case is for input such as "sendmail.5.2.18" # which should become "sendmail-5.2.18". # # We only manipulate the last part though, so if we have input that # contains a '/', we assume that this is a path and split it up. # This is the reason why we will use File.basename() # ======================================================================= # when 'FIRST_DOT_AS_HYPHEN' i = return_first_dot_as_hyphen_from_this_url(url) # ======================================================================= # # === URL_REPLACE_UNDERSCORE # # This entry point handles the case when the input has '_' characters # in the String. If this is the case then all '_' will be replaced # via '-' characters. # ======================================================================= # when 'URL_REPLACE_UNDERSCORE', 'URL_CONVERT_UNDERSCORE', 'USE_URL_SANITIZED', 'REPLACE_UNDERSCORES', 'USE_URL_MIDDLE_HYPHENS' i = return_url_replace_underscore(url) # ======================================================================= # # === USE_URL # # Simply use the URL as-is, for the program name. # ======================================================================= # when 'USE_URL' i = url else # ===================================================================== # # Handle github-specific links next. # ===================================================================== # if i and is_github_url? and i.start_with?('v-') and (i =~ /v-\d{0,2}.\d{1,2}.\d{1,2}/) # See: http://rubular.com/r/tWF7ikLZiw # =================================================================== # # Ok, we now know that the input is something like 'v-1.11.0'. # We must thus sanitize several parts of the dataset. # =================================================================== # if short_name? == 'v' # ← This must evidently be replaced then. set_short_name( search_for_this_program?.dup #, :also_set_other_names ) set_program_name set_base_dir i = program_name? end end end # ======================================================================= # # Get rid of any .tar.xz or similar archive end here. # ======================================================================= # i = remove_archive_from_the_end(i) return i # We must return something. end
#¶ ↑
return_url_replace_underscore
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4846 def return_url_replace_underscore(i = url?) _ = File.basename(i).dup if _.include? '_' _.tr!('_','-') # Replace all '_' with '-'. elsif _.include? '.' # Else replace just the first '.'. _.sub!('.','-') end _ = remove_file_extension(_) return _ end
#¶ ↑
return_version_from_url1
¶ ↑
This will return the inferred version from the url1 entry.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5149 def return_version_from_url1( use_this_URL = url1? ) _ = remove_archive_at_the_end( File.basename(use_this_URL) ) program_information_return_version(_) end
#¶ ↑
run_make
?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1168 def run_make? obtain(__method__.to_s.delete('?').to_sym) end
#¶ ↑
sanitize_apply_patch
¶ ↑
Here we sanitize the value for apply_patch. tiff.yml may be an example for how to use this setting.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 1369 def sanitize_apply_patch _ = raw_cookbook?.apply_patch? _ = apply_patch? unless _.is_a?(Array) if _ if _.include? '#' _ = _[0 .. (_.index('#') - 1)] set_apply_patch _ end if _.include? 'if PROGRAM_VERSION' # Ok, we specified a specific version. version_to_compare = _.split(' ').last if version_to_compare == program_version? # Ok, patch can be applied. else # Else do not apply this patch. _ = '' end end end set_apply_patch(_) end
#¶ ↑
sanitize_blfs_entry
¶ ↑
This will be only synced if we actually have an entry.
The BLFS entry must be guaranteed to be an Array.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 997 def sanitize_blfs_entry _ = raw_cookbook?.blfs? if _ unless _.is_a? Array if _.nil? _ = [] elsif _.empty? _ = [] # Empty Array then. else _ = [_] end end set_blfs(_) else # Set it to be an empty Array by default, in this case. set_blfs [] end end
#¶ ↑
sanitize_cmake_configure_options
¶ ↑
This method is similar to the method that will sanitize the configure options, but it is only valid for cmake, not for GNU autoconfigure.
A similar method exists for meson-configure-options by the way.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 442 def sanitize_cmake_configure_options _ = cmake_configure_options? if _.nil? if raw_cookbook?.cmake_configure_options? _ = raw_cookbook?.cmake_configure_options? end end if _ and !_.empty? _ = _.to_s.strip # ===================================================================== # # We will assume this to be a comment, so we have to remove these # comments. # ===================================================================== # if _.include? ' # ' _ = remove_comments_from_each_line(_) end _.tr!(N,' ') _.strip! set_cmake_configure_options(_) end end
#¶ ↑
sanitize_configure_base_dir
¶ ↑
We must ensure that this variable has a trailing / character.
There are several reasons for this, but one important reason is that class RBT::Compile
will do a calculation based on the amount of ‘/’ in the configure_base_dir string. So if we have one more or less ‘/’, the calculation’s result will vary - thus, we must ensure that the ‘/’ is trailing here.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 292 def sanitize_configure_base_dir _ = raw_cookbook?.configure_base_dir? if _.nil? _ = configure_base_dir? end set_configure_base_dir(rds("#{_}/")) end
#¶ ↑
sanitize_configure_command_to_use
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 740 def sanitize_configure_command_to_use _ = configure_command_to_use? if _ and _.empty? _ = raw_cookbook?.configure_command_to_use?.to_s # It must be a String. end if _ if _.empty? and deps_on? and deps_on?.include?('waf') _ = 'waf' end if _.empty? _ = 'configure' # set default, reset every time. else _ = convert_global_env(_) if _.include? '$' end set_configure_command_to_use(_) end end
#¶ ↑
sanitize_configure_options
(configure tag)¶ ↑
Work on the configure options, i.e. @dataset.
Note that this depends on program_version
? having been set properly.
Some options should not be sanitized, such as “-Wno-dev -G Ninja ..” in applications that use the cmake build system, e. g. LLVM.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 183 def sanitize_configure_options # ======================================================================= # # We must first check if we are allowed to modify the configure options # at all. Some programs, such as openssl, will not allow such # modification due to their strange way how they mix different # configure-options. # # There are some exceptions to this, though. Newlines for example # can always be removed. # ======================================================================= # _ = raw_cookbook?.configure_options?.to_s.strip # We don't want newlines. if may_we_modify_the_configure_options? # ===================================================================== # # Get rid of multi-blanks next. # ===================================================================== # if _ # =================================================================== # # We will assume this to be a comment, so we have to remove these # comments. # =================================================================== # if _.include? ' # ' _ = remove_comments_from_each_line(_) end _.squeeze!('/') _.gsub!(/#{N}/,' ') end # ===================================================================== # # Treat 'VERSION' as a macro, for expansion. # ===================================================================== # if _.include? 'PROGRAM_VERSION' _.gsub!(/PROGRAM_VERSION/, program_version?.to_s) if _ elsif _.include? 'VERSION' _.gsub!(/VERSION/, program_version?.to_s) if _ end # ===================================================================== # # Treat 'CURRENT' as a macro, for expansion. # ===================================================================== # if _.include? 'CURRENT' _.gsub!(/CURRENT/, program_version?.to_s) if _ end # ===================================================================== # # === NAME_OF_THE_DISTRIBUTION # ===================================================================== # if _.include? 'NAME_OF_THE_DISTRIBUTION' name = load_yaml( "#{project_yaml_directory?}configuration/name_of_the_distribution.yml" ) _.gsub!(/NAME_OF_THE_DISTRIBUTION/, name) end unless _.empty? # =================================================================== # # Finally, run through the configure options. If they start with # the Strings "enable" or "disable", with or without, we prepend -- # if this is not yet the case. # # Since as of September 2011, we will always prepend --, unless # the first character already is a '-' (this is done to # =================================================================== # splitted = _.split(' ') _ = splitted.map {|configure_option| # If configure_option =~ /^disable|enable|with|without/ # ================================================================= # # Only add when not yet first char is NOT a '-'. # ================================================================= # unless configure_option.start_with?('-') or configure_option.start_with?('$') or configure_option.start_with?('.') unless (configure_option == 'Ninja') and splitted.include?('-G') # For cmake variants like: "-G Ninja" configure_option.prepend('--') end end # end configure_option }.join(' ') end # ===================================================================== # # Try to handle $ input. # ===================================================================== # if _.include? '$' unless Object.const_defined? :ConvertGlobalEnv require 'convert_global_env' end _ = ConvertGlobalEnv.convert(_) end end _.tr!(N, ' ') # Replace all newlines again. set_configure_options(_) # Last but not least, reassign. end
#¶ ↑
sanitize_description
(description tag, desc tag)¶ ↑
Get rid of trailing newlines in our description, and apply some other operations.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 694 def sanitize_description _ = description?.to_s.chomp _.chop! if _.end_with? '"' # Get rid of leading and trailing ". _[0,1] = '' if _.start_with? '"' # ======================================================================= # # Some macros have to be expanded before we invoke substitute_macros(). # SELF_NAME is such an example. # ======================================================================= # if _.include? 'SELF_NAME' _.gsub!(/SELF_NAME/, short_name?) end _ = substitute_macros(_) begin # Replace newlines with ' ' characters. _ = _.gsub(/#{N}/,' ').squeeze(' ') rescue Exception => error cliner { opne 'An error happened for the description:' pp @_ pp error } end # ======================================================================= # # Next, if this is empty, but short_description? is not, then # simply copy-paste the content of short_description? onto # the main program description. # ======================================================================= # if _.to_s.empty? and !short_description?.to_s.strip.empty? _ = short_description?.dup end set_description(_) end
#¶ ↑
sanitize_env_variables
¶ ↑
This will sanitize ENV variables. The ENV variables must be a Hash at all times.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 150 def sanitize_env_variables # ======================================================================= # # Sync it first. # ======================================================================= # dataset?[:set_env_variables] = raw_cookbook?.set_env_variables? _ = set_env_variables? if _ and _.is_a? Array # Must also check for nil. # ===================================================================== # # If it is an Array, then it must be wrong, so correct this here # silently. We need a Hash, as specified in the specification. # ===================================================================== # hash = {} _.each {|inner_hash| if inner_hash.is_a? Hash key = inner_hash.keys.first value = inner_hash.values.first hash[key] = value end } dataset?[:set_env_variables] = hash end end
#¶ ↑
sanitize_everything
(sanitize tag, sanitize everything tag, sync tag, sani tag)¶ ↑
This is the method that will sanitize the whole internal dataset, which is typically derived from a yaml-based dataset, via class RawCookbook
.
Some entries have to come in a specific order, since they depend on prior values that were already set correctly.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 26 def sanitize_everything( url1 = raw_cookbook?.url1?, url2 = raw_cookbook?.url2? ) sanitize_url1(url1) # This must come before we sync program-name-and-program-version. sanitize_url2(url2) sanitize_program_name_and_program_version # The program name and program version should come quite early. sanitize_homepage sanitize_wikipedia sanitize_md5sum sanitize_required_deps_on sanitize_BLFS_entry sanitize_short_name sanitize_description sanitize_extra_information sanitize_last_update_entry sanitize_env_variables sanitize_has_to_be_compiled sanitize_short_description sanitize_pre_configure_steps sanitize_is_an_active_project sanitize_build_static sanitize_can_be_compiled_statically sanitize_keep_extracted sanitize_program_version sanitize_apply_patch # ======================================================================= # # === Sanitize the Prefix # # The prefix setting can only be sanitized after the program_version # has been sanitized, since the actual prefix may depend on the # program version in use, such as for AppDirs. # ======================================================================= # sanitize_the_prefix # Must come BEFORE we sanitize the post-installation steps. # ======================================================================= # # === Clean up post-install related activities # # The clean-up of post-install related activities should only be # called after the prefix was already defined, since a few # internal-parts of the method sync_postinstall # may need to know the real prefix in use. # ======================================================================= # sanitize_postinstall sanitize_sed_entry sanitize_the_binaries sanitize_the_headers sanitize_symlink_headers sanitize_the_libraries sanitize_configure_command_to_use sanitize_configure_options sanitize_configure_options_explained sanitize_may_we_modify_the_configure_options sanitize_cmake_configure_options sanitize_meson_configure_options sanitize_installation_steps sanitize_gir_files sanitize_tags sanitize_licence sanitize_autogen sanitize_use_autoconf sanitize_pre_make_commands sanitize_parameters_to_make sanitize_preinstall sanitize_git_url sanitize_use_this_make_command sanitize_use_this_program_name_on_gobolinux sanitize_pkgconfig_files sanitize_symlink_pkgconfig_files sanitize_symlink_headers sanitize_run_configure sanitize_autosymlink_lib64 sanitize_do_not_symlink sanitize_echo_yes sanitize_enable_shared sanitize_enable_static sanitize_flatpak_url sanitize_libexec sanitize_m4_files sanitize_mirror sanitize_symlink_glib_schema sanitize_use_this_make_install_command sanitize_configure_base_dir sanitize_base_dir sanitize_svn_url sanitize_use_build_directory sanitize_use_this_build_directory sanitize_use_this_build_system sanitize_localstatedir sanitize_do_not_download sanitize_modify_the_makefile sanitize_manual_steps sanitize_sha256 # ======================================================================= # # Last but not least, find out the file size of the program in question. # ======================================================================= # calculate_archive_size calculate_md5sum if shall_we_display_the_md5sum? end
#¶ ↑
sanitize_extra_information
¶ ↑
We must not lose information from the original dataset, in regards to extra_information.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 336 def sanitize_extra_information _ = raw_cookbook?.extra_information? if _ _.chomp! if _.respond_to? :chomp! _.rstrip! if _.respond_to? :rstrip! _ = word_wrap(_) if use_word_wrap? set_extra_information(_) end end
#¶ ↑
sanitize_has_to_be_compiled
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 648 def sanitize_has_to_be_compiled _ = raw_cookbook?.has_to_be_compiled? if _.nil? or (_.is_a?(String) and _.empty?) # Empty Strings will be "sanitized" here. _ = has_to_be_compiled? end set_has_to_be_compiled(to_bool(_)) end
#¶ ↑
sanitize_installation_steps
¶ ↑
Installation steps are steps that we have to perform in order to get different programs to install on a given computer system.
Special macros can be used as part of the installation steps.
For instance:
MY_PROGRAMS/Procps/PROGRAM_VERSION
Will be expanded to whatever value MY_PROGRAMS was set to; usually it is, or should be, pointing towards “/Programs/” or “/home/Programs/”.
Do note that this means that the value for MY_PROGRAMS must exist, otherwise this can not possibly work. Of course you can omit using macros and just hardcode values there anyway; the macros only exist to make it simpler to handle different programs.
Another example for macro-conversion would be the String ‘RINSTALL1’, which will become expanded into the following three actions:
ruby install.rb config ruby install.rb setup ruby install.rb install
The latter expansions are part of the file:
predefined_installation_instructions.yml
So, if you want to add new macros, you can do so by modifying that very yaml file.
Keep in mind that the installation steps are stored as Array at all times.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 1175 def sanitize_installation_steps _ = installation_steps? if _ and _.empty? if raw_cookbook?.installation_steps? and !raw_cookbook?.installation_steps?.empty? _ = raw_cookbook?.installation_steps? end end unless _.is_a? Array _ = [_].flatten.compact # ← .compact to avoid retaining nil values. end if _.empty? _ << 'make' # ← This is the hardcoded default value at all times. end # ======================================================================= # # bl $RBT/yaml/predefined_installation_instructions.yml # ======================================================================= # dataset = load_yaml( file_predefined_installation_instructions? ) _.map! {|entry| if dataset.has_key? entry entry = dataset[entry] if entry.is_a? String # ================================================================= # # The String may look like this: # # copy_ruby; ruby setup.rb config; ruby setup.rb setup; ruby setup.rb install # # ================================================================= # if entry.include? ';' entry = entry.split(';').map(&:strip) end end end } _.flatten! _.compact! _.reject!(&:empty?) # ========================================================================= # # Past this point here we have an Array. # ========================================================================= # unless _.empty? _.map! {|line| line = line.dup if line.frozen? line.strip! # =================================================================== # # Next, replace all ',' with ';' characters. # =================================================================== # line.tr!(',',';') if line.include? ',' if Object.const_defined? :ConvertGlobalEnv line = ConvertGlobalEnv[line] if line.include? '$' end # =================================================================== # # === Replace the predefined installation instruction next # =================================================================== # if predefined_installation_instructions?.include? line line = predefined_installation_instructions?[line] end if line.include? 'VERSION' # ================================================================= # # Need to set @program_version first, hence we update some stuff. # ================================================================= # set_program_name(program_name?) # This equals, for example, to "gnome-mahjonng-5.08" if line.include? 'PROGRAM_VERSION' line.gsub!(/PROGRAM_VERSION/, program_version?) if program_version? elsif line.include? 'VERSION' line.gsub!(/VERSION/, program_version?) if program_version? end end line = line.split(';') if line.include? ';' # This may turn it into an Array. line } end _.flatten! _.map!(&:strip) set_installation_steps(_) end
#¶ ↑
sanitize_is_an_active_project
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 1306 def sanitize_is_an_active_project _ = raw_cookbook?.is_an_active_project? if _.nil? _ = is_an_active_project? end set_is_an_active_project(to_bool(_)) end
#¶ ↑
sanitize_last_update
¶ ↑
The only sanitize-operation we do here is if it is an valid date, such as “32 Aug 2017”.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 832 def sanitize_last_update _ = last_update? if _ and _.include? ' ' splitted = _.split(' ') day = splitted.first # Fetch the day-entry. if day.to_i > 31 opne swarn('The last_update entry for ')+ steelblue(program_name?)+ swarn(' is wrong (too high).') opne swarn('Please correct this entry.') opne swarn('The faulty entry currently looks like this:') e e " #{_}" e # =================================================================== # # We could exit here but this is mostly an annoyance rather than # a bug, so we continue. As of April 2021, we will exit. # =================================================================== # exit end elsif _ and (_.count('.') == 2) # Input such as '24.09.2017' splitted = _.split('.') splitted[1] = return_month_based_on_this_number(splitted[1])[0,3] # This is the month but only the first 3 characters. _ = splitted.join(' ') set_last_update(_) end end
#¶ ↑
sanitize_licence
¶ ↑
Empty license should default to “unknown” license. This method will ensure that this is the case.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 1021 def sanitize_licence _ = licence? begin if _.nil? or _.empty? _ = 'unknown' else if _.is_a?(String) and _.include?(',') # ← In this case, turn it into an Array. _ = _.split(',').map(&:strip) else _ = 'unknown' if _.nil? or _.empty? end end set_licence(_) rescue Exception => error opne 'An error happened in sanitize_licence().' pp data? pp error pp error.class opne 'Exiting now - this error (in sanitize_licence()) '\ 'should be fixed though.' exit end end
#¶ ↑
sanitize_may_we_modify_the_configure_options
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 1391 def sanitize_may_we_modify_the_configure_options _ = raw_cookbook?.may_we_modify_the_configure_options?.to_s if _ and _.empty? _ = may_we_modify_the_configure_options?.to_s end set_may_we_modify_the_configure_options(to_bool(_)) end
#¶ ↑
sanitize_md5sum
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 1413 def sanitize_md5sum _ = raw_cookbook?.md5sum? if _.nil? _ = md5sum? if _.nil? _ = `md5sum #{program_path?}` if File.exist? program_path? end end set_md5sum(_) end
#¶ ↑
sanitize_meson_configure_options
¶ ↑
This method is similar to the method sanitize_configure_options
() but it is only valid for meson, not for GNU autoconfigure.
The configure options for meson must be kept as a String, at all times.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 472 def sanitize_meson_configure_options _ = raw_cookbook?.meson_configure_options? _ = meson_configure_options? unless meson_configure_options?.nil? # ======================================================================= # # We sanitize it a bit, if the option exists. # ======================================================================= # if _ _ = _.to_s.strip # ===================================================================== # # We will assume this to be a comment, so we have to remove these # comments. # ===================================================================== # if _.include? ' # ' _ = remove_comments_from_each_line(_) end if _.include? N _.tr!(N,' ') end _.strip! _.squeeze!(' ') set_meson_configure_options(_) end end
#¶ ↑
sanitize_modify_the_makefile
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 1402 def sanitize_modify_the_makefile _ = raw_cookbook?.modify_the_makefile? if _.nil? or ( _.is_a?(String) and _.empty? ) _ = false # This is the default value. end set_modify_the_makefile(to_bool(_)) end
#¶ ↑
sanitize_parameters_to_make
¶ ↑
This method will sanitize the parameters that can be given to the program called “make” (on the commandline). “make” is typically invoked for a given program.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 1283 def sanitize_parameters_to_make _ = parameters_to_make? if _ and _.empty? _ = raw_cookbook?.parameters_to_make? end _ = [_].flatten.compact.reject {|entry| entry.is_a?(String) and entry.empty? } set_parameters_to_make(_) end
#¶ ↑
sanitize_pkgconfig_files
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 508 def sanitize_pkgconfig_files _ = pkgconfig_files? if _ and _.empty? _ = raw_cookbook?.pkgconfig_files? if raw_cookbook?.pkgconfig_files? end set_pkgconfig_files(_) end
#¶ ↑
sanitize_postinstall
¶ ↑
This will sanitize the postinstall stuff, by assigning to the respective entry in the main Hash.
Note that we have to invoke this method only after short_name
and program_version
was set, because one entry requires this specifically.
As of 20.09.2014, the specification requires that postinstall must be an Array at all times.
Invocation example:
scookie libraw1394
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 566 def sanitize_postinstall _ = [postinstall?].flatten.compact # Get rid of nil values. if _ and _.is_a?(Array) and _.empty? _ = raw_cookbook_dataset?['postinstall'] end if _.is_a? Array _.map! {|entry| substitute_macros(entry) } end # ===================================================================== # # Turn it into an Array for sure: # ===================================================================== # _ = [_].flatten.compact # ===================================================================== # # Sanitize the @postinstall variable next. # ===================================================================== # if _.is_a? Array point_to_binaries = sysbin_directory? point_to_libraries = syslib_directory? point_to_includes = sysinclude_directory? point_to_program_dir = program_directory? _.map! {|entry| if entry.include? 'UNIVERSAL_BINARY_DIR' entry.gsub!(/UNIVERSAL_BINARY_DIR/, point_to_binaries) end entry.gsub!(/UNIVERSAL_BINARIES_DIR/, point_to_binaries) entry.sub!(/UBD/, point_to_binaries) entry.gsub!(/UNIVERSAL_LIBRARIES_DIR/, point_to_libraries) entry.sub!(/ULD/, point_to_libraries) entry.gsub!(/UNIVERSAL_INCLUDE_DIR/, point_to_includes) entry.gsub!(/PROGRAM_DIR/, point_to_program_dir) entry.gsub!(/PROGRAMS_DIR/, point_to_program_dir) entry.gsub!(/,cp/, ',copy_file') # ================================================================= # # Handle the MIDDLE_VERSION macro next. This one is, for # python, the value "8", from version "3.8.3" - thus the # middle part. # ================================================================= # if entry.include? 'MIDDLE_VERSION' entry.sub!(/MIDDLE_VERSION/, return_middle_part_of_the_program_version) end entry.strip! # Strip it. entry = rds(entry) # Replace // with // here. entry } set_postinstall _ # Reassign. end unless postinstall?.is_a? Array _ = rds(postinstall?) _ = _.split(',') if _.include? ',' set_postinstall [_].flatten end end
#¶ ↑
sanitize_pre_make_commands
¶ ↑
We must keep the pre_make_commands
in Array format. The method here will make sure of this.
We can only invoke this after having set program_version
before, because some macro-substitutions require the program version to be properly set before the make-commands can be sanitized.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 666 def sanitize_pre_make_commands _ = pre_make_commands? if _.empty? _ = raw_cookbook?.pre_make_commands? end _.compact! if _.is_a? Array # Get rid of nil values. case _ # Do a bit free-form sanitizing next. when 'handle configure.py' _ = 'python configure.py' end array = [] if _ unless _.empty? _ = substitute_macros(_) array << _ end end array.flatten! array.compact! set_pre_make_commands(array) # Turn it into an Array here. end
#¶ ↑
sanitize_preinstall
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 412 def sanitize_preinstall _ = preinstall? if _ and _.empty? _ = raw_cookbook?.preinstall? end if _.is_a?(String) and (_.count(N) > 1) _ = _.split(N) end if _.nil? # Safeguard to ensure Array. set_preinstall [] else _ = [_] if _.is_a? String if _.is_a? Array _.compact! _.map!(&:strip) _.reject! {|entry| entry.empty? } # Weed out empty entries. _.flatten! end set_preinstall _ end end
#¶ ↑
sanitize_program_name_and_program_version
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 1107 def sanitize_program_name_and_program_version _ = raw_cookbook?.program_name_and_program_version? if _.nil? _ = program_name_and_program_version? end _ = return_sanitized_program_name_and_program_version(_, url1?) unless _.nil? set_program_name_and_program_version(_) end end
#¶ ↑
sanitize_program_path
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 140 def sanitize_program_path reassemble_program_path end
#¶ ↑
sanitize_required_deps_on
¶ ↑
The entry required_deps_on will be sanitized here - it must be an Array at all times.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 904 def sanitize_required_deps_on _ = raw_cookbook?.required_deps_on? if _.nil? _ = return_proper_type_for(:required_deps_on) end if _.is_a? String # Input such as 'perl cmake'. Has to become an Array. if _.include? ' ' unless _.include?('>') or _.include?('<') # But not when we have comparison-operators. _ = _.split(' ') end end end array = [] _ = [_].flatten.compact # Must be an Array. _.map! {|entry| if entry.include? ',' entry = entry.split(',').map(&:strip) end entry } unless _.empty? array << _ array.flatten! array.compact! # ======================================================================= # # At this point the entry is a sanitized Array. But the cookbook # file may still have made a mistake, such as when an entry # was accidentally listed twice. (I had this problem in Feb # 2017, which was why I added the following code.) # So we need to check whether the entries are all unique - and # if they are not, we will notify the user that something may # be wrong with the yaml file in question. # ======================================================================= # if array.uniq.size != array.size path = RBT.individual_cookbooks_dir?+ program?+ '.yml' non_unique_entries = array.uniq.map { |e| [array.count(e), e] }.select {| c, _ | c > 1 }.sort.reverse.first.last unless non_unique_entries.is_a? Array non_unique_entries = [non_unique_entries] # We need an Array. end opnwarn('There may be one (or several) duplicate dependencies '\ 'listed in the yaml file.') opne swarn(' Path: ')+sfile(path) opne swarn('Here are the duplicate entries:') non_unique_entries.each {|duplicate_entry| e " #{simp(duplicate_entry)}" } e swarn('If you wish to check for that on your own, have a look at the') e swarn('yaml file at `')+sfile(path)+swarn('`.') e swarn('Check the "required_deps_on:" entry of the .yml file.') end set_required_deps_on(array) end
#¶ ↑
sanitize_run_configure
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 1350 def sanitize_run_configure _ = raw_cookbook?.run_configure? if _.nil? _ = run_configure? end if _ and _.is_a?(String) and _.empty? _ = run_configure?.to_s end _ = to_bool(_) _ = false if _.nil? set_run_configure(_) end
#¶ ↑
sanitize_sed_entry
(sed tag)¶ ↑
The sed entry allows us to make some very simple replacements in files.
We will guarantee that this setting will be an Array.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 967 def sanitize_sed_entry # ======================================================================= # # Only sanitize the sed entry if we have that key. # ======================================================================= # if has_key? :sed raw_data = raw_cookbook_dataset? _ = sed? if (_ == false) and raw_data.has_key?('sed') _ = raw_data['sed'] end if _ _ = _.split(N) if _.is_a? String if _ # ================================================================= # # We need an Array past this point. # ================================================================= # _ = [_].compact # We don't want to store nil values here. set_sed(_) end end end end
#¶ ↑
sanitize_short_description
¶ ↑
Right now this method will only get rid of newlines and do a .strip() call.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 1051 def sanitize_short_description short_description = short_description? if short_description.nil? short_description = raw_cookbook?.short_description? end if short_description and short_description.include? N set_short_description( short_description.to_s.delete(N).strip ) end end
#¶ ↑
sanitize_symlink_glib_schema
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 303 def sanitize_symlink_glib_schema _ = raw_cookbook?.symlink_glib_schema?.to_s if _ and _.empty? _ = symlink_glib_schema?.to_s end set_symlink_glib_schema(to_bool(_)) end
#¶ ↑
sanitize_symlink_headers
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 1454 def sanitize_symlink_headers _ = raw_cookbook?.symlink_headers? if _.nil? _ = symlink_headers? end case _ when 't' _ = 'yes' when 'f' _ = 'no' end set_symlink_headers(_) end
#¶ ↑
sanitize_symlink_pkgconfig_files
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 1121 def sanitize_symlink_pkgconfig_files _ = raw_cookbook?.symlink_pkgconfig_files? if _.nil? _ = symlink_pkgconfig_files? end case _ when 't' _ = 'yes' when 'f' _ = 'no' else _ = to_bool(_) end set_symlink_pkgconfig_files() end
#¶ ↑
sanitize_the_binaries
(binaries tag)¶ ↑
This method will sanitize the binaries entry.
The binaries must be kept in Array format at all times.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 626 def sanitize_the_binaries _ = raw_cookbook?.binaries? _ = [] if _.nil? if _ and !_.empty? if _.is_a?(String) and !_.empty? _ = _.split(',') elsif _.is_a? String _ = [_] end if _.is_a? Array if _.first.include? ',' # Assume that we must split then. _.map! {|entry| entry.split(',') } end if _.first end end _ = _.flatten.compact.map(&:strip) set_binaries(_) end
#¶ ↑
sanitize_the_headers
(headers tag)¶ ↑
The headers entry must be kept as an Array at all times, according to the specification.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 1474 def sanitize_the_headers _ = headers? if _ and _.is_a?(Array) and _.empty? _ = raw_cookbook_dataset?['headers'] end if _.is_a? Array if _.first.include? ',' _ = _.first.split(',') end if _.first end if _.is_a? String _ = _.to_s.strip _ = _.split(',') if _.include? ',' _ = nil if _.empty? end _ = [_].flatten.compact # ======================================================================= # # The individual entries may have a newline or an empty String at # the beginning. The next line of code ensures that we will get # rid of these. # ======================================================================= # _.map! {|entry| entry.delete(N).strip } # ======================================================================= # # Must keep it sorted, since as of July 2017. It is easier to # keep track of these entries on the commandline when they # are sorted. # ======================================================================= # _.sort! set_headers(_) end
#¶ ↑
sanitize_the_libraries
¶ ↑
This sanitizes the libraries entry, @_.
We must keep this entry in Array format.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 781 def sanitize_the_libraries _ = raw_cookbook?.libraries? unless _.is_a? Array _ = [_].compact end # ======================================================================= # # Next, we will assume something such as: # ["libdevkit-power-gobject.{so,a},libupower-glib.{so,a}"] # ======================================================================= # unless _.empty? # safeguard against nil entries. if _ and _.first and _.first.include?('}') and _.first.include?('{') splitted = _.first.split(/\},/) splitted.map! {|entry| entry =~ REGEX_TO_SANITIZE_LIBRARIES [$1+'.'+$2, $1+'.'+$3] } splitted.flatten! _ = splitted end end if _.is_a? Array if _.first.include? ',' _ = _.first.split(',') _.map!(&:strip) # It should not include empty whitespace. # =================================================================== # # Some libraries may have components such as foo{so.a} # We need to split these up into foo.so and foo.a. # =================================================================== # end if _.first end new_value = [_].flatten.compact set_libraries(new_value) end
#¶ ↑
sanitize_the_prefix
(sanitize prefix tag)¶ ↑
The value for the prefix of the program at hand will be sanitized here, in this method.
The prefix must be a String at all times according to the specification.
Since as of May 2013, we will never use a shortcut anymore, we will always store the full, absolute path to our entry.
“false” as value, is an indication of using the path to an AppDir.
For example, a value of false would be interpreted like /Programs/Htop/2.0.0 - in other words, a proper appdir.
The –prefix is always a directory, so as of Jan 2014 this method will append a / to this unless the last character is already a /.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 1524 def sanitize_the_prefix # ======================================================================= # # General way to overrule the prefix setting in this case. # ======================================================================= # if COMPILE_EVERYTHING_INTO_STANDALONE_DIRECTORY old_prefix = 't' else # ===================================================================== # # We need to use .to_s because the prefix can be a boolean value as # well, such as true or false. # ===================================================================== # old_prefix = prefix?.to_s.dup end # ======================================================================= # # As of January 2014, we will pass the String through the macro-check, # which has to be done because our string may include PROGRAM_NAME # as a prefix. # ======================================================================= # old_prefix = substitute_macros(old_prefix).dup case old_prefix # ======================================================================= # # === traditional # ======================================================================= # when 't', 'true', 'yes', 'y', 'traditional' set_internal_prefix('/usr/') # ======================================================================= # # === non-traditional # ======================================================================= # when 'f', 'false', 'no', 'AppDir', 'return_appdir_path', 'appdir_path' # ===================================================================== # # This must use an appdir prefix. # ===================================================================== # set_internal_prefix(return_appdir_prefix.dup) # ← This is the AppDir variant. else old_prefix = old_prefix.dup # ===================================================================== # # Append '/' unless we already have a trailing '/'. # ===================================================================== # old_prefix << '/' unless old_prefix.end_with? '/' old_prefix.sub!(/ULOCAL/,'/usr/local') if old_prefix.include? 'ULOCAL' # ULOCAL gets expanded to /usr/local old_prefix.sub!(/ULOC/, '/usr/local') if old_prefix.include? 'ULOC' # same counts for ULOC # ======================================================================= # # We used to delete '-' here in the past, but as of September 2017 # this is no longer the case. Some programs may have a '-' as part # of the program version, and it may be better to include this # rather than remove it. # ======================================================================= # # old_prefix.delete!('-') if _.include? '-' set_internal_prefix(old_prefix) end end
#¶ ↑
sanitize_then_set_boolean_value
¶ ↑
This method will turn ‘t’ into true and ‘f’ into false.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 1438 def sanitize_then_set_boolean_value(i) _ = obtain(i) set(i, to_bool(_)) end
#¶ ↑
sanitize_use_autoconf
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 368 def sanitize_use_autoconf _ = raw_cookbook?.use_autoconf? if _ and _.is_a?(String) and _.empty? _ = use_autoconf?.to_s end _ = to_bool(_) _ = false if _.nil? set_use_autoconf(_) end
#¶ ↑
sanitize_use_this_build_system
¶ ↑
The build_system entry must always be a String.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 1715 def sanitize_use_this_build_system _ = use_this_build_system? _ = '' if _.nil? if _ and _.is_a?(String) and _.empty? # ===================================================================== # # Must set a new default value in this case. # ===================================================================== # _ = :default # This means to infer the build system in use. end set_use_this_build_system(_) end
#¶ ↑
sanitize_use_this_make_command
¶ ↑
This will default to whatever is stored in the configuration file.
Should be ‘make’ usually, but could be “cmake” or another make-like command.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 319 def sanitize_use_this_make_command _ = use_this_make_command? if _ and _.empty? _ = raw_cookbook?.use_this_make_command? if _.nil? or _.empty? _ = MAKE_COMMAND_TO_USE # MAKE_COMMAND_TO_USE is defined in constants.rb end end set_use_this_make_command(_) end
#¶ ↑
sanitize_use_this_program_name_on_gobolinux
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_related_code.rb, line 398 def sanitize_use_this_program_name_on_gobolinux( are_we_on_gobolinux = are_we_on_gobolinux? ) _ = program_compile_name? if are_we_on_gobolinux and !use_this_program_name_on_gobolinux?.to_s.empty? _ = use_this_program_name_on_gobolinux?.to_s set_program_compile_name(_) # Will always be at the least an empty String. end end
#¶ ↑
seek_this_program
? (seek tag)¶ ↑
This method will tell us as for which program we will search.
Do note that this is NOT the same as program_name
? or short_name
?, because the latter two may contain upcased characters, such as for “libX11”, whereas the variable here is ALWAYS downcased.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5075 def seek_this_program? @internal_hash[:seek_this_program] end
#¶ ↑
send_this_method_and_sanitize_arrays
¶ ↑
The second argument can be used to “limit the result”, e. g. to show only n elements (from an Array, typically).
It is used in particular to not display too many elements, as these may overflow on the screen (commandline output) - but the user can override this behaviour, via –do-not-truncate.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4353 def send_this_method_and_sanitize_arrays( i, limit_the_result = false ) result = send(i) # ======================================================================= # # The following clause will be entered if there are too many entries # for the given field - in particular header-files, binaries and # libraries. # ======================================================================= # if @internal_hash[:try_to_truncate_too_long_output] and limit_the_result and (result.size > limit_the_result) # Check for more elements here. # ===================================================================== # # === Handle "headers?" next # ===================================================================== # if i.to_s.include?('headers?') if limit_the_result append_this = ' ... → TRUNCATED '+ (result.size - limit_the_result).to_s+ ' more .h header files' result = result[0 .. (limit_the_result - 1)] result << append_this end # ===================================================================== # # === Handle "libraries?" next # ===================================================================== # elsif i.to_s.include?('libraries?') if limit_the_result append_this = ' ... → TRUNCATED '+ (result.size - limit_the_result).to_s+ ' more library files' result = result[0 .. (limit_the_result - 1)] result << append_this end # ===================================================================== # # === Handle "binaries?" next # ===================================================================== # elsif i.to_s.include?('binaries?') if limit_the_result append_this = ' ... → TRUNCATED '+ (result.size - limit_the_result).to_s+ ' more binaries/executables' result = result[0 .. (limit_the_result - 1)] result << append_this end end end if result.is_a? Array result = '['+result.join(',')+']' unless result.compact.empty? end return result end
#¶ ↑
set (set tag, setter tag)¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 549 def set(key, value) dataset?[key.to_sym] = value end
#¶ ↑
set_active_project
¶ ↑
The default assumption is that all projects are actively maintained. If this assumption is incorrect then it has to be registered in the particular .yml file, via an entry such as: “active_project: no”
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1099 def set_active_project(i = true) set(:active_project, i) end
#¶ ↑
set_archive_size
¶ ↑
The archive size, that is, how large the archive is - in bytes.
The archive size will default to 0 on startup or when no argument is passed to it.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1884 def set_archive_size(i = 0) set(:archive_size, i) end
#¶ ↑
set_archive_type
(archive tag, 4 tag)¶ ↑
This method will set the ‘archive_type’ of a given program at hand.
It is entry number (5), and may typically look like ‘.tar.xz’, in a program like ‘gnome-mahjonng-5.08.tar.xz’.
Typically, archives will be kept in the .tar.xz format locally, or rather whatever the value of the DEFAULT_ARCHIVE_TYPE specifies.
We need this part when we wish to assemble the program_full_name
setting lateron, at entry number (6), which would then look like this: ‘gnome-mahjonng-5.08.tar.xz’
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1047 def set_archive_type( i = DEFAULT_ARCHIVE_TYPE ) case i when :infer_from_url1 i = File.basename(url1) when nil, :default, 'default' i = DEFAULT_ARCHIVE_TYPE # Safeguard. when :tar_xz i = TARXZ end i = i.to_s.dup.downcase # Keep it downcased as well, and in String format. # ======================================================================= # # === Get rid of '/' # ======================================================================= # if i.include? '/' i = File.basename(i) end # ======================================================================= # # Do some sanitizing next. # ======================================================================= # i.sub!(/\.source$/,'') if i.include? '.source' # ======================================================================= # # If the input includes a '-' token, then something can not be right. # ======================================================================= # if i.include? '-' i = i[(i.rindex('-')+1)..-1] # ======================================================================= # # Same for input containing '_'. # ======================================================================= # elsif i.include? '_' i = i[(i.rindex('_')+1)..-1] end if i == 'guess' i = File.basename(url?) end i = archive_type_of?(i) # This method must have registered all archive-types. set(:archive_type, i) end
#¶ ↑
set_autoconf
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1986 def set_autoconf(i) set(:use_autoconf, i) end
#¶ ↑
set_autosymlink_lib64
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1825 def set_autosymlink_lib64(i) set(:autosymlink_lib64, i) end
#¶ ↑
set_base_dir
(base_dir
tag, base dir tag, 7 tag)¶ ↑
This is (7), the base_dir.
It will be equivalent to a String such as “/home/x/src/gnomemahjongg/” or “/home/x/src/file/”.
It constitutes of:
- src_dir? - short_name? - '/'
The short_name
? will be used as name for the archive at hand, but it will always be downcased - see the .downcase variant.
If the input is :guess_base_dir then this means that the method will try to guess the base directory in use.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 657 def set_base_dir( i = :default ) case i # ======================================================================= # # === :default # # This clause can be entered via: # # set_base_dir(:default) # # Note that the base_dir entry is not allowed to have any '.' # characters. # ======================================================================= # when :default, :guess_base_dir, :guess i = "#{src_dir?}".dup unless base_dir?.nil? i << base_dir? i << '/' unless i.end_with?('/') else i << "#{short_name?.to_s.downcase.delete('.')}/" # This was guess_base_dir. end end if i i = i.dup if i.frozen? # ===================================================================== # # Assume that a path starting with ./ is never correct. # ===================================================================== # if i.start_with? './' i[0,2] = source_dir? end # ===================================================================== # # === Handle + tokens # # Some directory names may include a '+' character, such as is the # case with gtk+. There are several ways how to deal with this, but # if we have a certain configuration option set, then we will # replace '+' with long name, which is 'plus'. I personally no # longer use this - my directory names will also include a '+' # character as a consequence. # ===================================================================== # if i.include? '+' i.gsub!(/\+/, 'plus') if replace_plus_with_long_name? end # ===================================================================== # # === Delete _ from the name of the directory as well # # The following code was added as of January 2014. # # While programs can have names such as 'e_dbus', the directory # name itself is not allowed to contain any '_' token. It # looks visually odd otherwise. # ===================================================================== # i.delete!('_') if i.include? '_' # ===================================================================== # # We don't want any '-' in the base_dir name either, so away with them. # ===================================================================== # i.delete!('-') if i.include? '-' # ===================================================================== # # === Append / # # It is the correct way to ensure that the last char is a /. The # reason is: directories contain a '/' as part of their name. # ===================================================================== # i << '/' unless i.end_with? '/' end # ======================================================================= # # Remove double slashes # ======================================================================= # i = rds(i) dataset?[:base_dir] = i end
#¶ ↑
set_cmake_configure_options
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 961 def set_cmake_configure_options(i) set(:cmake_configure_options, i) end
#¶ ↑
set_compiler_to_use
¶ ↑
Do note that this method is normally not used by default; it primarily exists so that downstream code in RBT::Compile
can keep track of which compiler is used, e. g. :gcc or :clang and similar variants.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1957 def set_compiler_to_use(i = :gcc) set(:compiler_to_use, i) end
#¶ ↑
set_complex_program_version
¶ ↑
The purpose of this method is to allow the user to overrule the respective settings, at run-time.
That way, you can change e. g. “glib-2.24” to “glib-2.25”.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5863 def set_complex_program_version( i, be_verbose = true ) case be_verbose # ======================================================================= # # === :be_quiet # ======================================================================= # when :be_quiet, :be_silent be_verbose = false end i = i.dup if i.frozen? # ======================================================================= # # Add a '=' to make it easier to know what we want to modify. This # will NOT happen if the input includes a '@', though. # ======================================================================= # i.prepend '=' unless i.include?('=') or i.include?('@') # ======================================================================= # # Next, we fetch a specific version. We assume this to be the last part # of the command given, which must include a '=' character. Since as # of September 2022 a '@' is permissive as well. # ======================================================================= # if i.include? '=' new_version = i.split('=').last elsif i.include? '@' new_version = i.split('@').last end # ======================================================================= # # Chop off archive-extension since we don't need these. # ======================================================================= # new_version = remove_file_extension(new_version) if be_verbose opne "Setting a new version: #{simp(new_version)}" end set_program_version(new_version, :propagate_the_change) # The second argument will propagate the change, by cascading downwards. update_prefix :bypass_check end
#¶ ↑
set_configure_command_to_use
¶ ↑
The configure command will usually be configure, but it may also be cmake or waf or something like that.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 564 def set_configure_command_to_use( i = :configure ) set(:configure_command_to_use, i) end
#¶ ↑
set_configure_options
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1936 def set_configure_options(i) # ======================================================================= # # Since as of September 2017, the input is no longer allowed to have # any newlines. This is explicitely mentioned here in the event that # we may have to revert this decision one day. # ======================================================================= # if i and i.include?(N) i = i.dup if i.frozen? i.delete!(N) i.squeeze!(' ') # And also get rid of ' ' variants. end set(:configure_options, i) end
#¶ ↑
set_do_not_symlink
¶ ↑
The alias “do_not_symlink” is an emplicit set_do_not_symlink
() call with the argument true. If this is changed, we would also have to create a new method to specifically enable the behaviour desired by do_not_symlink
().
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1558 def set_do_not_symlink(i = true) set(__method__.to_s.delete_prefix('set_').to_sym, i) end
#¶ ↑
set_env_variables
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1701 def set_env_variables(i) set(__method__.to_s.delete_prefix('set_').to_sym, i) end
#¶ ↑
set_env_variables
?¶ ↑
Query the environment variables that this cookbook may set.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1222 def set_env_variables? obtain(__method__.to_s.delete('?').to_sym) end
#¶ ↑
set_extract_to
¶ ↑
Consistently use this method when you wish to use the extract_to variable.
This variable must ALWAYS keep the location of where to extract a package to lateron.
Values set in the corresponding .yml file are able to overrule this.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1658 def set_extract_to( i = :use_extract_to_or_the_default_rbt_log_directory_otherwise ) case i # ======================================================================= # # === :use_extract_to_or_the_default_rbt_log_directory_otherwise # ======================================================================= # when :use_extract_to_or_the_default_rbt_log_directory_otherwise if extract_to?.to_s.empty? i = rbt_log_directory? else i = extract_to? # This is for e. g. "linux.yml" which has an extract_to: entry. end # ======================================================================= # # === :default # ======================================================================= # when :default, nil i = rbt_log_directory? end i = i.dup # We don't want to keep a tainted reference. # ======================================================================= # # Ensure that we have a proper default value if the input was ''. # ======================================================================= # i = extract_to? if i.to_s.empty? # ======================================================================= # # Try to get an ENV variable here, if ENV is part of @extract_to. # ======================================================================= # if i.include? 'ENV' match = i.gsub(/ENV\['/,'').gsub(/'\]/,'') # contains the ENV variable i = ENV[match].dup end # ======================================================================= # # append / if the last character is not '/' # ======================================================================= # i << '/' unless i.end_with? '/' set(:extract_to, i) end
#¶ ↑
set_flatpak_url
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1589 def set_flatpak_url(i) set(__method__.to_s.delete_prefix('set_').to_sym, i) end
#¶ ↑
set_internal_commandline_arguments
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 2038 def set_internal_commandline_arguments( i = ARGV ) # ======================================================================= # # === :internal_commandline_arguments # # Keep track of the commandline arguments in the main Hash of this # class. # ======================================================================= # @internal_hash[:internal_commandline_arguments] = [i].flatten.compact end
#¶ ↑
set_internal_prefix
¶ ↑
Use this method to set towards a specific prefix, such as ‘/usr/’.
This is then the option that will be passed into scripts such as ‘configure’ or cmake-based systems.
This setter method is NOT allowed to modify the given input.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5935 def set_internal_prefix( i = '/usr/', bypass_check = :no_longer_available # false ) if i.is_a? Symbol i = '/usr/' end @internal_hash[:dataset][:prefix] = i # Or use set(:prefix, i). end
#¶ ↑
set_keep_extracted
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 2014 def set_keep_extracted(i) set(:keep_extracted, i) end
#¶ ↑
set_libexec
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1565 def set_libexec(i) set(__method__.to_s.delete_prefix('set_').to_sym, i) end
#¶ ↑
set_licence
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 595 def set_licence(i) set(:licence, i) end
#¶ ↑
set_m4_files
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1579 def set_m4_files(i) unless i.is_a? Array i = [i].compact end set(__method__.to_s.delete_prefix('set_').to_sym, i) end
#¶ ↑
set_make_use_of_aliases_kept_in_the_file_cookbook_aliases
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1971 def set_make_use_of_aliases_kept_in_the_file_cookbook_aliases(i) case i # ======================================================================= # # === :nope # ======================================================================= # when :nope, :user_disabled_this_setting_via_the_commandline i = false end @internal_hash[:make_use_of_aliases_kept_in_the_file_cookbook_aliases] = i end
#¶ ↑
set_meson_configure_options
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 954 def set_meson_configure_options(i) set(:meson_configure_options, i) end
#¶ ↑
set_parameters_to_make
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1964 def set_parameters_to_make(i) set(:parameters_to_make, i) end
#¶ ↑
set_pkgconfig_files
¶ ↑
Do note that this entry must be kept as an Array at all times.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 621 def set_pkgconfig_files(i) unless i.is_a? Array i = [i].compact end set(:pkgconfig_files, i) end
#¶ ↑
set_postinstall
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1027 def set_postinstall(i) set(:postinstall, i) end
#¶ ↑
set_preinstall
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 525 def set_preinstall(i) set(:preinstall, i) end
#¶ ↑
set_program_full_name
¶ ↑
This is entry (6) program_full_name
, a combination of the two other values called program_name_and_program_version
?+archive_type?.
The program_full_name
variable thus looks like this:
gnome-mahjonng-5.08.tar.xz
It consists of program_name_and_program_version
?+archive_type?
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1907 def set_program_full_name( i = :default ) case i # ======================================================================= # # === :default # ======================================================================= # when :default i = "#{program_name_and_program_version?}"\ "#{archive_type?}" end set(:program_full_name, i) end
#¶ ↑
set_program_name
(entry number 2)¶ ↑
This is entry number (2), the setter for the program name.
The program name of a program might be something such as this:
gnome-mahjonng file
A ‘-’ is usually required as separator for a proper “program_name” entry, about at the least in 99.5% of the programs out there in the wild. They usually include a ‘-’ as part of the program name.
Note that there are some weird exceptions, such as “boost_1_59_0”.
Consistently use this and ONLY this method when modifying the ‘program_name’ entry in the main dataset.
Some other programs require to have a ‘_’ as part of the program name.
This can lead to problems such as for those programs that have a _ as part of their name. A good example is the name “e_dbus”, which includes includes a ‘_’ token as part of its name.
In Jan 2014, I realized that eliminating ‘_’ is too much of a hassle, so I disabled it in this method. I will retain the explanation above though, in the event that future programmers - or future me - may encounter similar problems.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1736 def set_program_name( i = :default ) if i.is_a? Array i = i.first end case i when :default i = return_sanitize_url1(url1?.to_s.dup) when 'URL_REPLACE_UNDERSCORE' i = url1?.to_s.dup when :assemble, :guess # Then we assemble it for these two conditions. i = assemble_program_name # In these cases, we will try to guess the name. when 'FIRST_UNDERSCORE_IS_HYPHEN' e 'UNHANDLED - Reonsider.' exit end i = i.to_s.dup i = remove_archive_at_the_end(i) # ======================================================================= # # A program name never has a '/'. # ======================================================================= # if i.include? '/' i = File.basename(i) end i = remove_file_extension(i) if i.include? '.' # ← Added this as of Nov 2013. set(:program_name, i) end
#¶ ↑
set_program_name_and_program_version
¶ ↑
This is entry number (4), combining program_name
and program_version.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5906 def set_program_name_and_program_version( i = :default ) case i # === :default when :default i = "#{program_name?}#{connective_token?}#{program_version?}" end set(:program_name_and_program_version, i) end
#¶ ↑
set_program_path
(8 tag)¶ ↑
This is (8) program_path
, which may look like this:
'/home/x/src/gnomemahjongg/gnome-mahjonng-5.08.tar.xz' '/home/x/src/file/file-5.08.tar.xz'
So essentially, the program_path
is composed of these two elements:
- base_dir? - program_full_name?
In other words, this combines (7) + (6), the two main components, or shown one after the other:
(7) base_dir, such as: "/home/x/src/file/" (6) program_full_name, such as: "file-5.08.tar.xz" (so this is program_name_and_program_version?+archive_type?)
It is the most important entry, containing everything - which is the major goal for the class here.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 996 def set_program_path( i = :default ) case i # ======================================================================= # # === :default # ======================================================================= # when :default i = base_dir?.to_s+ program_full_name? # ======================================================================= # # === :try_to_rebuild_it_from_smaller_components # # This is similar to :default but will rebuild from slightly # smaller components. # ======================================================================= # when :try_to_rebuild_it_from_smaller_components archive_type = archive_type? if archive_type and archive_type.empty? archive_type = '.tar.xz' end i = base_dir?+ program_name_and_program_version?+ archive_type end set(:program_path, i) end
#¶ ↑
set_program_version
(version tag)¶ ↑
This is entry number (3), the program version of our program at hand.
An example for this would be ‘5.08’, for instance.
As of January 2019, this method will also eliminate all ‘/’ from the input, if found. A proper program version does not have this character.
# ¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5960 def set_program_version( i = program_version?, propagate_the_change = true ) case i # ======================================================================= # # === INFER_THE_VERSION # ======================================================================= # when /INFER_THE_VERSION/ # Match this one exactly. _ = url1? # This may be: https://github.com/FluidSynth/fluidsynth/archive/refs/tags/v2.3.1.tar.gz if _.include?('/') _ = File.basename(_) end i = remove_archive_at_the_end(_).delete('v') # ======================================================================= # # === :infer_from_the_program_name_and_program_version # ======================================================================= # when :infer_from_the_program_name_and_program_version i = ProgramInformation.return_version( program_name_and_program_version? ) end i = i.to_s.dup # Work on a copy. i.delete!('/') if i.include? '/' i.gsub!(/\.src/,'') if i.include? '.src' i.gsub!(/_src/,'') if i.include? '_src' i.sub!(/-source$/,'') if i.include? '-source' i.sub!(/-Source/,'') if i.include? '-Source' i = chop_off_archive(i) i = remove_file_suffix(i) # Added this as of January 2014. if i.include? '#' # This is an illegal character as of April 2014. i = i[0, i.index('#')] end set(:program_version, i) if propagate_the_change update_program_name_and_program_version update_the_program_path end end
#¶ ↑
set_programs_dir
¶ ↑
This method can be used to designate another directory for the programs to be stored, other than ‘/Programs/’.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1641 def set_programs_dir( i = '/Programs/' ) @internal_hash[:programs_dir] = i end
#¶ ↑
set_required_deps_on
¶ ↑
Set the required dependencies for a program through this method.
Note that this method will not do any sanitizing - you have to sanitize the input on your own prior to calling this method.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1929 def set_required_deps_on(i) set(:required_deps_on, i) end
#¶ ↑
set_sed
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1853 def set_sed(i) set(:sed, i) end
#¶ ↑
set_seek_this_program
¶ ↑
This method should be used to designate which program is to be sought.
The method is allowed to modify the given input.
The search-string should always be a String.
Keep in mind that the input to this method may also be in the form of a String such as “php.yml”. In that case, we have to get rid of the trailing ‘.yml’ part.
Additionally, do note that the input could be a binary name or a library name. In these two cases, we may overrule the input provided but this can be configured via some settings.
Since as of September 2012, aliases can overrule this setting. This, however had, may lead to problems, such as “make” suddenly becoming “makeinfo” rather than being kept as make.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 765 def set_seek_this_program( i = :default ) i = i.keys.first if i.is_a? Hash if i.is_a? Array # ===================================================================== # # Flatten the Array first, before using only the first entry. # ===================================================================== # i = i.flatten.first end case i when nil, '' i = DEFAULT_ENTRY end i = i.to_s.dup set_original_unmodified_name(i) # ======================================================================= # # Clean-up the input a bit next. # ======================================================================= # if i.end_with? '.yml' i.delete_suffix!('.yml') elsif i.end_with? '.pc' i.delete_suffix!('.pc') end i.downcase! # Work on a reference copy that is also downcased. i.delete!('-') if i.include? '-' i.delete!('_') if i.include? '_' # ======================================================================= # # Neither '-' nor '_' are allowed as input past this point. # ======================================================================= # if i.include? '.' i.sub!(/#{File.extname(i)}/,'') end # ======================================================================= # # === Chop off trailing '/' next # # Next, this method may chop off trailing '/' characters. # # A trailing '/' is assumed to have been a typo, since it evidently # can not be the name of an existing program. Nobody will call a # file or input program something such as 'libgweather/'. # ======================================================================= # i.chop! if i.end_with? '/' all_binaries = all_binaries? all_libraries = all_libraries? i = File.basename(i) if i.include? '/' # ======================================================================= # # === Handle possible binary names next # # Here we will check for binary names of programs, but only if the input # has not yet been found as regular name of a registered program at # hand. As this is not always needed anyway, we will use various checks # to make sure that we really want to find a binary name. # # In order to test this, try: # # cookbooks2 xmlif # ry xmlif # # ======================================================================= # if !does_include?(i) and check_for_binary_names? and all_binaries.has_key?(i) and (i != all_binaries[i]) and (!i.empty?) new_name = all_binaries[i] report_binary_or_library_program_name(i, new_name, :binary) i = new_name # ======================================================================= # # === Check for library names # # Similar reasoning applies to this entry point, as to the one above # for binary names. # ======================================================================= # elsif !does_include?(i) and check_for_library_names? and all_libraries.has_key?(i) and (i != all_libraries[i]) new_name = all_libraries[i] report_binary_or_library_program_name(i, new_name, :library) i = new_name end # ======================================================================= # # Query whether the program is included or whether it is not. If # it is not included, but is included if 'lib' is put before it, # then we will use that as name instead. # ======================================================================= # unless does_include?(i) if does_include?("lib#{i}") i.prepend('lib') end end if (does_include?(i, :do_not_check_for_aliases) == false) and does_include?(i) # ===================================================================== # # In this case we will assume it is an alias, such as 'ecm'. # ===================================================================== # available_aliases = YAML.load_file(RBT.file_cookbook_aliases) i = available_aliases[i] opne "An alias was found. It will be used now. (Name: #{steelblue(i)})." end # ======================================================================= # # === Next check for entries that lack a leading 'lib' entry # # If they do, and a program with the same name can be found, # it will be used as input instead. # # An example for this would be the input "x11" which would # become "libx11" due to the following code. # ======================================================================= # unless does_include?(i, :do_not_check_for_aliases) if does_include?("lib#{i}", :do_not_check_for_aliases) opne "The given input #{sfancy(i)} is not included "\ "but #{sfancy('lib'+i)} is." opne 'Thus using this as the new input next.' i.prepend('lib') end # ===================================================================== # # === Check for Abbreviations if the key was not found # ===================================================================== # unless i.empty? # =================================================================== # # Ok, we did not find anything, so check for abbreviations. # =================================================================== # available_programs = available_programs? require 'abbrev' unless Object.const_defined? :Abbrev abbrevs = Abbrev.abbrev(available_programs) if abbrevs.has_key? i # ================================================================= # # Ok, this means that our key is included. # ================================================================= # i = abbrevs.fetch(i) end end end if is_this_program_included? i the_program_was_found end @internal_hash[:seek_this_program] = i end
#¶ ↑
set_short_description
¶ ↑
The short_description entry should not end with a newline.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 2023 def set_short_description(i = nil) i.chomp! if i # We do not want trailing newlines. set(:short_description, i) end
#¶ ↑
set_short_name
¶ ↑
This is entry number (1), the setter for the short name of the program. It will set the short_name
entry in the main cookbook dataset.
The ‘short_name’ variable is NOT allowed to include the ‘-’ character.
Valid input to this method could be something like:
"xfce4-dev-tools"
We must delete all ‘-’ if they occur.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5709 def set_short_name( i = program_name? # 1 tag ) case i # ======================================================================= # # === :default # ======================================================================= # when :default i = program_name?.dup end i = i.to_s.dup # ← This must come after checking for Symbols. i.downcase! i.delete!('-') if i.include? '-' # ======================================================================= # # If the input includes .tar, check it further. # ======================================================================= # if i and i.include?('.tar') i = ::ProgramInformation.return_short_name(i) end # ======================================================================= # # === Eliminate '/' if they are found. # ======================================================================= # if i.include? '/' i = File.basename(i) end dataset?[:short_name] = i end
#¶ ↑
set_simple_or_complex
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5760 def set_simple_or_complex( i = :default ) # ======================================================================= # # === @simple_or_complex # # This can be :simple or :complex. The value for :default will be # :complex. # ======================================================================= # case i # ======================================================================= # # === :default # ======================================================================= # when :default, nil i = :complex # ======================================================================= # # === :use_expanded_dataset # ======================================================================= # when :use_expanded_dataset, :expanded, :fast, :complex i = :complex # ======================================================================= # # === :fast_and_be_verbose # ======================================================================= # when :fast_and_be_verbose i = :complex set_be_verbose # ======================================================================= # # === :simple # ======================================================================= # when :simple, :simple_cookbook i = :simple # ======================================================================= # # === :expanded # ======================================================================= # else pp caller() e 'Unknown: '+i.to_s+' ('+i.class.to_s+') - please fix this.' exit end @internal_hash[:simple_or_complex] = i end
#¶ ↑
set_symlink_headers
¶ ↑
If we want to symlink the headers, this is the setter-method that should be called.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1863 def set_symlink_headers(i = true) set(:symlink_headers, i) end
#¶ ↑
set_symlink_pkgconfig_files
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3189 def set_symlink_pkgconfig_files(i = true) set(__method__.to_s.delete_prefix('set_').to_sym, i) end
#¶ ↑
use_autogen
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 503 def set_use_autogen(i = true) set(:use_autogen, i) end
#¶ ↑
set_use_build_directory
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1546 def set_use_build_directory(i) set(__method__.to_s.delete_prefix('set_').to_sym, i) end
#¶ ↑
set_use_glib_schema
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1870 def set_use_glib_schema(i = nil) if i set(:use_glib_schema, i) end end
#¶ ↑
set_use_this_build_directory
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 574 def set_use_this_build_directory(i) set(:use_this_build_directory, i) end
#¶ ↑
set_use_this_build_system
¶ ↑
This method will set the build-system that should be used for the given program at hand. By default we will infer automatically, with the default being set to the Symbol called :infer_automatically.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 931 def set_use_this_build_system( i = :default ) case i # ======================================================================= # # === :default # ======================================================================= # when :default i = :infer_automatically end set(:use_this_build_system, i) end
#¶ ↑
set_use_this_connective_token
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 910 def set_use_this_connective_token(i = '-') @internal_hash[:use_this_connective_token] = i end
#¶ ↑
set_use_this_make_command
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1846 def set_use_this_make_command(i) set(:use_this_make_command, i) end
#¶ ↑
set_use_this_make_install_command
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1832 def set_use_this_make_install_command(i) set(:use_this_make_install_command, i) end
#¶ ↑
sha256?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3182 def sha256? obtain(__method__.to_s.delete('?').to_sym) end
#¶ ↑
shall_we_display_the_md5sum?¶ ↑
Query whether we shall display the md5sum or whether we shall not.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4878 def shall_we_display_the_md5sum? dataset?[:shall_we_display_the_md5sum] end
#¶ ↑
short_description?¶ ↑
This method will obtain the short description of a given program.
Not every program will have a short description, but it is recommended that all programs SHOULD have a short description.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5358 def short_description? obtain __method__.to_s.delete('?').to_sym end
#¶ ↑
short_name
?¶ ↑
Reader method for short_name.
This method will query the short name of the program we are trying to find.
For example, this method will return the program name without the version, such as:
"ruby" (which is part of the program_name "ruby-2.2.0")
This method must always return a String, even if it is an empty String.
Characters such as ‘-’ are NOT allowed to be part of the short_name
variable. The corresponding setter-method will make sure of this.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5383 def short_name? obtain __method__.to_s.delete('?').to_sym end
#¶ ↑
show_help
(help tag)¶ ↑
To invoke this particular method, try:
cookbook --help
To invoke individual entries, do:
cookbook nprograms? cookbook --overview cookbook --version
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4081 def show_help left_padding = ' ' # A bit of left-padding here. n_space_characters = 50 how_to_invoke_the_program = HOW_TO_INVOKE_THE_PROGRAM opne 'This class can feedback information about any '\ 'specific program.' e # ======================================================================= # # === Common usage examples # ======================================================================= # e 'Common usage examples:' e e left_padding+how_to_invoke_the_program+' ruby' e left_padding+how_to_invoke_the_program+' htop' e left_padding+how_to_invoke_the_program+' m4' e # ======================================================================= # # === Advanced Options # ======================================================================= # e 'Advanced options:' e e properly_pad_and_colourize_this_help_option('nprograms?', 'show how many programs are registered in the cookbooks-collection' ) e properly_pad_and_colourize_this_help_option('--aliases?', 'show all available aliases to the registered cookbooks-programs' ) e properly_pad_and_colourize_this_help_option('--available_programs?', 'show all available programs' ) e properly_pad_and_colourize_this_help_option('--batch-download-all-source-archives', 'batch-download all source archives (optionally select for specific tags)' ) e properly_pad_and_colourize_this_help_option('--overview', 'give us an overview over all programs in the utility_scripts directory,' ) e (' ' * n_space_characters)+'# of the cookbooks project' e properly_pad_and_colourize_this_help_option('--format=[name]', 'feedback the format type of this entry,' ) e (' ' * n_space_characters)+'# such as via '+simp('cookbook --format=postinstall') e properly_pad_and_colourize_this_help_option('--expand', 'to expand the short yaml dataset into' ) e properly_pad_and_colourize_this_help_option('--expand=PROGRAM_NAME', 'to expand an individual program, such as python or ruby' ) # ======================================================================= # # === --n-registered-binaries? # ======================================================================= # e properly_pad_and_colourize_this_help_option('--n-registered-binaries?', 'to report how many registered binaries are available' ) # ======================================================================= # # === --show-all-about=PROGRAM_NAME # ======================================================================= # e properly_pad_and_colourize_this_help_option('--show-all-about=PROGRAM_NAME', 'to show all about the given program at hand' ) e properly_pad_and_colourize_this_help_option('--permanently-disable-colours', 'to permanently disable all colour output by the Cookbooks project' ) e properly_pad_and_colourize_this_help_option('--update-kde-plasma', 'batch-update (that is, download) all KDE5 components of KDE Plasma' ) e (' ' * n_space_characters)+'# a long dataset; --initialize is an alias to this action' e properly_pad_and_colourize_this_help_option('--create-programs-version-html-file', 'create and upload a .html file containing all '\ 'program_name-program_versions' ) e (' ' * n_space_characters)+'# entries. This is primarily meant for my home system.' # ======================================================================= # # === --allowed_tags? # ======================================================================= # e properly_pad_and_colourize_this_help_option('--allowed_tags?', 'show a list of all allowed tags in the '+simp('tags: subsection')+ ' of a cookbook-yaml file' ) # ======================================================================= # # === --generate_version_file # ======================================================================= # e properly_pad_and_colourize_this_help_option('--generate_version_file', 'to generate a programs-version yaml file' ) # ======================================================================= # # === --use-psych # ======================================================================= # e properly_pad_and_colourize_this_help_option('--use-psych', 'to use psych for the yaml files' ) # ======================================================================= # # === --use-syck # ======================================================================= # e properly_pad_and_colourize_this_help_option('--use-syck', 'to use syck for the yaml files' ) # ======================================================================= # # === --create-html-page-for-these-programs= # ======================================================================= # e properly_pad_and_colourize_this_help_option('--create-html-page-for-these-programs=', 'to generate a .html page for the given programs; separate '\ 'the input via' ) e (' ' * n_space_characters)+'# "'+sfancy(',')+'" such as in '+ simp('=ruby,python,php') # ======================================================================= # # === --n_binaries? # ======================================================================= # e properly_pad_and_colourize_this_help_option('--n_binaries?', 'tell us how many binaries/executables are tracked '\ 'in all cookbook-yaml files' ) e properly_pad_and_colourize_this_help_option('--publish', 'publish the list of all program versions of the cookbooks project' ) e properly_pad_and_colourize_this_help_option('--total-size?', 'show the total size of all locally available archives' ) e properly_pad_and_colourize_this_help_option('--tutorial', 'do show the short tutorial how the Cookbooks project may be used' ) e properly_pad_and_colourize_this_help_option('--update-tags', 'do update the tags defined in the various cookbooks' ) e properly_pad_and_colourize_this_help_option('--validate-entries', 'validate all Cookbook entries' ) e properly_pad_and_colourize_this_help_option('--version', 'feedback the current version of the Cookbooks gem' ) e properly_pad_and_colourize_this_help_option('--set_source_dir=/tmp', 'permanently set a new source dir (aka where all '\ 'archives are kept locally)' ) e properly_pad_and_colourize_this_help_option('--set_temp_dir=/tmp', 'permanently change the yaml file to set a '\ 'new temp directory' ) e end
#¶ ↑
show_this_dataset_containing_which_entries_should_be_displayed
(display tag)¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 2262 def show_this_dataset_containing_which_entries_should_be_displayed( i = array_show_these_entries? ) # ======================================================================= # # Determine the threshold value to use for this display. # ======================================================================= # threshold_value = 68 left_pad = ' ' ljust_value = 43 i.each {|this_entry| case this_entry # case tag # ===================================================================== # # === extra_information # ===================================================================== # when :extra_information # =================================================================== # # === Handle extra_information # # Next, limit the size for extra_description. We do not want to show # too much here. # =================================================================== # result = send_this_method_and_sanitize_arrays("#{this_entry}?").to_s if self.class.honour_threshold_value? if (result.size > threshold_value) result = result[0, result.index("\n")].delete('"')+' [...]' end end result.chomp! e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ darkslateblue(result.lstrip) # ===================================================================== # # === description # # Handle the description entry here. # ===================================================================== # when :description result = description?.chomp.rstrip if (result.size > threshold_value) result = result.tr("\n",' ')[0..(threshold_value-2)]+' [...]' end e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ limegreen(result.lstrip)+rev # ===================================================================== # # === program_version # # Feedback the program-version at hand. # ===================================================================== # when :program_version e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ springgreen(send_this_method_and_sanitize_arrays("#{this_entry}?").to_s) # ===================================================================== # # === :use_this_build_system # ===================================================================== # when :use_this_build_system result = send_this_method_and_sanitize_arrays("#{this_entry}?").to_s.dup result.prepend(':') if result == 'infer_automatically' e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ mediumpurple(result) # ===================================================================== # # === homepage # # Colourize the homepage properly. # ===================================================================== # when :homepage e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ darkseagreen(send_this_method_and_sanitize_arrays("#{this_entry}?").to_s) # ===================================================================== # # === flatpak_url # ===================================================================== # when :flatpak_url e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ mediumseagreen(send_this_method_and_sanitize_arrays("#{this_entry}?").to_s)+rev # ===================================================================== # # === .gir files # # This entry point can be used to display the .gir files, if they # exist. # ===================================================================== # when :gir_files e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ darkseagreen( send_this_method_and_sanitize_arrays("#{this_entry}?") ) # ===================================================================== # # === extract_to # ===================================================================== # when :extract_to result = send_this_method_and_sanitize_arrays("#{this_entry}?").to_s unless result.empty? e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ cornflowerblue(result) end # ===================================================================== # # === program_name # ===================================================================== # when :program_name e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ mediumslateblue(send_this_method_and_sanitize_arrays("#{this_entry}?").to_s) # ===================================================================== # # === blfs # ===================================================================== # when :blfs result = send_this_method_and_sanitize_arrays("#{this_entry}?") result = result.flatten.first if result.is_a? Array e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ darkseagreen(result.to_s.delete('[]')) # .to_s to avoid nil values. # ===================================================================== # # === short_name # # Is steelblue. # ===================================================================== # when :short_name e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ steelblue(send_this_method_and_sanitize_arrays("#{this_entry}?")) # ===================================================================== # # === use_autogen # ===================================================================== # when :use_autogen e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ cadetblue( yes_or_no( send_this_method_and_sanitize_arrays("#{this_entry}?").to_s ) ) # ===================================================================== # # === headers # # This entry point can be used to display the headers. # ===================================================================== # when :headers e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ darkseagreen( send_this_method_and_sanitize_arrays(this_entry.to_s+'?', 5) # ← Limit to 5 by default. ) # ===================================================================== # # === binaries # # This entry point can be used to display the binaries. # ===================================================================== # when :binaries e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ sfancy( send_this_method_and_sanitize_arrays(this_entry.to_s+'?', 5) # ← Limit to 5 by default. ) # ===================================================================== # # === libraries # # This entry point can be used to display the libraries. # ===================================================================== # when :libraries e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ sfancy( send_this_method_and_sanitize_arrays(this_entry.to_s+'?', 5) # ← Limit to 5 by default. ) # ===================================================================== # # === sed # ===================================================================== # when :sed e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ mediumturquoise(send_this_method_and_sanitize_arrays("#{this_entry}?").to_s) # ===================================================================== # # === short_description # ===================================================================== # when :short_description e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ mediumturquoise(send_this_method_and_sanitize_arrays("#{this_entry}?").to_s) # ===================================================================== # # === run_configure # ===================================================================== # when :run_configure e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ olivedrab( yes_or_no(send_this_method_and_sanitize_arrays("#{this_entry}?")).to_s ) # ===================================================================== # # === has_to_be_compiled # ===================================================================== # when :has_to_be_compiled e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ steelblue( yes_or_no(send_this_method_and_sanitize_arrays("#{this_entry}?")).to_s ) # ===================================================================== # # === skip_configure # ===================================================================== # when :skip_configure e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ mediumorchid(send_this_method_and_sanitize_arrays("#{this_entry}?").to_s) # ===================================================================== # # === archive_size # ===================================================================== # when :archive_size, :file_size, :program_size # colourize program_size. e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ mediumorchid(send_this_method_and_sanitize_arrays("#{this_entry}?").to_s) # ===================================================================== # # === program_compile_name # ===================================================================== # when :program_compile_name e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ mediumslateblue(send_this_method_and_sanitize_arrays("#{this_entry}?")) # ===================================================================== # # === program_path # ===================================================================== # when :program_path e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ orange(send_this_method_and_sanitize_arrays("#{this_entry}?").to_s) # ===================================================================== # # === configure_options # ===================================================================== # when :configure_options unless configure_options?.empty? e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ mediumseagreen(send_this_method_and_sanitize_arrays("#{this_entry}?").to_s)+rev end # ===================================================================== # # === meson_configure_options # ===================================================================== # when :meson_configure_options if meson_configure_options? unless meson_configure_options.empty? e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ mediumseagreen(send_this_method_and_sanitize_arrays("#{this_entry}?").to_s)+rev end end # ===================================================================== # # === do_not_symlink # ===================================================================== # when :do_not_symlink e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ lightslategray(send_this_method_and_sanitize_arrays("#{this_entry}?").to_s) # ===================================================================== # # === keep_extracted # ===================================================================== # when :keep_extracted e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ seagreen( yes_or_no( send_this_method_and_sanitize_arrays("#{this_entry}?").to_s ) ) # ===================================================================== # # === prefix # ===================================================================== # when :prefix e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ darkseagreen(send_this_method_and_sanitize_arrays("#{this_entry}?").to_s) # ===================================================================== # # === url1 # ===================================================================== # when :url1,:url2,:url3,:url4,:url5 e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ sandybrown(send_this_method_and_sanitize_arrays("#{this_entry}?").to_s) # ===================================================================== # # === pkgconfig_files # ===================================================================== # when :pkgconfig_files e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ deepskyblue(send_this_method_and_sanitize_arrays("#{this_entry}?").to_s) # ===================================================================== # # === md5sum # ===================================================================== # when :md5sum if show_md5sum? e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ sfancy(send_this_method_and_sanitize_arrays("#{this_entry}?")) end # ===================================================================== # # === remote_url # ===================================================================== # when :remote_url e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ sfancy(send_this_method_and_sanitize_arrays("#{this_entry}?")) # ===================================================================== # # === program_full_name # ===================================================================== # when :program_full_name e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ sfancy(send_this_method_and_sanitize_arrays("#{this_entry}?")) # ===================================================================== # # === base_dir # ===================================================================== # when :base_dir e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ sfancy(send_this_method_and_sanitize_arrays("#{this_entry}?")) # ===================================================================== # # === archive_type # ===================================================================== # when :archive_type e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ sfancy(send_this_method_and_sanitize_arrays("#{this_entry}?")) # ===================================================================== # # === last_update # ===================================================================== # when :last_update e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ cornflowerblue(send_this_method_and_sanitize_arrays("#{this_entry}?").to_s) # ===================================================================== # # === mode # ===================================================================== # when :mode, :mode_in_use e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ cornflowerblue(send_this_method_and_sanitize_arrays("#{this_entry}?").to_s) else # else tag # ================================================================ # # Note that sfancy() is the default colour used here for the # else clause. # ================================================================ # e "#{rev}#{left_pad}#{this_entry}: ".ljust(ljust_value)+ sfancy(send_this_method_and_sanitize_arrays("#{this_entry}?")).to_s end } end
#¶ ↑
skip_configure
?¶ ↑
Query-method over as to whether we will skip configure or whether we will not.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4577 def skip_configure? !run_configure? end
#¶ ↑
sort_by_archive_priority
¶ ↑
This method will sort the archive format based on priorities.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3514 def sort_by_archive_priority(i) array_priority = %w( .xz .bz2 .gz .lz .gem .js ) begin selection = i.select {|entry| entry.include?('.') and is_an_archive?(entry) } i = selection.sort_by {|entry| extname = File.extname(entry) if array_priority.include? extname entry = array_priority.index(extname) end entry } rescue ArgumentError => error opne 'An error occurred in the method '+ slateblue(__method__.to_s)+'. (Line: '+royalblue(__LINE__)+')' pp i pp error exit end return i end
#¶ ↑
substitute_macros
¶ ↑
Do “macro” expansion through this method.
This method will sanitize some special variables, which are assumes to be “macros” - that is, to be substituted with another value.
Right now this is only used for kernel variable, PROGRAM_NAME, PNAME, NAME, KERNEL_V and PROGRAM_VERSION but maybe someone else wants to do more macro processing, so we will keep this bundled here together.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3803 def substitute_macros(input) if input.is_a? Array input.map {|entry| substitute_macros(entry) } # Recursive call. else i = input.to_s.dup # Work on a new copy here. if i.include? 'PROGRAM_VERSION' i.gsub!(/PROGRAM_VERSION/, program_version?) end if i.include? 'PNAME' i.gsub!(/PNAME/, short_name?) elsif i.include? 'NAME' i.gsub!(/NAME/, short_name?) elsif i.include? 'PROGRAM_NAME' i.gsub!(/PROGRAM_NAME/, short_name?) end if ENV['KERNEL_V'] && i.include?('KERNEL_V') i.gsub!(/#{i}/, ENV['KERNEL_V']) end i end end
#¶ ↑
symlink_headers
?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3266 def symlink_headers? obtain(__method__.to_s.delete('?').to_sym) end
#¶ ↑
symlink_pkgconfig_files
?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3196 def symlink_pkgconfig_files? obtain(__method__.to_s.delete('?').to_sym) end
#¶ ↑
the_program_is_included
¶ ↑
This method will set-toggle that the program we are looking for, is included; aka that it was found.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3550 def the_program_is_included @internal_hash[:found] = true end
#¶ ↑
this_program_was_not_found
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3118 def this_program_was_not_found(i) unless i.to_s.empty? orev "The program #{steelblue(i.to_s)} #{rev}does "\ "#{tomato('not')} #{rev}appear to be registered." end end
#¶ ↑
try_to_find_another_local_file
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3411 def try_to_find_another_local_file(i) without_file_extension = remove_file_extension_from(i) array = action(:return_alternative_archive, without_file_extension) if array and !array.empty? first_element = array.first if File.exist? first_element set_archive(first_element) end end end
#¶ ↑
try_to_guess_the_archive_type
¶ ↑
This method will try to guess the archive type, e. g. .tar.xz or .tar.gz of a given program at hand, based on which files may exist locally already.
Note that program_name
may look like ‘gnome-mahjongg’ and base_dir
may look like ‘/home/x/src/gnomemahjongg/’.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 4007 def try_to_guess_the_archive_type target = "#{base_dir?}#{program_name?}*" files = Dir[target] unless files.empty? first = files.first # And use the first variant here. set_archive(return_archive_type(first)) end # else we won't set it end
#¶ ↑
try_to_guess_the_program_path_based_on_the_program_name_and_program_version
¶ ↑
This will build program_path
, which is:
‘/home/x/src/gnomemahjongg/gnome-mahjonng-5.08.tar.xz’
aka base_dir
?+program_full_name?
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3834 def try_to_guess_the_program_path_based_on_the_program_name_and_program_version( _ = base_dir?+ program_full_name? ) if File.exist? _ set_program_path(_) end end
#¶ ↑
try_to_guess_the_program_version
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3634 def try_to_guess_the_program_version( i = program_name? ) _program_name, program_version = ProgramInformation.new(i).return_name_and_version set_program_version(program_version) end
#¶ ↑
update_kde_applications
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3318 def update_kde_applications unless RBT::Cookbooks.const_defined? :UpdateKdeApplications require 'rbt/check_for_updates/update_kde_applications.rb' end UpdateKdeApplications.new end
#¶ ↑
update_program_path
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5920 def update_program_path set_program_path(:default) end
#¶ ↑
url1?¶ ↑
This method will “hold” the “most” important URL of a program, which is the entry called url1.
Every entry of our cookbooks must have this entry available.
Usage example to query the value of url1?:
puts RBT::Action::Cookbooks::SanitizeCookbook.new('htop').url1?
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1193 def url1? obtain(__method__.to_s.delete('?').to_sym) end
#¶ ↑
url3?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5313 def url3? obtain __method__.to_s.delete('?').to_sym end
#¶ ↑
urls?¶ ↑
This method is an “aggregate-method”; it will return all available URLs in Array format.
We only support 5 URLs at max right now, though.
Since as of July 2012 this method will not return empty values, as they are useless anyway.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5132 def urls? # ======================================================================= # # Build our Array that will hold all 5 URLs. # ======================================================================= # array = %w( url1 url2 url3 url4 url5 ) _ = dataset?.values_at(*array) # We require the * here. _.compact! _.reject!(&:empty?) # We don't want empty entries, hence we filter them away. return _ end
#¶ ↑
use_autogen
?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1337 def use_autogen? obtain(__method__.to_s.delete('?').to_sym) end
#¶ ↑
use_glib_schema
?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5424 def use_glib_schema? obtain __method__.to_s.delete('?').to_sym end
#¶ ↑
use_this_build_system
?¶ ↑
This method will query as to which build-system will be used for the given program at hand.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 1511 def use_this_build_system? obtain(__method__.to_s.delete('?').to_sym) end
#¶ ↑
use_this_connective_token?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 3600 def use_this_connective_token? @internal_hash[:use_this_connective_token] end
#¶ ↑
use_this_make_command
?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5209 def use_this_make_command? obtain __method__.to_s.delete('?').to_sym end
#¶ ↑
use_this_make_install_command?¶ ↑
Which variant of “make install” we will use, if we will use a different variant that is.
#¶ ↑
# File lib/rbt/actions/individual_actions/cookbooks/sanitize_cookbook/sanitize_cookbook.rb, line 5239 def use_this_make_install_command? obtain __method__.to_s.delete('?').to_sym end