Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge heroku-buildpack-ruby v20 changes

  • Loading branch information...
commit ec0ceb387774e0c2ad2da6bb1281bc4d74940b6b 2 parents 8e1f60c + 0848ca0
@mattmanning mattmanning authored
View
23 CHANGELOG.md
@@ -1,3 +1,26 @@
+## v20 (3/12/2012)
+
+Features:
+
+* bundler 1.1.0 \o/
+
+## v19 (1/25/2012)
+
+Bugfixes:
+
+* fix native extension building for rbx 2.0.0dev
+
+## v18 (1/18/2012)
+
+Features:
+
+* JRuby support
+* rbx 2.0.0dev support
+
+Bugfixes:
+
+* force db password to be a string in the yaml file
+
## v17 (12/29/2011)
Features:
View
2  README.md
@@ -1,7 +1,7 @@
Heroku buildpack: Ruby
======================
-This is a [Heroku buildpack](http://devcenter.heroku.com/articles/buildpack) for Ruby, Rack, and Rails apps. It uses [Bundler](http://gembundler.com) for dependency management.
+This is a [Heroku buildpack](http://devcenter.heroku.com/articles/buildpacks) for Ruby, Rack, and Rails apps. It uses [Bundler](http://gembundler.com) for dependency management.
Usage
-----
View
101 Rakefile
@@ -67,6 +67,21 @@ def build_ruby_command(name, output, prefix, usr_dir, tmpdir)
s3_upload(tmpdir, output)
end
+def build_rbx_command(name, output, prefix, usr_dir, tmpdir, ruby_version)
+ build_command = [
+ # need to move libyaml/libffi to dirs we can see
+ "mv usr /tmp",
+ "ls /tmp/#{usr_dir}",
+ "./configure --prefix #{prefix} --enable-version=#{ruby_version} --default-version=#{ruby_version} --with-include-dir=/tmp/#{usr_dir}/include --with-lib-dir=/tmp/#{usr_dir}/lib",
+ "rake install"
+ ]
+ # build_command << "mv #{prefix} /app/vendor/#{name}" if name != output
+ build_command = build_command.join(" && ")
+
+ sh "vulcan build -v -o #{output}.tgz --source #{name} --prefix #{prefix} --command=\"#{build_command}\""
+ s3_upload(tmpdir, output)
+end
+
desc "update plugins"
task "plugins:update" do
vendor_plugin "http://github.com/ddollar/rails_log_stdout.git"
@@ -182,13 +197,97 @@ task "rbx:install", :version do |t, args|
end
end
+desc "install rbx 2.0.0dev"
+task "rbx2dev:install", :version, :ruby_version do |t, args|
+ version = args[:version]
+ ruby_version = args[:ruby_version]
+ source = "rubinius-#{version}"
+ name = "rubinius-2.0.0dev"
+ output = "rbx-#{version}-#{ruby_version}"
+ usr_dir = "usr"
+
+ Dir.mktmpdir("rbx-") do |tmpdir|
+ Dir.chdir(tmpdir) do |dir|
+ FileUtils.rm_rf("#{tmpdir}/*")
+
+ sh "curl http://asset.rubini.us/#{source}.tar.gz -s -o - | tar vzxf -"
+ FileUtils.mkdir_p("#{name}/#{usr_dir}")
+ Dir.chdir("#{name}/#{usr_dir}") do
+ sh "curl #{VENDOR_URL}/libyaml-0.1.4.tgz -s -o - | tar vzxf -"
+ sh "curl #{VENDOR_URL}/libffi-3.0.10.tgz -s -o - | tar vzxf -"
+ end
+
+ prefix = "/app/vendor/#{output}"
+ build_rbx_command(name, output, prefix, usr_dir, tmpdir, ruby_version)
+
+ # rbx build
+ prefix = "/tmp/#{output}"
+ output = "rbx-build-#{version}-#{ruby_version}"
+ build_rbx_command(name, output, prefix, usr_dir, tmpdir, ruby_version)
+ end
+ end
+end
+
+desc "install jruby"
+task "jruby:install", :version do |t, args|
+ version = args[:version]
+ name = "jruby-bin-#{version}"
+ output = "jruby-#{version}"
+ launcher = "launcher"
+
+ Dir.mktmpdir("jruby-") do |tmpdir|
+ Dir.chdir(tmpdir) do
+ sh "curl http://jruby.org.s3.amazonaws.com/downloads/#{version}/#{name}.tar.gz -s -o - | tar vzxf -"
+ Dir.chdir("#{output}/bin") do
+ sh "curl #{VENDOR_URL}/jruby-launcher-1.0.12-java.tgz -s -o - | tar vzxf -"
+ end
+ sh "rm #{output}/bin/*.bat"
+ sh "rm #{output}/bin/*.dll"
+ sh "rm #{output}/bin/*.exe"
+ sh "rm -rf #{output}/docs"
+ sh "rm -rf #{output}/samples"
+ sh "rm -rf #{output}/share"
+ sh "rm -rf #{output}/tool"
+ sh "ln -s jruby #{output}/bin/ruby"
+ Dir.chdir(output) do
+ sh("tar czvf #{tmpdir}/#{output}.tgz *")
+ s3_upload(tmpdir, output)
+ end
+ end
+ end
+end
+
+desc "build the jruby-launcher"
+task "jruby:launcher", :version do |t, args|
+ version = args[:version]
+ name = "jruby-launcher-#{version}-java"
+ prefix = "/tmp/jruby-launcher"
+
+ Dir.mktmpdir("jruby-launcher-") do |tmpdir|
+ Dir.chdir(tmpdir) do
+ sh "gem fetch jruby-launcher --platform java --version #{version}"
+ sh "gem unpack jruby-launcher-#{version}-java.gem"
+
+ build_command = [
+ "make",
+ "mkdir -p #{prefix}",
+ "cp jruby #{prefix}"
+ ].join(" && ")
+
+ sh "vulcan build -v -o #{name}.tgz --source #{name} --prefix #{prefix} --command=\"#{build_command}\""
+ s3_upload(tmpdir, name)
+ end
+ end
+
+end
+
desc "generate ruby versions manifest"
task "ruby:manifest" do
require 'rexml/document'
require 'yaml'
document = REXML::Document.new(`curl https://#{S3_BUCKET_NAME}.s3.amazonaws.com`)
- rubies = document.elements.to_a("//Contents/Key").map {|node| node.text }.select {|text| text.match(/^(ruby|rbx)-\d+\.\d+\.\d+(-p\d+)?/) }
+ rubies = document.elements.to_a("//Contents/Key").map {|node| node.text }.select {|text| text.match(/^(ruby|rbx|jruby)-\\\\d+\\\\.\\\\d+\\\\.\\\\d+(-p\\\\d+)?/) }
Dir.mktmpdir("ruby_versions-") do |tmpdir|
name = 'ruby_versions.yml'
View
2  lib/language_pack/rails3.rb
@@ -65,7 +65,7 @@ def run_assets_precompile_rake_task
end
end
- # setup the database url as on environment variable
+ # setup the database url as an environment variable
def setup_database_url_env
ENV["DATABASE_URL"] ||= begin
# need to use a dummy DATABASE_URL here, so rails can load the environment
View
61 lib/language_pack/ruby.rb
@@ -7,7 +7,7 @@
class LanguagePack::Ruby < LanguagePack::Base
LIBYAML_VERSION = "0.1.4"
LIBYAML_PATH = "libyaml-#{LIBYAML_VERSION}"
- BUNDLER_VERSION = "1.1.rc.7"
+ BUNDLER_VERSION = "1.1.0"
BUNDLER_GEM_PATH = "bundler-#{BUNDLER_VERSION}"
NODE_VERSION = "0.4.7"
NODE_JS_BINARY_PATH = "node-#{NODE_VERSION}"
@@ -27,11 +27,13 @@ def default_addons
end
def default_config_vars
- {
+ vars = {
"LANG" => "en_US.UTF-8",
"PATH" => default_path,
"GEM_PATH" => slug_vendor_base,
}
+
+ ruby_version_jruby? ? vars.merge("JAVA_OPTS" => default_java_opts) : vars
end
def default_process_types
@@ -93,6 +95,18 @@ def ruby_version_rbx?
ruby_version ? ruby_version.match(/^rbx-/) : false
end
+ # determine if we're using jruby
+ # @return [Boolean] true if we are and false if we aren't
+ def ruby_version_jruby?
+ ruby_version ? ruby_version.match(/^jruby-/) : false
+ end
+
+ # default JAVA_OPTS
+ # return [String] string of JAVA_OPTS
+ def default_java_opts
+ "-Xmx384m -Xss512k -XX:+UseCompressedOops -Dfile.encoding=UTF-8"
+ end
+
# list the available valid ruby versions
# @note the value is memoized
# @return [Array] list of Strings of the ruby versions available
@@ -131,10 +145,11 @@ def install_ruby
Valid versions: #{ruby_versions.join(", ")}
ERROR
- unless ruby_version_rbx?
+ if !ruby_version_jruby?
FileUtils.mkdir_p(build_ruby_path)
Dir.chdir(build_ruby_path) do
- run("curl #{VENDOR_URL}/#{ruby_version.sub("ruby", "ruby-build")}.tgz -s -o - | tar zxf -")
+ ruby_vm = ruby_version_rbx? ? "rbx" : "ruby"
+ run("curl #{VENDOR_URL}/#{ruby_version.sub(ruby_vm, "#{ruby_vm}-build")}.tgz -s -o - | tar zxf -")
end
error invalid_ruby_version_message unless $?.success?
end
@@ -147,8 +162,9 @@ def install_ruby
bin_dir = "bin"
FileUtils.mkdir_p bin_dir
- run("cp #{slug_vendor_ruby}/bin/* #{bin_dir}")
- Dir["bin/*"].each {|path| run("chmod +x #{path}") }
+ Dir["#{slug_vendor_ruby}/bin/*"].each do |bin|
+ run("ln -s ../#{bin} #{bin_dir}")
+ end
topic "Using RUBY_VERSION: #{ruby_version}"
@@ -159,11 +175,7 @@ def install_ruby
# @return [String] resulting path or empty string if ruby is not vendored
def ruby_install_binstub_path
if ruby_version
- if ruby_version_rbx?
- "bin"
- else
- "#{build_ruby_path}/bin"
- end
+ "#{build_ruby_path}/bin"
else
""
end
@@ -173,9 +185,8 @@ def ruby_install_binstub_path
def setup_ruby_install_env
ENV["PATH"] = "#{ruby_install_binstub_path}:#{ENV["PATH"]}"
- if ruby_version_rbx?
- ENV['RBX_RUNTIME'] = "#{build_path}/#{slug_vendor_ruby}/runtime"
- ENV['RBX_LIB'] = "#{build_path}/#{slug_vendor_ruby}/lib"
+ if ruby_version_jruby?
+ ENV['JAVA_OPTS'] = default_java_opts
end
end
@@ -298,7 +309,7 @@ def build_bundler
end
end
- # RUBYOPT line that requires syck_hack filerequires syck_hack file
+ # RUBYOPT line that requires syck_hack file
# @return [String] require string if needed or else an empty string
def syck_hack
syck_hack_file = File.expand_path(File.join(File.dirname(__FILE__), "../../vendor/syck_hack"))
@@ -331,8 +342,18 @@ def create_database_yml
raise "No RACK_ENV or RAILS_ENV found" unless ENV["RAILS_ENV"] || ENV["RACK_ENV"]
-def attribute(name, value)
- value ? "\#{name}: \#{value}" : ""
+def attribute(name, value, force_string = false)
+ if value
+ value_string =
+ if force_string
+ '"' + value + '"'
+ else
+ value
+ end
+ "\#{name}: \#{value_string}"
+ else
+ ""
+ end
end
adapter = uri.scheme
@@ -341,7 +362,7 @@ def attribute(name, value)
database = (uri.path || "").split("/")[1]
username = uri.user
-password = uri.password.to_s
+password = uri.password
host = uri.host
port = uri.port
@@ -354,7 +375,7 @@ def attribute(name, value)
<%= attribute "adapter", adapter %>
<%= attribute "database", database %>
<%= attribute "username", username %>
- <%= attribute "password", password %>
+ <%= attribute "password", password, true %>
<%= attribute "host", host %>
<%= attribute "port", port %>
@@ -405,7 +426,7 @@ def rake_task_defined?(task)
run("env PATH=$PATH bundle exec rake #{task} --dry-run") && $?.success?
end
- # executes the block without GIT_DIR environment variable removed since it can mess with the current working directory git thinks it's in
+ # executes the block with GIT_DIR environment variable removed since it can mess with the current working directory git thinks it's in
# param [block] block to be executed in the GIT_DIR free context
def allow_git(&blk)
git_dir = ENV.delete("GIT_DIR") # can mess with bundler
Please sign in to comment.
Something went wrong with that request. Please try again.