2000-09-01 07:31:05 +04:00
|
|
|
#!./miniruby
|
1999-01-20 07:59:39 +03:00
|
|
|
|
2009-09-15 01:43:00 +04:00
|
|
|
begin
|
|
|
|
load "./rbconfig.rb"
|
|
|
|
rescue LoadError
|
|
|
|
CONFIG = Hash.new {""}
|
|
|
|
else
|
|
|
|
include RbConfig
|
|
|
|
$".unshift File.expand_path("./rbconfig.rb")
|
|
|
|
end
|
1998-01-16 15:19:09 +03:00
|
|
|
|
2009-05-25 06:47:07 +04:00
|
|
|
srcdir = File.expand_path('../..', __FILE__)
|
2009-01-07 11:13:07 +03:00
|
|
|
unless defined?(CROSS_COMPILING) and CROSS_COMPILING
|
2009-05-25 06:47:07 +04:00
|
|
|
$:.replace([srcdir+"/lib", Dir.pwd])
|
2009-01-07 11:13:07 +03:00
|
|
|
end
|
2002-12-26 21:01:34 +03:00
|
|
|
require 'fileutils'
|
|
|
|
require 'shellwords'
|
2004-02-23 03:09:48 +03:00
|
|
|
require 'optparse'
|
|
|
|
require 'optparse/shellwords'
|
2011-08-04 10:44:13 +04:00
|
|
|
require 'ostruct'
|
2002-12-26 21:01:34 +03:00
|
|
|
|
2005-03-03 12:44:33 +03:00
|
|
|
STDOUT.sync = true
|
2003-05-02 10:07:54 +04:00
|
|
|
File.umask(0)
|
2002-10-22 08:19:26 +04:00
|
|
|
|
2008-02-20 07:08:54 +03:00
|
|
|
def parse_args(argv = ARGV)
|
2004-02-23 03:09:48 +03:00
|
|
|
$mantype = 'doc'
|
|
|
|
$destdir = nil
|
2006-09-16 11:06:57 +04:00
|
|
|
$extout = nil
|
2004-02-23 03:09:48 +03:00
|
|
|
$make = 'make'
|
|
|
|
$mflags = []
|
2005-03-03 12:44:33 +03:00
|
|
|
$install = []
|
2006-09-16 11:06:57 +04:00
|
|
|
$installed_list = nil
|
|
|
|
$dryrun = false
|
2006-09-17 12:43:19 +04:00
|
|
|
$rdocdir = nil
|
2008-02-13 18:49:56 +03:00
|
|
|
$data_mode = 0644
|
|
|
|
$prog_mode = 0755
|
2008-02-20 07:08:54 +03:00
|
|
|
$dir_mode = nil
|
|
|
|
$script_mode = nil
|
2009-01-12 06:43:57 +03:00
|
|
|
$strip = false
|
2010-11-10 01:20:12 +03:00
|
|
|
$cmdtype = (if File::ALT_SEPARATOR == '\\'
|
|
|
|
File.exist?("rubystub.exe") ? 'exe' : 'bat'
|
|
|
|
end)
|
2008-02-20 07:08:54 +03:00
|
|
|
mflags = []
|
2004-02-23 03:09:48 +03:00
|
|
|
opt = OptionParser.new
|
2009-09-15 01:43:00 +04:00
|
|
|
opt.on('-n', '--dry-run') {$dryrun = true}
|
2004-02-23 03:09:48 +03:00
|
|
|
opt.on('--dest-dir=DIR') {|dir| $destdir = dir}
|
2006-09-16 11:06:57 +04:00
|
|
|
opt.on('--extout=DIR') {|dir| $extout = (dir unless dir.empty?)}
|
2004-02-23 03:09:48 +03:00
|
|
|
opt.on('--make=COMMAND') {|make| $make = make}
|
|
|
|
opt.on('--mantype=MAN') {|man| $mantype = man}
|
2006-09-10 17:59:59 +04:00
|
|
|
opt.on('--make-flags=FLAGS', '--mflags', Shellwords) do |v|
|
2004-02-23 03:09:48 +03:00
|
|
|
if arg = v.first
|
|
|
|
arg.insert(0, '-') if /\A[^-][^=]*\Z/ =~ arg
|
|
|
|
end
|
|
|
|
$mflags.concat(v)
|
2003-01-27 22:48:02 +03:00
|
|
|
end
|
2009-09-15 01:24:39 +04:00
|
|
|
opt.on('-i', '--install=TYPE', $install_procs.keys) do |ins|
|
2006-09-16 11:06:57 +04:00
|
|
|
$install << ins
|
|
|
|
end
|
2008-02-13 18:49:56 +03:00
|
|
|
opt.on('--data-mode=OCTAL-MODE', OptionParser::OctalInteger) do |mode|
|
|
|
|
$data_mode = mode
|
|
|
|
end
|
|
|
|
opt.on('--prog-mode=OCTAL-MODE', OptionParser::OctalInteger) do |mode|
|
|
|
|
$prog_mode = mode
|
|
|
|
end
|
2008-02-20 07:08:54 +03:00
|
|
|
opt.on('--dir-mode=OCTAL-MODE', OptionParser::OctalInteger) do |mode|
|
|
|
|
$dir_mode = mode
|
|
|
|
end
|
|
|
|
opt.on('--script-mode=OCTAL-MODE', OptionParser::OctalInteger) do |mode|
|
|
|
|
$script_mode = mode
|
|
|
|
end
|
2006-09-16 11:06:57 +04:00
|
|
|
opt.on('--installed-list [FILENAME]') {|name| $installed_list = name}
|
2006-09-21 17:58:33 +04:00
|
|
|
opt.on('--rdoc-output [DIR]') {|dir| $rdocdir = dir}
|
2008-02-20 07:08:54 +03:00
|
|
|
opt.on('--cmd-type=TYPE', %w[bat cmd plain]) {|cmd| $cmdtype = (cmd unless cmd == 'plain')}
|
2009-01-12 06:43:57 +03:00
|
|
|
opt.on('--[no-]strip') {|strip| $strip = strip}
|
2008-02-20 07:08:54 +03:00
|
|
|
|
|
|
|
opt.order!(argv) do |v|
|
|
|
|
case v
|
|
|
|
when /\AINSTALL[-_]([-\w]+)=(.*)/
|
|
|
|
argv.unshift("--#{$1.tr('_', '-')}=#{$2}")
|
|
|
|
when /\A\w[-\w+]*=\z/
|
|
|
|
mflags << v
|
|
|
|
when /\A\w[-\w+]*\z/
|
|
|
|
$install << v.intern
|
|
|
|
else
|
|
|
|
raise OptionParser::InvalidArgument, v
|
|
|
|
end
|
2009-09-15 01:24:39 +04:00
|
|
|
end rescue abort "#{$!.message}\n#{opt.help}"
|
2003-01-27 22:48:02 +03:00
|
|
|
|
2009-09-15 01:43:00 +04:00
|
|
|
unless defined?(RbConfig)
|
|
|
|
puts opt.help
|
|
|
|
exit
|
|
|
|
end
|
|
|
|
|
2003-01-25 21:59:34 +03:00
|
|
|
$make, *rest = Shellwords.shellwords($make)
|
|
|
|
$mflags.unshift(*rest) unless rest.empty?
|
2008-02-20 07:08:54 +03:00
|
|
|
$mflags.unshift(*mflags)
|
2003-01-25 21:59:34 +03:00
|
|
|
|
2003-01-26 11:56:01 +03:00
|
|
|
def $mflags.set?(flag)
|
2008-03-21 03:24:30 +03:00
|
|
|
grep(/\A-(?!-).*#{flag.chr}/i) { return true }
|
2003-01-27 22:48:02 +03:00
|
|
|
false
|
2003-01-26 11:56:01 +03:00
|
|
|
end
|
2006-09-16 11:06:57 +04:00
|
|
|
def $mflags.defined?(var)
|
2008-02-20 07:08:54 +03:00
|
|
|
grep(/\A#{var}=(.*)/) {return block_given? ? yield($1) : $1}
|
2006-09-16 11:06:57 +04:00
|
|
|
false
|
|
|
|
end
|
2003-01-26 11:56:01 +03:00
|
|
|
|
|
|
|
if $mflags.set?(?n)
|
|
|
|
$dryrun = true
|
|
|
|
else
|
|
|
|
$mflags << '-n' if $dryrun
|
|
|
|
end
|
2003-01-25 21:59:34 +03:00
|
|
|
|
2006-09-16 11:06:57 +04:00
|
|
|
$destdir ||= $mflags.defined?("DESTDIR")
|
2006-09-17 12:43:19 +04:00
|
|
|
if $extout ||= $mflags.defined?("EXTOUT")
|
2009-04-30 20:34:01 +04:00
|
|
|
RbConfig.expand($extout)
|
2006-09-17 12:43:19 +04:00
|
|
|
end
|
2003-01-25 21:59:34 +03:00
|
|
|
|
2003-01-26 11:56:01 +03:00
|
|
|
$continue = $mflags.set?(?k)
|
2006-09-16 11:06:57 +04:00
|
|
|
|
|
|
|
if $installed_list ||= $mflags.defined?('INSTALLED_LIST')
|
2009-04-30 20:34:01 +04:00
|
|
|
RbConfig.expand($installed_list, RbConfig::CONFIG)
|
2006-09-16 11:06:57 +04:00
|
|
|
$installed_list = open($installed_list, "ab")
|
|
|
|
$installed_list.sync = true
|
|
|
|
end
|
2006-09-17 12:43:19 +04:00
|
|
|
|
|
|
|
$rdocdir ||= $mflags.defined?('RDOCOUT')
|
2008-02-20 07:08:54 +03:00
|
|
|
|
|
|
|
$dir_mode ||= $prog_mode | 0700
|
|
|
|
$script_mode ||= $prog_mode
|
2003-01-25 21:59:34 +03:00
|
|
|
end
|
|
|
|
|
2006-09-17 12:43:19 +04:00
|
|
|
$install_procs = Hash.new {[]}
|
|
|
|
def install?(*types, &block)
|
|
|
|
$install_procs[:all] <<= block
|
|
|
|
types.each do |type|
|
|
|
|
$install_procs[type] <<= block
|
|
|
|
end
|
2005-03-03 12:44:33 +03:00
|
|
|
end
|
|
|
|
|
2011-07-22 11:12:22 +04:00
|
|
|
def strip_file(files)
|
2009-01-12 06:43:57 +03:00
|
|
|
if !defined?($strip_command) and (cmd = CONFIG["STRIP"])
|
|
|
|
case cmd
|
|
|
|
when "", "true", ":" then return
|
|
|
|
else $strip_command = Shellwords.shellwords(cmd)
|
|
|
|
end
|
|
|
|
elsif !$strip_command
|
|
|
|
return
|
|
|
|
end
|
2011-07-22 11:12:22 +04:00
|
|
|
system(*($strip_command + [files].flatten))
|
2009-01-12 06:43:57 +03:00
|
|
|
end
|
|
|
|
|
2003-07-29 11:08:04 +04:00
|
|
|
def install(src, dest, options = {})
|
2009-01-12 06:43:57 +03:00
|
|
|
options = options.clone
|
|
|
|
strip = options.delete(:strip)
|
2003-07-29 14:24:28 +04:00
|
|
|
options[:preserve] = true
|
2009-01-12 06:43:57 +03:00
|
|
|
d = with_destdir(dest)
|
|
|
|
super(src, d, options)
|
2011-07-22 11:12:22 +04:00
|
|
|
srcs = Array(src)
|
2009-01-12 10:49:22 +03:00
|
|
|
if strip
|
2011-07-22 11:12:22 +04:00
|
|
|
d = srcs.map {|src| File.join(d, File.basename(src))} if $made_dirs[dest]
|
2009-01-12 06:43:57 +03:00
|
|
|
strip_file(d)
|
|
|
|
end
|
2006-09-16 11:06:57 +04:00
|
|
|
if $installed_list
|
2011-07-22 11:12:22 +04:00
|
|
|
dest = srcs.map {|src| File.join(dest, File.basename(src))} if $made_dirs[dest]
|
2006-09-16 11:06:57 +04:00
|
|
|
$installed_list.puts dest
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def ln_sf(src, dest)
|
2006-09-17 12:43:19 +04:00
|
|
|
super(src, with_destdir(dest))
|
2006-09-16 11:06:57 +04:00
|
|
|
$installed_list.puts dest if $installed_list
|
2003-01-26 00:42:42 +03:00
|
|
|
end
|
2003-07-29 11:08:04 +04:00
|
|
|
|
2003-01-26 01:23:17 +03:00
|
|
|
$made_dirs = {}
|
|
|
|
def makedirs(dirs)
|
|
|
|
dirs = fu_list(dirs)
|
2006-09-17 12:43:19 +04:00
|
|
|
dirs.collect! do |dir|
|
|
|
|
realdir = with_destdir(dir)
|
|
|
|
realdir unless $made_dirs.fetch(dir) do
|
2003-01-26 01:23:17 +03:00
|
|
|
$made_dirs[dir] = true
|
2006-09-21 17:58:33 +04:00
|
|
|
$installed_list.puts(File.join(dir, "")) if $installed_list
|
2006-09-17 12:43:19 +04:00
|
|
|
File.directory?(realdir)
|
2003-01-26 01:23:17 +03:00
|
|
|
end
|
2006-09-17 12:43:19 +04:00
|
|
|
end.compact!
|
2008-02-20 07:08:54 +03:00
|
|
|
super(dirs, :mode => $dir_mode) unless dirs.empty?
|
2003-01-26 01:23:17 +03:00
|
|
|
end
|
2000-02-17 10:11:22 +03:00
|
|
|
|
2009-01-12 06:39:58 +03:00
|
|
|
FalseProc = proc {false}
|
|
|
|
def path_matcher(pat)
|
|
|
|
if pat and !pat.empty?
|
|
|
|
proc {|f| pat.any? {|n| File.fnmatch?(n, f)}}
|
|
|
|
else
|
|
|
|
FalseProc
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2006-12-04 17:49:47 +03:00
|
|
|
def install_recursive(srcdir, dest, options = {})
|
2008-02-12 06:16:07 +03:00
|
|
|
opts = options.clone
|
|
|
|
noinst = opts.delete(:no_install)
|
|
|
|
glob = opts.delete(:glob) || "*"
|
2009-01-12 06:39:58 +03:00
|
|
|
subpath = (srcdir.size+1)..-1
|
2010-12-10 12:27:53 +03:00
|
|
|
prune = []
|
|
|
|
skip = []
|
2009-01-12 06:39:58 +03:00
|
|
|
if noinst
|
|
|
|
if Array === noinst
|
|
|
|
prune = noinst.grep(/#{File::SEPARATOR}/o).map!{|f| f.chomp(File::SEPARATOR)}
|
|
|
|
skip = noinst.grep(/\A[^#{File::SEPARATOR}]*\z/o)
|
|
|
|
else
|
|
|
|
if noinst.index(File::SEPARATOR)
|
|
|
|
prune = [noinst]
|
2007-06-10 07:06:15 +04:00
|
|
|
else
|
2009-01-12 06:39:58 +03:00
|
|
|
skip = [noinst]
|
2007-06-10 07:06:15 +04:00
|
|
|
end
|
|
|
|
end
|
2009-01-12 06:39:58 +03:00
|
|
|
end
|
2010-12-10 12:27:53 +03:00
|
|
|
skip |= %w"#*# *~ *.old *.bak *.orig *.rej *.diff *.patch *.core"
|
|
|
|
prune = path_matcher(prune)
|
|
|
|
skip = path_matcher(skip)
|
2009-01-12 06:39:58 +03:00
|
|
|
File.directory?(srcdir) or return rescue return
|
|
|
|
paths = [[srcdir, dest, true]]
|
|
|
|
found = []
|
|
|
|
while file = paths.shift
|
|
|
|
found << file
|
|
|
|
file, d, dir = *file
|
|
|
|
if dir
|
|
|
|
files = []
|
|
|
|
Dir.foreach(file) do |f|
|
|
|
|
src = File.join(file, f)
|
|
|
|
d = File.join(dest, dir = src[subpath])
|
2012-09-04 05:40:11 +04:00
|
|
|
stat = File.lstat(src) rescue next
|
2009-01-12 06:39:58 +03:00
|
|
|
if stat.directory?
|
|
|
|
files << [src, d, true] if /\A\./ !~ f and !prune[dir]
|
2012-09-04 05:40:11 +04:00
|
|
|
elsif stat.symlink?
|
|
|
|
# skip
|
2009-01-12 06:39:58 +03:00
|
|
|
else
|
|
|
|
files << [src, d, false] if File.fnmatch?(glob, f) and !skip[f]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
paths.insert(0, *files)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
for src, d, dir in found
|
|
|
|
if dir
|
2006-09-17 12:43:19 +04:00
|
|
|
makedirs(d)
|
|
|
|
else
|
2011-10-30 05:50:38 +04:00
|
|
|
makedirs(d[/.*(?=\/)/m])
|
2010-12-10 12:27:53 +03:00
|
|
|
if block_given?
|
|
|
|
yield src, d, opts
|
|
|
|
else
|
|
|
|
install src, d, opts
|
|
|
|
end
|
2006-09-17 12:43:19 +04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2008-03-21 03:24:30 +03:00
|
|
|
def open_for_install(path, mode)
|
|
|
|
data = open(realpath = with_destdir(path), "rb") {|f| f.read} rescue nil
|
|
|
|
newdata = yield
|
2006-09-17 12:43:19 +04:00
|
|
|
unless $dryrun
|
2008-03-21 03:24:30 +03:00
|
|
|
unless newdata == data
|
|
|
|
open(realpath, "wb", mode) {|f| f.write newdata}
|
|
|
|
end
|
2008-02-20 07:08:54 +03:00
|
|
|
File.chmod(mode, realpath)
|
2006-09-17 12:43:19 +04:00
|
|
|
end
|
2008-02-20 07:08:54 +03:00
|
|
|
$installed_list.puts path if $installed_list
|
2006-09-17 12:43:19 +04:00
|
|
|
end
|
|
|
|
|
2004-02-23 03:09:48 +03:00
|
|
|
def with_destdir(dir)
|
2005-07-05 18:45:33 +04:00
|
|
|
return dir if !$destdir or $destdir.empty?
|
2004-02-23 03:09:48 +03:00
|
|
|
dir = dir.sub(/\A\w:/, '') if File::PATH_SEPARATOR == ';'
|
|
|
|
$destdir + dir
|
2003-12-28 20:25:31 +03:00
|
|
|
end
|
|
|
|
|
2009-03-09 08:33:59 +03:00
|
|
|
def prepare(mesg, basedir, subdirs=nil)
|
2012-03-13 05:59:54 +04:00
|
|
|
return unless basedir
|
2009-03-09 08:33:59 +03:00
|
|
|
case
|
|
|
|
when !subdirs
|
|
|
|
dirs = basedir
|
|
|
|
when subdirs.size == 0
|
|
|
|
subdirs = nil
|
|
|
|
when subdirs.size == 1
|
|
|
|
dirs = [basedir = File.join(basedir, subdirs)]
|
|
|
|
subdirs = nil
|
|
|
|
else
|
|
|
|
dirs = [basedir, *subdirs.collect {|dir| File.join(basedir, dir)}]
|
|
|
|
end
|
|
|
|
printf("installing %-18s %s%s\n", "#{mesg}:", basedir,
|
|
|
|
(subdirs ? " (#{subdirs.join(', ')})" : ""))
|
|
|
|
makedirs(dirs)
|
|
|
|
end
|
|
|
|
|
2012-03-13 05:59:54 +04:00
|
|
|
def CONFIG.[](name, mandatory = false)
|
|
|
|
value = super(name)
|
|
|
|
if mandatory
|
|
|
|
raise "CONFIG['#{name}'] must be set" if !value or value.empty?
|
|
|
|
end
|
|
|
|
value
|
|
|
|
end
|
|
|
|
|
2002-10-22 08:19:26 +04:00
|
|
|
exeext = CONFIG["EXEEXT"]
|
|
|
|
|
2012-03-13 05:59:54 +04:00
|
|
|
ruby_install_name = CONFIG["ruby_install_name", true]
|
2002-10-22 08:19:26 +04:00
|
|
|
rubyw_install_name = CONFIG["rubyw_install_name"]
|
2007-12-26 08:39:03 +03:00
|
|
|
goruby_install_name = "go" + ruby_install_name
|
2000-02-17 10:11:22 +03:00
|
|
|
|
2012-03-13 05:59:54 +04:00
|
|
|
bindir = CONFIG["bindir", true]
|
|
|
|
libdir = CONFIG["libdir", true]
|
|
|
|
archhdrdir = rubyhdrdir = CONFIG["rubyhdrdir", true]
|
|
|
|
archhdrdir += "/" + CONFIG["arch", true]
|
|
|
|
rubylibdir = CONFIG["rubylibdir", true]
|
|
|
|
archlibdir = CONFIG["archdir", true]
|
2006-09-17 12:43:19 +04:00
|
|
|
sitelibdir = CONFIG["sitelibdir"]
|
|
|
|
sitearchlibdir = CONFIG["sitearchdir"]
|
2007-11-03 14:35:59 +03:00
|
|
|
vendorlibdir = CONFIG["vendorlibdir"]
|
|
|
|
vendorarchlibdir = CONFIG["vendorarchdir"]
|
2012-03-13 05:59:54 +04:00
|
|
|
mandir = CONFIG["mandir", true]
|
2012-05-03 18:56:39 +04:00
|
|
|
docdir = CONFIG["docdir", true]
|
2002-10-23 21:40:36 +04:00
|
|
|
configure_args = Shellwords.shellwords(CONFIG["configure_args"])
|
2002-11-04 14:06:03 +03:00
|
|
|
enable_shared = CONFIG["ENABLE_SHARED"] == 'yes'
|
2012-03-13 05:59:54 +04:00
|
|
|
dll = CONFIG["LIBRUBY_SO", enable_shared]
|
|
|
|
lib = CONFIG["LIBRUBY", true]
|
|
|
|
arc = CONFIG["LIBRUBY_A", true]
|
|
|
|
major = CONFIG["MAJOR", true]
|
|
|
|
minor = CONFIG["MINOR", true]
|
2010-11-06 01:30:13 +03:00
|
|
|
load_relative = configure_args.include?("--enable-load-relative")
|
2002-10-22 08:19:26 +04:00
|
|
|
|
2008-02-20 07:08:54 +03:00
|
|
|
install?(:local, :arch, :bin, :'bin-arch') do
|
2009-03-09 08:33:59 +03:00
|
|
|
prepare "binary commands", bindir
|
2003-01-21 11:03:05 +03:00
|
|
|
|
2009-01-12 06:43:57 +03:00
|
|
|
install ruby_install_name+exeext, bindir, :mode => $prog_mode, :strip => $strip
|
2006-02-24 06:12:27 +03:00
|
|
|
if rubyw_install_name and !rubyw_install_name.empty?
|
2009-01-12 06:43:57 +03:00
|
|
|
install rubyw_install_name+exeext, bindir, :mode => $prog_mode, :strip => $strip
|
2006-02-24 06:12:27 +03:00
|
|
|
end
|
2007-12-26 08:39:03 +03:00
|
|
|
if File.exist? goruby_install_name+exeext
|
2009-01-12 06:43:57 +03:00
|
|
|
install goruby_install_name+exeext, bindir, :mode => $prog_mode, :strip => $strip
|
2007-12-26 08:39:03 +03:00
|
|
|
end
|
2006-02-24 06:12:27 +03:00
|
|
|
if enable_shared and dll != lib
|
2009-01-12 06:43:57 +03:00
|
|
|
install dll, bindir, :mode => $prog_mode, :strip => $strip
|
2006-02-24 06:12:27 +03:00
|
|
|
end
|
2009-03-09 08:33:59 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
install?(:local, :arch, :lib) do
|
|
|
|
prepare "base libraries", libdir
|
|
|
|
|
2009-01-12 06:43:57 +03:00
|
|
|
install lib, libdir, :mode => $prog_mode, :strip => $strip unless lib == arc
|
2008-02-13 18:49:56 +03:00
|
|
|
install arc, libdir, :mode => $data_mode
|
2009-03-09 08:33:59 +03:00
|
|
|
if dll == lib and dll != arc
|
|
|
|
for link in CONFIG["LIBRUBY_ALIASES"].split
|
|
|
|
ln_sf(dll, File.join(libdir, link))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
prepare "arch files", archlibdir
|
2008-02-13 18:49:56 +03:00
|
|
|
install "rbconfig.rb", archlibdir, :mode => $data_mode
|
2006-02-24 06:12:27 +03:00
|
|
|
if CONFIG["ARCHFILE"]
|
|
|
|
for file in CONFIG["ARCHFILE"].split
|
2008-02-13 18:49:56 +03:00
|
|
|
install file, archlibdir, :mode => $data_mode
|
2006-02-24 06:12:27 +03:00
|
|
|
end
|
1999-01-20 07:59:39 +03:00
|
|
|
end
|
1999-08-13 09:45:20 +04:00
|
|
|
end
|
2002-09-08 13:08:15 +04:00
|
|
|
|
2010-10-25 19:29:32 +04:00
|
|
|
install?(:local, :arch, :data) do
|
|
|
|
pc = CONFIG["ruby_pc"]
|
2010-10-26 07:47:15 +04:00
|
|
|
if pc and File.file?(pc) and File.size?(pc)
|
2010-10-25 19:29:32 +04:00
|
|
|
prepare "pkgconfig data", pkgconfigdir = File.join(libdir, "pkgconfig")
|
|
|
|
install pc, pkgconfigdir, :mode => $data_mode
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-09-15 01:24:39 +04:00
|
|
|
install?(:ext, :arch, :'ext-arch') do
|
|
|
|
prepare "extension objects", archlibdir
|
2010-07-16 07:06:10 +04:00
|
|
|
noinst = %w[-* -*/] | (CONFIG["no_install_files"] || "").split
|
2009-09-15 01:24:39 +04:00
|
|
|
install_recursive("#{$extout}/#{CONFIG['arch']}", archlibdir, :no_install => noinst, :mode => $prog_mode, :strip => $strip)
|
|
|
|
prepare "extension objects", sitearchlibdir
|
|
|
|
prepare "extension objects", vendorarchlibdir
|
|
|
|
end
|
|
|
|
install?(:ext, :arch, :'ext-arch') do
|
|
|
|
prepare "extension headers", archhdrdir
|
2010-01-05 08:59:23 +03:00
|
|
|
install_recursive("#{$extout}/include/#{CONFIG['arch']}", archhdrdir, :glob => "*.h", :mode => $data_mode)
|
2009-09-15 01:24:39 +04:00
|
|
|
end
|
|
|
|
install?(:ext, :comm, :'ext-comm') do
|
|
|
|
prepare "extension scripts", rubylibdir
|
|
|
|
install_recursive("#{$extout}/common", rubylibdir, :mode => $data_mode)
|
|
|
|
prepare "extension scripts", sitelibdir
|
|
|
|
prepare "extension scripts", vendorlibdir
|
|
|
|
end
|
|
|
|
install?(:ext, :comm, :'ext-comm') do
|
|
|
|
hdrdir = rubyhdrdir + "/ruby"
|
|
|
|
prepare "extension headers", hdrdir
|
|
|
|
install_recursive("#{$extout}/include/ruby", hdrdir, :glob => "*.h", :mode => $data_mode)
|
2006-09-16 11:06:57 +04:00
|
|
|
end
|
|
|
|
|
2008-12-22 16:19:08 +03:00
|
|
|
install?(:doc, :rdoc) do
|
2006-09-17 12:43:19 +04:00
|
|
|
if $rdocdir
|
2009-05-23 20:07:46 +04:00
|
|
|
ridatadir = File.join(CONFIG['ridir'], CONFIG['ruby_version'], "system")
|
2009-03-09 08:33:59 +03:00
|
|
|
prepare "rdoc", ridatadir
|
2008-02-13 18:49:56 +03:00
|
|
|
install_recursive($rdocdir, ridatadir, :mode => $data_mode)
|
2006-09-17 12:43:19 +04:00
|
|
|
end
|
|
|
|
end
|
2008-12-22 16:19:08 +03:00
|
|
|
install?(:doc, :capi) do
|
2012-05-03 18:56:39 +04:00
|
|
|
prepare "capi-docs", docdir
|
|
|
|
install_recursive "doc/capi", docdir+"/capi", :mode => $data_mode
|
2008-12-22 16:19:08 +03:00
|
|
|
end
|
1999-08-13 09:45:20 +04:00
|
|
|
|
2010-11-06 01:30:13 +03:00
|
|
|
if load_relative
|
|
|
|
PROLOG_SCRIPT = <<EOS
|
|
|
|
#!/bin/sh\n# -*- ruby -*-
|
|
|
|
bindir=`#{CONFIG["CHDIR"]} "${0%/*}" 2>/dev/null; pwd`
|
|
|
|
EOS
|
|
|
|
if CONFIG["LIBRUBY_RELATIVE"] != 'yes' and libpathenv = CONFIG["LIBPATHENV"]
|
|
|
|
pathsep = File::PATH_SEPARATOR
|
|
|
|
PROLOG_SCRIPT << <<EOS
|
|
|
|
prefix="${bindir%/bin}"
|
|
|
|
export #{libpathenv}="$prefix/lib${#{libpathenv}#{pathsep}+#{pathsep}$#{libpathenv}}"
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
PROLOG_SCRIPT << %Q[exec "$bindir/#{ruby_install_name}" -x "$0" "$@"\n]
|
|
|
|
else
|
|
|
|
PROLOG_SCRIPT = nil
|
|
|
|
end
|
|
|
|
|
2008-02-20 07:08:54 +03:00
|
|
|
install?(:local, :comm, :bin, :'bin-comm') do
|
2009-03-09 08:33:59 +03:00
|
|
|
prepare "command scripts", bindir
|
2006-09-17 12:43:19 +04:00
|
|
|
|
|
|
|
ruby_shebang = File.join(bindir, ruby_install_name)
|
2008-03-21 03:24:30 +03:00
|
|
|
if File::ALT_SEPARATOR
|
2008-02-20 07:08:54 +03:00
|
|
|
ruby_bin = ruby_shebang.tr(File::SEPARATOR, File::ALT_SEPARATOR)
|
2010-11-10 01:20:12 +03:00
|
|
|
if $cmdtype == 'exe'
|
|
|
|
stub = File.open("rubystub.exe", "rb") {|f| f.read} << "\n" rescue nil
|
|
|
|
end
|
2006-09-16 11:06:57 +04:00
|
|
|
end
|
2009-04-09 22:01:26 +04:00
|
|
|
if trans = CONFIG["program_transform_name"]
|
|
|
|
exp = []
|
|
|
|
trans.gsub!(/\$\$/, '$')
|
2009-08-26 14:56:55 +04:00
|
|
|
trans.scan(%r[\G[\s;]*(/(?:\\.|[^/])*/)?([sy])(\\?\W)((?:(?!\3)(?:\\.|.))*)\3((?:(?!\3)(?:\\.|.))*)\3([gi]*)]) do
|
2009-04-09 22:01:26 +04:00
|
|
|
|addr, cmd, sep, pat, rep, opt|
|
|
|
|
addr &&= Regexp.new(addr[/\A\/(.*)\/\z/, 1])
|
|
|
|
case cmd
|
|
|
|
when 's'
|
|
|
|
next if pat == '^' and rep.empty?
|
|
|
|
exp << [addr, (opt.include?('g') ? :gsub! : :sub!),
|
2009-06-25 08:10:21 +04:00
|
|
|
Regexp.new(pat, opt.include?('i')), rep.gsub(/&/){'\&'}]
|
2009-04-09 22:01:26 +04:00
|
|
|
when 'y'
|
|
|
|
exp << [addr, :tr!, Regexp.quote(pat), rep]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
trans = proc do |base|
|
|
|
|
exp.each {|addr, opt, pat, rep| base.__send__(opt, pat, rep) if !addr or addr =~ base}
|
|
|
|
base
|
|
|
|
end
|
|
|
|
elsif /ruby/ =~ ruby_install_name
|
|
|
|
trans = proc {|base| ruby_install_name.sub(/ruby/, base)}
|
|
|
|
else
|
|
|
|
trans = proc {|base| base}
|
|
|
|
end
|
2010-12-10 12:27:53 +03:00
|
|
|
install_recursive(File.join(srcdir, "bin"), bindir) do |src, cmd|
|
2011-10-30 05:50:38 +04:00
|
|
|
cmd = cmd.sub(/[^\/]*\z/m) {|n| RbConfig.expand(trans[n])}
|
2003-01-21 11:03:05 +03:00
|
|
|
|
2006-09-16 11:06:57 +04:00
|
|
|
shebang = ''
|
|
|
|
body = ''
|
2008-02-20 07:08:54 +03:00
|
|
|
open(src, "rb") do |f|
|
2006-09-16 11:06:57 +04:00
|
|
|
shebang = f.gets
|
|
|
|
body = f.read
|
2008-02-20 07:08:54 +03:00
|
|
|
end
|
2010-11-06 01:30:13 +03:00
|
|
|
if PROLOG_SCRIPT
|
|
|
|
shebang.sub!(/\A(\#!.*?ruby\b)?/) {PROLOG_SCRIPT + ($1 || "#!ruby\n")}
|
|
|
|
else
|
|
|
|
shebang.sub!(/\A\#!.*?ruby\b/) {"#!" + ruby_shebang}
|
|
|
|
end
|
2008-02-20 07:08:54 +03:00
|
|
|
shebang.sub!(/\r$/, '')
|
|
|
|
body.gsub!(/\r$/, '')
|
|
|
|
|
|
|
|
cmd << ".#{$cmdtype}" if $cmdtype
|
2008-03-21 03:24:30 +03:00
|
|
|
open_for_install(cmd, $script_mode) do
|
2008-02-20 07:08:54 +03:00
|
|
|
case $cmdtype
|
2010-11-10 01:20:12 +03:00
|
|
|
when "exe"
|
|
|
|
stub + shebang + body
|
2008-02-20 07:08:54 +03:00
|
|
|
when "bat"
|
2010-04-24 11:27:18 +04:00
|
|
|
[<<-"EOH".gsub(/^\s+/, ''), shebang, body, "__END__\n:endofruby\n"].join.gsub(/$/, "\r")
|
2009-12-27 03:44:11 +03:00
|
|
|
@echo off
|
|
|
|
@if not "%~d0" == "~d0" goto WinNT
|
|
|
|
#{ruby_bin} -x "#{cmd}" %1 %2 %3 %4 %5 %6 %7 %8 %9
|
|
|
|
@goto endofruby
|
|
|
|
:WinNT
|
|
|
|
"%~dp0#{ruby_install_name}" -x "%~f0" %*
|
|
|
|
@goto endofruby
|
|
|
|
EOH
|
2008-02-20 07:08:54 +03:00
|
|
|
when "cmd"
|
2010-04-24 11:27:18 +04:00
|
|
|
<<"/EOH" << shebang << body
|
2008-02-20 07:08:54 +03:00
|
|
|
@"%~dp0#{ruby_install_name}" -x "%~f0" %*
|
|
|
|
@exit /b %ERRORLEVEL%
|
2009-01-08 11:32:17 +03:00
|
|
|
/EOH
|
2008-02-20 07:08:54 +03:00
|
|
|
else
|
2008-03-21 03:24:30 +03:00
|
|
|
shebang + body
|
2008-02-20 07:08:54 +03:00
|
|
|
end
|
2006-09-16 11:06:57 +04:00
|
|
|
end
|
2003-01-21 11:03:05 +03:00
|
|
|
end
|
2006-09-21 17:58:33 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
install?(:local, :comm, :lib) do
|
2009-03-09 08:33:59 +03:00
|
|
|
prepare "library scripts", rubylibdir
|
2012-11-10 07:15:55 +04:00
|
|
|
noinst = %w[README* *.txt *.rdoc *.gemspec]
|
2008-10-16 09:30:38 +04:00
|
|
|
install_recursive(File.join(srcdir, "lib"), rubylibdir, :no_install => noinst, :mode => $data_mode)
|
2006-09-21 17:58:33 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
install?(:local, :arch, :lib) do
|
2009-03-09 08:33:59 +03:00
|
|
|
prepare "common headers", rubyhdrdir
|
1999-01-20 07:59:39 +03:00
|
|
|
|
2007-06-10 07:06:15 +04:00
|
|
|
noinst = []
|
2009-02-02 02:12:52 +03:00
|
|
|
unless RUBY_PLATFORM =~ /mswin|mingw|bccwin/
|
2007-06-10 07:06:15 +04:00
|
|
|
noinst << "win32.h"
|
2006-09-16 11:06:57 +04:00
|
|
|
end
|
2007-06-10 07:06:15 +04:00
|
|
|
noinst = nil if noinst.empty?
|
2009-03-09 08:33:59 +03:00
|
|
|
install_recursive(File.join(srcdir, "include"), rubyhdrdir, :no_install => noinst, :glob => "*.h", :mode => $data_mode)
|
2005-03-03 12:44:33 +03:00
|
|
|
end
|
1999-01-20 07:59:39 +03:00
|
|
|
|
2006-09-16 11:06:57 +04:00
|
|
|
install?(:local, :comm, :man) do
|
2009-03-09 08:33:59 +03:00
|
|
|
mdocs = Dir["#{srcdir}/man/*.[1-9]"]
|
|
|
|
prepare "manpages", mandir, ([] | mdocs.collect {|mdoc| mdoc[/\d+$/]}).sort.collect {|sec| "man#{sec}"}
|
2006-09-21 17:58:33 +04:00
|
|
|
|
2009-03-09 08:33:59 +03:00
|
|
|
mandir = File.join(mandir, "man")
|
2008-10-25 19:15:24 +04:00
|
|
|
has_goruby = File.exist?(goruby_install_name+exeext)
|
2009-01-12 21:08:02 +03:00
|
|
|
require File.join(srcdir, "tool/mdoc2man.rb") if $mantype != "doc"
|
2009-03-09 08:33:59 +03:00
|
|
|
mdocs.each do |mdoc|
|
2006-09-16 11:06:57 +04:00
|
|
|
next unless File.file?(mdoc) and open(mdoc){|fh| fh.read(1) == '.'}
|
2009-03-09 09:19:57 +03:00
|
|
|
base = File.basename(mdoc)
|
|
|
|
if base == "goruby.1"
|
2008-10-25 19:15:24 +04:00
|
|
|
next unless has_goruby
|
|
|
|
end
|
2003-07-09 10:45:45 +04:00
|
|
|
|
2009-03-09 08:33:59 +03:00
|
|
|
destdir = mandir + (section = mdoc[/\d+$/])
|
2009-03-09 09:19:57 +03:00
|
|
|
destname = ruby_install_name.sub(/ruby/, base.chomp(".#{section}"))
|
2008-10-25 19:15:24 +04:00
|
|
|
destfile = File.join(destdir, "#{destname}.#{section}")
|
2003-01-20 15:51:50 +03:00
|
|
|
|
2006-09-16 11:06:57 +04:00
|
|
|
if $mantype == "doc"
|
2008-02-13 18:49:56 +03:00
|
|
|
install mdoc, destfile, :mode => $data_mode
|
2006-09-16 11:06:57 +04:00
|
|
|
else
|
2010-05-07 06:30:57 +04:00
|
|
|
class << (w = [])
|
|
|
|
alias print push
|
2009-01-07 11:13:07 +03:00
|
|
|
end
|
2010-05-07 06:30:57 +04:00
|
|
|
open(mdoc) {|r| Mdoc2Man.mdoc2man(r, w)}
|
|
|
|
open_for_install(destfile, $data_mode) {w.join("")}
|
2006-09-16 11:06:57 +04:00
|
|
|
end
|
2003-01-20 15:51:50 +03:00
|
|
|
end
|
|
|
|
end
|
2002-10-22 08:19:26 +04:00
|
|
|
|
2011-08-03 22:08:57 +04:00
|
|
|
# :stopdoc:
|
2011-08-04 10:44:13 +04:00
|
|
|
module Gem
|
|
|
|
if defined?(Specification)
|
|
|
|
remove_const(:Specification)
|
|
|
|
end
|
|
|
|
|
|
|
|
class Specification < OpenStruct
|
|
|
|
def initialize(*)
|
|
|
|
super
|
|
|
|
yield(self) if defined?(yield)
|
|
|
|
self.executables ||= []
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.load(path)
|
|
|
|
src = File.open(path, "rb") {|f| f.read}
|
|
|
|
src.sub!(/\A#.*/, '')
|
|
|
|
eval(src, nil, path)
|
|
|
|
end
|
2012-12-01 07:35:36 +04:00
|
|
|
|
|
|
|
def to_ruby
|
|
|
|
<<-GEMSPEC
|
|
|
|
Gem::Specification.new do |s|
|
|
|
|
s.name = #{name.dump}
|
|
|
|
s.version = #{version.dump}
|
|
|
|
s.summary = #{summary.dump}
|
|
|
|
s.description = #{description.dump}
|
|
|
|
s.homepage = #{homepage.dump}
|
|
|
|
s.authors = #{authors.inspect}
|
|
|
|
s.email = #{email.inspect}
|
|
|
|
s.files = #{files.inspect}
|
|
|
|
end
|
|
|
|
GEMSPEC
|
|
|
|
end
|
2011-08-04 10:44:13 +04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-08-03 22:08:57 +04:00
|
|
|
module RbInstall
|
|
|
|
module Specs
|
2012-12-01 07:35:36 +04:00
|
|
|
class FileCollector
|
|
|
|
def initialize(base_dir)
|
|
|
|
@base_dir = base_dir
|
|
|
|
end
|
|
|
|
|
|
|
|
def collect
|
|
|
|
ruby_libraries + built_libraries
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
def type
|
|
|
|
/\/(ext|lib)?\/.*?\z/ =~ @base_dir
|
|
|
|
$1
|
|
|
|
end
|
|
|
|
|
|
|
|
def ruby_libraries
|
|
|
|
case type
|
|
|
|
when "ext"
|
|
|
|
prefix = "#{$extout}/common/"
|
|
|
|
base = "#{prefix}#{relative_base}"
|
|
|
|
when "lib"
|
|
|
|
base = @base_dir
|
|
|
|
prefix = base.sub(/lib\/.*?\z/, "") + "lib/"
|
|
|
|
end
|
|
|
|
|
|
|
|
Dir.glob("#{base}{.rb,/**/*.rb}").collect do |ruby_source|
|
|
|
|
remove_prefix(prefix, ruby_source)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def built_libraries
|
|
|
|
case type
|
|
|
|
when "ext"
|
|
|
|
prefix = "#{$extout}/#{CONFIG['arch']}/"
|
|
|
|
base = "#{prefix}#{relative_base}"
|
|
|
|
Dir.glob("#{base}{.so,/**/*.so}").collect do |built_library|
|
|
|
|
remove_prefix(prefix, built_library)
|
|
|
|
end
|
|
|
|
when "lib"
|
|
|
|
[]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def relative_base
|
|
|
|
/\/#{Regexp.escape(type)}\/(.*?)\z/ =~ @base_dir
|
|
|
|
$1
|
|
|
|
end
|
|
|
|
|
|
|
|
def remove_prefix(prefix, string)
|
|
|
|
string.sub(/\A#{Regexp.escape(prefix)}/, "")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-08-04 11:08:48 +04:00
|
|
|
class Reader < Struct.new(:src)
|
2011-08-03 22:08:57 +04:00
|
|
|
def gemspec
|
|
|
|
@gemspec ||= begin
|
2012-12-01 07:35:36 +04:00
|
|
|
spec = Gem::Specification.load(src) || raise("invalid spec in #{src}")
|
|
|
|
file_collector = FileCollector.new(File.dirname(src))
|
|
|
|
spec.files = file_collector.collect
|
|
|
|
spec
|
2011-08-03 22:08:57 +04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def spec_source
|
2012-12-01 07:35:36 +04:00
|
|
|
@gemspec.to_ruby
|
2011-08-03 22:08:57 +04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-12-01 07:35:36 +04:00
|
|
|
class Generator < Struct.new(:name, :base_dir, :src, :execs)
|
2011-08-03 22:08:57 +04:00
|
|
|
def gemspec
|
|
|
|
@gemspec ||= eval spec_source
|
|
|
|
end
|
|
|
|
|
|
|
|
def spec_source
|
|
|
|
<<-GEMSPEC
|
|
|
|
Gem::Specification.new do |s|
|
|
|
|
s.name = #{name.dump}
|
|
|
|
s.version = #{version.dump}
|
|
|
|
s.summary = "This #{name} is bundled with Ruby"
|
|
|
|
s.executables = #{execs.inspect}
|
2012-12-01 07:35:36 +04:00
|
|
|
s.files = #{files.inspect}
|
2011-08-03 22:08:57 +04:00
|
|
|
end
|
|
|
|
GEMSPEC
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
def version
|
|
|
|
version = open(src) { |f|
|
|
|
|
f.find { |s| /^\s*\w*VERSION\s*=(?!=)/ =~ s }
|
|
|
|
} or return
|
|
|
|
version.split(%r"=\s*", 2)[1].strip[/\A([\'\"])(.*?)\1/, 2]
|
|
|
|
end
|
2012-12-01 07:35:36 +04:00
|
|
|
|
|
|
|
def files
|
|
|
|
file_collector = FileCollector.new(base_dir)
|
|
|
|
file_collector.collect
|
|
|
|
end
|
2011-08-03 22:08:57 +04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
# :startdoc:
|
|
|
|
|
2009-01-12 06:39:58 +03:00
|
|
|
install?(:ext, :comm, :gem) do
|
2011-06-01 10:40:55 +04:00
|
|
|
$:.unshift(File.join(srcdir, "lib"))
|
|
|
|
require("rubygems.rb")
|
2011-07-22 07:16:48 +04:00
|
|
|
gem_dir = Gem.default_dir
|
|
|
|
directories = Gem.ensure_gem_subdirectories(gem_dir)
|
|
|
|
prepare "default gems", gem_dir, directories
|
2009-03-09 08:55:28 +03:00
|
|
|
|
2011-07-22 07:16:48 +04:00
|
|
|
spec_dir = File.join(gem_dir, directories.grep(/^spec/)[0])
|
2012-12-01 07:35:36 +04:00
|
|
|
default_spec_dir = "#{spec_dir}/default"
|
|
|
|
makedirs(default_spec_dir)
|
|
|
|
|
2011-08-04 11:08:48 +04:00
|
|
|
gems = {}
|
2011-07-30 18:19:11 +04:00
|
|
|
File.foreach(File.join(srcdir, "defs/default_gems")) do |line|
|
|
|
|
line.chomp!
|
|
|
|
line.sub!(/\s*#.*/, '')
|
|
|
|
next if line.empty?
|
|
|
|
words = []
|
|
|
|
line.scan(/\G\s*([^\[\]\s]+|\[([^\[\]]*)\])/) do
|
|
|
|
words << ($2 ? $2.split : $1)
|
|
|
|
end
|
2012-12-01 07:35:36 +04:00
|
|
|
name, base_dir, src, execs = *words
|
|
|
|
next unless name and base_dir and src
|
2011-07-22 07:16:48 +04:00
|
|
|
|
2011-08-03 22:08:57 +04:00
|
|
|
src = File.join(srcdir, src)
|
2012-12-01 07:35:36 +04:00
|
|
|
base_dir = File.join(srcdir, base_dir)
|
|
|
|
specgen = RbInstall::Specs::Generator.new(name, base_dir, src, execs || [])
|
2011-08-04 11:08:48 +04:00
|
|
|
gems[name] ||= specgen
|
|
|
|
end
|
|
|
|
|
|
|
|
Dir.glob(srcdir+"/{lib,ext}/**/*.gemspec").each do |src|
|
|
|
|
specgen = RbInstall::Specs::Reader.new(src)
|
|
|
|
gems[specgen.gemspec.name] ||= specgen
|
|
|
|
end
|
|
|
|
|
|
|
|
gems.sort.each do |name, specgen|
|
2011-08-03 22:08:57 +04:00
|
|
|
gemspec = specgen.gemspec
|
2012-12-01 07:35:36 +04:00
|
|
|
base_dir = specgen.src.sub(/\A#{Regexp.escape(srcdir)}\//, "")
|
2011-08-03 22:08:57 +04:00
|
|
|
full_name = "#{gemspec.name}-#{gemspec.version}"
|
|
|
|
|
|
|
|
puts "#{" "*30}#{gemspec.name} #{gemspec.version}"
|
2012-12-01 07:35:36 +04:00
|
|
|
gemspec_path = File.join(default_spec_dir, "#{full_name}.gemspec")
|
|
|
|
open_for_install(gemspec_path, $data_mode) do
|
2011-08-03 22:08:57 +04:00
|
|
|
specgen.spec_source
|
2009-03-09 08:55:28 +03:00
|
|
|
end
|
2011-07-22 07:16:48 +04:00
|
|
|
|
2011-08-03 22:08:57 +04:00
|
|
|
unless gemspec.executables.empty? then
|
2011-07-22 07:16:48 +04:00
|
|
|
bin_dir = File.join(gem_dir, 'gems', full_name, 'bin')
|
|
|
|
makedirs(bin_dir)
|
|
|
|
|
2011-08-03 22:08:57 +04:00
|
|
|
execs = gemspec.executables.map {|exec| File.join(srcdir, 'bin', exec)}
|
2011-07-22 11:12:22 +04:00
|
|
|
install(execs, bin_dir, :mode => $prog_mode)
|
2011-07-22 07:16:48 +04:00
|
|
|
end
|
2009-03-09 08:55:28 +03:00
|
|
|
end
|
2009-01-04 11:07:22 +03:00
|
|
|
end
|
|
|
|
|
2009-09-15 01:24:39 +04:00
|
|
|
parse_args()
|
|
|
|
|
|
|
|
include FileUtils
|
|
|
|
include FileUtils::NoWrite if $dryrun
|
|
|
|
@fileutils_output = STDOUT
|
|
|
|
@fileutils_label = ''
|
|
|
|
|
2006-09-17 12:43:19 +04:00
|
|
|
$install << :local << :ext if $install.empty?
|
|
|
|
$install.each do |inst|
|
2008-02-20 07:08:54 +03:00
|
|
|
if !(procs = $install_procs[inst]) || procs.empty?
|
|
|
|
next warn("unknown install target - #{inst}")
|
|
|
|
end
|
|
|
|
procs.each do |block|
|
2006-09-17 12:43:19 +04:00
|
|
|
dir = Dir.pwd
|
|
|
|
begin
|
|
|
|
block.call
|
|
|
|
ensure
|
|
|
|
Dir.chdir(dir)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
1998-01-16 15:19:09 +03:00
|
|
|
# vi:set sw=2:
|