Skip to content
Snippets Groups Projects
install.rb 23.1 KiB
Newer Older
  • Learn to ignore specific revisions
  •     while a = ARGV.shift
          case a
          when /\A--no-harm\z/
            @options['no-harm'] = true
          when /\A--prefix=(.*)\z/
            path = $1
            path = File.expand_path(path) unless path[0,1] == '/'
            @options['install-prefix'] = path
          else
            raise InstallError, "install: unknown option #{a}"
          end
        end
      end
    
    
      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 = "  %-20s %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, '-h,--help',    'print this message'
        out.printf fmt, '-v,--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 "  %-10s  %s\n", name, desc
        end
    
        out.puts
        out.puts 'Options for config:'
        ConfigTable.each_definition do |name, (default, arg, desc, default2)|
          out.printf "  %-20s %s [%s]\n",
                     '--'+ name + (ConfigTable.bool_config?(name) ? '' : '='+arg),
                     desc,
                     default2 || default
        end
        out.printf "  %-20s %s [%s]\n",
            '--rbconfig=path', 'your rbconfig.rb to load', "running ruby's"
    
        out.puts
        out.puts 'Options for install:'
        out.printf "  %-20s %s [%s]\n",
            '--no-harm', 'only display what to do if given', 'off'
        out.printf "  %-20s %s [%s]\n",
            '--prefix',  'install path prefix', '$prefix'
    
        out.puts
      end
    
      #
      # config
      #
    
      def exec_config
        super
        @config.save
      end
    
      #
      # show
      #
    
      def exec_show
        ConfigTable.each_name do |k|
          v = @config.get_raw(k)
          if not v or v.empty?
            v = '(not specified)'
          end
          printf "%-10s %s\n", k, v
        end
      end
    
    end
    
    ### end toplevel.rb
    
    if $0 == __FILE__
      begin
        ToplevelInstaller.invoke
      rescue
        raise if $DEBUG
        $stderr.puts $!.message
        $stderr.puts "Try 'ruby #{$0} --help' for detailed usage."
        exit 1
      end
    end