module RBT
#¶ ↑
#¶ ↑
#¶ ↑
#¶ ↑
#¶ ↑
RBT::Cookbooks::Aliases
¶ ↑
#¶ ↑
require 'rbt/aliases/report.rb'
#¶ ↑
#¶ ↑
require 'rbt/base/be_verbose.rb'
#¶ ↑
#¶ ↑
require 'rbt/base/change_directory.rb'
#¶ ↑
#¶ ↑
require 'rbt/base/debug.rb'
#¶ ↑
#¶ ↑
require 'rbt/base/ee.rb'
#¶ ↑
#¶ ↑
require 'rbt/base/email.rb'
#¶ ↑
#¶ ↑
require 'rbt/base/exit_program.rb'
#¶ ↑
#¶ ↑
require 'rbt/base/run.rb'
#¶ ↑
#¶ ↑
require 'rbt/base/save_file.rb'
#¶ ↑
#¶ ↑
Just a stub to make the RBT::Base
namespace known.
#¶ ↑
require 'rbt/base/stub.rb'
#¶ ↑
#¶ ↑
#¶ ↑
Autoconf-related code will be gathered in this file.
#¶ ↑
require 'rbt/compile/autoconf.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/autogen.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/batch_compile_the_programs.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/blfs.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/cflags.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/clang.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/cmake.rb'
#¶ ↑
#¶ ↑
Colour-related code for RBT::Compile
is stored here. This also includes code that has something to do with colour-related changes.
#¶ ↑
require 'rbt/compile/colours.rb'
#¶ ↑
#¶ ↑
Commandline-related information is kept in this file here.
#¶ ↑
require 'rbt/compile/commandline.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/cookbook_dataset.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/debug.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/ensure.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/env.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/exit.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/gnome.rb'
#¶ ↑
#¶ ↑
Everything related to headers, that is, C-style header files .h, will be stored here.
#¶ ↑
require 'rbt/compile/headers.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/kde.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/ldconfig.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/lxqt.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/make_install.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/mate_desktop.rb'
#¶ ↑
If you wish to compile all mate-components into their own standalone prefix via an environment value, you can use the following list:
env_compile_via_prefix matedesktop MATE_DESKTOP env_compile_via_prefix libmatemixer MATE_DESKTOP env_compile_via_prefix libmateweather MATE_DESKTOP env_compile_via_prefix matemenus MATE_DESKTOP env_compile_via_prefix matepanel MATE_DESKTOP env_compile_via_prefix matenetbook MATE_DESKTOP env_compile_via_prefix matemedia MATE_DESKTOP env_compile_via_prefix marco MATE_DESKTOP env_compile_via_prefix matesettingsdaemon MATE_DESKTOP env_compile_via_prefix libmatekbd MATE_DESKTOP env_compile_via_prefix matecontrolcenter MATE_DESKTOP env_compile_via_prefix matesensorsapplet MATE_DESKTOP env_compile_via_prefix caja MATE_DESKTOP env_compile_via_prefix cajaextensions MATE_DESKTOP env_compile_via_prefix engrampa MATE_DESKTOP env_compile_via_prefix eom MATE_DESKTOP env_compile_via_prefix mateutils MATE_DESKTOP env_compile_via_prefix pluma MATE_DESKTOP env_compile_via_prefix mateterminal MATE_DESKTOP
#¶ ↑
#¶ ↑
Bundle together meson and ninja-related code in this file here.
#¶ ↑
require 'rbt/compile/meson_and_ninja.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/obtain.rb'
#¶ ↑
#¶ ↑
This file deals solely with the $PATH environment variable, which is available in ruby through ENV.
#¶ ↑
require 'rbt/compile/path.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/permanent.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/porg.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/preinstall.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/python.rb'
#¶ ↑
#¶ ↑
This file collects register and de-register activities for the class RBT::Compile
.
#¶ ↑
require 'rbt/compile/register.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/set.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/set_compile_these_programs.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/sigint.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/static.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/strip.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/system.rb'
#¶ ↑
#¶ ↑
Time-related code for class RBT::Compile
will be kept in this file.
#¶ ↑
require 'rbt/compile/time.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/version.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/warnings.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/xfce.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/xorg.rb'
#¶ ↑
#¶ ↑
require 'rbt/compile/yaml.rb'
#¶ ↑
#¶ ↑
Constants that are essentially archive-extensions can be kept here in this file.
#¶ ↑
require 'rbt/constants/archive_types.rb'
#¶ ↑
#¶ ↑
This file collects useful regexes that can be used within the scope of the RBT
project.
#¶ ↑
require 'rbt/constants/regexes.rb'
#¶ ↑
#¶ ↑
This file will hold the relevant remote URL entries for the classes found in this directory.
#¶ ↑
require 'rbt/constants/remote_urls.rb'
#¶ ↑
#¶ ↑
Constants in this file here, may not depend on information derived from the outside. It is ok to define shortcuts within this file, though.
#¶ ↑
require 'rbt/constants/standalone_constants.rb'
#¶ ↑
#¶ ↑
This file contains standalone file constants - aka these are never dependent on any other constant or setting.
#¶ ↑
require 'rbt/constants/standalone_file_constants.rb'
#¶ ↑
#¶ ↑
require 'rbt/cookbooks/class/constants.rb'
#¶ ↑
#¶ ↑
class Cookbook also has to ensure that certain values are set to default (and thus correct) values. This file here ensures this.
All methods that have something to do with ensure-functionality are bundled together in this file here.
#¶ ↑
require 'rbt/cookbooks/class/ensure.rb'
#¶ ↑
#¶ ↑
#¶ ↑
require 'rbt/cookbooks/class/help.rb'
#¶ ↑
#¶ ↑
require 'rbt/cookbooks/class/misc.rb'
#¶ ↑
#¶ ↑
require 'rbt/cookbooks/create_cookbook_yaml_file/constants.rb'
#¶ ↑
#¶ ↑
require 'rbt/cookbooks/create_cookbook_yaml_file/menu.rb'
#¶ ↑
#¶ ↑
require 'rbt/cookbooks/create_cookbook_yaml_file/misc.rb'
#¶ ↑
#¶ ↑
require 'rbt/cookbooks/create_cookbook_yaml_file/reset.rb'
#¶ ↑
#¶ ↑
require 'rbt/cookbooks/create_cookbook_yaml_file/run.rb'
#¶ ↑
#¶ ↑
require 'rbt/create_program/menu.rb'
#¶ ↑
#¶ ↑
All constants related to different encodings will be stored here.
#¶ ↑
require 'rbt/encoding/encoding.rb'
#¶ ↑
#¶ ↑
require 'rbt/errors/exceptions.rb'
#¶ ↑
#¶ ↑
RBT::FileDoesNotExist
¶ ↑
When a file does not exist, this error can be raised.
#¶ ↑
#¶ ↑
RBT::Errors::MapLineToASpecificError
¶ ↑
The purpose of the code in this file here is to map a particular line to a particular error. This error will be registered and is then made available to other classes.
The reason why this file has been created was so that we can re-use the code that checks for such errors.
#¶ ↑
require 'rbt/errors/map_line_to_a_specific_error.rb'
#¶ ↑
#¶ ↑
require 'rbt/infobox/constants.rb'
#¶ ↑
#¶ ↑
require 'rbt/infobox/display.rb'
#¶ ↑
#¶ ↑
require 'rbt/infobox/misc.rb'
#¶ ↑
#¶ ↑
require 'rbt/infobox/run.rb'
#¶ ↑
#¶ ↑
require 'rbt/libtool/class_methods/return_all_la_files_from_this_directory.rb'
#¶ ↑
#¶ ↑
require 'rbt/libtool/class_methods/use_this_directory.rb'
#¶ ↑
#¶ ↑
require 'rbt/libtool/help.rb'
#¶ ↑
#¶ ↑
#¶ ↑
require 'rbt/libtool/menu.rb'
#¶ ↑
#¶ ↑
#¶ ↑
require 'rbt/make/menu.rb'
#¶ ↑
#¶ ↑
require 'rbt/namespace/namespace.rb' RBT::NAMESPACE
#¶ ↑
#¶ ↑
require 'rbt/project/project_base_and_yaml_directory.rb'
#¶ ↑
#¶ ↑
We will also enable a custom variant to load yaml files.
#¶ ↑
#¶ ↑
require 'rbt/shell/constants.rb'
#¶ ↑
#¶ ↑
require 'rbt/shell/help.rb'
#¶ ↑
#¶ ↑
This file holds the menu-interface of class RBT::Compile::Shell
.
#¶ ↑
require 'rbt/shell/menu.rb'
#¶ ↑
#¶ ↑
require 'rbt/symlink_this_program/reset.rb'
#¶ ↑
#¶ ↑
require 'rbt/symlink_this_program/run.rb'
#¶ ↑
#¶ ↑
#¶ ↑
require 'rbt/toplevel_methods/change_directory.rb'
#¶ ↑
#¶ ↑
require 'rbt/toplevel_methods/chmod.rb'
#¶ ↑
#¶ ↑
require 'rbt/toplevel_methods/cliner.rb'
#¶ ↑
#¶ ↑
require 'rbt/toplevel_methods/determine_host_architecture.rb'
#¶ ↑
#¶ ↑
require 'rbt/toplevel_methods/do_show_the_classname.rb'
#¶ ↑
#¶ ↑
require 'rbt/toplevel_methods/e.rb'
#¶ ↑
#¶ ↑
require 'rbt/toplevel_methods/editor.rb'
#¶ ↑
#¶ ↑
This file can be used to set an error message.
#¶ ↑
require 'rbt/toplevel_methods/error_message.rb'
#¶ ↑
#¶ ↑
#¶ ↑
require 'rbt/toplevel_methods/get_all_directories_from.rb'
#¶ ↑
#¶ ↑
require 'rbt/toplevel_methods/home_dir.rb'
#¶ ↑
#¶ ↑
require 'rbt/toplevel_methods/is_on_windows.rb'
#¶ ↑
#¶ ↑
require 'rbt/toplevel_methods/rds.rb'
#¶ ↑
#¶ ↑
require 'rbt/toplevel_methods/remove_archive_from_the_end.rb'
#¶ ↑
#¶ ↑
require 'rbt/toplevel_methods/remove_file_extension.rb'
#¶ ↑
#¶ ↑
require 'rbt/toplevel_methods/return_pwd.rb'
#¶ ↑
#¶ ↑
require 'rbt/toplevel_methods/roebe.rb'
#¶ ↑
#¶ ↑
require 'rbt/toplevel_methods/show_names.rb'
#¶ ↑
#¶ ↑
require 'rbt/toplevel_methods/split_at.rb'
#¶ ↑
#¶ ↑
require 'rbt/toplevel_methods/to_bool.rb'
#¶ ↑
#¶ ↑
require 'rbt/toplevel_methods/try_to_find_shortcut_for_a_chain_compiled_program.rb'
#¶ ↑
#¶ ↑
require 'rbt/toplevel_methods/uchroot.rb'
#¶ ↑
#¶ ↑
require 'rbt/toplevel_methods/update_all_ruby_gems.rb'
#¶ ↑
#¶ ↑
require 'rbt/toplevel_methods/verbose_truth.rb'
#¶ ↑
#¶ ↑
RBT::UrlAction
¶ ↑
#¶ ↑
require 'rbt/url_action/compile_mode.rb'
#¶ ↑
#¶ ↑
require 'rbt/utility_scripts/generate_homepage/html_tags.rb'
#¶ ↑
#¶ ↑
require 'rbt/utility_scripts/generate_homepage/initialize.rb'
#¶ ↑
#¶ ↑
require 'rbt/utility_scripts/generate_homepage/run.rb'
#¶ ↑
#¶ ↑
require 'rbt/utility_scripts/lfs/constants.rb'
#¶ ↑
#¶ ↑
require 'rbt/utility_scripts/lfs/reset.rb'
#¶ ↑
#¶ ↑
require 'rbt/utility_scripts/lfs/run.rb'
#¶ ↑
#¶ ↑
#¶ ↑
require 'rbt/utility_scripts/search_for_tags/help.rb'
#¶ ↑
#¶ ↑
#¶ ↑
#¶ ↑
require 'rbt/version/version.rb'
#¶ ↑
Constants
- ALL_BINARIES
- ALL_LIBRARIES
- ALL_TAGS
- ALPHABET
#¶ ↑
ALPHABET
¶ ↑#¶ ↑
- ARRAY_HELP_OPTIONS
#¶ ↑
ARRAY_HELP_OPTIONS
(help tag)¶ ↑All the help options are stored here. These are the ones that work on e. g. “rbt –help”.
#¶ ↑
- ARRAY_HELP_VERSION_OPTIONS
#¶ ↑
ARRAY_HELP_VERSION_OPTIONS
¶ ↑#¶ ↑
- ARRAY_REGISTERED_ARCHIVES
#¶ ↑
ARRAY_REGISTERED_ARCHIVES
¶ ↑Keep these archive formats registered in this Array.
#¶ ↑
- BASE_URL_TO_GNOME_SOURCES
#¶ ↑
RBT::BASE_URL_TO_GNOME_SOURCES
¶ ↑#¶ ↑
- BLFS_CHANGELOG_WEBPAGE
#¶ ↑
RBT::BLFS_CHANGELOG_WEBPAGE
¶ ↑#¶ ↑
- CAPITALIZE_PROGRAM_NAME
- CAPITALIZE_PROGRAM_NAMES
#¶ ↑
CAPITALIZE_PROGRAM_NAME
¶ ↑Whether we should capitalize the program names or not. The difference will then be e. g. “htop” versus “Htop”.
#¶ ↑
- CHAINED_PROGRAMS
- CHECK_FOR_BINARY_NAMES
#¶ ↑
RBT::CHECK_FOR_BINARY_NAMES
¶ ↑#¶ ↑
- CHECK_FOR_LIBRARY_NAMES
#¶ ↑
RBT::CHECK_FOR_LIBRARY_NAMES
¶ ↑#¶ ↑
- COLOURS
#¶ ↑
COLOURS
¶ ↑#¶ ↑
- COMPILE_EVERYTHING_INTO_STANDALONE_DIRECTORY
#¶ ↑
RBT::COMPILE_EVERYTHING_INTO_STANDALONE_DIRECTORY
¶ ↑Whether to compile everything into a standalone directory or not.
#¶ ↑
- COOKBOOKS_BASE_DIRECTORY
#¶ ↑
RBT::COOKBOOKS_BASE_DIRECTORY
¶ ↑The following constant is actually only useful for my home system, and only if I don't use any other setting. So this is mostly just here for legacy reasons.
#¶ ↑
- COOKBOOK_ALIASES
- CURRENT_VERSION_OF_LXQT
#¶ ↑
CURRENT_VERSION_OF_LXQT
¶ ↑Use this constant to keep track as to which lxqt version is the one that is currently tracked by
RBT
. It has to be manually updated (for now).#¶ ↑
- ColourMake
- CreateSlackwarePackage
- DEFAULT_ARCHIVE_TYPE
#¶ ↑
RBT::DEFAULT_ARCHIVE_TYPE
¶ ↑This constant may be required so that other classes know which is the default archive. This can then be used to, for example, repackage archives into this format.
#¶ ↑
- DEFAULT_COLOUR_TO_USE
#¶ ↑
RBT::DEFAULT_COLOUR_TO_USE
¶ ↑Specify what is our main colour to use for the
Cookbooks
project.#¶ ↑
- DEFAULT_ENTRY
- DEFAULT_PROGRAM_ENTRY
#¶ ↑
RBT::DEFAULT_PROGRAM_ENTRY
¶ ↑#¶ ↑
- DEPOT_DIR
#¶ ↑
RBT::DEPOT_DIR
¶ ↑#¶ ↑
- DIRECTORY_INDIVIDUAL_COOKBOOKS_AT_ROEBE_HOME
#¶ ↑
DIRECTORY_INDIVIDUAL_COOKBOOKS_AT_ROEBE_HOME
¶ ↑This constant is used mostly on my home system.
#¶ ↑
- DIRECTORY_RBT_PROFILES
#¶ ↑
RBT::DIRECTORY_RBT_PROFILES
¶ ↑#¶ ↑
- ENCODING_ISO
#¶ ↑
ENCODING_ISO
¶ ↑#¶ ↑
- ENCODING_UTF
#¶ ↑
ENCODING_UTF
¶ ↑#¶ ↑
- ERROR_LINE
- FILE_ABBREVIATIONS
#¶ ↑
FILE_ABBREVIATIONS
¶ ↑Note that this file will store only abbreviations to the programs, not the name of the program at hand.
#¶ ↑
- FILE_ALLOWED_TAGS
#¶ ↑
RBT::FILE_ALLOWED_TAGS
¶ ↑#¶ ↑
- FILE_BASE_TEMPLATE_FOR_COOKBOOK_YAML_FILES
#¶ ↑
FILE_BASE_TEMPLATE_FOR_COOKBOOK_YAML_FILES
¶ ↑This constant specifies the path to the base-template file that can be used for creating new .yml files, for the
RBT::Cookbooks
namespace.#¶ ↑
- FILE_BUILD_SYSTEMS_PRIORITIES
#¶ ↑
FILE_BUILD_SYSTEMS_PRIORITIES
¶ ↑#¶ ↑
- FILE_BUILD_SYSTEM_PRIORITIES
#¶ ↑
FILE_BUILD_SYSTEM_PRIORITIES
¶ ↑#¶ ↑
- FILE_CCACHE
#¶ ↑
RBT::FILE_CCACHE
¶ ↑#¶ ↑
- FILE_CMAKE_LISTS
#¶ ↑
FILE_CMAKE_LISTS
¶ ↑#¶ ↑
- FILE_COMPILE_HOOKS
#¶ ↑
RBT::FILE_COMPILE_HOOKS
¶ ↑#¶ ↑
- FILE_COOKBOOK_ALIASES
#¶ ↑
RBT::FILE_COOKBOOK_ALIASES
¶ ↑#¶ ↑
- FILE_COOKBOOK_CHAINED_PROGRAMS
#¶ ↑
RBT::FILE_COOKBOOK_CHAINED_PROGRAMS
¶ ↑Easier constant to keep track of the chained cookbook-programs. In this context, a chain means a successive run of programs that are to be compiled.
This will then yield to a path such as the following:
/Programs/Ruby/2.5.1/lib/ruby/site_ruby/2.5.0/rbt/yaml/cookbook_chained_programs.yml
#¶ ↑
- FILE_CPUINFO
#¶ ↑
RBT::FILE_CPUINFO
¶ ↑#¶ ↑
- FILE_DEBUG
#¶ ↑
RBT::FILE_DEBUG
¶ ↑The debug file.
#¶ ↑
- FILE_GLOBAL_FLAGS
#¶ ↑
RBT::FILE_GLOBAL_FLAGS
¶ ↑#¶ ↑
- FILE_IS_ON_GOBOLINUX
#¶ ↑
RBT::FILE_IS_ON_GOBOLINUX
¶ ↑This file may be generated by
RBT
if you issue any of the following commands:rbt --is-on-gobolinux rbt --isongobolinux rbt isongobolinux
#¶ ↑
- FILE_LAST_COMPILED_PROGRAM
#¶ ↑
FILE_LAST_COMPILED_PROGRAM
¶ ↑The YAML file containing the last compiled program. You should use the method
RBT.file_last_compiled_program
instead, though, as this one is more dynamic.#¶ ↑
- FILE_PROGRAMS_DIRECTORY
#¶ ↑
FILE_PROGRAMS_DIRECTORY
¶ ↑#¶ ↑
- FILE_PROGRAMS_VERSION
#¶ ↑
RBT::FILE_PROGRAMS_VERSION
¶ ↑This file, when existing, holds a shorter name: version dataset for all programs.
#¶ ↑
- FILE_REGISTERED_BINARIES
#¶ ↑
FILE_REGISTERED_BINARIES
¶ ↑This may be a file path such as:
/Programs/Ruby/2.4.1/lib/ruby/site_ruby/2.4.0/cookbooks/yaml/registered_binaries.yml
cat $COOKBOOKS/yaml/registered_binaries.yml
#¶ ↑
- FILE_REGISTERED_HEADERS
#¶ ↑
FILE_REGISTERED_HEADERS
¶ ↑#¶ ↑
- FILE_REGISTERED_LIBRARIES
#¶ ↑
FILE_REGISTERED_LIBRARIES
¶ ↑This may be a file path such as:
/Programs/Ruby/2.4.1/lib/ruby/site_ruby/2.4.0/rbt/yaml/registered_libraries.yml
cat $RBT/yaml/registered_libraries.yml
#¶ ↑
- FILE_SCONS
#¶ ↑
FILE_SCONS
¶ ↑#¶ ↑
- FILE_SETUP_PY
#¶ ↑
FILE_SETUP_PY
¶ ↑This constant can be useful if you have to install a program that depends on the file 'setup.py'.
#¶ ↑
- FILE_SHORT_TUTORIAL
#¶ ↑
RBT::FILE_SHORT_TUTORIAL
¶ ↑#¶ ↑
- FILE_SPECIFICATION_OF_REGISTERED_COOKBOOK_ENTRIES
#¶ ↑
RBT::FILE_SPECIFICATION_OF_REGISTERED_COOKBOOK_ENTRIES
¶ ↑#¶ ↑
- FILE_STORING_THE_TIME_IT_TOOK_TO_COMPILE_PROGRAMS
#¶ ↑
FILE_STORING_THE_TIME_IT_TOOK_TO_COMPILE_PROGRAMS
¶ ↑Ideally do not use this constant, but the method defined below instead.
#¶ ↑
- FILE_TIME_COMPILATION
#¶ ↑
RBT::FILE_TIME_COMPILATION
¶ ↑#¶ ↑
- FILE_TRY_TO_USE_THE_FILE_WINDOWS_COOKBOOK
#¶ ↑
FILE_TRY_TO_USE_THE_FILE_WINDOWS_COOKBOOK
¶ ↑#¶ ↑
- FILE_USE_FLAGS
#¶ ↑
RBT::FILE_USE_FLAGS
¶ ↑#¶ ↑
- FILE_USE_MD5SUM
#¶ ↑
RBT::FILE_USE_MD5SUM
¶ ↑#¶ ↑
- FILE_USE_PORG
#¶ ↑
RBT::FILE_USE_PORG
¶ ↑#¶ ↑
- FILE_WAF
#¶ ↑
FILE_WAF
¶ ↑#¶ ↑
- FILE_WINDOWS_COOKBOOK
#¶ ↑
RBT::FILE_WINDOWS_COOKBOOK
¶ ↑#¶ ↑
- GEM
#¶ ↑
GEM
¶ ↑#¶ ↑
- GOBOLINUX_LAYOUT
#¶ ↑
RBT::GOBOLINUX_LAYOUT
¶ ↑This constant is probably only needed for gobolinux systems.
#¶ ↑
- HASH_ENGLISH_NUMBERS
#¶ ↑
HASH_ENGLISH_NUMBERS
¶ ↑#¶ ↑
- HASH_INSTALLATION_INSTRUCTIONS
#¶ ↑
RBT::HASH_INSTALLATION_INSTRUCTIONS
¶ ↑This Hash gives us an easier handle to sanitize our data.
It has some constant-shortcuts that are convenient for use lateron.
For instance, RINSTALL means “ruby install”, PINSTALL means “python install”.
#¶ ↑
- HOST_CPU
#¶ ↑
RBT::HOST_CPU
¶ ↑The host CPU that the scripts are running on.
#¶ ↑
- ISO_ENCODING
- LAST_DOWNLOADED_FILE
#¶ ↑
RBT::LAST_DOWNLOADED_FILE
¶ ↑#¶ ↑
- LAST_UPDATE
#¶ ↑
LAST_UPDATE
¶ ↑This specifies when the
RBT
project was last updated. It should be updated whenever theVERSION
constant changes.#¶ ↑
- LINUX
#¶ ↑
RBT::LINUX
¶ ↑#¶ ↑
- LOCATION_REGISTERED_TAGS
#¶ ↑
LOCATION_REGISTERED_TAGS
¶ ↑cat $COOKBOOKS/yaml/registered_tags.yml
#¶ ↑
- LZ
#¶ ↑
LZ
¶ ↑#¶ ↑
- MAKE_COMMAND_TO_USE
#¶ ↑
RBT::MAKE_COMMAND_TO_USE
¶ ↑Which make command to use by default.
#¶ ↑
- N
#¶ ↑
N
¶ ↑#¶ ↑
- NAMESPACE
#¶ ↑
RBT::NAMESPACE
¶ ↑Which namespace we shall use for the
RBT
project may be defined here.#¶ ↑
- N_CHARACTERS_PER_LINE
#¶ ↑
RBT::N_CHARACTERS_PER_LINE
¶ ↑Default value to be used for word-wrap splitting.
#¶ ↑
- PROGRAM_VERSION
- PROJECT_BASE_DIR
#¶ ↑
RBT::PROJECT_BASE_DIR
¶ ↑#¶ ↑
- PROJECT_BASE_DIRECTORY
#¶ ↑
RBT::PROJECT_BASE_DIRECTORY
¶ ↑#¶ ↑
- PROJECT_YAML_DIR
- PROJECT_YAML_DIRECTORY
#¶ ↑
RBT::PROJECT_YAML_DIRECTORY
¶ ↑This constant specifies where our project-specific YAML files are to be kept - the yaml base directory.
There are several “aliases” to this constant here.
This constant will store a path, as String, such as this one here:
/Programs/Ruby/2.5.1/lib/ruby/site_ruby/2.5.0/rbt/yaml/
#¶ ↑
- RBT_BASE_DIR
#¶ ↑
RBT::RBT_BASE_DIR
¶ ↑#¶ ↑
- RBT_HOMEPAGE_URL
#¶ ↑
RBT::RBT_HOMEPAGE_URL
¶ ↑The
RBT
Homepage is defined here.#¶ ↑
- RBT_VERSION_NUMBER
- RBT_YAML
#¶ ↑
RBT_YAML
¶ ↑RBT_YAML
is simply an alias to the above constant ^^^.#¶ ↑
- RBT_YAML_DIRECTORY
#¶ ↑
RBT_YAML_DIRECTORY
¶ ↑#¶ ↑
- REGEX_TO_SANITIZE_LIBRARIES
#¶ ↑
REGEX_TO_SANITIZE_LIBRARIES
¶ ↑Use this regex if you wish to sanitize some libraries.
#¶ ↑
- REGEX_TO_USE_FOR_FOR_GITHUB
#¶ ↑
RBT::REGEX_TO_USE_FOR_FOR_GITHUB
¶ ↑This constant is used to grab archives from github. These archives have a form like:
https://github.com/ninja-build/ninja/archive/v1.7.1.tar.gz
The following example on rubular shows how to use this:
http://rubular.com/r/xTVfP9TWKG
#¶ ↑
- REGISTERED_COOKBOOK_ENTRIES
- REGISTER_COMPILED_PROGRAM
#¶ ↑
RBT::REGISTER_COMPILED_PROGRAM
¶ ↑Whether we should register compiled programs or not.
#¶ ↑
- REMOTE_DOWNLOAD_BASE_URL_FOR_LXQT
#¶ ↑
REMOTE_DOWNLOAD_BASE_URL_FOR_LXQT
¶ ↑#¶ ↑
- REMOTE_DOWNLOAD_URL_FOR_KDE_PLASMA
#¶ ↑
RBT::REMOTE_DOWNLOAD_URL_FOR_KDE_PLASMA
¶ ↑#¶ ↑
- REMOTE_DOWNLOAD_URL_FOR_LXQT
#¶ ↑
REMOTE_DOWNLOAD_URL_FOR_LXQT
¶ ↑The following constant should have an URL such as:
https://downloads.lxqt.org/0.14.1.html
#¶ ↑
- REMOTE_PUB_MATE_DESKTOP_RELEASES
#¶ ↑
RBT::REMOTE_PUB_MATE_DESKTOP_RELEASES
¶ ↑#¶ ↑
- REMOTE_PUB_MATE_DESKTOP_RELEASES_LATEST_VERSION
#¶ ↑
RBT::REMOTE_PUB_MATE_DESKTOP_RELEASES_LATEST_VERSION
(mate tag)¶ ↑This should be used as the base for the download-functionality in the file check_for_mate_desktop_updates.rb
This would correspond to an URL like:
http://pub.mate-desktop.org/releases/1.22/
#¶ ↑
- REMOTE_SLACKWARE_HOMEPAGE
#¶ ↑
RBT::REMOTE_SLACKWARE_HOMEPAGE
¶ ↑#¶ ↑
- REMOTE_URL_FOR_KDE_APPLICATIONS
#¶ ↑
RBT::REMOTE_URL_FOR_KDE_APPLICATIONS
¶ ↑To batch-update these applications, do:
update_kde_applications
#¶ ↑
- REMOTE_URL_FOR_KDE_FRAMEWORKS
#¶ ↑
RBT::REMOTE_URL_FOR_KDE_FRAMEWORKS
¶ ↑This URL should point to the latest KDE-frameworks release.
Presently, (08 September 2018) the latest KDE-frameworks release is 5.50.0 (the URL, oddly enough, does not include the trailing “0”).
To batch-update from the commandline, try this:
update_kde_frameworks
#¶ ↑
- REMOTE_URL_FOR_KDE_PLASMA
#¶ ↑
RBT::REMOTE_URL_FOR_KDE_PLASMA
¶ ↑Always point to the latest KDE-Plasma (upstream) URL here, such as www.kde.org/info/plasma-5.14.3.php.
To invoke updating all KDE-plasma components from the commandline, you may issue the following command:
update_kde_plasma
#¶ ↑
- REMOTE_URL_FOR_KDE_PORTING_AIDS
#¶ ↑
RBT::REMOTE_URL_FOR_KDE_PORTING_AIDS
¶ ↑This constant must come after the constant
REMOTE_URL_FOR_KDE_FRAMEWORKS
has been defined.To update these, try:
rbt --update_porting_aids
#¶ ↑
- REMOTE_URL_TO_THE_HOMEBREW_FORMULAS
#¶ ↑
RBT::REMOTE_URL_TO_THE_HOMEBREW_FORMULAS
¶ ↑#¶ ↑
- REMOTE_URL_TO_THE_MATE_DESKTOP_COMPONENTS
#¶ ↑
RBT::REMOTE_URL_TO_THE_MATE_DESKTOP_COMPONENTS
¶ ↑This constant specifies where we can find the (remote) source code to the mate-desktop, via HTTP-file listing.
#¶ ↑
- REPORT_SPECIFIC_PROGRAM_NAME
#¶ ↑
REPORT_SPECIFIC_PROGRAM_NAME
¶ ↑#¶ ↑
- ROEBE_FILE_GLOBAL_FLAGS
#¶ ↑
RBT::ROEBE_FILE_GLOBAL_FLAGS
¶ ↑This constant here is only for my home system, hence the prefix ROEBE in it.
#¶ ↑
- ROEBE_PATH_TO_COOKBOOKS
- RUBY_RBT
#¶ ↑
RBT::RUBY_RBT
¶ ↑#¶ ↑
- RUBY_SRC
- RUBY_SRC_DIR
#¶ ↑
RBT::RUBY_SRC_DIR
¶ ↑This deliberately hard-coded constant is for my home system - it helps speed up the development process if I can use such constants as shortcuts.
#¶ ↑
- RUBY_SRC_DIRECTORY
- RUBY_SRC_DIR_AT_HOME
- RUBY_SRC_DIR_RBT
#¶ ↑
RBT::RUBY_SRC_DIR_RBT
¶ ↑This constant is only useful on my home system.
It corresponds to:
/Users/x/DATA/PROGRAMMING_LANGUAGES/RUBY/src/rbt/lib/rbt/
#¶ ↑
- RUBY_SRC_DIR_RBT_YAML
#¶ ↑
RBT::RUBY_SRC_DIR_RBT_YAML
¶ ↑This constant may correspond to the String “/Users/x/DATA/PROGRAMMING_LANGUAGES/RUBY/src/rbt/lib/rbt/yaml/”.
#¶ ↑
- RUBY_SRC_DIR_RBT_YAML_AT_HOME
#¶ ↑
RUBY_SRC_DIR_RBT_YAML_AT_HOME
¶ ↑#¶ ↑
- SHALL_WE_DEBUG
- SHELL_ERROR_CODE
#¶ ↑
RBT::SHELL_ERROR_CODE
¶ ↑Shell Error code - to append.
# ¶ ↑
- SHOW_EXTRA_INFORMATION
#¶ ↑
RBT::SHOW_EXTRA_INFORMATION
¶ ↑#¶ ↑
- SPECIFICATION_OF_REGISTERED_COOKBOOK_ENTRIES
- STOP_ON_ERROR
#¶ ↑
STOP_ON_ERROR
¶ ↑Whether we stop on error or not.
#¶ ↑
- SYSBIN_DIRECTORY
#¶ ↑
SYSBIN_DIRECTORY
¶ ↑The following constant should not be used; instead, one should rather use the method
RBT.sysbin_directory?
, since that method also is set through the yaml-configuration.#¶ ↑
- TABULATOR
#¶ ↑
RBT::TABULATOR
¶ ↑#¶ ↑
- TARBZ2
- TARGET_CPU
#¶ ↑
TARGET_CPU
¶ ↑The target CPU that we are running on.
#¶ ↑
- TARGZ
- TARXZ
- TAR_BZ2
#¶ ↑
TAR_BZ2
¶ ↑#¶ ↑
- TAR_GZ
#¶ ↑
TAR_GZ
¶ ↑#¶ ↑
- TAR_XZ
#¶ ↑
TAR_XZ
¶ ↑Several archive types are kept here.
#¶ ↑
- TRY_TO_DOWNLOAD_IF_NOT_FOUND
#¶ ↑
RBT::TRY_TO_DOWNLOAD_IF_NOT_FOUND
¶ ↑Whether to try and download a program if we can not find it locally.
#¶ ↑
- URL_TO_REMOTE_CHANGELOG
#¶ ↑
URL_TO_REMOTE_CHANGELOG
¶ ↑Where to keep the remote changelog, if we make use of one that is.
#¶ ↑
- URL_TO_THE_DOCUMENTATION
#¶ ↑
RBT::URL_TO_THE_DOCUMENTATION
¶ ↑#¶ ↑
- USER_HOME_DIRECTORY
#¶ ↑
USER_HOME_DIRECTORY
¶ ↑This constant can also be used in order to determine the home directory.
#¶ ↑
- USE_ABSOLUTE_SYMLINKING
#¶ ↑
RBT::USE_ABSOLUTE_SYMLINKING
¶ ↑#¶ ↑
- USE_FLAGS
- USE_MAIN_ENCODING
- USE_TAGS
#¶ ↑
USE_TAGS
¶ ↑Whether to use (and thus symlink) tags. Can be changed via the yaml configuration file.
#¶ ↑
- USE_THIS_ENCODING
#¶ ↑
USE_THIS_ENCODING
¶ ↑Main pointer towards the main Encoding for the
RBT
project.#¶ ↑
- USR_INCLUDE_DIR
#¶ ↑
RBT::USR_INCLUDE_DIR
¶ ↑This can be standalone because it will be ALWAYS absolute, pointing towards “/usr/include/”.
#¶ ↑
- VERSION
#¶ ↑
RBT::VERSION
¶ ↑Which version does
RBT
have. Query via:RBT::VERSION
.PROGRAM_VERSION
is just an alias to it - stick to usingVERSION
instead “officially” whenever possible.#¶ ↑
- YAML_DATABASE_DIRECTORY
#¶ ↑
YAML_DATABASE_DIRECTORY
¶ ↑Directory definition to use our yaml databases.
#¶ ↑
- YAML_FILE_REGISTERED_BINARIES
- YAML_FILE_REGISTERED_LIBRARIES
- YAML_FILE_REGISTERED_TAGS
- ZIP
#¶ ↑
RBT::ZIP
¶ ↑#¶ ↑
Public Class Methods
#¶ ↑
RBT.are_we_on_gobolinux?
¶ ↑
This method can help us when we wish to determine whether we are on GoboLinux or whether we are not.
Note that this will return a “static” result. If you need a value that is dynamic, you ought to query an instance variable instead.
#¶ ↑
# File lib/rbt/toplevel_methods/gobolinux.rb, line 33 def self.are_we_on_gobolinux? return_this = false use_this_env_key = 'IS_ON_GOBOLINUX' if ENV.has_key? use_this_env_key if ENV[use_this_env_key].to_s == '1' return_this = true end elsif File.exist? FILE_IS_ON_GOBOLINUX return_this = true elsif GOBOLINUX_LAYOUT.to_s == '1' # The constant GOBOLINUX_LAYOUT is a String. return_this = true elsif File.exist?(RBT.file_is_on_gobolinux) and (File.read(RBT.file_is_on_gobolinux).strip.to_s == '1') return_this = true end return return_this end
#¶ ↑
RBT.array_all_rubygems
¶ ↑
This method will return all rubygems, as an Array.
This can then be used in other programs, such as in RBT
to batch-install all rubygems.
#¶ ↑
# File lib/rbt/toplevel_methods/array_all_rubygems.rb, line 19 def self.array_all_rubygems # ======================================================================= # # This is a bit hack-ish, but it is also fast. We will scan for entries # that hold the content 'url1:'; and also the substring '.gem' within # that entry. Other entries will be ignored. # ======================================================================= # array = [] # ======================================================================= # # Obtain all .yml files first: # ======================================================================= # all_yaml_files = Dir["#{RBT.individual_cookbooks_directory?}*.yml"] all_yaml_files.each {|path_to_the_yaml_file| name_of_the_program = File.basename(path_to_the_yaml_file.sub(/\.yml$/,'')) dataset_of_the_program = File.read(path_to_the_yaml_file) if dataset_of_the_program =~ /^ url1: .*\.gem$/ # =================================================================== # # In this case we will assume that it is a ruby .gem file, so we # add it into the Array that will be returned. # =================================================================== # array << name_of_the_program end } array.sort # Keep it sorted, for easier reading. end
#¶ ↑
RBT.array_binary_duplicates
¶ ↑
This method will return an Array of all “/usr/bin/” binary duplicates, or from wherever else you wish to get the listing of duplicates. The default target is “/usr/bin/” but you could also pass in the argument “/usr/bin/”, as second argument to this method.
The first argument to this method is the directory where your main binaries should reside at. On GoboLinux-like systems, this will default to '/System/Index/bin'.
Invocation example for this method from within ruby code:
array = RBT.array_binary_duplicates
#¶ ↑
# File lib/rbt/toplevel_methods/check_for_binary_duplicates.rb, line 30 def self.array_binary_duplicates( from_this_directory = :default, to = :default ) # ======================================================================= # # The following two case-menus will handle the :default arguments # passed. The default is, on my home system, for '/System/Index/bin/' # as the first argument, and for '/usr/bin/' as the second argument # to this method here. # ======================================================================= # case from_this_directory when :default from_this_directory = SYSBIN_DIRECTORY end case to when :default to = '/usr/bin/' end array = [] Dir["#{from_this_directory}*"].each {|this_file| # Return the Array here. name_of_the_program = File.basename(this_file) target_file = "#{to}#{name_of_the_program}" if File.exist? target_file array << target_file end } return array end
#¶ ↑
RBT.autoswitch_python?
¶ ↑
Whether to autoswitch python or whether to not autoswitch python.
If set to true then RBT
will attempt to switch to another python version, if it is available. It will try to do so only once, though.
#¶ ↑
# File lib/rbt/configuration/configuration.rb, line 174 def self.autoswitch_python? RBT.configuration?.autoswitch_python end
#¶ ↑
RBT.available_programs?
¶ ↑
This method will return an Array of all available (registered or otherwise made known) programs.
By default it will return a list of programs from the given .yml files.
The optional argument allows us to also use abbreviations, if the argument is the Symbol called :include_abbreviations, :include_aliases or :with_aliases. (These symbols are aliases and do the same.)
The reason why this is not enabled by default is primarily because many other files are only interested in the directly registered programs.
The aliases will at first appear in a Hash, with key->value pairs such as:
"gnomewe"=>"gnomeweather"
Obviously we are here only interested in the keys, which is why the code below will use the method .keys().
Keep in mind that whenever you wish to compile one such program, you need to check to which the program may point at.
#¶ ↑
# File lib/rbt/toplevel_methods/available_programs.rb, line 181 def self.available_programs?( extra_arguments = nil ) array = determine_available_programs case extra_arguments when :include_abbreviations, :include_aliases, :with_aliases, :with_abbreviations keys = @hash_aliases_to_the_available_programs.keys array << keys else if extra_arguments.is_a? Symbol e "Warning - not registered Symbol called :#{extra_arguments.to_s}" end end # ======================================================================= # # The resulting Array that will be returned from this method will # always be sorted and contain only unique entries: # ======================================================================= # array = array.flatten.uniq.sort array # Return the Array finally. end
#¶ ↑
RBT.batch_compile
¶ ↑
This method can be used to batch compile programs.
The second argument to this method controls as to whether we will make use of chained programs or not.
#¶ ↑
# File lib/rbt/toplevel_methods/batch_compile.rb, line 19 def self.batch_compile( i = ARGV, try_to_use_chained_programs = true ) i = [i].flatten.compact compile_object = RBT::Compile.new { :do_not_run_yet } i.each {|compile_this_program| if compile_this_program.is_a?(String) and compile_this_program.include?(',') compile_this_program = compile_this_program.split(',').map(&:strip) end # ===================================================================== # # Obtain the Array next that will hold our chained programs. # ===================================================================== # if RBT.chained_programs?.include? compile_this_program and try_to_use_chained_programs compile_this_program = RBT.chained_programs?[compile_this_program] end compile_object.set_compile_these_programs(i) compile_object.run compile_object.reset } end
#¶ ↑
RBT.build_type?
¶ ↑
This should default to the current directory.
The method will return a Symbol, such as :configure or :cmake.
Usage examples:
RBT.build_type? # => :configure RBT.build_type? # => :cmake
#¶ ↑
# File lib/rbt/utility_scripts/build_detector.rb, line 237 def self.build_type? RBT::BuildDetector.build_type? end
#¶ ↑
RBT.chained_programs?
¶ ↑
Simply return the dataset from the yaml file here.
The file that is used here is the file chained_programs.yml, which you can access via:
bl $RSRC/rbt/lib/rbt/yaml/chained_programs.yml
#¶ ↑
# File lib/rbt/constants/chained_programs.rb, line 47 def self.chained_programs?( i = RBT.file_cookbook_chained_programs ) YAML.load_file(i) end
#¶ ↑
RBT.check_and_report_whether_file_exists
¶ ↑
The first argument to this method must be the path to the archive.
#¶ ↑
# File lib/rbt/toplevel_methods/report_extended_information_about_this_program.rb, line 18 def self.check_and_report_whether_file_exists( i, optional_cookbook_object = nil ) i = i.to_s unless File.exist? i opnn; Colours.ewarn 'This archive does not exist locally, at' opnn; Colours.ewarn " `#{Colours.sfile(i)}#{swarn('`')}" if optional_cookbook_object if optional_cookbook_object.do_not_download? opnn; e 'This is, however had, no problem as it will not' opnn; e 'be downloaded anyway.' end end cliner :lightblue end end
#¶ ↑
RBT.check_for_binary_duplicates
¶ ↑
This method will check for binary duplicates in the directory /usr/bin/.
#¶ ↑
# File lib/rbt/toplevel_methods/check_for_binary_duplicates.rb, line 65 def self.check_for_binary_duplicates array_binary_duplicates.each {|target_file| surrounded_target_file = "`#{target_file}`" colourized_target_file = sfile(surrounded_target_file) padded_and_colourized_target_file = colourized_target_file.ljust(70) e "Yes, #{padded_and_colourized_target_file} is a duplicate." } end
#¶ ↑
RBT.check_this_cookbook_file_for_errors
¶ ↑
The first file should be an existing .yml file holding the dataset that may be faulty.
#¶ ↑
# File lib/rbt/toplevel_methods/check_this_cookbook_file_for_errors.rb, line 58 def self.check_this_cookbook_file_for_errors( this_file = '/Users/x/DATA/PROGRAMMING_LANGUAGES/RUBY/src/rbt/lib/rbt/yaml/individual_cookbooks/'\ 'jasper.yml' ) if this_file.is_a? Array this_file = this_file.first end if this_file.nil? this_file = '/Users/x/DATA/PROGRAMMING_LANGUAGES/RUBY/src/rbt/lib/rbt/yaml/individual_cookbooks/'\ 'jasper.yml' end if File.exist? this_file registered_cookbook_entries = RBT.registered_cookbook_entries? dataset = YAML.load_file(this_file) key = dataset.keys.first available_entries_from_the_cookbooks_file = dataset[key].keys # ===================================================================== # # Next, obtain the entries that were not registered. Keep in mind # that this Array may be entry. # ===================================================================== # these_entries_were_not_registered = available_entries_from_the_cookbooks_file.reject {|entry| registered_cookbook_entries.include? entry } unless these_entries_were_not_registered.empty? opn; e 'The file at `'+sfile(this_file)+'`' opn; e 'contains at the least one erroneous entry.' these_entries_were_not_registered.each {|this_entry_is_not_included| opn; e 'The entry `'+sfancy(this_entry_is_not_included)+'` is not registered.' } else opn; e 'Everything is fine for '+sfile(this_file)+'.' opn; e 'It has '+RBT.violet('no incorrect entries')+'.' end else opn; e 'No file exists at '+this_file+'.' end end
#¶ ↑
RBT.chmod
(chmod tag)¶ ↑
Use this method to chmod a file or a directory. It also works with several files/directories passed in as Array.
#¶ ↑
# File lib/rbt/toplevel_methods/chmod.rb, line 15 def self.chmod( this_file, permission = 0755 ) if this_file.is_a? Array this_file.each { |file| chmod(file, permission) } else File.chmod(permission.to_i, this_file) end end
#¶ ↑
RBT.chroot_compile
¶ ↑
This method can be used to chroot-compile a given program, that is, to compile it INTO the chroot.
This is mostly a “hackish” method in that I needed it to quickly compile programs into my main chroot, for when I build it up.
#¶ ↑
# File lib/rbt/toplevel_methods/chroot_compile.rb, line 20 def self.chroot_compile( this_program = ARGV, use_this_as_prefix = '/Depot/Chroot/usr/' ) RBT::Compile.new(this_program) {{ use_this_as_prefix: use_this_as_prefix }} end
#¶ ↑
RBT.cliner
¶ ↑
This method accepts block-parameters such as :unicode, which will be “converted” into a corresponding horizontal line via a certain unicode block-symbol.
#¶ ↑
# File lib/rbt/toplevel_methods/cliner.rb, line 34 def self.cliner( use_this_token = '=', use_this_colour = nil, &block ) case use_this_token when :default use_this_token = '=' end case use_this_colour when :default use_this_colour = nil end if block_given? yielded = yield case yielded when :unicode_middle_horizontal_bar begin # ================================================================= # # Fetch the unicode block here. # ================================================================= # require 'roebe/requires/require_unicode.rb' use_this_token = ::Roebe.horizontal_double_bar rescue LoadError end when :unicode begin # ================================================================= # # Fetch the unicode block here. # ================================================================= # require 'roebe/requires/require_unicode.rb' use_this_token = ::Roebe.return_horizontal_unicode_block rescue LoadError end end end use_this_colour = nil if use_this_token.is_a? Hash if use_this_token.has_key? :use_colour use_this_colour = use_this_token[:use_colour] use_this_token = '=' # Restore the default in this case. end end case use_this_token when nil, :default use_this_token = '=' # <- Restore to the default in this case. end if use_this_colour if use_this_colour.to_s.start_with?('konsole_dodgerblue') and !use_this_colour.to_s.include?('colour_') # ================================================================= # # In this case, rewrite the colour-code a little, such as from # 'konsole_dodgerblue' towards 'konsole_colour_blue'. # ================================================================= # use_this_colour = 'konsole_colour_'+use_this_colour.to_s.split('_').last end puts ::Colours::AllColourMethods.send(use_this_colour, (use_this_token * 80)) else if use_this_token.is_a? Symbol use_this_token = ::Colours::AllColourMethods.send(use_this_token, '=') end puts (use_this_token * 80) end end
#¶ ↑
RBT.compile_via_appdir_prefix_without_symlinking
¶ ↑
This method will compile via a versioned AppDir approach, but will not symlink after compilation has finished.
#¶ ↑
# File lib/rbt/toplevel_methods/compile_via_appdir_prefix_without_symlinking.rb, line 17 def self.compile_via_appdir_prefix_without_symlinking(i = ARGV) i = [i].flatten.compact i.each {|this_program| _ = Compile.new(this_program) {{ run_already: :do_not_run_yet, symlink_after_compilation_has_finished: false }} _.do_use_an_appdir_prefix _.run } end
#¶ ↑
RBT.compile_via_environment_variable_as_prefix
¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/compile_via_environment_variable_as_prefix.rb, line 158 def self.compile_via_environment_variable_as_prefix( compile_these_programs = ARGV, use_this_environment_variable = :default ) RBT::CompileViaEnvironmentVariableAsPrefix.new( compile_these_programs, use_this_environment_variable ) end
#¶ ↑
RBT.configure_appdir_prefix
¶ ↑
This method will return the AppDir prefix, based on the given input, which defaults to the current working directory.
#¶ ↑
# File lib/rbt/toplevel_methods/configure_appdir_prefix.rb, line 23 def self.configure_appdir_prefix( i = return_pwd ) i = i.first if i.is_a? Array if i.nil? or i.empty? i = return_pwd end target = File.basename(i) _ = './configure --prefix='+ programs_dir?+ ProgramInformation.return_name(target).capitalize+'/'+ ProgramInformation.return_version(target)+ '/' e _ end
#¶ ↑
RBT.configure_has_a_higher_priority_than_meson?
¶ ↑
This method will return true if “configure” has a higher priority than “meson”. A yaml file keeps track of these priorities.
#¶ ↑
# File lib/rbt/toplevel_methods/configure_has_a_higher_priority_than_meson.rb, line 17 def self.configure_has_a_higher_priority_than_meson? array = YAML.load_file(FILE_BUILD_SYSTEMS_PRIORITIES) array.index('configure') < array.index('meson') end
#¶ ↑
RBT.copy_recursively
¶ ↑
We can use a call to system(), or the pure ruby version, in order to recursively copy files. But you may not enough information if the pure ruby version is used.
#¶ ↑
# File lib/rbt/toplevel_methods/copy_recursively.rb, line 18 def self.copy_recursively( what, where_to = '/usr/', be_verbose = false ) if what.is_a? String what << '.' unless what.end_with? '.' end begin FileUtils.cp_r(what, where_to, :verbose => be_verbose) rescue Exception => error pp error end end
#¶ ↑
RBT.create_directory
¶ ↑
Internal Wrapper to create a directory.
We will also check if a Dir exists before actually creating it. This is the method of choice for creating a directory. Use it for all the RBT
scripts, whenever you need to create a directory.
#¶ ↑
# File lib/rbt/toplevel_methods/create_directory.rb, line 22 def self.create_directory( where = '/Users/Packages/', use_this_mode = 0755, be_verbose = :be_quiet, do_use_opnn = true ) case use_this_mode when :be_verbose be_verbose = :be_verbose use_this_mode = :default end if where.is_a? Array where.each {|entry| create_directory( entry, use_this_mode, be_verbose, do_use_opnn ) } else if File.directory? where unless where.end_with? '/' # Append a /. where = where.dup if where.frozen? where << '/' end end case use_this_mode when :default # Default value is 0755. use_this_mode = 0755 when Hash if use_this_mode.has_key? :verbosity use_this_mode = use_this_mode.delete(:verbosity) end use_this_mode = 0755 when '', true use_this_mode = 0755 when :be_verbose use_this_mode = 0755 be_verbose = true end # ===================================================================== # # Handle special symbols given to be_verbose. # ===================================================================== # case be_verbose when Hash if be_verbose.has_key? :verbosity be_verbose = be_verbose.delete(:verbosity) end when :be_quiet, :be_silent be_verbose = false end case do_use_opnn when :do_not_use_opn, :do_not_use_opnn do_use_opnn = false end if File.exist? where if be_verbose opnn if do_use_opnn e "Directory `#{sdir(where)}` "\ "already exists, thus" opnn if do_use_opnn e 'skipping creating a new one.' end else if where if be_verbose opnn if do_use_opnn e "Creating the directory `#{sdir(where)}` next." end unless File.directory? where # basedir = File.dirname(where) FileUtils.mkdir_p(where, { mode: use_this_mode, verbose: false } ) if be_verbose opnn if do_use_opnn e "Can not write into the directory `#{sdir(where)}` "\ "due to insufficient permissions." end end else opnn if do_use_opnn; e 'No directory was given.' end end end end
#¶ ↑
RBT.create_html_page_for_these_programs
¶ ↑
This method works on an Array as its input. This Array should be about programs that you want to see an auto-generated webpage containing some information about this program.
#¶ ↑
# File lib/rbt/toplevel_methods/create_html_page_for_these_programs.rb, line 25 def self.create_html_page_for_these_programs(array = ARGV) if array.is_a?(String) and array.start_with?(':') array = array.to_s.delete(':').to_sym end if array.is_a? Symbol require 'rbt/utility_scripts/search_for_tags/search_for_tags.rb' # ===================================================================== # # Handle special cases such as KDE5. # ===================================================================== # case array # case tag # ===================================================================== # # === cookbooks --create_html_page_for_these_programs=:kde5 # ===================================================================== # when :kde, :kde5 array = RBT.return_all_programs_that_match_this_tag(:kde5) # ===================================================================== # # === cookbooks --create_html_page_for_these_programs=:kde5_toolchain # ===================================================================== # when :kde5_toolchain # =================================================================== # # This variant here should be equivalent to LFS/BLFS, in the proper # order. This thus requires a yaml file. # =================================================================== # dataset = YAML.load_file(RBT.file_cookbook_chained_programs) array = dataset['kde5_foundation']+ dataset['kde5_plasma']+ dataset['kde5_applications']+ dataset['kde5_porting_aids'] if array.is_a? String # Well ... :) array.delete!(' ') array = array.split(',') end end end if array.is_a? Array if array.first.is_a?(String) and array.first.include?(',') # <- Input such as ["php,kio,ruby"] array = array.first.split(',') end array.flatten! if array.size > 20 opn; e 'More than 20 entries were given (exactly '+ sfancy(array.size.to_s)+'). This may take a while.' end @html_page_content = "<html><head><title>HTML Pages for programs</title>"\ "<style>pre { font-size: 1.4em; }</style>"\ "</head><body><hr>\n".dup # Reset again. array.each_with_index {|this_program, index| index += 1 # =================================================================== # # For each program, we do the same actions: # (1) Obtain the dataset via Cookbooks::Cookbook.new() OR # from the expanded directory containing all yaml files. # (2) # =================================================================== # if File.directory?(RBT.directory_expanded_cookbooks) and File.exist?(target_file = "#{RBT.directory_expanded_cookbooks}#{this_program}.yml") dataset = YAML.load_file(target_file) remote_url = dataset['url1'] description = dataset['raw_description'] licence = dataset['licence'] homepage = dataset['homepage'].to_s binaries = dataset['binaries'] else dataset = RBT::Cookbooks::Cookbook.new(this_program) { :bypass_menu_check } remote_url = dataset.url1? description = dataset.raw_description? licence = dataset.licence? homepage = dataset.homepage? binaries = dataset.binaries? end if licence.is_a? Array licence = licence.join(', ') end @html_page_content << "<p>\n<h3 style=\"color:darkgreen\"><b style=\"color:darkblue\">"\ "#{index})</b> #{this_program}</h3><br>\n" @html_page_content << " <span style=\"margin-left: 1em; font-weight:bold; color: darkblue\">wget #{remote_url}<span><br><br>\n" unless description.to_s.empty? # <- Ignore empty descriptions. @html_page_content << "<pre>#{description}</pre>\n" end # =================================================================== # # Add the binaries next: # =================================================================== # if binaries and binaries.is_a?(Array) and !binaries.empty? @html_page_content << "Binaries:<br>\n" binaries.each {|this_binary| @html_page_content << "<span style=\"margin-left:2em\">#{this_binary}<span><br>\n" } @html_page_content << "<br>\n" end @html_page_content << "licence: #{licence}<br><br>\n" @html_page_content << "homepage: <a href=\"#{homepage}\">#{homepage}</a><br>\n" @html_page_content << "</p><br><hr>\n" } # ===================================================================== # # Next, store that HTML page somewhere. # ===================================================================== # what = @html_page_content into = "#{log_dir?}programs.html" opn; e "Storing these #{sfancy(array.size)} programs into the file:" e e " #{sfile(into)}" e write_what_into(what, into) @html_page_content = ''.dup # Clear it again here. else opn; e 'This method requires an Array as input.' end end
#¶ ↑
RBT.create_log_directory
¶ ↑
This method will create the log directory, e. g. “/tmp/rbt/” or wherever else the user has set this directory to be at.
#¶ ↑
# File lib/rbt/toplevel_methods/create_log_directory.rb, line 20 def self.create_log_directory _ = @log_directory unless File.directory? _ opn; e "Creating the directory `#{sdir(_)}` now." else opn; e "Directory at `#{sdir(_)}` already exists." end end
#¶ ↑
RBT.create_program_version_url_file
¶ ↑
The boolean argument that can be passed to this method determines as to whether we will also show the time when the program has been last updated. By default this is true, meaning that we WILL show when a program has been last updated.
To invoke this method from the commandline, do:
rbt --create_program_version_url_file
#¶ ↑
# File lib/rbt/utility_scripts/create_program_version_url_file.rb, line 164 def self.create_program_version_url_file( also_show_last_update = :default # Since Feb 2018, we will show the last update by default. ) case also_show_last_update # case tag when :also_show_last_update, :include_last_update, :default also_show_last_update = true end RBT::CreateProgramVersionUrlFile.new {{ show_last_update: also_show_last_update }} end
#¶ ↑
RBT.create_programs_version_html_file
¶ ↑
Commandline
invocation example:
rbt --create_programs_version_html_file
The default input file can be found at:
/Depot/Temp/rbt/CookbookDirectory/programs_version_url.txt
#¶ ↑
# File lib/rbt/toplevel_methods/create_programs_version_html_file.rb, line 28 def self.create_programs_version_html_file( use_this_file = "#{RBT.store_into_this_directory}programs_version.txt" ) updated_when = "#{RBT.return_date} #{RBT.return_time}" # ======================================================================= # # Generate a .html file. # ======================================================================= # dataset = '<html><title>Programs of Cookbooks Version: '+RBT.version?+ ' Last updated: '+updated_when+ '</title><body> Last update: <b>'+updated_when+'</b><br> <pre style="font-size:1.2em">'+ File.read(use_this_file)+'</pre></body></html>' # ======================================================================= # # Store that file next: # ======================================================================= # use_this_file = RBT.temp_directory?+'programs_version.html' opn; e "Generating a new file at `#{sfile(use_this_file)}`." RBT.write_what_into( dataset, use_this_file ) # Store it here. end
#¶ ↑
RBT.determine_appdir_prefix_from_this_input
¶ ↑
This method will return a String such as “/Programs/Htop/1.1.1/”.
#¶ ↑
# File lib/rbt/toplevel_methods/determine_appdir_prefix_from_this_input.rb, line 21 def self.determine_appdir_prefix_from_this_input( name_of_the_program = 'htop', version_of_the_program = nil ) if name_of_the_program.is_a? Array name_of_the_program = name_of_the_program.first end name_of_the_program = 'htop' if name_of_the_program.nil? new_prefix = ''.dup # ======================================================================= # # Append the "/Programs/" string next: # ======================================================================= # new_prefix << programs_directory? if name_of_the_program.nil? e 'Please supply a valid argument to this method.' e e 'A valid input-argument may be:' e e ' foobar-1.0' e raise 'A program-name (String) is required.' end # ======================================================================= # # === Safeguard against improper versions # ======================================================================= # if version_of_the_program.nil? and name_of_the_program.include?('-') version_of_the_program = ProgramInformation.return_version(name_of_the_program) name_of_the_program = ProgramInformation.return_name(name_of_the_program) end new_prefix << name_of_the_program.capitalize new_prefix << '/' if version_of_the_program new_prefix << "#{version_of_the_program}/" end return new_prefix end
#¶ ↑
RBT.determine_host_architecture
¶ ↑
If you ever want to determine the host architecture, make use of this method here. This method will return a String.
Invocation example:
RBT.determine_host_architecture # => "x86_64"
#¶ ↑
# File lib/rbt/toplevel_methods/determine_host_architecture.rb, line 18 def self.determine_host_architecture # ======================================================================= # # We use uname to query the host architecture. This will thus # not work on Windows. An alternative would be to use: # RbConfig::CONFIG['host'] # This is now what we will use. # ======================================================================= # # this_architecture = `uname -m`.to_s.chomp this_architecture = RbConfig::CONFIG['host'] if this_architecture.include? '-' this_architecture = this_architecture.split('-').first end return this_architecture end
#¶ ↑
RBT.directory_expanded_cookbooks?
¶ ↑
On my home system, this method will return the following String:
"/Depot/Temp/rbt/expanded_cookbooks/"
#¶ ↑
# File lib/rbt/constants/file_and_directory_constants.rb, line 204 def self.directory_expanded_cookbooks? "#{RBT.rbt_log_directory?}expanded_cookbooks/" end
#¶ ↑
RBT.do_not_show_names?
¶ ↑
This is the reverse complement to RBT.show_the_classname?
.
#¶ ↑
# File lib/rbt/toplevel_methods/do_show_the_classname.rb, line 42 def self.do_not_show_names? !RBT.show_the_classname? end
#¶ ↑
RBT.does_include_this_binary?
¶ ↑
This will return true if we have a binary with that name.
Usage example:
RBT.does_include_this_binary? 'xxd' RBT.has_this_binary? 'xzcmp'
#¶ ↑
# File lib/rbt/toplevel_methods/all_binaries.rb, line 70 def self.does_include_this_binary?(i) all_binaries?.has_key?(i) end
#¶ ↑
RBT.does_include_this_library?
¶ ↑
This will return true if we have a binary with that name.
Usage example:
RBT.does_include_this_binary? 'xxd' RBT.has_this_binary? 'xzcmp'
#¶ ↑
# File lib/rbt/toplevel_methods/all_libraries.rb, line 70 def self.does_include_this_library?(i) all_libraries?.has_key?(i) end
#¶ ↑
RBT.does_this_cookbook_file_have_any_erroneous_entry?
¶ ↑
This method will return a boolen value - true or false.
If true then the cookbook file in question has had an erroneous entry.
#¶ ↑
# File lib/rbt/toplevel_methods/check_this_cookbook_file_for_errors.rb, line 25 def self.does_this_cookbook_file_have_any_erroneous_entry?( this_file = RUBY_SRC_DIR+'rbt/lib/rbt/yaml/individual_cookbooks/jasper.yml' ) if this_file.is_a? Array this_file = this_file.first end if this_file.nil? this_file = RUBY_SRC_DIR+'rbt/lib/rbt/yaml/individual_cookbooks/jasper.yml' end if File.exist? this_file registered_cookbook_entries = RBT.registered_cookbook_entries? dataset = YAML.load_file(this_file) key = dataset.keys.first available_entries_from_the_cookbooks_file = dataset[key].keys # ===================================================================== # # Next, obtain the entries that were not registered. Keep in mind # that this Array may be entry. # ===================================================================== # these_entries_were_not_registered = available_entries_from_the_cookbooks_file.reject {|entry| registered_cookbook_entries.include? entry } !these_entries_were_not_registered.empty? else false # You have to ensure that the file exists on your own. end end
#¶ ↑
RBT.does_this_file_exist?
¶ ↑
This method will check whether a given file exists or whether it does not.
The second argument can be used to determine whether we shall use a file at a particular position on the filesystem, e. g. like '../include/' that can be passed. This would check for the file at the directory below the current one, within the include/ subdirectory.
#¶ ↑
# File lib/rbt/toplevel_methods/does_this_file_exist.rb, line 44 def self.does_this_file_exist?( i = FILE_SCONS, prepend_this_for_the_check = nil ) if i.is_a? Array i = i.first end i = i.to_s unless i.is_a? String # We need a String past this point. if prepend_this_for_the_check unless prepend_this_for_the_check.is_a? String if prepend_this_for_the_check == true # ================================================================= # # true values are converted into '../' strings. # ================================================================= # prepend_this_for_the_check = '../'.dup end end i = i.dup.prepend( prepend_this_for_the_check.dup ) end File.exist? i end
#¶ ↑
RBT.download
¶ ↑
This method can be used to download a remote source archive, if the argument is a symbol. Additionally direct URLs can also be given.
The second argument is optional. If given then the method will attempt to download only a specific version from the remote location. In order for this to work, the method may first have to “probe” whether the remote file exists. For this functionality, wget it used.
In general the method depends on “wget”, largely due to reasons of simplicity.
Invocation examples:
RBT.download :htop RBT.download :php RBT.download :libx11
#¶ ↑
# File lib/rbt/toplevel_methods/download.rb, line 36 def self.download( i = ARGV, optional_use_this_version = nil ) # ======================================================================= # # Treat all input as an Array. # ======================================================================= # i = [i].flatten.compact i.each {|remote_url| # ===================================================================== # # === Handle symbols next # # Symbols will be treated differently, as we can assume that a user # normally would not pass in a Symbol to the method. So if we see # a Symbol, then we can also handle this situation in a special # manner. # ===================================================================== # if remote_url.is_a? Symbol case remote_url when :pwd # This is special - we will take the dirname. remote_url = File.basename(Dir.pwd).to_s if Object.const_defined?(ProgramInformation) and (remote_url =~ /\d+/) # <- And if it has at the least one number. remote_url = ProgramInformation.return_short_name(remote_url) end remote_url = remote_url.delete('-').to_sym end remote_url = RBT.location_of?(remote_url) # <- This should return an Array. if remote_url.is_a? Array remote_url = remote_url.first end end # ===================================================================== # # Next, honour the situation where the user wants to specifically # download a specific version of a program. # ===================================================================== # if optional_use_this_version if optional_use_this_version.is_a? Hash if optional_use_this_version.has_key? :version optional_use_this_version = optional_use_this_version[:version] end end _ = optional_use_this_version # =================================================================== # # else it does not exist, so we try other archive formats. This # will be handled by the following Array. # =================================================================== # array_formats_to_check_for = %w( .tar.xz .tar.gz .tar.bz2 ) # =================================================================== # # The old URL will already be available in the variable remote_url. # =================================================================== # remote_url = RBT.return_remote_url_from_this_input(remote_url, optional_use_this_version) require 'wget' if Wget.check_if_remote_file_exists(remote_url) array_formats_to_check_for = [] # Clear it here. else # ================================================================= # # We reject the ones that we already have checked before: # ================================================================= # array_formats_to_check_for.reject! {|entry| remote_url.end_with? entry } unless array_formats_to_check_for.empty? array_formats_to_check_for.each {|inner_entry| if Wget.check_if_remote_file_exists(inner_entry) # =========================================================== # # The next check is not ideal, but it may suffice for now. # After all we only need at the least one remote URl that # can be used. # =========================================================== # remote_url = inner_entry end } end end end if remote_url.empty? e "The given #{crimson('URL')} was not found - thus, "\ "no download can occur." else e "Next downloading from the remote URL `#{sfancy(remote_url)}`." use_this_command = "wget #{remote_url}" e use_this_command result = `#{use_this_command} 2>&1` if result.include? 'ERROR 404: Not Found' e "No archive/program was found at the remote url #{remote_url}." end if File.exist? File.basename(remote_url) e "Success! The file can be found at `"\ "#{sfile( File.absolute_path(File.basename(remote_url)) )}`." end end } end
#¶ ↑
RBT.enable_module_programs
¶ ↑
This method will be invoked when we require the cookbooks project in a special manner.
We add the individual cookbooks onto the Cookbooks
. namespace directly there.
This will then allow us to call methods such as:
RBT.htop
Do note that we will also radically override already existing methods, so this is functionality that should be used with care.
Testing this method can happen either like this:
RBT.enable_module_programs; RBT.htop require 'rbt/module_programs'; htop = RBT.htop
#¶ ↑
# File lib/rbt/toplevel_methods/module_programs.rb, line 31 def self.enable_module_programs( also_add_reader_methods = true ) available_programs?.each {|this_program| self.class.class_eval { _ = this_program.to_sym if respond_to? _ # This here happens when we enable the methods. # This is just here as a placeholder, if we ever want # to debug this. else # ::RBT.e 'Defining the method `'+_.to_s+'` next.' # <- This is more o a debug-statement. define_method(_) { # Simply delegate to class Cookbook then. RBT::Cookbooks::Cookbook.new(this_program) } # ================================================================= # # We will additionally add reader-methods, if the argument is # set to true. These reader methods will directly return the # dataset, as a Hash. # # This can be tested like so in IRB: # require 'rbt/module_programs'; x = RBT.htop.hash? # ================================================================= # if also_add_reader_methods define_method(_.to_s+'?') { # Simply delegate to class Cookbook then. RBT::Cookbooks::Cookbook.new(this_program).hash? } end end } } end
#¶ ↑
RBT.ensure_that_the_required_directories_exist
¶ ↑
This method ensures that the base-directory exists.
This can also be invoked from the commandline, by issuing:
rbt --ensure-that-the-required-directories-exist
#¶ ↑
# File lib/rbt/toplevel_methods/ensure_that_the_required_directories_exist.rb, line 23 def self.ensure_that_the_required_directories_exist( use_this_as_directory = RBT.store_into_this_directory?, be_verbose = false ) if block_given? yielded = yield case yielded when :be_verbose be_verbose = true when :be_quiet be_verbose = false end end if Dir.exist?(use_this_as_directory) if be_verbose opn; e "The directory at `#{use_this_as_directory}` "\ "already exists." end else target = File.dirname(use_this_as_directory) if File.writable?(target) require 'fileutils' opn; e "Creating directory `#{use_this_as_directory}`." FileUtils.mkdir_p(use_this_as_directory) else e "Can not write into the directory "\ "`#{use_this_as_directory}` as it is not writable. "\ "Consider using" e 'another setting for temp_directory.yml perhaps.' e e 'This file can be found here:' e e " #{file_temp_directory}" e end end end
#¶ ↑
RBT.extract
¶ ↑
#¶ ↑
# File lib/rbt/toplevel_methods/extract.rb, line 17 def self.extract( i, extract_to_this_directory = "#{Dir.pwd}/".squeeze('/') ) unless Object.const_defined? :Extracter e 'RBT can not extract anything as the gem extracter '\ '(module Extracter) is not installed.' return end [i].flatten.compact.each {|this_program| Extracter.extract_this( i, to: extract_to_this_directory ) } end
#¶ ↑
RBT.fast_return_file_size_of_this_program
¶ ↑
This method will quickly return the file size of the given input program.
Invocation example from ruby:
RBT.fast_return_file_size_of_this_program(:htop) # => 213004
#¶ ↑
# File lib/rbt/toplevel_methods/fast_return_file_size_of_this_program.rb, line 23 def self.fast_return_file_size_of_this_program(i) if i.is_a? Array i = i.join(' ').strip end i = i.to_s unless i.is_a? String if File.directory? RBT.base_dir_to_store_expanded_cookbooks? target_file = "#{RBT.base_dir_to_store_expanded_cookbooks?}#{i}.yml" if File.exist? target_file dataset = YAML.load_file(target_file) archive_size = dataset['archive_size'] return archive_size else e "No file exists at `#{target_file}`" end else e 'No directory exists at '+ RBT.base_dir_to_store_expanded_cookbooks? end end
#¶ ↑
RBT.feedback_available_programs
¶ ↑
This method will report to the user, in a more verbose manner, which specific programs are registered in the RBT-project.
#¶ ↑
# File lib/rbt/toplevel_methods/available_programs.rb, line 218 def self.feedback_available_programs result = ''.dup # Build up the return String. opn; e "Feedbacking all available programs next,"\ " #{available_programs.size} of them." available_programs?.each_with_index {|entry, index| index += 1 result << "(#{simp(index.to_s.rjust(3))}) #{sfancy(entry)}#{N}" } e result end
#¶ ↑
RBT.feedback_program_description
¶ ↑
This will feedback the description of the program at hand.
#¶ ↑
# File lib/rbt/toplevel_methods/feedback_program_description.rb, line 16 def self.feedback_program_description( i ) i = i.first if i.is_a? Array if i _ = RBT::Cookbooks::Cookbook.new _.find_this_program(i) e _.description? end end
#¶ ↑
RBT.file_compiled_programs
¶ ↑
This method will return a location such as “/Depot/Temp/rbt/compiled_programs.yml”.
Note that from this you can also obtain the “last compiled program”.
#¶ ↑
# File lib/rbt/configuration/configuration.rb, line 153 def self.file_compiled_programs "#{RBT.rbt_log_directory?}compiled_programs.yml" end
#¶ ↑
RBT.file_cookbook_aliases
¶ ↑
Simply return where the cookbook_aliases.yml file resides.
This is, for instance, here:
/Programs/Ruby/2.5.1/lib/ruby/site_ruby/2.5.0/rbt/yaml/cookbook_aliases.yml
#¶ ↑
# File lib/rbt/constants/file_and_directory_constants.rb, line 133 def self.file_cookbook_aliases "#{RBT.project_yaml_directory?}cookbook_aliases.yml" end
#¶ ↑
RBT.file_cookbook_chained_programs
¶ ↑
This is the preferred way to determine where the file “cookbook_chained_programs.yml” can be found.
#¶ ↑
# File lib/rbt/constants/file_and_directory_constants.rb, line 264 def self.file_cookbook_chained_programs "#{RBT.project_yaml_directory?}chained_programs.yml" end
#¶ ↑
RBT.file_predefined_installation_instructions
¶ ↑
Method to return where the file location is. There used to be a constant available called FILE_PREDEFINED_INSTALLATION_INSTRUCTIONS but this was removed in January 2019.
#¶ ↑
# File lib/rbt/constants/predefined_installation_instructions.rb, line 31 def self.file_predefined_installation_instructions( use_this_directory = RBT.project_yaml_directory? ) "#{use_this_directory}predefined_installation_instructions.yml" end
#¶ ↑
RBT.file_registered_cookbook_entries
¶ ↑
Tell use where the file registered_cookbook_entries.yml is stored.
#¶ ↑
# File lib/rbt/constants/registered_cookbook_entries.rb, line 31 def self.file_registered_cookbook_entries( use_this_directory = RBT.yaml_directory? ) "#{use_this_directory}registered_cookbook_entries.yml" end
#¶ ↑
RBT.file_storing_the_time_it_took_to_compile_programs
¶ ↑
Use this method variant here rather than the constant. Reason is that the method assembles its method dynamically.
#¶ ↑
# File lib/rbt/constants/file_and_directory_constants.rb, line 181 def self.file_storing_the_time_it_took_to_compile_programs "#{RBT.log_directory?}database_storing_compile_times.yml" end
#¶ ↑
RBT.file_temp_directory
¶ ↑
This reader method will return the location to the file named “temp_directory.yml”, as a String.
On my system, the method may return a String such as “/Programs/Ruby/2.5.1/lib/ruby/site_ruby/2.5.0/rbt/yaml/configuration/temp_directory.yml”
#¶ ↑
# File lib/rbt/toplevel_methods/temp_directory.rb, line 42 def self.file_temp_directory "#{RBT.configuration_directory?}temp_directory.yml" end
#¶ ↑
RBT.file_use_colours?
¶ ↑
This method will point to a path such as:
/Programs/Ruby/2.5.1/lib/ruby/site_ruby/2.5.0/rbt/yaml/configuration/use_colours.yml
#¶ ↑
# File lib/rbt/toplevel_methods/configuration_directory.rb, line 57 def self.file_use_colours?( use_this_directory = @configuration_directory ) "#{use_this_directory}use_colours.yml" end
#¶ ↑
RBT.find_url_for
¶ ↑
Use this method to find a specific URL quickly. We will return the first URL always, also called url1. The method will also try to return url2 - and hence return an Array.
Usage example:
RBT.find_url_for() RBT.find_url_for(:htop) # => ["http://hisham.hm/htop/releases/2.2.0/htop-2.2.0.tar.gz", "http://hisham.hm/htop/index.php?page=downloads"] RBT.url_for? :patch # => ["https://ftp.gnu.org/pub/gnu/patch/patch-2.7.6.tar.xz", "http://ftp.gnu.org/gnu/patch/?C=M;O=D"]
#¶ ↑
# File lib/rbt/toplevel_methods/find_url_for.rb, line 24 def self.find_url_for( i = ARGV ) i = i.first if i.is_a? Array i = i.to_s # ======================================================================= # # Next, we will try to use the expanded dataset, if it exists. This # will be MUCH faster than instantiating a new ruby object, as is # done in the else clause. # ======================================================================= # expanded_file = RBT.return_location_to_this_programs_yaml_file(i) if File.exist? expanded_file if i.end_with? '.yml' i = i.dup if i.frozen? i.sub!(/\.yml$/,'') end dataset = YAML.load_file(expanded_file) if dataset.has_key?(i) dataset = dataset[i] end url1 = dataset['url1'] # Is a String. url2 = dataset['url2'] # Is a String. else _ = RBT::Cookbooks::Cookbook.new(i) { :skip_menu_interface } url1 = _.url1? # Return the URL here. url2 = _.url2? end url1 = url1.to_s.strip url2 = url2.to_s.strip return [ url1, url2 ] end
#¶ ↑
RBT.fix_chown_root_entries_in_this_file
¶ ↑
This method can be used to replace all “chown root:root” entries with “chown 0:0” entries. It may be necessary for when we have setup a chroot.
#¶ ↑
# File lib/rbt/toplevel_methods/misc.rb, line 72 def self.fix_chown_root_entries_in_this_file( this_file = 'Makefile' ) what = ''.dup if File.exist? this_file File.readlines(this_file).each {|this_entry| if this_entry.include? 'chown root:root' this_entry.gsub!(/root:root/, '0:0') end what << this_entry } e "Now modifying the file `#{sfile(this_file)}`." write_what_into(what, this_file) end end
#¶ ↑
RBT.generate_pdf_tutorial_then_upload_it
¶ ↑
Use this method to upload the .pdf tutorial to a remote host.
#¶ ↑
# File lib/rbt/utility_scripts/generate_pdf_tutorial.rb, line 107 def self.generate_pdf_tutorial_then_upload_it RBT.generate_pdf_tutorial # Next comes the upload part. require 'ftp_paradise/without_gui_bindings' connection = FtpParadise.connect to: :shevy connection.set_to_binary_mode connection.upload_this_file RBT::GeneratePdfTutorial.store_pdf_file_where? end
#¶ ↑
RBT.generate_programs_version_yaml_file
¶ ↑
This method will create one big yaml file that is a Hash. This big Hash will have the name of all programs and the corresponding version of said programs.
The key will be the name of the program and the value will be the respective program version.
You can also pass in your own dataset. If you do so, remember to use a hash, with specific key->value pairs that reflect the name of the program and the specific version of said program.
You can invoke this method from the commandline, by issuing:
cookbook --generate_version_file
#¶ ↑
# File lib/rbt/toplevel_methods/generate_programs_version_yaml_file.rb, line 36 def self.generate_programs_version_yaml_file( use_this_dataset = nil ) _ = ''.dup # We will append onto this String. unless use_this_dataset # This is the default behaviour/clause. hash = {} # We store into this hash here. all_programs = RBT.available_programs all_programs.each {|this_program| opn; e "Now working on the program "\ "`#{Colours.lightgray(this_program)}`." cookbook = RBT::Cookbooks::Cookbook.new(this_program) { :bypass_menu } # =================================================================== # # Add onto the Hash next. Should keep it as a String. # =================================================================== # hash[this_program] = cookbook.version?.to_s } use_this_dataset = hash end use_this_dataset.each_pair {|key, value| value = '"'+value.to_s+'"' unless value.include? '"' _ << key.to_s+': '+value.to_s+N } # ======================================================================= # # Ok, now we should have all programs and the respective version # at hand - we can store it next. In the past, this made use of # YAML.dump() but for some strange reason, YAML.dump() gave strange # results; which is why I decided to generate the .yml file # on my own. # ======================================================================= # what = _ into = RBT.yaml_directory?+'programs_version.yml' opn; e "Will also store into `#{sfile(into)}`." RBT.write_what_into(what, into) # Store into the file programs_version.yml # ======================================================================= # # Store for my home-system as well. # ======================================================================= # if is_roebe? # On my system. into = RUBY_SRC_DIR_AT_HOME+'rbt/lib/rbt/yaml/programs_version.yml' opn; e "Will also store into `#{sfile(into)}`." RBT.write_what_into(what, into) end end
#¶ ↑
RBT.get_all_directories_from
¶ ↑
This will return all directories.
Invocation example:
RBT.get_all_directories_from('/Users/x/SRC/')
#¶ ↑
# File lib/rbt/toplevel_methods/get_all_directories_from.rb, line 17 def self.get_all_directories_from( here = Dir.pwd, return_full_path = false ) here << '/' unless here.end_with? '/' _ = Dir["#{here}*"] _.select! {|entry| File.directory?(entry) } result = _.map {|entry| "#{entry}/" } if return_full_path result.map! {|line| File.absolute_path(line) } end return result end
#¶ ↑
RBT.get_all_files_from
¶ ↑
We will only obtain files through this method here.
#¶ ↑
# File lib/rbt/toplevel_methods/get_all_files_from.rb, line 16 def self.get_all_files_from( this_dir = Dir.pwd, return_full_path = true, include_hidden_files = false ) this_dir = Dir.pwd if this_dir.nil? _ = this_dir.dup _ << '/*' unless _.end_with? '/*' _ = rds(_) # Make use of RBT:rds() here. _ = Dir[_].select {|entry| File.file?(entry) } return _ end
#¶ ↑
RBT.get_date
¶ ↑
As of Sep 2014, this method will return a string such as:
"12 Jan 2015"
#¶ ↑
# File lib/rbt/toplevel_methods/time.rb, line 37 def self.get_date current_day = Time.now.strftime('%d') # This will return a string such as "30". current_day+ ' '+ Date::MONTHNAMES[Date.today.month][0,3]+ ' '+ Time.now.strftime('%Y') end
#¶ ↑
RBT.get_files_and_directories_from
¶ ↑
Simply combine RBT.get_all_directories_from
and RBT.get_files_from
via this method here.
#¶ ↑
# File lib/rbt/toplevel_methods/get_all_files_and_directories_from.rb, line 18 def self.get_files_and_directories_from( here = Dir.pwd ) _ = RBT.get_all_directories_from(here)+ RBT.get_all_files_from(here) return _.flatten end
#¶ ↑
RBT.gobolinux_naming_convention
¶ ↑
Easier toplevel method for accessing the functionality of class RBT::GobolinuxNamingConvention.
#¶ ↑
# File lib/rbt/linux/gobolinux/gobolinux_naming_convention.rb, line 138 def self.gobolinux_naming_convention(i) i = i.first if i.is_a? Array RBT::Gobolinux::NamingConvention.new(i).translated_name? end
#¶ ↑
RBT.hash_aliases_to_the_available_programs?
¶ ↑
Query method over the available aliases to the given programs. This will include the abbreviations, too.
Usage example:
RBT.hash_aliases_to_the_available_programs?['libxshmfenc'] # => "libxshmfence"
#¶ ↑
# File lib/rbt/toplevel_methods/available_programs.rb, line 42 def self.hash_aliases_to_the_available_programs? @hash_aliases_to_the_available_programs end
#¶ ↑
RBT.hash_registered_binaries?
¶ ↑
This method is similar to the method RBT.registered_binaries?
- but rather than an Array we will return the original Hash.
#¶ ↑
# File lib/rbt/utility_scripts/registered_binaries.rb, line 198 def self.hash_registered_binaries? ALL_BINARIES end
#¶ ↑
RBT.infer_build_system
¶ ↑
This method will return a String, indicating which build system is most likely to be used for a given program at hand.
#¶ ↑
# File lib/rbt/toplevel_methods/infer_build_system.rb, line 19 def self.infer_build_system( i = :infer_automatically, program_path = nil, depends_on = nil, # <- This optional argument can be an Array. optional_hash = {} ) case i when nil, :default i = :infer_automatically end use_a_build_directory = false use_this_build_system = 'configure' # <- Default value. unless optional_hash.empty? if optional_hash.has_key? :use_a_build_directory if optional_hash[:use_a_build_directory] == true use_a_build_directory = true end end end case i # ======================================================================= # # Must query whether we will try to infer the build system automatically. # ======================================================================= # when :infer_automatically # ===================================================================== # # We will start with a check for configure first. Do note that # ideally the order here should reflect the order given in the # file called 'build_systems_priorities.yml'. # ===================================================================== # if does_this_file_exist?('configure', use_a_build_directory) use_this_build_system = 'configure' # ===================================================================== # # Check for a rubygem file: # ===================================================================== # elsif program_path and program_path.end_with?('.gem') use_this_build_system = 'rubygem' # ===================================================================== # # Check for ninja: # ===================================================================== # elsif depends_on and depends_on_ninja?(depends_on) use_this_build_system = 'ninja' # ===================================================================== # # === Handle cmake installation types next # # This ought to come quite early. # ===================================================================== # elsif does_this_file_exist?(FILE_CMAKE_LISTS, use_a_build_directory) if depends_on and depends_on_cmake? use_this_build_system = 'cmake' else use_this_build_system = 'cmake' end # ===================================================================== # # === Handle 'waf' installations next # ===================================================================== # elsif does_this_file_exist?(FILE_WAF, use_a_build_directory) and !meson_build_file_exists? if depends_on and depends_on_waf? use_this_build_system = 'waf' else use_this_build_system = 'waf' end # ===================================================================== # # === Handle programs based on scons next # ===================================================================== # elsif does_this_file_exist?(FILE_SCONS) and !meson_build_file_exists? if depends_on and depends_on_python? use_this_build_system = 'scons' else use_this_build_system = 'scons' end # ===================================================================== # # === Handle "setup.py" files next # ===================================================================== # elsif does_this_file_exist?(FILE_SETUP_PY) and !meson_build_file_exists? if depends_on and depends_on_python? use_this_build_system = 'python' else use_this_build_system = 'python' end # ===================================================================== # # === Handle meson build next (meson tag) # # However had, some programs may have both a configure-script # and meson files. In this case, we have to determine which # one is to be run, which is done within the following "elsif" # clause. # ===================================================================== # elsif meson_build_file_exists?(:default, use_a_build_directory) # In this case, handle meson. use_this_build_system = 'meson' if does_this_file_exist?('configure') and configure_has_a_higher_priority_than_meson? use_this_build_system = 'configure' end end else if does_this_file_exist?(FILE_SETUP_PY) use_this_build_system = 'python' elsif meson_build_file_exists?(:default, use_a_build_directory) use_this_build_system = 'meson' else # This is our default then. if i.is_a? Symbol e 'Unregistered symbol: '+i.to_s else use_this_build_system = i end end end use_this_build_system # Return our findings here. end
#¶ ↑
RBT.infer_these_binaries_will_be_installed_by
¶ ↑
This method can be used to infer the binaries that may be installed by a given program at hand. This requires that the program has been installed already under an AppDir prefix.
#¶ ↑
# File lib/rbt/utility_scripts/suggest_cookbook_for.rb, line 657 def self.infer_these_binaries_will_be_installed_by( this_program = ARGV ) RBT::SuggestCookbookFor.new(this_program) { :do_not_report }.binaries? end
#¶ ↑
RBT.infer_these_libraries_will_be_installed_by
¶ ↑
This method can be used to infer the libraries that may be installed by a given program at hand. This requires that the program has been installed already under an AppDir prefix.
#¶ ↑
# File lib/rbt/utility_scripts/suggest_cookbook_for.rb, line 644 def self.infer_these_libraries_will_be_installed_by( this_program = ARGV ) RBT::SuggestCookbookFor.new(this_program) { :do_not_report }.libraries? end
#¶ ↑
RBT.initialize_configuration
¶ ↑
Use a method to initialize the configuration for the RBT
project.
#¶ ↑
# File lib/rbt/configuration/initialize_configuration.rb, line 31 def self.initialize_configuration # ======================================================================= # # We will set the @configuration variable to a specific value here. # ======================================================================= # RBT.set_configuration( # ===================================================================== # # Load up the data from the directory. This requires the file called # 'configuration_directory.rb'. # ===================================================================== # RBT.configuration_directory? # <- This is a String such as "/Programs/Ruby/2.5.1/lib/ruby/site_ruby/2.5.0/rbt/yaml/configuration/" ) # ======================================================================= # # === enable_gobolinux_config # # Use a specific "template" when we are on a GoboLinux distribution. # # Do also note that in the more recent GoboLinux versions, say past # the year 2017, the directories have changed a bit. The following # code will ONLY honour the current versions, not the older legacy # GoboLinux versions. # ======================================================================= # if @configuration.respond_to?(:enable_gobolinux_config) and @configuration.enable_gobolinux_config RBT.set_system_directory('/System/') # === SYSTEM_DIR @system_index_directory = "#{SYSTEM_DIR}Index/" RBT.set_source_directory('/Files/Compile/Source/') # /Files/Compile/Archives/ RBT.set_programs_directory('/Programs/') # Hardcoded. RBT.set_temp_directory(SYSTEM_DIR+'Variable/tmp/') # CONFIG.temp_dir RBT.set_depot_directory('/Depot/') @system_links_directory = "#{SYSTEM_DIR}Links/" RBT.set_packages_directory("#{DEPOT_DIR}Packages/") # This is not a Gobolinux Directory, though. @pkgconfig_directory = "#{SYSTEM_LINKS_DIR}Libraries/pkgconfig/" RBT.set_sysbin_directory("#{SYSTEM_INDEX}bin/") RBT.set_syslib_directory("#{SYSTEM_INDEX}lib/") RBT.set_sysinclude_directory("#{SYSTEM_INDEX}include/") RBT.set_system_settings_directory("#{SYSTEM_DIR}Settings/") RBT.set_system_share_directory("#{SYSTEM_LINKS_DIR}Shared/") @system_libexec_directory = "#{SYSTEM_INDEX}libexec/" @system_environment_directory = "#{SYSTEM_LINKS_DIR}Environment/" @system_tasks_directory = "#{SYSTEM_LINKS_DIR}Tasks/" @system_logs_directory = "#{SYSTEM_DIR}Logs/" @system_kernel_directory = "#{SYSTEM_DIR}Kernel/" else # ================================================================== # # Else, we will set the default variables here via the CONFIG # object. Keep a trailing / here. # ===================================================================== # # Keep a reference to the TEMP Directory used by the RBT Scripts here. # We will extract archives into this directory (the temp directory). # Before we will assign to the constant, we first have to do some # sanitizing. # ===================================================================== # _ = rds( @configuration.temp_directory ) if _.include? '#' # Chop off in this case. _ = _[0, _.index('#')].strip _ << '/' unless _.end_with? '/' end # ===================================================================== # # _ may be "/Depot/Temp/rbt/". # ===================================================================== # RBT.set_temp_directory(_) # ===================================================================== # # Keep a reference to the Programs dir. # ===================================================================== # RBT.set_programs_directory(@configuration.programs_directory) # ===================================================================== # # === The source directory # ===================================================================== # RBT.set_source_directory(@configuration.source_directory) # Where to store all Source files. # ===================================================================== # # === The /System/ directory # ===================================================================== # RBT.set_system_directory(@configuration.system_directory) # '/System/' RBT.set_sysbin_directory(@configuration.sysbin_directory) # Standard sysbin directory. RBT.set_syslib_directory(@configuration.syslib_directory) # Standard syslib directory. RBT.set_sysinclude_directory(@configuration.sysinclude_dir) # Standard include directory. # SYSLIB_DIR+'/pkgconfig/' # including pkgconfig RBT.set_depot_directory(@configuration.depot_dir) @system_logs_directory = rds(@configuration.system_logs+'/') # SYSTEM_DIR+'Logs' # Where to keep our syslogs. RBT.set_log_directory # Default it to some value. # ===================================================================== # # === SYSTEM_SETTINGS_DIR # # Where to keep the /etc equivalent. # ===================================================================== # RBT.set_system_settings_directory(@configuration.system_settings_dir) # ===================================================================== # # === The Packages Dir # # On my system it is at /Depot/Packages. # ===================================================================== # RBT.set_packages_directory(@configuration.packages_directory) # ===================================================================== # # === MY_SYSSHARE # # Next, handle the SYSSHARE_DIR directory. # ===================================================================== # if ENV['MY_SYSSHARE'] RBT.set_system_share_directory(ENV['MY_SYSSHARE'].dup) else RBT.set_system_share_directory(@configuration.sysshare_directory) end # ===================================================================== # # === PKGCONFIG_DIR # # PKGCONFIG_DIR is hardcoded for now. # ===================================================================== # @pkgconfig_directory = rds(@configuration.pkgconfig_dir+'/') end end
#¶ ↑
RBT.install_libstdc_plus_plus
¶ ↑
The following code was taken/adapted from:
http://www.linuxfromscratch.org/lfs/view/stable/chapter05/gcc-libstdc++.html
#¶ ↑
# File lib/rbt/toplevel_methods/install_libstdc_plus_plus.rb, line 25 def self.install_libstdc_plus_plus( shall_we_extract_the_tarball = true, # <- We could skip it, too. use_this_gcc_version = '9.1.0', to = RBT.log_dir?, use_this_as_target_prefix = '/Programs/' ) what = "/Users/x/SRC/gcc/gcc-#{use_this_gcc_version}.tar.xz" if shall_we_extract_the_tarball Extracter.what_to(what, to) end cd("#{to}#{use_this_gcc_version}/") use_this_as_host = 'x86_64-linux-gnu' target_dir = 'BUILD_FOR_LIBSTDC++' mkdir target_dir cd target_dir use_this_full_prefix_target = use_this_as_target_prefix+'Libstdc++/'+use_this_gcc_version _ = '../libstdc++-v3/configure \ --host='+use_this_as_host+' \ --prefix='+use_this_full_prefix_target+' \ --disable-multilib \ --disable-nls \ --disable-libstdcxx-threads \ --disable-libstdcxx-pch \ --with-gxx-include-dir='+use_this_as_target_prefix+'Gcc/Current/include/c++/'+use_this_gcc_version esystem _ esystem 'make' esystem 'make install' RBT::ToCurrent.new(use_this_full_prefix_target) end
#¶ ↑
RBT.install_this_rubygem
¶ ↑
#¶ ↑
# File lib/rbt/compile/ruby.rb, line 231 def self.install_this_rubygem(i) compile_object = RBT::Compile.new(:do_not_run_yet) compile_object.determine_the_dataset_for_this_program(i) compile_object.set_program_path(compile_object.cookbook_dataset_program_path?) compile_object.install_this_ruby_gem(:default, :do_not_exit) end
#¶ ↑
RBT.is_an_alias?
¶ ↑
This method will return true if the input is an alias, and otherwise it will return false.
We will get rid of ':' in the input.
To test this method, do:
RBT.is_an_alias? 'htop' RBT.is_an_alias? 'blkid'
#¶ ↑
# File lib/rbt/aliases/aliases.rb, line 322 def self.is_an_alias?(i) RBT::Cookbooks::Aliases.new(i).is_an_alias? end
#¶ ↑
RBT.is_included?
¶ ↑
This method can be used to query whether a given input is included or whether it is not - that is, if the input may be a program that is registered in the RBT
project.
By default we will also include aliases, but this can be disabled, such as by using the Symbol :do_not_check_for_aliases.
Remember that all aliases in use are stored in a yaml file. If you want to add new aliases or change the existing ones, you may have to modify that yaml file.
In principle, we could also restrict this method here to only-aliases but I found that the API reads differently than this intent.
Usage examples:
RBT.is_included? 'abiword' # => true RBT.is_included? 'aclocal'
#¶ ↑
# File lib/rbt/toplevel_methods/is_included.rb, line 34 def self.is_included?( i, honour_aliases = true ) if i i = i.join(' ').strip if i.is_a? Array i.delete!(':') if i.include? ':' # We ignore ':' tokens. keys = available_programs? case honour_aliases when :default # Restore the default state in this case. honour_aliases = true when :do_not_honour_aliases, :do_not_check_for_aliases, :do_not_use_aliases, :ignore_aliases, :user_disabled_this_setting_via_the_commandline honour_aliases = false end if honour_aliases aliases = RBT::Cookbooks::Aliases.new(i) all_aliases = aliases.dataset # =================================================================== # # Merge the keys together next, starting with the default programs. # ==================================================================== # keys << all_aliases.keys end keys.flatten! return keys.include?(i) else false end end
#¶ ↑
RBT.is_this_a_real_gobolinux_system?
¶ ↑
This method queries whether we are on a real GoboLinux system. In order to determine this, we will ONLY check on local file-paths and possibly directory-paths,
#¶ ↑
# File lib/rbt/toplevel_methods/gobolinux.rb, line 18 def self.is_this_a_real_gobolinux_system? File.exist?('/System/Aliens') and File.exist?('/System/Kernel/Boot/System.map') and File.symlink?('/System/Kernel/Boot/System.map') end
#¶ ↑
RBT.is_this_program_included?
¶ ↑
This method can be used to determine whether the given input argument to this method is a registered program; aka whether this program is included as part of the RBT
project. A boolean will thus be returned, true indicating inclusion, and false indicating that the input is NOT a registered program.
Any input that is assumed to be a program, and included (thus returning true via this method), is additionally assumed to have an associated .yml dataset that describes how this program can be installed.
If the second argument is given, and is the Symbol :include_abbreviations or :with_abbreviations, or any similar symbol, then the abbreviations will also be considered.
Usage examples:
RBT.is_this_program_included? 'gawk' RBT.is_this_program_included? 'awk'
#¶ ↑
# File lib/rbt/toplevel_methods/available_programs.rb, line 323 def self.is_this_program_included?( this_program, optional_argument = nil # <- Can be :include_abbreviations ) result = RBT.determine_available_programs.include?(this_program) case optional_argument # when :do_not_check_for_aliases # ^^^ this should not check for aliases which is the default. # ======================================================================= # # === :include_abbreviations # ======================================================================= # when :include_abbreviations, :with_abbreviations, :with_aliases # ===================================================================== # # Keep a reference to the Hash that stores the aliases to the # available programs at hand. # ===================================================================== # abbreviations = RBT.hash_aliases_to_the_available_programs if abbreviations.has_key? this_program result = true end end result end
#¶ ↑
RBT.log_directory?
¶ ↑
Query method for the @log_directory variable. Prefer to use this method or any of its aliases rather than the constant called LOG_DIR.
On my home system this defaults to “/Depot/Temp/rbt/”.
#¶ ↑
# File lib/rbt/toplevel_methods/log_directory.rb, line 25 def self.log_directory? @log_directory end
#¶ ↑
RBT.meson_appdir_prefix
¶ ↑
#¶ ↑
# File lib/rbt/toplevel_methods/meson.rb, line 25 def self.meson_appdir_prefix( i = :use_cwd_as_input ) case i when :use_cwd_as_input i = return_pwd end i = File.basename(i) require 'program_information' this_program_name = ProgramInformation.return_name(i).delete('-_') this_program_version = ProgramInformation.return_version(i) use_this_build_directory = 'BUILD_DIRECTORY_FOR_MESON' use_this_prefix = programs_dir?+ this_program_name.capitalize+ '/'+ this_program_version+ '/' esystem 'meson --prefix='+use_this_prefix+' '+use_this_build_directory cd use_this_build_directory esystem 'ninja' esystem 'ninja install' e "If everything went fine then the program "\ "#{sfancy(this_program_name)} has been compiled" e "successfully into the prefix `#{sfancy(use_this_prefix)}`." end
#¶ ↑
RBT.meson_build_file_exists?
¶ ↑
When we check for the file called “meson.build”, we must also keep in mind that we may use a build directory. This is the reason why the following code uses a variable.
#¶ ↑
# File lib/rbt/toplevel_methods/does_this_file_exist.rb, line 19 def self.meson_build_file_exists?( check_for_this_file = 'meson.build', prepend_this_for_the_check = nil ) case check_for_this_file when :default check_for_this_file = 'meson.build' end does_this_file_exist?( check_for_this_file, prepend_this_for_the_check ) end
#¶ ↑
RBT.opn
(opn tag, opnn tag)¶ ↑
The argument to this method may be interpreted as a “namespace” to be used.
#¶ ↑
# File lib/rbt/toplevel_methods/opn.rb, line 61 def self.opn( i = NAMESPACE, &block ) if @use_opn if i.is_a? String i.delete!('.') if i.include? '.' i = { namespace: i } end # ======================================================================= # # Support a little bit of padding: # ======================================================================= # if i.is_a?(Hash) and RBT.n_padding_to_use_for_opn? i.update(padding: @n_padding_to_use_for_opn) end Opn.opn(i, &block) # The NAMESPACE constant is already a Hash. end end
#¶ ↑
RBT.permanently_disable_colours
¶ ↑
This method can be used to permanently disable the colours for the RBT
project. This essentially just saves into the file 'use_colours.yml'.
To invoke this method from the commandline, try this command:
rbt --permanently-disable-colours
#¶ ↑
# File lib/rbt/colours/permanently_disable_colours.rb, line 25 def self.permanently_disable_colours into = RBT.file_use_colours? what = YAML.dump(false) message_for_the_user = 'Permanently disabling the colours for the '\ 'RBT project.' opn; e message_for_the_user opn; e "(file: #{sfile(into)})" write_what_into(what, into) if is_on_roebe? into = "#{RUBY_SRC_DIR_AT_HOME}rbt/lib/rbt/yaml/configuration/"\ "#{File.basename(FILE_USE_COLOURS)}" opn; e message_for_the_user opn; e "(file: #{sfile(into)})" write_what_into(what, into) end end
#¶ ↑
RBT.permanently_set_source_directory
¶ ↑
Use this method if you wish to permanently modify the source directory, that is, the directory where our archives will be stored.
Invocation example from the commandline:
rbt --set_source_dir=/opt rbt --permanently-set-base-directory-to=/opt
#¶ ↑
# File lib/rbt/toplevel_methods/source_base_directory.rb, line 104 def self.permanently_set_source_directory(i) i = i.dup if i.frozen? i << '/' unless i.end_with? '/' unless i.start_with? '/' i.prepend('/') # We require leading '/'. end # ======================================================================= # # Modify the yaml file next: # ======================================================================= # what = i into = RBT.file_source_directory RBT.write_what_into(what, into) if block_given? yielded = yield case yielded when :be_verbose e "We will permanently set to a new source "\ "directory next (#{sdir(i)})" end end opn; e "Setting the new source directory to point towards `#{sdir(what)}`." opn; e "Storing into the file `#{sfile(into)}` next." # ======================================================================= # # And also modify it on my home system, if IS_ROEBE is true. This will # go right into the configuration/ subirectory. # ======================================================================= # if is_on_roebe? into = "#{RUBY_SRC_DIR_RBT}yaml/configuration/"\ "#{File.basename(into)}" opn; e "Will also store into the file `#{sfile(into)}`." RBT.write_what_into(what, into) end RBT.set_source_base_directory(i) # And also sync it back. unless File.directory? i opnn; e 'Since that directory does not exist, it will be created now.' mkdir(i) { :be_quiet } end end
#¶ ↑
RBT.permanently_set_temp_directory
¶ ↑
Use this method if you wish to permanently modify the temp directory, that is, the directory we will extract to (or to a subdirectory in that directory).
#¶ ↑
# File lib/rbt/toplevel_methods/temp_directory.rb, line 70 def self.permanently_set_temp_directory(i) case i when :pwd,'pwd', :default i = return_pwd.dup # Return the current working directory here. when :home_directory i = (ENV['HOME'].to_s+'/').squeeze('/') end # ======================================================================= # # Next, ensure trailing '/' character - unless the input includes # a '$' character. # ======================================================================= # unless i.include? '$' i << '/' unless i.end_with? '/' end opn; e "Setting the new temp directory to point towards `#{sdir(i)}`." # ======================================================================= # # Modify the yaml file next: # ======================================================================= # what = i into = RBT.file_temp_directory_yaml RBT.write_what_into(what, into) # ======================================================================= # # And also modify it on my home system, if IS_ROEBE is set to true. # ======================================================================= # if is_on_roebe? into = "#{RUBY_SRC_DIR_RBT_YAML_AT_HOME}configuration/"\ "#{File.basename(into)}" RBT.write_what_into(what, into) end RBT.set_temp_directory(i) # And also sync it. unless File.directory? i opnn; e 'Since that directory does not exist, it will be created now.' mkdir(i) { :be_quiet } end i # Also return the variable, so we can re-use it in other methods. end
#¶ ↑
RBT.project_base_directory?
¶ ↑
This method will yield to us the base directory of the RBT
project.
For example, it will return a String such as:
/Programs/Ruby/2.6.0/lib/ruby/site_ruby/2.6.0/rbt/
#¶ ↑
# File lib/rbt/project/project_base_and_yaml_directory.rb, line 40 def self.project_base_directory? RBT::PROJECT_BASE_DIRECTORY end
#¶ ↑
RBT.project_yaml_dir?
¶ ↑
This is a query-method for the constant PROJECT_YAML_DIRECTORY
.
#¶ ↑
# File lib/rbt/project/project_base_and_yaml_directory.rb, line 87 def self.project_yaml_dir? RBT::PROJECT_YAML_DIRECTORY end
#¶ ↑
RBT.publish_list_of_all_programs_version
¶ ↑
To invoke this method, do:
cookbooks --publish-list-of-all-programs-version
#¶ ↑
# File lib/rbt/toplevel_methods/ftp.rb, line 23 def self.publish_list_of_all_programs_version( file_programs_version = FILE_PROGRAMS_VERSION # This is the file 'programs_version.yml' ) _ = ''.dup opn; e 'The file '+sfile(file_programs_version)+' will next '\ 'be FTP-uploaded/published.' hash = YAML.load_file(file_programs_version) hash.each_pair {|name_of_the_program, program_version| _ << name_of_the_program.ljust(28)+program_version.to_s+N } what = _ into = RBT.store_into_this_directory+'programs_version.txt' opn; e 'Storing into `'+sfile(into)+'`.' RBT::SaveFile.write_what_into(what, into) RBT.upload_list_of_all_programs_version(into) # ========================================================================= # # Also upload a .html variant. # ========================================================================= # RBT.upload_list_of_all_programs_version(into, :html) end
#¶ ↑
RBT.query_binary_to_package
¶ ↑
The input argument should be the path to the directory that you wish to test. By default we will use '/usr/bin/' as a target here.
#¶ ↑
# File lib/rbt/utility_scripts/query_binary_to_package.rb, line 269 def self.query_binary_to_package(i = '/usr/bin/') RBT::QueryBinaryToPackage.new(i) end
#¶ ↑
RBT.query_header_to_package
¶ ↑
The input argument should be the path to the directory that you wish to test. By default we will use '/usr/include/' as a target here.
#¶ ↑
# File lib/rbt/utility_scripts/query_header_to_package.rb, line 265 def self.query_header_to_package(i = '/usr/include/') RBT::QueryHeaderToPackage.new(i) end
#¶ ↑
RBT.registered_binaries?
¶ ↑
Simply return an Array with all the binaries.
Full usage example:
require 'rbt/utility_scripts/registered_binaries.rb' RBT.registered_binaries?
#¶ ↑
# File lib/rbt/utility_scripts/registered_binaries.rb, line 188 def self.registered_binaries? ALL_BINARIES.keys.uniq.sort end
#¶ ↑
RBT.remove_archive_from_the_end
¶ ↑
This will remove the trailing archive type such as .tar.xz or .tar.gz and so forth.
#¶ ↑
# File lib/rbt/toplevel_methods/remove_archive_from_the_end.rb, line 15 def self.remove_archive_from_the_end(i) i = i.dup if i.frozen? if i.end_with? '.tar.gz' i.sub!(/\.tar\.gz$/,'') elsif i.end_with? '.tar.xz' i.sub!(/\.tar\.xz$/,'') elsif i.end_with? '.txz' i.sub!(/\.txz$/,'') elsif i.end_with? '.tar.bz2' i.sub!(/\.tar\.bz2$/,'') elsif i.end_with? '.tar' i.sub!(/\.tar$/,'') elsif i.end_with? '.jar' i.sub!(/\.jar$/,'') elsif i.end_with? '.phar' i.sub!(/\.phar$/,'') end return i end
#¶ ↑
RBT.remove_file
¶ ↑
Use this method to remove a file, but check if the file exists before actually deleting it. Additionally, also check for proper file permissions permissions as well.
#¶ ↑
# File lib/rbt/toplevel_methods/remove_file.rb, line 18 def self.remove_file( file, report_action = false ) file = file.dup if file.frozen? file.squeeze!('/') # We do not want double '/' entries. case report_action when :be_quiet report_action = false when :be_verbose report_action = true end can_we_delete_this_entry = false can_we_delete_this_entry = true if File.exist? file begin if File.ftype(file) == 'link' can_we_delete_this_entry = true end rescue Errno::ENOENT can_we_delete_this_entry = true # Failsafe. end # ======================================================================= # # We also have to handle symlinks, aka 'link', entries. These may no # longer exist, but we still will to delete such stray links, hence # why the above check has to be the way it is. # ======================================================================= # if can_we_delete_this_entry # ===================================================================== # # We need to check whether we can write to the file at hand. # ===================================================================== # base_directory = File.dirname(file) if File.writable? base_directory unless File.directory? file # Safeguard. if report_action e "Now removing the file `#{sfile(file)}`." end if File.exist? file File.delete(file) else if report_action e "No file exists at `#{sfile(file)}`." end end end else opnn(__FILE__) ewarn "Insufficient permission to remove file #{sfile(file)}" end else # Not sure if we should report this. if report_action opnn(__FILE__) ewarn "Trying to remove a file, but the file #{sfile(where)}" ewarn ' does not exist.' end end end
#¶ ↑
RBT.remove_file_extension
¶ ↑
This method will try to remove anything we declare to be an improper file extension.
The order is important here. That's why I start with download as gsub (via a call to the method .remove_crap_at_url_end()), to get rid of those pesky sourcefourge /download URLs.
File.basename() may be easier to handle altogether though.
#¶ ↑
# File lib/rbt/toplevel_methods/remove_file_extension.rb, line 21 def self.remove_file_extension(i) i = File.basename(i) i = i.sub(/\.bz2$/, ''). sub(/\.gz$/, ''). sub(/\.zip$/, ''). sub(/\.xz$/, ''). sub(/\.Z$/, ''). sub(/\.tar$/, ''). sub(/\.tgz$/, ''). sub(/\.gem$/, ''). sub(/\.yml$/, ''). sub(/\.js$/, ''). sub(/-trunk/, '').# <- Also remove weird things like that. sub(/-source/,'') # <- and also this. return i # Last but not least, always return it. end
#¶ ↑
RBT.remove_libtool_files_from
¶ ↑
Easier top-level API for removing libtool files from a certain directory (and subdirectories).
The input-argument should be a locally existing directory which should contain .la files.
#¶ ↑
# File lib/rbt/libtool/remove_libtool_files.rb, line 132 def self.remove_libtool_files_from( this_directory = '' ) RBT::Libtool::RemoveLibtoolFiles.new(this_directory) # <- Just delegate to the class. end
#¶ ↑
RBT.report_all_registered_programs_of_homebrew
¶ ↑
#¶ ↑
# File lib/rbt/homebrew/registered_programs_of_homebrew.rb, line 38 def self.report_all_registered_programs_of_homebrew these_entries = RBT.return_all_registered_programs_of_homebrew e 'The following entries were found:' index = 0 these_entries.each {|name_of_the_program, program_version| index += 1 padded_index = (index.to_s.rjust(4)).ljust(6) colourized_and_padded_index = RBT.dodgerblue(padded_index) e ' '+colourized_and_padded_index+ name_of_the_program.delete('-').ljust(40)+ program_version } end
#¶ ↑
RBT.report_extended_information_about_this_program
¶ ↑
(feedback tag, debug tag, main tag)
Use this feedback-method to report extended information about a program, in a colourful manner. This program must have been registered in the Cookbooks
namespace - otherwise we can not really display much about that program at hand.
The input to this method can be either be a String or an Array.
#¶ ↑
# File lib/rbt/toplevel_methods/report_extended_information_about_this_program.rb, line 48 def self.report_extended_information_about_this_program( i ) commandline_arguments = [] if i.is_a? Array commandline_arguments << i.select {|line| line.start_with? '--'} i = i.first end if i # ===================================================================== # # Delegate towards class RBT::Cookbooks::Cookbook next: # ===================================================================== # _ = RBT::Cookbooks::Cookbook.new(:do_not_run_yet) { :bypass_menu_check } unless commandline_arguments.flatten.compact.empty? _.menu( commandline_arguments.flatten.compact ) end _.find_this_program(i) _.report check_and_report_whether_file_exists( _.full_path?, _ ) end end
#¶ ↑
RBT.report_how_many_binaries_are_registered
¶ ↑
This method will report how many binaries are registered in total.
Example output from this method:
RBT: There are 3849 registered binaries in all cookbook files.
#¶ ↑
# File lib/rbt/toplevel_methods/report_how_many_binaries_are_registered.rb, line 24 def self.report_how_many_binaries_are_registered n_binaries = RBT.all_binaries.keys.uniq.size opn; e "There are #{sfancy(n_binaries.to_s)} registered binaries in "\ "all cookbook files." end
#¶ ↑
RBT.report_total_size_of_all_archives
¶ ↑
This method can be used to report the total size of all locally available archives.
Invocation example from the commandline:
rbt --report_total_size_of_all_archives
#¶ ↑
# File lib/rbt/toplevel_methods/report_total_size_of_all_archives.rb, line 23 def self.report_total_size_of_all_archives total_size = 0 available_programs = available_programs? available_programs.each {|this_program| possible_target = "#{RBT.directory_expanded_cookbooks?}#{this_program}.yml" if File.exist? possible_target dataset = YAML.load_file(possible_target) program_path = dataset['program_path'] else # =================================================================== # # The expanded-cookbooks file does not exist, so use # Cookbooks::Cookbook instead. # =================================================================== # require 'rbt/cookbooks/class/class.rb' program_path = RBT::Cookbooks::Cookbook.new(this_program) { :bypass_menu_check }.program_path? end if File.exist? program_path total_size += File.size(program_path) end } n_kilobytes = total_size / 1024.0 n_megabytes = n_kilobytes / 1024.0 n_gigabytes = n_megabytes / 1024.0 # ======================================================================= # # Finally, report it here. # ======================================================================= # e "The total file size of all #{sfancy(available_programs.size.to_s)}"\ " programs is #{total_size.to_s} bytes." e " (#{n_kilobytes.round(2)} KB; "+ n_megabytes.round(2).to_s+' MB; '+ crimson(n_gigabytes.round(2).to_s+' GB')+')' end
#¶ ↑
RBT.report_where_the_cookbook_directory_can_be_found
¶ ↑
This method will report where the cookbook directory can be found.
#¶ ↑
# File lib/rbt/toplevel_methods/cookbook_directory.rb, line 73 def self.report_where_the_cookbook_directory_can_be_found opn(namespace: RBT::NAMESPACE[:namespace]) e 'The cookbook directory can be found at this location:' e Colours.sfancy(" #{RBT.individual_cookbooks_directory?}") end
#¶ ↑
RBT.require_validation_scripts
¶ ↑
use this method to require the validation scripts.
#¶ ↑
# File lib/rbt/requires/require_validation_scripts.rb, line 18 def self.require_validation_scripts Dir["#{RBT.validation_directory}*.rb"].uniq.each {|file| require "rbt/validation/#{File.basename(file)}" } end
#¶ ↑
RBT.return_alias_program_name_for
¶ ↑
This method will return the (aliased) program name for the given input. If no alias name was found, it will return the input.
#¶ ↑
# File lib/rbt/aliases/aliases.rb, line 305 def self.return_alias_program_name_for(i) RBT::Cookbooks::Aliases.new(i).translate_alias end
#¶ ↑
RBT.return_all_abbreviations_of_this_array
¶ ↑
This method will calculate all abbreviations for a given program.
It will NOT include the self-name, e. g. to avoid redundant 'php' => 'php' entries.
For lib-entries, such as “libX11”, entries such as “X11” will also work in principle, but this conflicts with e. g. “x11perf”. So we have to keep this in mind.
To store these abbreviations from the commandline, do:
rbt --store
# ¶ ↑
# File lib/rbt/toplevel_methods/available_programs.rb, line 64 def self.return_all_abbreviations_of_this_array( i = determine_available_programs ) require 'yaml' require 'abbrev' # ======================================================================= # # The next constant refers to a location such as: # /Programs/Ruby/2.5.1/lib/ruby/site_ruby/2.5.0/rbt/yaml/abbrevations_to_the_programs.yml # ======================================================================= # if File.exist?(FILE_ABBREVIATIONS) and !File.empty?(FILE_ABBREVIATIONS) # ===================================================================== # # If the abbreviations exist, we will load this file. # ===================================================================== # result = YAML.load_file(FILE_ABBREVIATIONS) else # ===================================================================== # # Else we will have to re-create the file, or rather the content # of the file next. # ===================================================================== # result = {} # <- We will store into this Hash. # ===================================================================== # # Iterate over the registered programs next: # ===================================================================== # i.each {|entry| # =================================================================== # # Obtain all abbreviations for this specific entry. # =================================================================== # abbreviations = Abbrev.abbrev([entry]) # =================================================================== # # Next, if entry starts with 'lib', we will enable more aliases # to this. # =================================================================== # if entry.start_with? 'lib' suffix = entry[3 .. -1] more_abbreviations = {} loop { more_abbreviations[suffix] = entry suffix.chop! # Chop off the last character. break if suffix.size < 1 } more_abbreviations.update(abbreviations) abbreviations = more_abbreviations end # =================================================================== # # Now that the abbreviations have been entered, we will again # overwrite the result-hash with the core programs. # =================================================================== # abbreviations.reject! {|key, value| # ================================================================= # # Two conditions possible: # key == value means that this is a self-alias # or # it has already been defined # ================================================================= # (key == value) or i.include?(key) } result.update(abbreviations) } end if File.exist? FILE_COOKBOOK_ALIASES # ===================================================================== # # If the file "cookbook_aliases.yml" exists, use that file to merge # it into the above abbreviations-hash. # ===================================================================== # result.update( YAML.load_file(FILE_COOKBOOK_ALIASES) ) end # ======================================================================= # # Merge in the file "windows_cookbook.yml". # ======================================================================= # if File.exist?(FILE_WINDOWS_COOKBOOK) and File.exist?(FILE_TRY_TO_USE_THE_FILE_WINDOWS_COOKBOOK) and File.read(FILE_TRY_TO_USE_THE_FILE_WINDOWS_COOKBOOK).strip.start_with?("t") array = YAML.load_file(FILE_WINDOWS_COOKBOOK).keys array = Abbrev.abbrev(array) result.update(array) end result end
#¶ ↑
RBT.return_all_archives_from_this_directory
¶ ↑
This method will return all archives from a given directory.
#¶ ↑
# File lib/rbt/toplevel_methods/return_all_archives_from_this_directory.rb, line 17 def self.return_all_archives_from_this_directory(i) i = i.first if i.is_a? Array i = i.dup if i.frozen? if File.directory? i i << '/' unless i.end_with? '/' end potential_matches = [] ARRAY_REGISTERED_ARCHIVES.each {|file_format| potential_matches << Dir[i+'*'+file_format] } potential_matches.flatten.compact end
#¶ ↑
RBT.return_all_blfs_entries
¶ ↑
This method will (silently) return an Array with all entries that have a specific tag.
This currently uses grep.
The result will look like this:
["libpcap", "http://www.linuxfromscratch.org/blfs/view/svn/basicnet/libpcap.html"], ["xulrunner", "http://www.linuxfromscratch.org/blfs/view/7.5/x/xulrunner.html"],
#¶ ↑
# File lib/rbt/utility_scripts/blfs.rb, line 224 def self.return_all_blfs_entries cmd = 'grep -r "^ blfs" '+RBT.individual_cookbooks_directory? result = `#{cmd}`.split(N).map {|entry| entry.gsub!(/ blfs: /,' ') if entry.include? ':' splitted = entry.split ':' splitted[0] = File.basename(splitted[0]).sub(/\.yml$/,'') entry = splitted.join ':' end entry.split(': ') } return result end
#¶ ↑
RBT.return_all_registered_programs_of_homebrew
¶ ↑
#¶ ↑
# File lib/rbt/homebrew/registered_programs_of_homebrew.rb, line 24 def self.return_all_registered_programs_of_homebrew require 'rbt/check_for_updates/base.rb' _ = RBT::Cookbooks::CheckForRemoteWebpages.new _.obtain_dataset_from_the_remote_webpage(REMOTE_URL_TO_THE_HOMEBREW_FORMULAS) result = _.dataset? use_this_regex = # See: http://rubular.com/r/ASTY2a3ukx /<tr><td><a href="\/formula\/(.+)">.+\s*.+\s*.+\s*<td>(\d{0,2}\.\d{0,2}\.\d{0,2})<\/td>/ scanned = result.scan(use_this_regex) scanned end
#¶ ↑
RBT.return_archive_type
¶ ↑
This method will feedback the archive type in use, for the given input at gabd.
It is used in class RBT::UpdateEntry
.
The default will be, as you can see from the default argument, .tar.xz. Note that this assumption is not always correct, e. g. if you do not repackage.
Note that the simple archives, such as .gem or .zip, could be detected automatically, but entries such as .tar.gz are harder detect, hence why we will use a hardcoded case menu here.
#¶ ↑
# File lib/rbt/toplevel_methods/archive_type.rb, line 39 def self.return_archive_type( i = '.tar.xz' ) if i.is_a? Array i = i.first end if i.end_with? '.tar.xz' '.tar.xz' elsif i.end_with? '.xz' '.tar.xz' elsif i.end_with? '.tar.gz' '.tar.gz' elsif i.end_with? '.tar.bz2' '.tar.bz2' elsif i.end_with? '.tar.lz' '.tar.lz' elsif i.end_with? '.gem' '.gem' elsif i.end_with? '.zip' '.zip' elsif i.end_with? '.jar' '.jar' elsif i.end_with? '.phar' '.phar' else # else try to make an "educated guess" - via File.extname(). # ===================================================================== # # But this can also return faulty results. For example, if the input # is "27.01.2019" then it does not make any sense to return ".2019" as # an archive type, since that is not an archive type. This is the # reason why specifically numbers are excluded in the following # check. # ===================================================================== # extname = File.extname(i) if extname.delete('.') =~ /^\d+$/ # If only numbers. extname = ''.dup end extname end end
#¶ ↑
RBT.return_array_of_programs_without_a_blfs_entry
¶ ↑
This method will return an Array that keeps track of all local cookbook files without a BLSF entry.
This functionality can then be used to output this Array on the commandline
#¶ ↑
# File lib/rbt/toplevel_methods/return_array_of_programs_without_a_blfs_entry.rb, line 20 def self.return_array_of_programs_without_a_blfs_entry array_of_programs_without_a_blfs_entry = [] # ======================================================================= # # First, obtain all available programs. # ======================================================================= # all_available_programs = RBT.available_programs? all_available_programs.each {|this_program| location = individual_cookbooks_directory?+this_program+'.yml' dataset = File.read(location) unless dataset =~ /^ blfs:/ array_of_programs_without_a_blfs_entry << this_program end } return array_of_programs_without_a_blfs_entry end
#¶ ↑
RBT.return_array_of_this_tag
¶ ↑
This method will return an Array of programs that qualify for a given tag.
The input argument to this method should be the name of the tag that is being sought, such as 'php' or 'kde5'.
Usage example:
RBT.return_array_of_this_tag 'php' # => ["drupal", "eaccelerator"] RBT.return_array_of_this_tag 'kde5'
#¶ ↑
# File lib/rbt/utility_scripts/search_for_tags/search_for_tags.rb, line 545 def self.return_array_of_this_tag(i) RBT::Cookbooks::SearchForTags.new(i.to_s) { :be_quiet }.array_of_programs.sort end
#¶ ↑
RBT.return_base_directory_of_this_program
¶ ↑
This method will return the base-directory for a given program, such as “/Users/x/SRC/htop/” for the program htop.
A String is returned from this method.
#¶ ↑
# File lib/rbt/toplevel_methods/return_base_directory_of_this_program.rb, line 19 def self.return_base_directory_of_this_program(i) i = i.first if i.is_a? Array _ = RBT::Cookbooks::Cookbook.new(i) { :bypass_menu_check } _.base_dir? end
#¶ ↑
RBT.return_binaries_of_this_program
¶ ↑
This method will return the binaries of a given program at hand.
An Array will be returned which may look like this, for the program called “ruby”:
["erb", "gem", "irb", "rake", "ri", "rdoc", "ruby"]
#¶ ↑
# File lib/rbt/toplevel_methods/return_binaries_of_this_program.rb, line 20 def self.return_binaries_of_this_program(i) i = i.first if i.is_a? Array RBT::Cookbooks::Cookbook.new(i) { :bypass_menu_check }.binaries? end
#¶ ↑
RBT.return_blfs_page_of_this_program
¶ ↑
This method will either return a String or nil.
If a String is returned then we will assume that this is to the remote BLFS page entry of a (locally registered) program.
This method will return the BLfS page of a program, or nil if it was not registered.
Returns:
- either a string - or nil
Invocation example:
result = RBT.return_blfs_page_of_this_program('gcc')
#¶ ↑
# File lib/rbt/toplevel_methods/return_blfs_page_of_this_program.rb, line 34 def self.return_blfs_page_of_this_program( this_program = 'gcc' ) this_program = this_program.first if this_program.is_a? Array _ = RBT::Blfs.new(this_program) { :be_quiet_and_do_not_tamper_with_the_xorg_buffer } result = _.remote_url? result = result.first if result.is_a? Array return result end
#¶ ↑
RBT.return_configuration_options_for?
¶ ↑
We delegate towards class RBT::Cookbooks::Cookbook
here.
Usage example:
php_options = RBT.return_configuration_options_for? 'php'
#¶ ↑
# File lib/rbt/utility_scripts/show_configuration_options.rb, line 416 def self.return_configuration_options_for?(this_program) RBT::Cookbooks::Cookbook.new(this_program).configuration_options? end
#¶ ↑
RBT.return_games_components
¶ ↑
Return, as Array, all registered games that are part of the RBT
project.
Several aliases are available for this - see the aliases defined below the method here.
#¶ ↑
# File lib/rbt/toplevel_methods/games.rb, line 24 def self.return_games_components result = RBT.return_chained_programs['games'] if result.is_a? String result = result.split(',') end result.map!(&:strip) return result.sort end
#¶ ↑
RBT.return_location_to_this_programs_yaml_file
¶ ↑
Easier access-method to determine where the yaml file may be.
Invocation example:
RBT.return_location_to_this_programs_yaml_file 'ruby'
#¶ ↑
# File lib/rbt/toplevel_methods/return_location_to_this_programs_yaml_file.rb, line 21 def self.return_location_to_this_programs_yaml_file(i) i = i.to_s unless i.is_a? String unless i.end_with? '.yml' i = i.dup if i.frozen? i << '.yml' end result = "#{individual_cookbooks_directory?}#{i}".dup if is_on_roebe? # ===================================================================== # # Hardcoded on my own system. # ===================================================================== # possible_target = "#{DIRECTORY_INDIVIDUAL_COOKBOOKS_AT_ROEBE_HOME}#{i}".dup if File.exist? possible_target result = possible_target end end return result end
#¶ ↑
RBT.return_mate_desktop_version_string
¶ ↑
This method will return the String that contains the information which mate-desktop components are available. That way we can then embed this String in other programs.
#¶ ↑
# File lib/rbt/utility_scripts/report_mate_desktop_version.rb, line 490 def self.return_mate_desktop_version_string RBT::ReportMateDesktopVersion.new { :do_not_report_anything }.string? end
#¶ ↑
RBT.return_programs_from_this_url
¶ ↑
The task of this method is to return an Array of programs that can be found on a remote URL. If we take the example below for KDE's plasma related code, then the Array that will be returned will include the names of all the programs that can be found at that particular remote URL.
This then allows us to do various further checks, such as whether the RBT
project is tracking all these programs or not, and so forth.
The first input argument to this method is assumed to be a remote URL, as a String - so only pass an URL to the method here.
Specific invocation example in ruby:
pp RBT.return_program_from_this_url('https://download.kde.org/stable/plasma/5.10.5/'); ''
#¶ ↑
# File lib/rbt/toplevel_methods/return_programs_from_this_url.rb, line 32 def self.return_programs_from_this_url(i) begin require 'program_information' unless Object.const_defined? :ProgramInformation rescue LoadError; end i = i.first if i.is_a? Array regex_to_use = /<tr><td valign="top"> <\/td><td><a href="(.+?)">/ # See: http://rubular.com/r/fIcvzXfPi1 dataset = open(i).read scanned = dataset.scan(regex_to_use).flatten scanned.reject! {|entry| entry.end_with? '.sig' or entry.start_with? '/' } scanned.map! {|entry| entry.sub!(/\.xz$/,'') entry.sub!(/\.tar$/,'') program_name = ProgramInformation.return_program_name(entry) program_name } scanned.uniq! return scanned.sort end
#¶ ↑
RBT.return_programs_that_are_exlusively_registered_in_the_homebrew_programs
¶ ↑
Usage example:
x = RBT.return_programs_that_are_exlusively_registered_in_the_homebrew_programs
#¶ ↑
# File lib/rbt/homebrew/registered_programs_of_homebrew.rb, line 57 def self.return_programs_that_are_exlusively_registered_in_the_homebrew_programs require 'rbt/toplevel_methods/available_programs.rb' available_programs = RBT.available_programs? remote_registered_programs = RBT.return_all_registered_programs_of_homebrew.map {|a,b| a.delete('-_') } remote_registered_programs.reject! {|entry| available_programs.include? entry } remote_registered_programs end
#¶ ↑
RBT.return_remote_url_from_this_input
¶ ↑
Give the below input, this method should return a String like:
http://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.xz
#¶ ↑
# File lib/rbt/toplevel_methods/misc.rb, line 29 def self.return_remote_url_from_this_input( remote_url = 'http://ftp.gnu.org/gnu/glibc/glibc-2.29.tar.xz', version = '2.28' ) require 'program_information' program_version = ProgramInformation.return_version(remote_url) result = remote_url.sub( program_version, version ) result end
#¶ ↑
RBT.return_version_of_this_program
¶ ↑
Usage example:
RBT.return_version_of_this_program 'htop'
#¶ ↑
# File lib/rbt/toplevel_methods/return_version_of_this_program.rb, line 17 def self.return_version_of_this_program(i = 'htop') if i.is_a? Array i = i.first end i = i.to_s # We have to work on Strings. if RBT::Cookbooks::Cookbook.does_include? i dataset = RBT::Cookbooks::Cookbook.new(i) { :bypass_menu } return dataset.program_version? else nil end end
#¶ ↑
RBT.returned_chained_programs_of_the_mate_desktop
¶ ↑
This will return the mate-desktop entry, in a sanitized manner, in Array form.
#¶ ↑
# File lib/rbt/constants/chained_programs.rb, line 67 def self.returned_chained_programs_of_the_mate_desktop result = return_chained_programs['all_of_the_mate_desktop'] if result.is_a? String result = result.delete("\n").delete(' ') # ===================================================================== # # Turn it into an Array next. # ===================================================================== # result = result.split(',').flatten end return result end
#¶ ↑
RBT.run_makepkg_command
¶ ↑
This method will invoke the slackware “makepkg” command, in order to create a slackware package.
By default, this method will work from the current working directory, so it is recommended to have already extracted the target archive in question.
#¶ ↑
# File lib/rbt/toplevel_methods/run_makepkg_command.rb, line 22 def self.run_makepkg_command( i = :from_the_current_working_directory, optional_program_version = nil, use_this_architecture = RBT.determine_host_architecture # <= "x86_64" ) # ======================================================================= # # Determine which makepkg command variant to use next. # ======================================================================= # use_this_makepkg_command = 'makepkg --chown n --linkadd y' case i when :from_the_current_working_directory, :default # This is the default. _ = File.basename(Dir.pwd) name_of_the_package, the_program_version = _.split('-') else # else depend on TWO input arguments: (a) name and (b) version. name_of_the_package = i the_program_version = optional_program_version end # ======================================================================= # # === Host Architecture # # The host architecture is currently "x86_64". This may change at # a later time, though; at the least it may be more flexible. # ======================================================================= # full_name_of_the_package = "#{name_of_the_package}-"\ "#{the_program_version}-"\ "#{use_this_architecture}"\ "-1.tgz" _ = use_this_makepkg_command+' ../'+full_name_of_the_package esystem(_) path_to_the_package = File.expand_path('../'+full_name_of_the_package) return path_to_the_package end
#¶ ↑
RBT.set_array_these_ruby_gems_were_updated
¶ ↑
Setter method to modify the top-level instance variable called @array_these_ruby_gems_were_updated.
#¶ ↑
# File lib/rbt/toplevel_methods/update_all_ruby_gems.rb, line 31 def self.set_array_these_ruby_gems_were_updated(i) @array_these_ruby_gems_were_updated = i end
#¶ ↑
RBT.set_configuration
¶ ↑
This method will automatically invoke class RBT::Configuration::SimpleConfigurationLoader
.
It has to be manually called to some meaningful value in other code parts.
#¶ ↑
# File lib/rbt/configuration/configuration_instance_variable.rb, line 49 def self.set_configuration( i = RBT::Configuration::SimpleConfigurationLoader.new ) if i.is_a? String i = RBT::Configuration::SimpleConfigurationLoader.new(i) end @configuration = i end
#¶ ↑
RBT.set_cookbook_directory
¶ ↑
This setter-method can be used to determine whether the individual cookbooks are to be found normally.
#¶ ↑
# File lib/rbt/toplevel_methods/cookbook_directory.rb, line 43 def self.set_cookbook_directory(i) if i # <- Assignment is only done if the user supplies a valid argument. unless i.end_with? '/' i = i.dup if i.frozen? i << '/' end @cookbook_directory = i end end
#¶ ↑
RBT.set_depot_directory
¶ ↑
#¶ ↑
# File lib/rbt/toplevel_methods/depot_directory.rb, line 19 def self.set_depot_directory( i = '/Depot/' ) i = i.dup if i.frozen? i = convert_global_env(i) if i.include? '$' # ======================================================================= # # If there is still at the least one '$' entry then this variable does # not exist. In this case, use a hardcoded entry instead. # ======================================================================= # i = '/Depot/' if i.include? '$' # <- See above for the explanation. i << '/' unless i.end_with? '/' i = i.dup if i.frozen? # <- Need to do so again, e. g. in a .cgi environment context. i.squeeze!('/') @depot_directory = i end
#¶ ↑
RBT.set_log_directory
¶ ↑
This defaults to “/Depot/Temp/rbt/” on my system.
#¶ ↑
# File lib/rbt/toplevel_methods/log_directory.rb, line 42 def self.set_log_directory( i = "#{RBT.temp_directory}rbt/" ) i = i.dup if i.frozen? i = convert_global_env(i) if i.include? '$' i << '/' unless i.end_with? '/' # ======================================================================= # # Next, we must ensure that the required directories exist. # ======================================================================= # i = i.dup if i.frozen? # <- Need to do so again, e. g. in a .cgi environment context. # ======================================================================= # # In the past we did ensure that the required directories exist, # whenever RBT.set_log_directory() is called. But this does not # make that much sense, and can lead to other problems, so it # was disabled here at 24.01.2019. Do note that the functionality # of ensuring that the required directories exist will still be # handled by RBT, but in other code parts instead. # ======================================================================= # # require 'rbt/toplevel_methods/ensure_that_the_required_directories_exist.rb' # ^^^ this used to be on top # ======================================================================= # # ensure_that_the_required_directories_exist( # i # ) @log_directory = i end
#¶ ↑
RBT.set_packages_directory
¶ ↑
#¶ ↑
# File lib/rbt/toplevel_methods/packages_directory.rb, line 19 def self.set_packages_directory( i = '/Depot/Packages/' ) i = i.dup if i.frozen? i = convert_global_env(i) if i.include? '$' # ======================================================================= # # If there is still at the least one '$' entry then this variable does # not exist. In this case, use a hardcoded entry instead. # ======================================================================= # i = '/Depot/Packages/' if i.include? '$' # <- See above for the explanation. i << '/' unless i.end_with? '/' i = i.dup if i.frozen? # <- Need to do so again, e. g. in a .cgi environment context. i.squeeze!('/') @packages_directory = i end
#¶ ↑
RBT.set_pkgconfig_directory
¶ ↑
#¶ ↑
# File lib/rbt/toplevel_methods/pkgconfig_directory.rb, line 19 def self.set_pkgconfig_directory( i = '/usr/lib/pkgconfig/' ) i = i.dup if i.frozen? i = convert_global_env(i) if i.include? '$' # ======================================================================= # # If there is still at the least one '$' entry then this variable does # not exist. In this case, use a hardcoded entry instead. # ======================================================================= # i = '/usr/lib/pkgconfig/' if i.include? '$' # <- See above for the explanation. i << '/' unless i.end_with? '/' i = i.dup if i.frozen? # <- Need to do so again, e. g. in a .cgi environment context. i.squeeze!('/') @pkgconfig_directory = i end
#¶ ↑
RBT.set_programs_directory
¶ ↑
#¶ ↑
# File lib/rbt/toplevel_methods/programs_directory.rb, line 19 def self.set_programs_directory( i = '/Programs/' # This is hardcoded default, but can be changed by the user through later calls. ) i = i.dup if i.frozen? # ======================================================================= # # Replace all $ with proper env-variables if they are included. # ======================================================================= # i = convert_global_env(i) if i.include? '$' # ======================================================================= # # If there is still at the least one '$' entry then this variable does # not exist. In this case, use a hardcoded entry instead. It is up to # the user to resolve this problem. # ======================================================================= # i = '/Programs/' if i.include? '$' # <- See above for the explanation. i = i.dup if i.frozen? # <- Need to do so again, e. g. in a .cgi environment context. i << '/' unless i.end_with? '/' i.squeeze!('/') @programs_directory = i end
#¶ ↑
RBT.set_source_base_directory
¶ ↑
Note that the environment variable called RBT_SOURCE_DIRECTORY can be used to use another default value.
#¶ ↑
# File lib/rbt/toplevel_methods/source_base_directory.rb, line 52 def self.set_source_base_directory( i = :default_but_consider_environment_variables # <- Preferred default. ) case i # ======================================================================= # # === :default_but_consider_environment_variables # ======================================================================= # when :default_but_consider_environment_variables # ===================================================================== # # Handle the environment-variable RBT_SOURCE_DIRECTORY first, as # it has a higher priority in this case. # ===================================================================== # if ENV.has_key? 'RBT_SOURCE_DIRECTORY' i = ENV['RBT_SOURCE_DIRECTORY'].to_s.dup else # =================================================================== # # else the user does not have this ENV-variable, so we use the # "regular" default. # =================================================================== # i = @source_base_directory end # ======================================================================= # # This is for the "regular" default. This one will always assign. # ======================================================================= # when :default, nil, '' i = @source_base_directory end i = i.dup if i.frozen? i = RBT.convert_global_env(i) if i.include? '$' i = @source_base_directory if i.include? '$' # <- Overrule missing environment variables. i << '/' unless i.end_with? '/' @source_base_directory = i end
#¶ ↑
RBT.set_sysbin_directory
¶ ↑
#¶ ↑
# File lib/rbt/toplevel_methods/sysbin_directory.rb, line 19 def self.set_sysbin_directory( i = '/System/Index/bin/' ) i = i.dup if i.frozen? i = convert_global_env(i) if i.include? '$' # ======================================================================= # # If there is still at the least one '$' entry then this variable does # not exist. In this case, use a hardcoded entry instead. # ======================================================================= # i = '/System/Index/bin/' if i.include? '$' # <- See above for the explanation. i << '/' unless i.end_with? '/' i = i.dup if i.frozen? # <- Need to do so again, e. g. in a .cgi environment context. i.squeeze!('/') @sysbin_directory = i end
#¶ ↑
RBT.set_sysetc_directory
¶ ↑
#¶ ↑
# File lib/rbt/toplevel_methods/sysetc_directory.rb, line 19 def self.set_sysetc_directory( i = '/System/Index/etc/' ) i = i.dup if i.frozen? i = convert_global_env(i) if i.include? '$' # ======================================================================= # # If there is still at the least one '$' entry then this variable does # not exist. In this case, use a hardcoded entry instead. # ======================================================================= # i = '/System/Index/etc/' if i.include? '$' # <- See above for the explanation. i << '/' unless i.end_with? '/' i = i.dup if i.frozen? # <- Need to do so again, e. g. in a .cgi environment context. i.squeeze!('/') @sysetc_directory = i end
#¶ ↑
RBT.set_sysinclude_directory
¶ ↑
#¶ ↑
# File lib/rbt/toplevel_methods/sysinclude_directory.rb, line 19 def self.set_sysinclude_directory( i = '/System/Index/include/' ) i = i.dup if i.frozen? i = convert_global_env(i) if i.include? '$' # ======================================================================= # # If there is still at the least one '$' entry then this variable does # not exist. In this case, use a hardcoded entry instead. # ======================================================================= # i = '/System/Index/include/' if i.include? '$' # <- See above for the explanation. i = i.dup if i.frozen? # <- Need to do so again, e. g. in a .cgi environment context. i << '/' unless i.end_with? '/' i.squeeze!('/') @sysinclude_directory = i end
#¶ ↑
RBT.set_syslib_directory
¶ ↑
#¶ ↑
# File lib/rbt/toplevel_methods/syslib_directory.rb, line 19 def self.set_syslib_directory( i = '/System/Index/lib/' ) i = i.dup if i.frozen? i = convert_global_env(i) if i.include? '$' # ======================================================================= # # If there is still at the least one '$' entry then this variable does # not exist. In this case, use a hardcoded entry instead. # ======================================================================= # i = '/System/Index/lib/' if i.include? '$' # <- See above for the explanation. i << '/' unless i.end_with? '/' i = i.dup if i.frozen? # <- Need to do so again, e. g. in a .cgi environment context. i.squeeze!('/') @syslib_directory = i end
#¶ ↑
RBT.set_system_directory
¶ ↑
#¶ ↑
# File lib/rbt/toplevel_methods/system_directory.rb, line 19 def self.set_system_directory( i = '/System/' ) i = i.dup if i.frozen? i = convert_global_env(i) if i.include? '$' # ======================================================================= # # If there is still at the least one '$' entry then this variable does # not exist. In this case, use a hardcoded entry instead. # ======================================================================= # i = '/System/' if i.include? '$' # <- See above for the explanation. i << '/' unless i.end_with? '/' i = i.dup if i.frozen? # <- Need to do so again, e. g. in a .cgi environment context. i.squeeze!('/') @system_directory = i end
#¶ ↑
RBT.set_system_settings_directory
¶ ↑
#¶ ↑
# File lib/rbt/toplevel_methods/system_settings_directory.rb, line 19 def self.set_system_settings_directory( i = '/System/Settings/' ) i = i.dup if i.frozen? i = convert_global_env(i) if i.include? '$' # ======================================================================= # # If there is still at the least one '$' entry then this variable does # not exist. In this case, use a hardcoded entry instead. # ======================================================================= # i = '/System/Settings/' if i.include? '$' # <- See above for the explanation. i << '/' unless i.end_with? '/' i = i.dup if i.frozen? # <- Need to do so again, e. g. in a .cgi environment context. i.squeeze!('/') @system_settings_directory = i end
#¶ ↑
RBT.set_temp_directory
¶ ↑
#¶ ↑
# File lib/rbt/toplevel_methods/temp_directory.rb, line 49 def self.set_temp_directory( i = '/tmp/' ) i = convert_global_env(i) if i.include? '$' if i.include? '$' i = '/tmp/' # Use a default value in this case. end unless i.end_with? '/' # We must ensure that the last charcter is always a '/'. i = i.dup if i.frozen? i << '/' end @temp_directory = i end
#¶ ↑
RBT.set_yaml_engine
¶ ↑
This method will assign (and thus keep track of) the yaml engine that the RBT
project will use. Since some time this is standard psych; in the past it used to be syck.
#¶ ↑
# File lib/rbt/requires/require_yaml.rb, line 22 def self.set_yaml_engine(i) case i # case tag when :psych, :default # <- psych is the default since some time. # ===================================================================== # # pass through because psych is the default yaml engine that will # work without modification. # ===================================================================== # when :syck begin require 'syck' rescue LoadError; end begin YAML::ENGINE.yamler = 'syck' rescue NameError; end end @yaml_engine = i end
#¶ ↑
RBT.show_available_utility_scripts
¶ ↑
Simply show all available utility scripts.
Invocation example from the commandline:
cookbooks --show-available-scripts
#¶ ↑
# File lib/rbt/toplevel_methods/show_available_utility_scripts.rb, line 21 def self.show_available_utility_scripts files = Dir["#{utility_scripts?}*.rb"].sort.map {|file| File.basename(file) } files = files - ['utility_scripts.rb'] e; files.each_with_index {|file, index| index += 1 e sfancy(index.to_s.rjust(4))+') '+simp(file) }; e end
#¶ ↑
RBT.show_last_configure_option
¶ ↑
#¶ ↑
# File lib/rbt/toplevel_methods/show_last_configure_option.rb, line 16 def self.show_last_configure_option _ = RBT.store_the_last_configuration_options_in_this_file if File.exist? _ # The next two lines are mostly for debug-related output. # require 'rbt/colours/sfile.rb' # e 'Obtaining the information from the file `'+sfile(_)+'`.' e File.read(_) else e "No configure options have been stored yet "\ "(File checked: #{_})." end end
#¶ ↑
RBT.show_overview_over_available_utility_scripts
¶ ↑
This method will show all available utility scripts and provide an overview over them.
To trigger this method, do:
cookbooks OVERVIEW cookbooks --show-available-utility-scripts
#¶ ↑
# File lib/rbt/constants/utility_scripts.rb, line 43 def self.show_overview_over_available_utility_scripts target = "#{utility_scripts?}*.rb" available_files = Dir[target] if Object.const_defined? :ClassDocuShower available_files.each {|file| cliner ClassDocuShower[file] # Delegate towards ClassDocuShower here. } else opn(namespace: RBT::NAMESPACE[:namespace]) e 'The class ClassDocuShower is not available.' e opn(namespace: RBT::NAMESPACE[:namespace]) e 'It can be installed via:' e opn(namespace: RBT::NAMESPACE[:namespace]) e ' gem install class_docu_shower' e end end
#¶ ↑
RBT.show_registered_binaries
¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/registered_binaries.rb, line 205 def self.show_registered_binaries _ = ::RBT.registered_binaries? RegisteredBinaries.opnn; e 'These '+_.size.to_s+' binaries are registered:' e _.reject {|entry| entry.to_s.empty? }.join(', ').strip.chop end
#¶ ↑
RBT.show_tutorial
¶ ↑
This will show a tutorial to the user, instructing them how to use the Cookbooks
project.
Usage example:
cookbooks --tutorial
#¶ ↑
# File lib/rbt/cookbooks/class/tutorial.rb, line 18 def self.show_tutorial( try_to_use_colours = true ) require 'io/console' display_this_message = "\n[Press any key to continue; q to exit early]" # ========================================================================= # # The file for the short tutorial can be seen in # "tutorial/short_tutorial.md". # ========================================================================= # _ = RBT.file_short_tutorial? if File.exist? _ dataset = File.readlines(_) # Display the file next. chunks = dataset.each_slice(20).to_a counter = 0 e # And a newline to start with. loop { content_that_will_be_displayed = chunks[counter] if try_to_use_colours content_that_will_be_displayed.map! {|line| # ================================================================= # # Next colourize anything that is indented with 4 leading spaces. # ================================================================= # line.gsub(/^( .+)$/, lightgreen('\1')) } end e content_that_will_be_displayed # ===================================================================== # # Next, display the "press any key to continue" message. # ===================================================================== # if try_to_use_colours display_this_message = mediumseagreen(display_this_message) end e display_this_message case STDIN.getch when 'q' exit else counter += 1 exit if counter >= chunks.size end } end end
#¶ ↑
RBT.source_base_directory?
¶ ↑
This is a simple query-method for the source directory in use (called “source base directory”).
The default value to it is “/Users/x/SRC/” on my system - which may be different on other computers, which is why this has to be settable and modifiable by the user via the setter method called RBT.set_source_base_directory()
.
#¶ ↑
# File lib/rbt/toplevel_methods/source_base_directory.rb, line 40 def self.source_base_directory? @source_base_directory end
#¶ ↑
RBT.stderr
¶ ↑
By default, “puts” in ruby writes to STDOUT. We can use STDERR.puts to send to the error-stream specifically.
The best practice is to log debugging information, errors, warnings, status and so forth to STDERR; actual program output should go towards STDOUT.
#¶ ↑
# File lib/rbt/toplevel_methods/stderr.rb, line 21 def self.stderr( i = '', use_puts_or_print = :puts ) if i.is_a? Array i = i.join end case use_puts_or_print when :puts $stderr.puts i when :print, :use_print $stderr.print i else e 'Unknown input at line 32 in the method RBT.stderr()' end end
#¶ ↑
RBT.store_abbreviations
¶ ↑
This method will store the abbreviations to the programs in a file.
To invoke this method on the commandline do:
rbt --generate-abbreviations
#¶ ↑
# File lib/rbt/toplevel_methods/available_programs.rb, line 285 def self.store_abbreviations what = return_all_abbreviations_of_this_array what = YAML.dump(what) into = FILE_ABBREVIATIONS e "Storing into the file `#{::Colours.sfile(into)}`." RBT.write_what_into(what, into) if is_on_roebe? # ===================================================================== # # Also store this in my home directory, the respective yaml # directory. # ===================================================================== # into = RUBY_SRC_DIR_RBT_YAML+File.basename(into) e "Also storing into the file `#{::Colours.sfile(into)}`." RBT.write_what_into(what, into) end end
#¶ ↑
RBT.store_the_last_configuration_options_in_this_file
¶ ↑
You can also use this alias-method for invoking the method:
RBT.store_the_last_configuration_options_into_which_file? # => "/Depot/Temp/rbt/last_configure_options_used.md"
#¶ ↑
# File lib/rbt/toplevel_methods/log_directory.rb, line 79 def self.store_the_last_configuration_options_in_this_file "#{RBT.store_into_this_directory?}"\ "last_configure_options_used_through_class_show_configuration_options.md" end
#¶ ↑
RBT.swift_return_version_of_this_program
¶ ↑
This method here is different from RBT.return_version_of_this_program()
Rather than instantiate a new RBT::Cookbooks::Cookbook
object, we just query the version from a yaml file directly. This is obviously much faster.
The obvious drawback is that we may have to manually update that yaml file and keep it up-to-date - but the advantage by far outweights this disadvantage. This method here will be much faster than Cookbooks.return_version_of_this_program() - and ideally, you should use it, rather than the other method.
If the program in question can not be found, this method will return nil.
Invocation examples:
RBT.swift_return_version_of_this_program(:ruby) # => "2.3.1" RBT.swift_return_version_of_this_program(:htop) # => "2.0.2" RBT.swift_return_version_of_this_program(:awk) # => "2.0.2"
#¶ ↑
# File lib/rbt/toplevel_methods/swift_return_version_of_this_program.rb, line 37 def self.swift_return_version_of_this_program( this_program = :htop ) this_program = this_program.to_s # ======================================================================= # # Next, try to pass it against a list of aliases, if it has not # been yet "findable". # ======================================================================= # if !RBT.does_include?(this_program, :ignore_aliases) possible_alternative_name = RBT.find_cookbook_alias_for(this_program) if possible_alternative_name if possible_alternative_name != this_program this_program = possible_alternative_name end end end _ = FILE_PROGRAMS_VERSION if File.exist? _ dataset = YAML.load_file(_) if dataset.has_key? this_program program_version = dataset.fetch(this_program) return program_version end else e "No file called `#{sfile(_)}` exists." raise FileDoesNotExist, _.to_s+' does not exist.' end return nil # Default return value here. end
#¶ ↑
RBT.symlink
(symlink tag)¶ ↑
Wrapper to symlink something, by delegating towards class Symlink.
This could also be adapted to work on Windows.
Please use this and only this method consistently when wanting to create a symlink from within the RBT
project.
Here we have to be careful with the arguments, because File.symlink will fail if the file already exists. Right now we default to the behaviour that we will ALWAYS remove any file that exists at `new_location`.
#¶ ↑
# File lib/rbt/toplevel_methods/symlink.rb, line 31 def self.symlink( existing, new_location = nil, be_verbose = true, use_colours = RBT.use_colours? # Here we need colours/colours.rb ) case be_verbose when :be_quiet, :be_silent be_verbose = false when :default be_verbose = true end if existing.is_a? Hash if existing.has_key? :to new_location = existing.delete(:to) end if existing.has_key? :from existing = existing.delete(:from) end end # ======================================================================= # # === Delegate towards class Symlink next, after a check # ======================================================================= # unless Object.const_defined? :Symlink if is_on_roebe? e '(from rbt/toplevel_methods/symlink.rb): class Symlink '\ 'is not available - consider installing it.' end end _ = Symlink.new( existing, new_location, be_verbose, :do_not_run_yet ) unless _.namespace?.start_with? 'RBT->' _.prepend_this_to_namespace 'RBT->' end _.shall_we_use_colours?(use_colours) # ======================================================================= # # For understanding the next line look at USE_ABSOLUTE_SYMLINKING above. # ======================================================================= # _.use_absolute_symlinking if USE_ABSOLUTE_SYMLINKING _.disable_opn if RBT.do_not_show_names? _.run end
#¶ ↑
RBT.symlink_appdir_libraries_into_usr_lib_directory
¶ ↑
The following method is very specialized - it will symlink all entries under lib/* into the /usr/lib/ hierarchy.
This will be invoked as part of the postinstallation-steps, but only if we make use of an AppDir layout, and only if we are on a roebe-system (aka my home directory normally).
#¶ ↑
# File lib/rbt/toplevel_methods/misc.rb, line 51 def self.symlink_appdir_libraries_into_usr_lib_directory( from_this_appdir_library_target ) e "Now obtaining all entries from the directory `"\ "#{sdir(from_this_appdir_library_target)}`:" entries = Dir["#{from_this_appdir_library_target}*"] entries.each {|this_library| symlink( this_library, "/usr/lib/#{File.basename(this_library)}" ) } end
#¶ ↑
RBT.test_this_alias
¶ ↑
This method here is mostly used by a .rb file under the rbt/bin/ hierarchy.
#¶ ↑
# File lib/rbt/toplevel_methods/available_programs.rb, line 245 def self.test_this_alias(i) require 'rbt/aliases/aliases.rb' e 'This program will test whether the given input is:' e e ' - a registered cookbook program (1)' e ' - a registered cookbook alias (2)' e ' - a registered cookbook abbrevation (3)' e e 'in precisely this order.' e i = [i].flatten.compact i.each {|entry| if RBT.is_a_registered_cookbook_program?(entry) e 'Yes, '+RBT.sfancy(entry)+' is a registered cookbook program.' else e 'No, '+RBT.sfancy(entry)+' is NOT a registered cookbook program.' end if RBT.is_an_alias?(entry) e 'Yes, '+RBT.sfancy(entry)+' is an alias.' else e 'No, '+RBT.sfancy(entry)+' is NOT an alias.' end if RBT.is_an_abbreviation?(entry) e 'Yes, '+RBT.sfancy(entry)+' is an abbreviation.' else e 'No, '+RBT.sfancy(entry)+' is NOT an abbreviation.' end } end
#¶ ↑
RBT.toplevel_methods?
¶ ↑
Simply return the constant here. This will tell us where the module_method .rb files are kept.
This will typically return a path such as:
/Programs/Ruby/2.6.0/lib/ruby/site_ruby/2.6.0/rbt/toplevel_methods/
#¶ ↑
# File lib/rbt/constants/toplevel_methods.rb, line 22 def self.toplevel_methods? "#{RBT.project_base_directory?}toplevel_methods/" end
#¶ ↑
RBT.try_to_find_shortcut_for_a_chain_compiled_program
¶ ↑
Use this method if you wish to find a shortcut.
#¶ ↑
# File lib/rbt/toplevel_methods/try_to_find_shortcut_for_a_chain_compiled_program.rb, line 14 def self.try_to_find_shortcut_for_a_chain_compiled_program( i ) i = i.to_s.delete('_') # Since as of Aug 2011, we will get rid of all '_' characters. i = case i # case tag when 'games','gam' 'games' when 'protos','proto','xorgprotos','xorg1','x1','1' 'xorg_protos' when 'utils','xorgutils','xorg2','x2','2' 'xorg_utils' when 'libs','libraries','xorg3','xorglibraries','x3','3' 'xorg_libraries' when 'data','xorg4','xorgdata','x4','4' 'xorg_data' when 'apps','xorg5','xorgapps','x5','5' 'xorg_apps' when 'fonts','xorg6','xorgfonts','x6','6' 'xorg_fonts' when 'server','xorg7','xorgserver','x7','7' 'xorg_server' when 'addons','ruby_addons','rubyaddons','raddons','raddon', 'rub','r','rand','all','8' 'ruby_addons' when 'python','mypython','pp','pyt','pyth','9' 'my_python' when 'gnome','xorg10','10' 'gnome5' when 'e','11','xorg11','e17' 'e17' when 'audio_suite','audsuite' 'aud_suite' when 'video_base','vidbase','vid_base', /video(_|-)?subsection/ 'vid_base' when 'kde','kde3','kde4','kd','default' 'kde' else i # Else return the input unaltered. end return i end
#¶ ↑
RBT.uchroot_compile
¶ ↑
Compile
via a /usr prefix to the main chroot.
#¶ ↑
# File lib/rbt/toplevel_methods/uchroot.rb, line 14 def self.uchroot_compile( these_programs = ARGV ) require 'rbt/compile/compile.rb' [these_programs].flatten.compact.each {|this_program| RBT::Compile.new(this_program) {{ use_this_prefix: '/Depot/Chroot/usr/' }} } end
#¶ ↑
RBT.unicode_cliner
¶ ↑
This is like RBT.cliner()
, but it will make use of unicode horizontal building block.
#¶ ↑
# File lib/rbt/toplevel_methods/cliner.rb, line 15 def self.unicode_cliner( use_this_token = '=', use_this_colour = nil, &block ) yielded = :unicode if block_given? yielded = yield end RBT.cliner(use_this_token, use_this_colour) { yielded } end
#¶ ↑
RBT.update_all_ruby_gems
¶ ↑
This method can be used to update all local ruby gems (.gem files).
#¶ ↑
# File lib/rbt/check_for_updates/check_for_new_release_on_rubygems.rb, line 216 def self.update_all_ruby_gems # ======================================================================= # # Instantiate the main class defined in this .rb file here: # ======================================================================= # _ = RBT::Cookbooks::CheckForNewReleaseOnRubygems.new(:dont_run_yet) base_dir = RBT.individual_cookbooks_directory? # ======================================================================= # # First, we must obtain all entries thave have the strings "url1" # and ".gem". We will ask ruby to perform a grep-operation. We will # store these in an array. # ======================================================================= # array_ruby_gems = [] available_programs = available_programs? available_programs.each {|this_program| target_yaml_file = "#{base_dir}#{this_program}.yml" if File.exist? target_yaml_file dataset = File.read(target_yaml_file) if dataset.include?('url1') line_holding_url1 = dataset.scan(/^ url1: (.+)$/).flatten.first if line_holding_url1.nil? e 'No result has been found on the dataset at hand, from the file' e sfile(target_yaml_file) end if line_holding_url1 if line_holding_url1.end_with? '.gem' # Found ruby gems. array_ruby_gems << [this_program, line_holding_url1] end end end end } # ======================================================================= # # Ok - now that we have obtained the files that are .gem files, # we can proceed them and check for an updated. This taps into # a specialized class that will do so for us. # ======================================================================= # array_ruby_gems.each {|this_ruby_gem, remote_url| _.check_this_remote_url(remote_url) } end
#¶ ↑
RBT.update_entry
¶ ↑
This is a simpler toplevel API to tap into class RBT::UpdateEntry
.
#¶ ↑
# File lib/rbt/utility_scripts/update_entry.rb, line 612 def self.update_entry(i) RBT::UpdateEntry.new(i) end
#¶ ↑
RBT.update_these_rubygems
¶ ↑
Usage example:
array = %w( thor prawn ); RBT.update_these_rubygems(array)
#¶ ↑
# File lib/rbt/compile/ruby.rb, line 244 def self.update_these_rubygems( array_to_use = RBT.array_all_rubygems ) unless array_to_use.empty? array_to_use.each {|this_gem| RBT.install_this_rubygem(this_gem) } end end
#¶ ↑
RBT.upload_list_of_all_programs_version
¶ ↑
This will use my FTP wrapper to upload this file.
The local .txt file is usually kept or autogenerated here:
/Depot/Temp/CookbookDirectory/programs_version.txt
#¶ ↑
# File lib/rbt/toplevel_methods/ftp.rb, line 53 def self.upload_list_of_all_programs_version( this_file = RBT.store_into_this_directory+'programs_version.txt', type = :txt # type can be :txt or :html ) if File.exist? this_file case type when :html RBT.create_programs_version_html_file(this_file) this_file.sub!(/\.txt$/,'') end opn; e 'Uploading the file '+sfile(this_file)+' next.' begin require 'ftp_paradise' rescue LoadError rescue SyntaxError end if Object.const_defined? :FtpParadise begin _ = FtpParadise::Connection.new(:dont_run_yet) _.set_be_verbose _.set_mode :ascii _.set_data('SHEVY') _.do_login('SHEVY') _.upload(this_file, :be_silent) # ===================================================================== # # We have to rescue the following error because FtpParadise may be # unavailable - but we may still want to upload the RBT project. # ===================================================================== # rescue NameError => error pp error pp error.class e 'Continuing nonetheless despite the above ^^^ error.' end end else opn; e "No file exists at `#{sfile(this_file)}`." end end
#¶ ↑
RBT.verbose_truth
¶ ↑
This “converts” the given appropriate input to a “Yes.” or “No.” String.
If you need a boolean variant, you can use the method RBT.to_bool()
.
#¶ ↑
# File lib/rbt/toplevel_methods/verbose_truth.rb, line 17 def self.verbose_truth( i = 'true' ) i = i.first if i.is_a? Array case i.to_s when 'true','t','j','ja','yes' i = 'Yes.' when 'false','f','no','n' i = 'No.' end i end
#¶ ↑
RBT.will_install_which_binaries?
¶ ↑
This method will simply return an Array of binaries that belong to the rbt project.
#¶ ↑
# File lib/rbt/toplevel_methods/install_which_binaries.rb, line 19 def self.will_install_which_binaries? results = [] if is_on_roebe? results = Dir["#{RUBY_SRC_DIR_AT_HOME}rbt/bin/*"] else # Else we handle the case for regular users. # This depends on information stored in the file called # rbt_installs_these_executables.yml, which has to be # upgraded every now and then. results = YAML.load_file( "#{RBT.project_yaml_directory?}rbt_installs_these_executables.yml" ) end # ======================================================================= # # Use only the basename of any results: # ======================================================================= # results.map! {|entry| File.basename(entry) } results.sort # <- Keep the entries alphabetically sorted. end
#¶ ↑
RBT.wrap_at
(Begrenzung tag, limit tag, boundary tag)¶ ↑
Wraps at a specified position.
Specific examples:
puts "abc abc abdc abc abc abc abc abc abc abc abcdef abc abc abc abc abc abc abc abc abc ".wrap_at(20) puts RBT.wrap_at(("x"*200), 30) ("x"*200).wrap_at(30,true,5)
# ¶ ↑
# File lib/rbt/toplevel_methods/split_at.rb, line 26 def self.wrap_at( this_string, my_limit = N_CHARACTERS_PER_LINE, add_newline = true, add_padding = nil ) case my_limit when :default my_limit = N_CHARACTERS_PER_LINE end begin add_padding = add_padding.to_i unless add_padding.nil? if add_newline _ = "\\1\\3\n" # newline at end unless add_padding.nil? _ = _.linsert(' ' * add_padding) end return this_string.gsub(/(.{1,#{my_limit}})( +|$)\n?|(.{#{my_limit}})/,_) else _ = "\\1\\3" unless add_padding.nil? _ = _.linsert(' ' * add_padding) end return this_string.gsub( /(.{1,#{my_limit}})( +|$)\n?|(.{#{my_limit}})/, _ ) # No newline at the end. end rescue Exception => error puts error end end
Public Instance Methods
#¶ ↑
all_binaries
?¶ ↑
#¶ ↑
# File lib/rbt/toplevel_methods/all_binaries.rb, line 57 def all_binaries? RBT.all_binaries? end
#¶ ↑
all_libraries
?¶ ↑
#¶ ↑
# File lib/rbt/toplevel_methods/all_libraries.rb, line 57 def all_libraries? RBT.all_libraries? end
#¶ ↑
get_file_listing
¶ ↑
Get the file listing of a specific directory. Input will always become a string. Use this method consistently when you want to get files from a directory, for use in the RBT
Project.
Since September 2014 we will ONLY return real files.
#¶ ↑
# File lib/rbt/toplevel_methods/get_all_files_from.rb, line 38 def get_file_listing(a = Dir.pwd, b = true, c = false) RBT.get_all_files_from(a, b, c) end
#¶ ↑
individual_cookbooks_directory?¶ ↑
#¶ ↑
# File lib/rbt/toplevel_methods/cookbook_directory.rb, line 82 def individual_cookbooks_directory? ::RBT.cookbook_directory? end
#¶ ↑
is_on_roebe?¶ ↑
#¶ ↑
# File lib/rbt/toplevel_methods/roebe.rb, line 23 def is_roebe? RBT.is_roebe? end
#¶ ↑
rbt_yaml_directory?¶ ↑
#¶ ↑
# File lib/rbt/project/project_base_and_yaml_directory.rb, line 96 def rbt_yaml_directory? self.project_yaml_directory? end
#¶ ↑
registered_cookbook_entries
?¶ ↑
Just a pointer to the module-method with the same name.
#¶ ↑
# File lib/rbt/constants/registered_cookbook_entries.rb, line 74 def registered_cookbook_entries? RBT.registered_cookbook_entries? end
#¶ ↑
toplevel_methods?¶ ↑
#¶ ↑
# File lib/rbt/constants/toplevel_methods.rb, line 29 def toplevel_methods? RBT.toplevel_methods? end
#¶ ↑
utility_scripts¶ ↑
#¶ ↑
# File lib/rbt/constants/utility_scripts.rb, line 29 def utility_scripts? RBT.utility_scripts? end