class RBT::PostInstall
Constants
- NAMESPACE
#¶ ↑
NAMESPACE
¶ ↑#¶ ↑
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 36 def initialize( use_this_dataset = nil, run_already = true ) reset set_dataset( use_this_dataset ) if block_given? yielded = yield if yielded.is_a? Hash 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 157 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 169 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
run()
click to toggle source
#¶ ↑
run¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/post_install.rb, line 197 def run show_header # ======================================================================= # # We will split on ',' entries. # ======================================================================= # dataset = postinstall? dataset = dataset.split(',') if dataset.is_a? String dataset.each { |post_install| # ===================================================================== # # Keep in mind that the variable post_install is now a String, ideally. # ===================================================================== # next if post_install.to_s.empty? # Skip empty entries. post_install = rds(post_install).strip opnn; e sfancy('Contemplating postinstall-action in `')+ sdir_return_pwd+ sfancy('` with') # ===================================================================== # # Use another colour next. # ===================================================================== # opnn; e lightblue(" #{post_install}") opnn; e sfancy('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) work_on_this_action = splitted.first first_argument = splitted[1] second_argument = splitted[2] third_argument = splitted[3] fourth_argument = splitted[4] splitted = convert_env_variable(splitted) # Get rid of all $. # ===================================================================== # # Next, we work on the commands given in the postinstall entry. # ===================================================================== # case work_on_this_action # case tag # ===================================================================== # # === symlink_binary # ===================================================================== # when /^symlink(_|-)?binary$/, /^symlink(_|-)?this(_|-)?binary$/ _ = "#{prefix?}/bin/" symlink(_+splitted[1],_+splitted[2]) # ===================================================================== # # === ln # ===================================================================== # 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? opnn; e crimson('Can not symlink into ')+sfancy(first_argument)+crimson(' as this program') opnn; e crimson('is not compiled via an AppDir prefix.') else if @compile_prefix and !@compile_prefix.include?(programs_directory?) opnn; e crimson('Can not symlink into an AppDir path, as the prefix in use is') opnn; e crimson('`')+sfancy(@compile_prefix)+crimson('`.') else symlink(second_argument, first_argument) end end else opnn; e "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_directory # ===================================================================== # when 'create_directory' create_directory(splitted[1]) # ===================================================================== # # === create_pkgconfig_file # ===================================================================== # when /^create(_|-)?pkgconfig(_|-)?file$/ create_pkgconfig_file # ===================================================================== # # === patch_pkgconfig_file # ===================================================================== # when 'patch_pkgconfig_file:',/patch_?pkgconfig_?file/ opnn; e '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 # when 'install' # Install actions are handled by the else clause below. else # else, simply run through esystem(). cliner { esystem(post_install) } 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 74 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 88 def set_dataset( i = nil ) i = i.first if i.is_a? Array # ======================================================================= # # Next handle nils. # ======================================================================= # if i.nil? if Dir.pwd.include? programs_dir? # =================================================================== # # Ok, input can be such as "/Programs/Gcc/5.2.0". Let's work on that. # =================================================================== # i = Dir.pwd.split('/').reject(&:empty?)[1].downcase end end if i.is_a? String # postinstall gcc i = RBT::Cookbooks::Cookbook.new(i) { :bypass_menu_check } 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 119 def short_name? dataset?.short_name? end
Also aliased as: program?, short_program_name?
show_header()
click to toggle source
use_appdir_prefix?()
click to toggle source
#¶ ↑
use_appdir_prefix?¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/post_install.rb, line 189 def use_appdir_prefix? prefix?.include? programs_dir? end
Also aliased as: appdir_prefix?, is_appdir?