setup.rb User Manual

What is setup.rb ?

setup.rb is the installer for (mainly) ruby scripts, and ruby extentions. You can automate installation and configuration of your program package with this script.

Usage from the real users' view

see "ruby setup.rb --help"

Usage from the developpers' view

Overview

setup.rb can handle an archive which includes many packages. In this sentence "package" means a set of commands, ruby scripts, ruby extentions, and data files.

Archive Structure

setup.rb requires that the archive is structured like this:

package-top/
  setup.rb
  setup/
    PACKAGE1.rb
    PACKAGE2.rb
        :
  lib/
    [dirs...]/ANYFILES.rb
  ext/
    [dirs...]/ANYFILES.c
  bin/
    [dirs...]/ANYFILES
  share/
    [dirs...]/ANYFILES

Each file/directories acts as below:

setup.rb
The installer core. This file is included in this archive. Just copy it to archive.
setup/*.rb
Packages' own installer. You must prepare these files. See next section for details.
lib/, ext/, bin/, share/
These directories includes data files which are to be installed. Use lib/ for ruby scripts, ext/ for ruby extentions, bin/ for binaries (commands), share/ for any other data files.

Archive Structure Example

This is an example archive that I'm using really.


tmail-0.9.6/
|- setup.rb
|- setup/
|  |- amstd.rb
|  |- raccrt.rb
|  |- strscan.rb
|  o- tmail.rb
|- lib/
|  |- amstd/
|  |  |- bench.rb
|  |  |- bug.rb
|  |  |- collfrom.rb
|  |  |- constdef.rb
|  |  |- dispatch.rb
|  |  |- errutil.rb
|  |  |- extmod.rb
|  |  |- fileutils.rb
|  |  |- futils.rb
|  |  |- gconst.rb
|  |  |- getdep.rb
|  |  |- info.rb
|  |  |- must.rb
|  |  |- pipeline.rb
|  |  |- rbparams.rb
|  |  |- recycle.rb
|  |  |- rubyemu.rb
|  |  |- strquote.rb
|  |  |- symbol.rb
|  |  |- timer.rb
|  |  |- to_s.rb
|  |  o- version.rb
|  |- raccrt/
|  |  o- parser.rb
|  |- strscan/
|  |  |- rscan.rb
|  |  |- scanner.rb
|  |  o- strscan.rb
|  o- tmail/
|      |- _loadlib.rb
|      |- base64.rb
|      |- encode.rb
|      |- facade.rb
|      |- field.rb
|      |- info.rb
|      |- loader.rb
|      |- mail.rb
|      |- net.rb
|      |- parsemail.rb
|      |- port.rb
|      |- rmails.rb
|      |- scanmail.rb
|      o- tmail.rb
o- ext/
   |- b64/
   |  |- MANIFEST
   |  |- depend
   |  |- extconf.rb
   |  o- tmbase64.c
   |- cparse/
   |  |- MANIFEST
   |  |- cparse.c
   |  o- extconf.rb
   |- cscan/
   |  |- MANIFEST
   |  |- cscan.c
   |  o- extconf.rb
   o- mails/
       |- MANIFEST
       |- depend
       |- extconf.rb
       o- mails.c

setup/*.rb examples

This is setup/tmail.rb for "tmail" package.

class Installer_tmail < Installer
  DIRS = {
    'lib/tmail' => 'tmail',
    'ext/b64'   => 'tmail',
    'ext/mails' => 'tmail'
  }
end

Hook tasks

You can hook any tasks, such as "config" "setup". Create the file "setup/PACKAGE_NAME.rb" and write down in it like this:

class Installer_PACKAGE_NAME < Installer
  def setup
    Dir.mkdir 'doc'
    system "rd2html #{package_root}/doc/manual.rd > doc/manual.html"
    super
  end
end

"pre_TASK" is invoked before the task is executed. "post_TASK" is invoked after the task is executed.

NOTE: Since setup.rb supports srcdir, it is not assured that the current directory equals the package top. Get real package's top directory by package_root().

License

GNU General Public License (GPL) version 2. For details, see file "GPL". NOTE: You CAN distribute your program under the any licenses you like. GPL does not force you to make your programs GPL if installer is GPLed one.


Copyright (c) 2000,2001 Minero Aoki <aamine@loveruby.net>