class RBT::PostInstall
Public Class Methods
new( use_this_dataset = nil, run_already = true ) { || ... }
click to toggle source
#¶ ↑
initialize¶ ↑
The first argument must be our dataset, which shall be of class Cookbooks::Cookbook.
#¶ ↑
# File lib/rbt/utility_scripts/post_install.rb, line 33 def initialize( use_this_dataset = nil, run_already = true ) reset set_dataset( use_this_dataset ) # ======================================================================= # # === Handle blocks next # ======================================================================= # if block_given? yielded = yield if yielded.is_a? Hash # =================================================================== # # === :use_this_compile_prefix # =================================================================== # if yielded.has_key? :use_this_compile_prefix set_compile_prefix( yielded.delete(:use_this_compile_prefix) ) end end end run if run_already end
Public Instance Methods
compile_prefix?()
click to toggle source
create_pkgconfig_file()
click to toggle source
#¶ ↑
create_pkgconfig_file
¶ ↑
This method will delegate towards creating a new .pc file.
#¶ ↑
# File lib/rbt/utility_scripts/post_install.rb, line 167 def create_pkgconfig_file RBT::CreatePkgconfigFile.new( pkgconfig_filename: pkgconfig_filename?, prefix: prefix?, version: program_version?, description: short_desc? ) end
dataset?()
click to toggle source
pkgconfig_filename?()
click to toggle source
#¶ ↑
pkgconfig_filename?¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/post_install.rb, line 179 def pkgconfig_filename? program_name = short_program_name? if program_name.start_with? 'lib' # .pc files do not usually have the lib part. program_name.sub!(/^lib/,'') end _ = rds("#{prefix?}/lib/pkgconfig/#{program_name}") _ << '.pc' unless _.end_with? '.pc' _ # ← Return that result here. end
postinstall?()
click to toggle source
prefix?()
click to toggle source
program_name?()
click to toggle source
program_version?()
click to toggle source
reset()
click to toggle source
#¶ ↑
reset¶ ↑
#¶ ↑
Calls superclass method
RBT::Base#reset
# File lib/rbt/utility_scripts/post_install.rb, line 63 def reset super() infer_the_namespace # ======================================================================= # # === @compile_prefix # ======================================================================= # @compile_prefix = nil # This prefix is initially nil. end
run()
click to toggle source
#¶ ↑
run¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/post_install.rb, line 208 def run show_header # ======================================================================= # # We will split on ',' entries. # ======================================================================= # dataset = postinstall? dataset = dataset.split(',') if dataset.is_a? String dataset.each { |post_install| # ===================================================================== # # === Big post-install sanitizer code block # # Keep in mind that the variable post_install is now a String, ideally. # A typically example for this may be the String # "symlink_this_binary vte-2.91 vte". # ===================================================================== # next if post_install.to_s.empty? # Skip empty entries. post_install = post_install.dup # Work on a copy here. post_install = rds(post_install).strip opne sfancy('Contemplating postinstall-action in `')+ sdir_return_pwd+ sfancy('` with') # ===================================================================== # # Use another colour next. # ===================================================================== # opne lightblue(" #{post_install}") opnfancy 'next.' # ===================================================================== # # Next, we have to split up the line based on ' ', so that we can # determine which action ought to be applied. # ===================================================================== # splitted = post_install.split(' ').map(&:strip).map {|entry| convert_env_variable(entry) } work_on_this_action = splitted.first first_argument = splitted[1] second_argument = splitted[2] third_argument = splitted[3] fourth_argument = splitted[4] # ===================================================================== # # Next, we work on the commands given in the postinstall entry. # The following variable will contain entry points such as # "symlink_this_binary". # ===================================================================== # case work_on_this_action # case tag # ===================================================================== # # === create_directory # # This entry point is for creating a directory. # ===================================================================== # when 'create_directory', /mkdir/ _ = splitted[1].to_s.dup if _.include?('APPDIR_INSTALLATION_PREFIX') and uses_appdir_prefix? _.sub!( /APPDIR_INSTALLATION_PREFIX/, prefix? ) _ = rds(_) end create_directory(_) # ===================================================================== # # === symlink_binary # # This handles both "symlink_binary" and "symlink_this_binary" # cases. The latter is simply an "alias" to the former. An example # for a .yml file making use of this is the file called 'vte.yml'. # ===================================================================== # when /^symlink(_|-)?binary$/, /^symlink(_|-)?this(_|-)?binary$/ _ = "#{prefix?}bin/" symlink(_+first_argument,_+splitted[2]) # ===================================================================== # # === ln # # This entry is the general symlink-entry. # ===================================================================== # when 'ln', 'symlink' # run symlink here, but handle it internally. splitted.delete_at(1) if splitted[1] == '-s' splitted.delete_at(1) if splitted[1] == '-v' first_argument = splitted[-1] second_argument = splitted[-2] if File.exist?(second_argument) if first_argument.include?(programs_directory?) and !appdir_prefix? opne crimson('Can not symlink into ')+sfancy(first_argument)+crimson(' as this program') opne crimson('is not compiled via an AppDir prefix.') else if @compile_prefix and !@compile_prefix.include?(programs_directory?) opne crimson('Can not symlink into an AppDir path, as the prefix in use is') opne crimson('`')+sfancy(@compile_prefix)+crimson('`.') else symlink(second_argument, first_argument) end end else opne "Can not symlink towards #{sfancy(second_argument)}"\ " as it does not exist." end # ===================================================================== # # === copy_files # ===================================================================== # when 'copy_files' # =================================================================== # # This entry point can involve some more complicated instructions. # =================================================================== # if (first_argument == '{') and # In this case we assume the user wants to batch-copy some files. (third_argument == '}') target_dir = fourth_argument second_argument_splitted = second_argument.split(',') second_argument_splitted.each {|this_file| new_target = ("#{target_dir}/#{this_file}").squeeze('/') ftype = File.ftype(this_file) case ftype when 'directory' copy_directory(this_file, new_target, :be_verbose) when 'file' copy_file(this_file, new_target, :be_verbose) end } end # ===================================================================== # # === copy_file # ===================================================================== # when 'copy_file' copy_file(splitted[1], splitted[2]) # ===================================================================== # # === create_pkgconfig_file # ===================================================================== # when /^create(_|-)?pkgconfig(_|-)?file$/ create_pkgconfig_file # ===================================================================== # # === patch_pkgconfig_file # ===================================================================== # when /^-?-?patch(_|-)?pkgconfig(_|-)?file:?$/ opne 'Now patching the version in the pkg-config file '\ 'for that program.' new_version = splitted.last # =================================================================== # # Currently, the path is hardcoded. # =================================================================== # use_this_as_pkgconfig_file = Dir[ "/usr/lib/pkgconfig/*#{program?}*.pc" ].first # =================================================================== # # Now we can delegate to class RBT::FixPkgconfigFile. # =================================================================== # RBT::FixPkgconfigFile.new( { use_this_pkgconfig_file: use_this_as_pkgconfig_file, use_this_as_the_new_version: new_version } ) # ===================================================================== # # === add_user # ===================================================================== # when /^add_?user$/ AddUser.new(splitted[1]) if Object.const_defined? :AddUser # ===================================================================== # # === make # ===================================================================== # when /^make$/ esystem(post_install) # when 'install' # Install actions are handled by the else clause below. else # else, simply run through esystem(). if is_on_roebe? opne tomato('Debug: the following use case is not handled.') opne tomato(work_on_this_action) end cliner esystem(post_install) cliner end } cliner end
set_compile_prefix(i)
click to toggle source
#¶ ↑
set_compile_prefix
¶ ↑
The compile_prefix is the one that is used by RBT::Compile
, e. g. /usr/ prefix usually or an AppDir prefix. The reason why this class here may need to know about it, is because some actions depend on this - such as postinstall-action involving symlinks.
#¶ ↑
# File lib/rbt/utility_scripts/post_install.rb, line 80 def set_compile_prefix(i) @compile_prefix = i end
set_dataset( i = nil )
click to toggle source
#¶ ↑
set_dataset
¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/post_install.rb, line 94 def set_dataset( i = nil ) i = i.first if i.is_a? Array # ======================================================================= # # Next handle nils. # ======================================================================= # if i.nil? if return_pwd.include? programs_dir? # =================================================================== # # Ok, input can be such as "/Programs/Gcc/5.2.0". Let's work on that. # =================================================================== # i = return_pwd.split('/').reject(&:empty?)[1].downcase end end if i.is_a? String # postinstall gcc # ===================================================================== # # We must turn it into an instance of RBT::Cookbooks::SanitizeCookbook # here. # ===================================================================== # i = RBT::Cookbooks::SanitizeCookbook.new(i) { :fast } end @dataset = i end
short_desc?()
click to toggle source
short_name?()
click to toggle source
#¶ ↑
short_name?¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/post_install.rb, line 129 def short_name? dataset?.short_name? end
Also aliased as: program?, short_program_name?
show_header()
click to toggle source