class ToplevelInstaller
Constants
- Copyright
- TASKS
- Version
Public Class Methods
invoke()
click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 767 def ToplevelInstaller.invoke config = ConfigTable.new(load_rbconfig()) config.load_standard_entries config.load_multipackage_entries if multipackage? config.fixup klass = (multipackage?() ? ToplevelInstallerMulti : ToplevelInstaller) klass.new(File.dirname($0), config).invoke end
load_rbconfig()
click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 780 def ToplevelInstaller.load_rbconfig if arg = ARGV.detect {|arg| /\A--rbconfig=/ =~ arg } ARGV.delete(arg) load File.expand_path(arg.split(/=/, 2)[1]) $".push 'rbconfig.rb' else require 'rbconfig' end ::Config::CONFIG end
multipackage?()
click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 776 def ToplevelInstaller.multipackage? File.dir?(File.dirname($0) + '/packages') end
new(ardir_root, config)
click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 791 def initialize(ardir_root, config) @ardir = File.expand_path(ardir_root) @config = config # cache @valid_task_re = nil end
Public Instance Methods
config(key)
click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 798 def config(key) @config[key] end
exec_clean()
click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 1013 def exec_clean @installer.exec_clean end
exec_config()
click to toggle source
Task Handlers
# File pkg/statsample-1.4.0/setup.rb, line 990 def exec_config @installer.exec_config @config.save # must be final end
exec_distclean()
click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 1017 def exec_distclean @installer.exec_distclean end
exec_install()
click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 999 def exec_install @installer.exec_install end
exec_setup()
click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 995 def exec_setup @installer.exec_setup end
exec_show()
click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 1007 def exec_show @config.each do |i| printf "%-20s %s\n", i.name, i.value if i.value? end end
exec_test()
click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 1003 def exec_test @installer.exec_test end
init_installers()
click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 834 def init_installers @installer = Installer.new(@config, @ardir, File.expand_path('.')) end
inspect()
click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 802 def inspect "#<#{self.class} #{__id__()}>" end
invoke()
click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 806 def invoke run_metaconfigs case task = parsearg_global() when nil, 'all' parsearg_config init_installers exec_config exec_setup exec_install else case task when 'config', 'test' ; when 'clean', 'distclean' @config.load_savefile if File.exist?(@config.savefile) else @config.load_savefile end __send__ "parsearg_#{task}" init_installers __send__ "exec_#{task}" end end
objdir_root()
click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 846 def objdir_root '.' end
parsearg_config()
click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 905 def parsearg_config evalopt = [] set = [] @config.config_opt = [] while i = ARGV.shift if /\A--?\z/ =~ i @config.config_opt = ARGV.dup break end name, value = *@config.parse_opt(i) if @config.value_config?(name) @config[name] = value else evalopt.push [name, value] end set.push name end evalopt.each do |name, value| @config.lookup(name).evaluate value, @config end # Check if configuration is valid set.each do |n| @config[n] if @config.value_config?(n) end end
parsearg_global()
click to toggle source
Option Parsing
# File pkg/statsample-1.4.0/setup.rb, line 858 def parsearg_global while arg = ARGV.shift case arg when /\A\w+\z/ setup_rb_error "invalid task: #{arg}" unless valid_task?(arg) return arg when '-q', '--quiet' @config.verbose = false when '--verbose' @config.verbose = true when '--help' print_usage $stdout exit 0 when '--version' puts "#{File.basename($0)} version #{Version}" exit 0 when '--copyright' puts Copyright exit 0 else setup_rb_error "unknown global option '#{arg}'" end end nil end
parsearg_install()
click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 931 def parsearg_install @config.no_harm = false @config.install_prefix = '' while a = ARGV.shift case a when '--no-harm' @config.no_harm = true when /\A--prefix=/ path = a.split(/=/, 2)[1] path = File.expand_path(path) unless path[0,1] == '/' @config.install_prefix = path else setup_rb_error "install: unknown option #{a}" end end end
parsearg_no_options()
click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 892 def parsearg_no_options unless ARGV.empty? task = caller(0).first.slice(%r<`parsearg_(\w+)'>, 1) setup_rb_error "#{task}: unknown options: #{ARGV.join(' ')}" end end
Also aliased as: parsearg_show, parsearg_setup, parsearg_test, parsearg_clean, parsearg_distclean, parsearg_show, parsearg_setup, parsearg_test, parsearg_clean, parsearg_distclean
print_usage(out)
click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 948 def print_usage(out) out.puts 'Typical Installation Procedure:' out.puts " $ ruby #{File.basename $0} config" out.puts " $ ruby #{File.basename $0} setup" out.puts " # ruby #{File.basename $0} install (may require root privilege)" out.puts out.puts 'Detailed Usage:' out.puts " ruby #{File.basename $0} <global option>" out.puts " ruby #{File.basename $0} [<global options>] <task> [<task options>]" fmt = " %-24s %s\n" out.puts out.puts 'Global options:' out.printf fmt, '-q,--quiet', 'suppress message outputs' out.printf fmt, ' --verbose', 'output messages verbosely' out.printf fmt, ' --help', 'print this message' out.printf fmt, ' --version', 'print version and quit' out.printf fmt, ' --copyright', 'print copyright and quit' out.puts out.puts 'Tasks:' TASKS.each do |name, desc| out.printf fmt, name, desc end fmt = " %-24s %s [%s]\n" out.puts out.puts 'Options for CONFIG or ALL:' @config.each do |item| out.printf fmt, item.help_opt, item.description, item.help_default end out.printf fmt, '--rbconfig=path', 'rbconfig.rb to load',"running ruby's" out.puts out.puts 'Options for INSTALL:' out.printf fmt, '--no-harm', 'only display what to do if given', 'off' out.printf fmt, '--prefix=path', 'install path prefix', '' out.puts end
relpath()
click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 850 def relpath '.' end
run_metaconfigs()
click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 830 def run_metaconfigs @config.load_script "#{@ardir}/metaconfig" end
srcdir_root()
click to toggle source
Hook Script API bases
# File pkg/statsample-1.4.0/setup.rb, line 842 def srcdir_root @ardir end
valid_task?(t)
click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 884 def valid_task?(t) valid_task_re() =~ t end
valid_task_re()
click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 888 def valid_task_re @valid_task_re ||= /\A(?:#{TASKS.map {|task,desc| task }.join('|')})\z/ end