* instruby.rb (open_for_install): write block result and rewrite only

if changed from existing file.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2008-03-21 00:24:30 +00:00
parent 5cce095f11
commit c367a39c14
3 changed files with 20 additions and 11 deletions

View file

@ -1,3 +1,8 @@
Fri Mar 21 09:24:28 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* instruby.rb (open_for_install): write block result and rewrite only
if changed from existing file.
Wed Mar 19 21:01:08 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> Wed Mar 19 21:01:08 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* dir.c (dir_inspect, dir_path, dir_tell): check for frozen and closed * dir.c (dir_inspect, dir_path, dir_tell): check for frozen and closed

View file

@ -80,7 +80,7 @@ def parse_args(argv = ARGV)
$mflags.unshift(*mflags) $mflags.unshift(*mflags)
def $mflags.set?(flag) def $mflags.set?(flag)
grep(/\A-(?!-).*#{'%c' % flag}/i) { return true } grep(/\A-(?!-).*#{flag.chr}/i) { return true }
false false
end end
def $mflags.defined?(var) def $mflags.defined?(var)
@ -183,9 +183,13 @@ def install_recursive(srcdir, dest, options = {})
end end
end end
def open_for_install(path, mode, &block) def open_for_install(path, mode)
data = open(realpath = with_destdir(path), "rb") {|f| f.read} rescue nil
newdata = yield
unless $dryrun unless $dryrun
open(realpath = with_destdir(path), "wb", mode, &block) unless newdata == data
open(realpath, "wb", mode) {|f| f.write newdata}
end
File.chmod(mode, realpath) File.chmod(mode, realpath)
end end
$installed_list.puts path if $installed_list $installed_list.puts path if $installed_list
@ -280,7 +284,7 @@ install?(:local, :comm, :bin, :'bin-comm') do
makedirs [bindir, rubylibdir] makedirs [bindir, rubylibdir]
ruby_shebang = File.join(bindir, ruby_install_name) ruby_shebang = File.join(bindir, ruby_install_name)
if $cmdtype if File::ALT_SEPARATOR
ruby_bin = 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/*"]
@ -301,10 +305,10 @@ install?(:local, :comm, :bin, :'bin-comm') do
cmd = File.join(bindir, name) cmd = File.join(bindir, name)
cmd << ".#{$cmdtype}" if $cmdtype cmd << ".#{$cmdtype}" if $cmdtype
open_for_install(cmd, $script_mode) do |f| open_for_install(cmd, $script_mode) do
case $cmdtype case $cmdtype
when "bat" when "bat"
f.print((<<EOH+shebang+body+<<EOF).gsub(/$/, "\r")) "#{<<EOH}#{shebang}#{body}#{<<EOF}".gsub(/$/, "\r")
@echo off @echo off
@if not "%~d0" == "~d0" goto WinNT @if not "%~d0" == "~d0" goto WinNT
#{ruby_bin} -x "#{cmd}" %1 %2 %3 %4 %5 %6 %7 %8 %9 #{ruby_bin} -x "#{cmd}" %1 %2 %3 %4 %5 %6 %7 %8 %9
@ -317,12 +321,12 @@ __END__
:endofruby :endofruby
EOF EOF
when "cmd" when "cmd"
f.print(<<EOH, shebang, body) "#{<<EOH}#{shebang}#{body}"
@"%~dp0#{ruby_install_name}" -x "%~f0" %* @"%~dp0#{ruby_install_name}" -x "%~f0" %*
@exit /b %ERRORLEVEL% @exit /b %ERRORLEVEL%
EOH EOH
else else
f.print shebang, body shebang + body
end end
end end
end end

View file

@ -1,7 +1,7 @@
#define RUBY_VERSION "1.8.6" #define RUBY_VERSION "1.8.6"
#define RUBY_RELEASE_DATE "2008-03-19" #define RUBY_RELEASE_DATE "2008-03-21"
#define RUBY_VERSION_CODE 186 #define RUBY_VERSION_CODE 186
#define RUBY_RELEASE_CODE 20080319 #define RUBY_RELEASE_CODE 20080321
#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 3 #define RUBY_RELEASE_MONTH 3
#define RUBY_RELEASE_DAY 19 #define RUBY_RELEASE_DAY 21
#ifdef RUBY_EXTERN #ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[]; RUBY_EXTERN const char ruby_version[];