Permalink
Browse files

Added automated rewriting of the shebang lines on installs through th…

…e gem rails command #379 [Manfred Stienstra]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@300 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
dhh committed Jan 1, 2005
1 parent cab2494 commit 07989b64f47112d7e501e2114284dec322ac2c6c
Showing with 27 additions and 12 deletions.
  1. +6 −4 railties/CHANGELOG
  2. +21 −8 railties/Rakefile
View
@@ -1,20 +1,22 @@
*SVN*
+* Added automated rewriting of the shebang lines on installs through the gem rails command #379 [Manfred Stienstra]
+
* Fixed that generated action_mailers doesnt need to require the action_mailer since thats already done in the environment #382 [Lucas Carlson]
* Fixed dependency management to happen in a unified fashion for Active Record and Action Pack using the new Dependencies module. This means that
the environment options needs to change from:
Before in development.rb:
- ActionController::Base.reload_dependencies= true
- ActiveRecord::Base.reload_associations� � �= true
+ ActionController::Base.reload_dependencies = true  
+ ActiveRecord::Base.reload_associations     = true
Now in development.rb:
Dependencies.mechanism = :load
Before in production.rb and test.rb:
- ActionController::Base.reload_dependencies= false
- ActiveRecord::Base.reload_associations� � �= false
+ ActionController::Base.reload_dependencies = false
+ ActiveRecord::Base.reload_associations     = false
Now in production.rb and test.rb:
Dependencies.mechanism = :require
View
@@ -5,7 +5,7 @@ require 'rake/gempackagetask'
require 'rake/contrib/rubyforgepublisher'
require 'date'
-
+require 'rbconfig'
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
PKG_NAME = 'rails'
@@ -100,17 +100,14 @@ task :copy_ties_content => [
:copy_app_doc_readme ]
task :copy_dispatches do
- cp "dispatches/dispatch.rb", "#{PKG_DESTINATION}/public/dispatch.rb"
+ copy_with_rewritten_ruby_path("dispatches/dispatch.rb", "#{PKG_DESTINATION}/public/dispatch.rb")
chmod 0755, "#{PKG_DESTINATION}/public/dispatch.rb"
- cp "dispatches/dispatch.rb", "#{PKG_DESTINATION}/public/dispatch.cgi"
+ copy_with_rewritten_ruby_path("dispatches/dispatch.rb", "#{PKG_DESTINATION}/public/dispatch.cgi")
chmod 0755, "#{PKG_DESTINATION}/public/dispatch.cgi"
- cp "dispatches/dispatch.fcgi", "#{PKG_DESTINATION}/public/dispatch.fcgi"
+ copy_with_rewritten_ruby_path("dispatches/dispatch.fcgi", "#{PKG_DESTINATION}/public/dispatch.fcgi")
chmod 0755, "#{PKG_DESTINATION}/public/dispatch.fcgi"
-
- cp "bin/console", "#{PKG_DESTINATION}/script/console"
- chmod 0755, "#{PKG_DESTINATION}/script/console"
end
task :copy_html_files do
@@ -145,7 +142,7 @@ end
task :copy_binfiles do
BIN_FILES.each do |file|
dest_file = File.join(PKG_DESTINATION, 'script', file)
- cp File.join('bin', file), dest_file
+ copy_with_rewritten_ruby_path(File.join('bin', file), dest_file)
chmod 0755, dest_file
end
end
@@ -174,6 +171,22 @@ task :link_apache_config do
}
end
+def copy_with_rewritten_ruby_path(src_file, dest_file)
+ ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
+
+ File.open(dest_file, 'w') do |df|
+ File.open(src_file) do |sf|
+ line = sf.gets
+ if (line =~ /#!.+ruby\s*/) != nil
+ df.puts("#!#{ruby}")
+ else
+ df.puts(line)
+ end
+ df.write(sf.read)
+ end
+ end
+end
+
# Generate documentation ------------------------------------------------------------------

0 comments on commit 07989b6

Please sign in to comment.