Class: ToplevelInstaller
Direct Known Subclasses
Constant Summary collapse
- Version =
'3.4.1'
- Copyright =
'Copyright (c) 2000-2005 Minero Aoki'
- TASKS =
[ [ 'all', 'do config, setup, then install' ], [ 'config', 'saves your configurations' ], [ 'show', 'shows current configuration' ], [ 'setup', 'compiles ruby extentions and others' ], [ 'install', 'installs files' ], [ 'test', 'run all tests in test/' ], [ 'clean', "does `make clean' for each extention" ], [ 'distclean',"does `make distclean' for each extention" ] ]
Class Method Summary collapse
Instance Method Summary collapse
-
#config(key) ⇒ Object
# === config ========================================================================= #.
- #exec_clean ⇒ Object
-
#exec_config ⇒ Object
Task Handlers.
- #exec_distclean ⇒ Object
- #exec_install ⇒ Object
- #exec_setup ⇒ Object
- #exec_show ⇒ Object
- #exec_test ⇒ Object
- #init_installers ⇒ Object
-
#initialize(ardir_root, config) ⇒ ToplevelInstaller
constructor
A new instance of ToplevelInstaller.
- #inspect ⇒ Object
- #invoke ⇒ Object
- #objdir_root ⇒ Object
- #parsearg_config ⇒ Object
-
#parsearg_global ⇒ Object
Option Parsing.
- #parsearg_install ⇒ Object
- #parsearg_no_options ⇒ Object (also: #parsearg_show, #parsearg_setup, #parsearg_test, #parsearg_clean, #parsearg_distclean)
- #print_usage(out) ⇒ Object
- #relpath ⇒ Object
- #run_metaconfigs ⇒ Object
-
#srcdir_root ⇒ Object
Hook Script API bases.
- #valid_task?(t) ⇒ Boolean
- #valid_task_re ⇒ Object
Constructor Details
#initialize(ardir_root, config) ⇒ ToplevelInstaller
Returns a new instance of ToplevelInstaller.
852 853 854 855 856 857 |
# File 'lib/roebe/setup/setup.rb', line 852 def initialize(ardir_root, config) @ardir = File.(ardir_root) @config = config # cache @valid_task_re = nil end |
Class Method Details
.invoke ⇒ Object
828 829 830 831 832 833 834 835 |
# File 'lib/roebe/setup/setup.rb', line 828 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 ⇒ Object
841 842 843 844 845 846 847 848 849 850 |
# File 'lib/roebe/setup/setup.rb', line 841 def ToplevelInstaller.load_rbconfig if arg = ARGV.detect {|inner_arg| /\A--rbconfig=/ =~ inner_arg } ARGV.delete(arg) load File.(arg.split(/=/, 2)[1]) $".push 'rbconfig.rb' else require 'rbconfig' end ::RbConfig::CONFIG end |
.multipackage? ⇒ Boolean
837 838 839 |
# File 'lib/roebe/setup/setup.rb', line 837 def ToplevelInstaller.multipackage? File.dir?(File.dirname($0) + '/packages') end |
Instance Method Details
#config(key) ⇒ Object
#
config
#
862 863 864 |
# File 'lib/roebe/setup/setup.rb', line 862 def config(key) @config[key] end |
#exec_clean ⇒ Object
1078 1079 1080 |
# File 'lib/roebe/setup/setup.rb', line 1078 def exec_clean @installer.exec_clean end |
#exec_config ⇒ Object
Task Handlers
1055 1056 1057 1058 |
# File 'lib/roebe/setup/setup.rb', line 1055 def exec_config @installer.exec_config @config.save # must be final end |
#exec_distclean ⇒ Object
1082 1083 1084 |
# File 'lib/roebe/setup/setup.rb', line 1082 def exec_distclean @installer.exec_distclean end |
#exec_install ⇒ Object
1064 1065 1066 |
# File 'lib/roebe/setup/setup.rb', line 1064 def exec_install @installer.exec_install end |
#exec_setup ⇒ Object
1060 1061 1062 |
# File 'lib/roebe/setup/setup.rb', line 1060 def exec_setup @installer.exec_setup end |
#exec_show ⇒ Object
1072 1073 1074 1075 1076 |
# File 'lib/roebe/setup/setup.rb', line 1072 def exec_show @config.each do |i| printf "%-20s %s\n", i.name, i.value if i.value? end end |
#exec_test ⇒ Object
1068 1069 1070 |
# File 'lib/roebe/setup/setup.rb', line 1068 def exec_test @installer.exec_test end |
#init_installers ⇒ Object
899 900 901 |
# File 'lib/roebe/setup/setup.rb', line 899 def init_installers @installer = Installer.new(@config, @ardir, File.('.')) end |
#inspect ⇒ Object
866 867 868 |
# File 'lib/roebe/setup/setup.rb', line 866 def inspect "#<#{self.class} #{__id__()}>" end |
#invoke ⇒ Object
870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 |
# File 'lib/roebe/setup/setup.rb', line 870 def invoke case task = parsearg_global() when nil, 'all' parsearg_config init_installers exec_config exec_setup exec_install else case task # === config 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 ⇒ Object
911 912 913 |
# File 'lib/roebe/setup/setup.rb', line 911 def objdir_root '.' end |
#parsearg_config ⇒ Object
970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 |
# File 'lib/roebe/setup/setup.rb', line 970 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 |inner_name, inner_value| @config.lookup(inner_name).evaluate inner_value, @config end # Check if configuration is valid set.each do |n| @config[n] if @config.value_config?(n) end end |
#parsearg_global ⇒ Object
Option Parsing
923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 |
# File 'lib/roebe/setup/setup.rb', line 923 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 ⇒ Object
996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 |
# File 'lib/roebe/setup/setup.rb', line 996 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.(path) unless path[0,1] == '/' @config.install_prefix = path else setup_rb_error "install: unknown option #{a}" end end end |
#parsearg_no_options ⇒ Object Also known as: parsearg_show, parsearg_setup, parsearg_test, parsearg_clean, parsearg_distclean
957 958 959 960 961 962 |
# File 'lib/roebe/setup/setup.rb', line 957 def unless ARGV.empty? task = caller(0).first.slice(%r<`parsearg_(\w+)'>, 1) setup_rb_error "#{task}: unknown options: #{ARGV.join(' ')}" end end |
#print_usage(out) ⇒ Object
1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 |
# File 'lib/roebe/setup/setup.rb', line 1013 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 ⇒ Object
915 916 917 |
# File 'lib/roebe/setup/setup.rb', line 915 def relpath '.' end |
#run_metaconfigs ⇒ Object
895 896 897 |
# File 'lib/roebe/setup/setup.rb', line 895 def @config.load_script "#{@ardir}/metaconfig" end |
#srcdir_root ⇒ Object
Hook Script API bases
907 908 909 |
# File 'lib/roebe/setup/setup.rb', line 907 def srcdir_root @ardir end |
#valid_task?(t) ⇒ Boolean
949 950 951 |
# File 'lib/roebe/setup/setup.rb', line 949 def valid_task?(t) valid_task_re() =~ t end |