mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* instruby.rb (parse_args): added --dir-mode, --script-mode and
--cmd-type options. [ruby-dev:33816] * instruby.rb (parse_args): added bin-arch and bin-comm to install type, for compiled files and script files. * instruby.rb (parse_args): deal with make style command line macros, and count as long syle options if prefixed with INSTALL_. * instruby.rb (makedirs): use $dir_mode. [ruby-dev:33805] * instruby.rb (open_for_install): set file mode, which is now permission mode instead of access mode. * instruby.rb (bin-comm): installs scripts with replacing shebang lines. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c90f8f0918
commit
9a4b141f97
3 changed files with 106 additions and 45 deletions
19
ChangeLog
19
ChangeLog
|
@ -1,3 +1,22 @@
|
||||||
|
Wed Feb 20 13:08:52 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* instruby.rb (parse_args): added --dir-mode, --script-mode and
|
||||||
|
--cmd-type options. [ruby-dev:33816]
|
||||||
|
|
||||||
|
* instruby.rb (parse_args): added bin-arch and bin-comm to install
|
||||||
|
type, for compiled files and script files.
|
||||||
|
|
||||||
|
* instruby.rb (parse_args): deal with make style command line macros,
|
||||||
|
and count as long syle options if prefixed with INSTALL_.
|
||||||
|
|
||||||
|
* instruby.rb (makedirs): use $dir_mode. [ruby-dev:33805]
|
||||||
|
|
||||||
|
* instruby.rb (open_for_install): set file mode, which is now
|
||||||
|
permission mode instead of access mode.
|
||||||
|
|
||||||
|
* instruby.rb (bin-comm): installs scripts with replacing shebang
|
||||||
|
lines.
|
||||||
|
|
||||||
Tue Feb 19 18:34:32 2008 Tanaka Akira <akr@fsij.org>
|
Tue Feb 19 18:34:32 2008 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* gc.c (STACK_LENGTH) [SPARC] : 0x80 offset removed. [ruby-dev:33857]
|
* gc.c (STACK_LENGTH) [SPARC] : 0x80 offset removed. [ruby-dev:33857]
|
||||||
|
|
126
instruby.rb
126
instruby.rb
|
@ -14,7 +14,7 @@ require 'tempfile'
|
||||||
STDOUT.sync = true
|
STDOUT.sync = true
|
||||||
File.umask(0)
|
File.umask(0)
|
||||||
|
|
||||||
def parse_args()
|
def parse_args(argv = ARGV)
|
||||||
$mantype = 'doc'
|
$mantype = 'doc'
|
||||||
$destdir = nil
|
$destdir = nil
|
||||||
$extout = nil
|
$extout = nil
|
||||||
|
@ -26,6 +26,10 @@ def parse_args()
|
||||||
$rdocdir = nil
|
$rdocdir = nil
|
||||||
$data_mode = 0644
|
$data_mode = 0644
|
||||||
$prog_mode = 0755
|
$prog_mode = 0755
|
||||||
|
$dir_mode = nil
|
||||||
|
$script_mode = nil
|
||||||
|
$cmdtype = ('bat' if File::ALT_SEPARATOR == '\\')
|
||||||
|
mflags = []
|
||||||
opt = OptionParser.new
|
opt = OptionParser.new
|
||||||
opt.on('-n') {$dryrun = true}
|
opt.on('-n') {$dryrun = true}
|
||||||
opt.on('--dest-dir=DIR') {|dir| $destdir = dir}
|
opt.on('--dest-dir=DIR') {|dir| $destdir = dir}
|
||||||
|
@ -39,7 +43,7 @@ def parse_args()
|
||||||
$mflags.concat(v)
|
$mflags.concat(v)
|
||||||
end
|
end
|
||||||
opt.on('-i', '--install=TYPE',
|
opt.on('-i', '--install=TYPE',
|
||||||
[:local, :bin, :lib, :man, :ext, :"ext-arch", :"ext-comm", :rdoc]) do |ins|
|
[:local, :bin, :"bin-arch", :"bin-comm", :lib, :man, :ext, :"ext-arch", :"ext-comm", :rdoc]) do |ins|
|
||||||
$install << ins
|
$install << ins
|
||||||
end
|
end
|
||||||
opt.on('--data-mode=OCTAL-MODE', OptionParser::OctalInteger) do |mode|
|
opt.on('--data-mode=OCTAL-MODE', OptionParser::OctalInteger) do |mode|
|
||||||
|
@ -48,20 +52,39 @@ def parse_args()
|
||||||
opt.on('--prog-mode=OCTAL-MODE', OptionParser::OctalInteger) do |mode|
|
opt.on('--prog-mode=OCTAL-MODE', OptionParser::OctalInteger) do |mode|
|
||||||
$prog_mode = mode
|
$prog_mode = mode
|
||||||
end
|
end
|
||||||
|
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
|
||||||
opt.on('--installed-list [FILENAME]') {|name| $installed_list = name}
|
opt.on('--installed-list [FILENAME]') {|name| $installed_list = name}
|
||||||
opt.on('--rdoc-output [DIR]') {|dir| $rdocdir = dir}
|
opt.on('--rdoc-output [DIR]') {|dir| $rdocdir = dir}
|
||||||
|
opt.on('--cmd-type=TYPE', %w[bat cmd plain]) {|cmd| $cmdtype = (cmd unless cmd == 'plain')}
|
||||||
|
|
||||||
opt.parse! rescue abort [$!.message, opt].join("\n")
|
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
|
||||||
|
end rescue abort [$!.message, opt].join("\n")
|
||||||
|
|
||||||
$make, *rest = Shellwords.shellwords($make)
|
$make, *rest = Shellwords.shellwords($make)
|
||||||
$mflags.unshift(*rest) unless rest.empty?
|
$mflags.unshift(*rest) unless rest.empty?
|
||||||
|
$mflags.unshift(*mflags)
|
||||||
|
|
||||||
def $mflags.set?(flag)
|
def $mflags.set?(flag)
|
||||||
grep(/\A-(?!-).*#{'%c' % flag}/i) { return true }
|
grep(/\A-(?!-).*#{'%c' % flag}/i) { return true }
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
def $mflags.defined?(var)
|
def $mflags.defined?(var)
|
||||||
grep(/\A#{var}=(.*)/) {return $1}
|
grep(/\A#{var}=(.*)/) {return block_given? ? yield($1) : $1}
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -85,6 +108,9 @@ def parse_args()
|
||||||
end
|
end
|
||||||
|
|
||||||
$rdocdir ||= $mflags.defined?('RDOCOUT')
|
$rdocdir ||= $mflags.defined?('RDOCOUT')
|
||||||
|
|
||||||
|
$dir_mode ||= $prog_mode | 0700
|
||||||
|
$script_mode ||= $prog_mode
|
||||||
end
|
end
|
||||||
|
|
||||||
parse_args()
|
parse_args()
|
||||||
|
@ -127,29 +153,42 @@ def makedirs(dirs)
|
||||||
File.directory?(realdir)
|
File.directory?(realdir)
|
||||||
end
|
end
|
||||||
end.compact!
|
end.compact!
|
||||||
super(dirs, :mode => $prog_mode) unless dirs.empty?
|
super(dirs, :mode => $dir_mode) unless dirs.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def install_recursive(src, dest, options = {})
|
def install_recursive(srcdir, dest, options = {})
|
||||||
noinst = options.delete(:no_install)
|
opts = options.clone
|
||||||
subpath = src.size..-1
|
noinst = opts.delete(:no_install)
|
||||||
Dir.glob("#{src}/**/*", File::FNM_DOTMATCH) do |src|
|
glob = opts.delete(:glob) || "*"
|
||||||
next if /\A\.{1,2}\z/ =~ (base = File.basename(src))
|
subpath = srcdir.size..-1
|
||||||
next if noinst and File.fnmatch?(noinst, File.basename(src))
|
Dir.glob("#{srcdir}/**/#{glob}") do |src|
|
||||||
|
case base = File.basename(src)
|
||||||
|
when /\A\#.*\#\z/, /~\z/
|
||||||
|
next
|
||||||
|
end
|
||||||
|
if noinst
|
||||||
|
if Array === noinst
|
||||||
|
next if noinst.any? {|n| File.fnmatch?(n, base)}
|
||||||
|
else
|
||||||
|
next if File.fnmatch?(noinst, base)
|
||||||
|
end
|
||||||
|
end
|
||||||
d = dest + src[subpath]
|
d = dest + src[subpath]
|
||||||
if File.directory?(src)
|
if File.directory?(src)
|
||||||
makedirs(d)
|
makedirs(d)
|
||||||
else
|
else
|
||||||
install src, d
|
makedirs(File.dirname(d))
|
||||||
|
install src, d, opts
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def open_for_install(path, mode, &block)
|
def open_for_install(path, mode, &block)
|
||||||
unless $dryrun
|
unless $dryrun
|
||||||
open(with_destdir(path), mode, &block)
|
open(realpath = with_destdir(path), "wb", mode, &block)
|
||||||
|
File.chmod(mode, realpath)
|
||||||
end
|
end
|
||||||
$installed_list.puts path if /^w/ =~ mode and $installed_list
|
$installed_list.puts path if $installed_list
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_destdir(dir)
|
def with_destdir(dir)
|
||||||
|
@ -177,7 +216,7 @@ dll = CONFIG["LIBRUBY_SO"]
|
||||||
lib = CONFIG["LIBRUBY"]
|
lib = CONFIG["LIBRUBY"]
|
||||||
arc = CONFIG["LIBRUBY_A"]
|
arc = CONFIG["LIBRUBY_A"]
|
||||||
|
|
||||||
install?(:local, :arch, :bin) do
|
install?(:local, :arch, :bin, :'bin-arch') do
|
||||||
puts "installing binary commands"
|
puts "installing binary commands"
|
||||||
|
|
||||||
makedirs [bindir, libdir, archlibdir]
|
makedirs [bindir, libdir, archlibdir]
|
||||||
|
@ -214,12 +253,12 @@ if $extout
|
||||||
if noinst = CONFIG["no_install_files"] and noinst.empty?
|
if noinst = CONFIG["no_install_files"] and noinst.empty?
|
||||||
noinst = nil
|
noinst = nil
|
||||||
end
|
end
|
||||||
install_recursive("#{extout}/#{CONFIG['arch']}", archlibdir, :no_install => noinst)
|
install_recursive("#{extout}/#{CONFIG['arch']}", archlibdir, :no_install => noinst, :mode => $prog_mode)
|
||||||
end
|
end
|
||||||
install?(:ext, :comm, :'ext-comm') do
|
install?(:ext, :comm, :'ext-comm') do
|
||||||
puts "installing extension scripts"
|
puts "installing extension scripts"
|
||||||
makedirs [rubylibdir, sitelibdir]
|
makedirs [rubylibdir, sitelibdir]
|
||||||
install_recursive("#{extout}/common", rubylibdir)
|
install_recursive("#{extout}/common", rubylibdir, :mode => $data_mode)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -230,51 +269,45 @@ install?(:rdoc) do
|
||||||
ridatadir = File.join(CONFIG['datadir'], 'ri/$(MAJOR).$(MINOR)/system')
|
ridatadir = File.join(CONFIG['datadir'], 'ri/$(MAJOR).$(MINOR)/system')
|
||||||
Config.expand(ridatadir)
|
Config.expand(ridatadir)
|
||||||
makedirs [ridatadir]
|
makedirs [ridatadir]
|
||||||
install_recursive($rdocdir, ridatadir)
|
install_recursive($rdocdir, ridatadir, :mode => $data_mode)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
install?(:local, :comm, :bin) do
|
install?(:local, :comm, :bin, :'bin-comm') do
|
||||||
puts "installing command scripts"
|
puts "installing command scripts"
|
||||||
|
|
||||||
Dir.chdir srcdir
|
Dir.chdir srcdir
|
||||||
makedirs [bindir, rubylibdir]
|
makedirs [bindir, rubylibdir]
|
||||||
|
|
||||||
ruby_shebang = File.join(bindir, ruby_install_name)
|
ruby_shebang = File.join(bindir, ruby_install_name)
|
||||||
if File::ALT_SEPARATOR
|
if $cmdtype
|
||||||
ruby_bin_dosish = ruby_shebang.tr(File::SEPARATOR, File::ALT_SEPARATOR)
|
ruby_bin = ruby_shebang.tr(File::SEPARATOR, File::ALT_SEPARATOR)
|
||||||
end
|
end
|
||||||
for src in Dir["bin/*"]
|
for src in Dir["bin/*"]
|
||||||
next unless File.file?(src)
|
next unless File.file?(src)
|
||||||
next if /\/[.#]|(\.(old|bak|orig|rej|diff|patch|core)|~|\/core)$/i =~ src
|
next if /\/[.#]|(\.(old|bak|orig|rej|diff|patch|core)|~|\/core)$/i =~ src
|
||||||
|
|
||||||
name = ruby_install_name.sub(/ruby/, File.basename(src))
|
name = ruby_install_name.sub(/ruby/, File.basename(src))
|
||||||
dest = File.join(bindir, name)
|
|
||||||
|
|
||||||
install src, dest, :mode => $prog_mode
|
|
||||||
|
|
||||||
next if $dryrun
|
|
||||||
|
|
||||||
shebang = ''
|
shebang = ''
|
||||||
body = ''
|
body = ''
|
||||||
open_for_install(dest, "r+") { |f|
|
open(src, "rb") do |f|
|
||||||
shebang = f.gets
|
shebang = f.gets
|
||||||
body = f.read
|
body = f.read
|
||||||
|
end
|
||||||
|
shebang.sub!(/^\#!.*?ruby\b/) {"#!" + ruby_shebang}
|
||||||
|
shebang.sub!(/\r$/, '')
|
||||||
|
body.gsub!(/\r$/, '')
|
||||||
|
|
||||||
if shebang.sub!(/^\#!.*?ruby\b/) {"#!" + ruby_shebang}
|
cmd = File.join(bindir, name)
|
||||||
f.rewind
|
cmd << ".#{$cmdtype}" if $cmdtype
|
||||||
f.print shebang, body
|
open_for_install(cmd, $script_mode) do |f|
|
||||||
f.truncate(f.pos)
|
case $cmdtype
|
||||||
end
|
when "bat"
|
||||||
}
|
f.print((<<EOH+shebang+body+<<EOF).gsub(/$/, "\r"))
|
||||||
|
|
||||||
if ruby_bin_dosish
|
|
||||||
batfile = File.join(bindir, name + ".bat")
|
|
||||||
open_for_install(batfile, "wb") {|b|
|
|
||||||
b.print((<<EOH+shebang+body+<<EOF).gsub(/\r?\n/, "\r\n"))
|
|
||||||
@echo off
|
@echo off
|
||||||
@if not "%~d0" == "~d0" goto WinNT
|
@if not "%~d0" == "~d0" goto WinNT
|
||||||
#{ruby_bin_dosish} -x "#{batfile}" %1 %2 %3 %4 %5 %6 %7 %8 %9
|
#{ruby_bin} -x "#{cmd}" %1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||||
@goto endofruby
|
@goto endofruby
|
||||||
:WinNT
|
:WinNT
|
||||||
"%~dp0#{ruby_install_name}" -x "%~f0" %*
|
"%~dp0#{ruby_install_name}" -x "%~f0" %*
|
||||||
|
@ -283,7 +316,14 @@ EOH
|
||||||
__END__
|
__END__
|
||||||
:endofruby
|
:endofruby
|
||||||
EOF
|
EOF
|
||||||
}
|
when "cmd"
|
||||||
|
f.print(<<EOH, shebang, body)
|
||||||
|
@"%~dp0#{ruby_install_name}" -x "%~f0" %*
|
||||||
|
@exit /b %ERRORLEVEL%
|
||||||
|
EOH
|
||||||
|
else
|
||||||
|
f.print shebang, body
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -347,10 +387,12 @@ install?(:local, :comm, :man) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
$install.concat ARGV.collect {|n| n.intern}
|
|
||||||
$install << :local << :ext if $install.empty?
|
$install << :local << :ext if $install.empty?
|
||||||
$install.each do |inst|
|
$install.each do |inst|
|
||||||
$install_procs[inst].each do |block|
|
if !(procs = $install_procs[inst]) || procs.empty?
|
||||||
|
next warn("unknown install target - #{inst}")
|
||||||
|
end
|
||||||
|
procs.each do |block|
|
||||||
dir = Dir.pwd
|
dir = Dir.pwd
|
||||||
begin
|
begin
|
||||||
block.call
|
block.call
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#define RUBY_VERSION "1.8.6"
|
#define RUBY_VERSION "1.8.6"
|
||||||
#define RUBY_RELEASE_DATE "2008-02-19"
|
#define RUBY_RELEASE_DATE "2008-02-20"
|
||||||
#define RUBY_VERSION_CODE 186
|
#define RUBY_VERSION_CODE 186
|
||||||
#define RUBY_RELEASE_CODE 20080219
|
#define RUBY_RELEASE_CODE 20080220
|
||||||
#define RUBY_PATCHLEVEL 5000
|
#define RUBY_PATCHLEVEL 5000
|
||||||
|
|
||||||
#define RUBY_VERSION_MAJOR 1
|
#define RUBY_VERSION_MAJOR 1
|
||||||
|
@ -9,7 +9,7 @@
|
||||||
#define RUBY_VERSION_TEENY 6
|
#define RUBY_VERSION_TEENY 6
|
||||||
#define RUBY_RELEASE_YEAR 2008
|
#define RUBY_RELEASE_YEAR 2008
|
||||||
#define RUBY_RELEASE_MONTH 2
|
#define RUBY_RELEASE_MONTH 2
|
||||||
#define RUBY_RELEASE_DAY 19
|
#define RUBY_RELEASE_DAY 20
|
||||||
|
|
||||||
#ifdef RUBY_EXTERN
|
#ifdef RUBY_EXTERN
|
||||||
RUBY_EXTERN const char ruby_version[];
|
RUBY_EXTERN const char ruby_version[];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue