Skip to content

Commit

Permalink
Added automated rewriting of the shebang lines on installs through th…
Browse files Browse the repository at this point in the history
…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 07989b6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
10 changes: 6 additions & 4 deletions railties/CHANGELOG
@@ -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
Expand Down
29 changes: 21 additions & 8 deletions railties/Rakefile
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ------------------------------------------------------------------

Expand Down

0 comments on commit 07989b6

Please sign in to comment.