Skip to content

Commit

Permalink
Merge pull request #1 from DouweM/update
Browse files Browse the repository at this point in the history
Update to heroku-buildpack-ruby v50
  • Loading branch information
ndbroadbent committed Feb 6, 2013
2 parents ea6763a + 0a0798e commit ed1db34
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 17 deletions.
62 changes: 62 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,65 @@
## v50

Features:

* Restore ruby deploys back to normal

## v49 (1/30/2013)

Features:

* Re-enable ruby deploys for apps just using the heroku cache
* Display ruby version change when busting the cache

## v48 (1/30/2013)

Features:

* Update deploy error message copy to link to status incident.

## v47 (1/30/2013)

Features:

* Disable ruby deploys due to rubygems.org compromise

## v46 (1/10/2013)

Features:

* Upgrade Bundler to 1.3.0.pre.5
* bundler binstubs now go in vendor/bundle/bin

## v45 (12/14/2012)

Features:

* Stop setting env vars in bin/release now that login-shell is released
* Enable Invoke Dynamic on JRuby by default
* GEM_PATH is now updated on each push

## v44 (12/14/2012)

Faulty Release

## v43 (12/13/2012)

Features:

* Upgrade Bundler to 1.3.0.pre.2

## v42 (11/26/2012)

Features:

* Upgrade Bundler to 1.2.2 to fix Ruby 2.0.0/YAML issues

## v41 (11/1/2012)

Features:

* Enable ruby 2.0.0 support for testing

## v40 (10/14/2012)

Features:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Example Usage:
$ ls
Gemfile Gemfile.lock

$ heroku create --stack cedar --buildpack http://github.com/heroku/heroku-buildpack-ruby.git
$ heroku create --stack cedar --buildpack https://github.com/heroku/heroku-buildpack-ruby.git

$ git push heroku master
...
Expand Down Expand Up @@ -47,7 +47,7 @@ Example Usage:
$ ls config/environment.rb
config/environment.rb

$ heroku create --stack cedar --buildpack http://github.com/heroku/heroku-buildpack-ruby.git
$ heroku create --stack cedar --buildpack https://github.com/heroku/heroku-buildpack-ruby.git

$ git push heroku master
...
Expand Down Expand Up @@ -81,7 +81,7 @@ Example Usage:
$ ls config/application.rb
config/application.rb

$ heroku create --stack cedar --buildpack http://github.com/heroku/heroku-buildpack-ruby.git
$ heroku create --stack cedar --buildpack https://github.com/heroku/heroku-buildpack-ruby.git

$ git push heroku master
-----> Heroku receiving push
Expand Down
5 changes: 3 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def install_gem(gem, version)
end

def build_ruby_command(name, output, prefix, usr_dir, tmpdir, rubygems = nil)
vulcan_prefix = "/app/vendor/#{output}"
build_command = [
# need to move libyaml/libffi to dirs we can see
"mv #{usr_dir} /tmp",
Expand All @@ -65,7 +66,7 @@ def build_ruby_command(name, output, prefix, usr_dir, tmpdir, rubygems = nil)
build_command << "mv #{prefix} /app/vendor/#{output}" if prefix != "/app/vendor/#{output}"
build_command = build_command.join(" && ")

sh "vulcan build -v -o #{output}.tgz --prefix #{prefix} --source #{name} --command=\"#{build_command}\""
sh "vulcan build -v -o #{output}.tgz --prefix #{vulcan_prefix} --source #{name} --command=\"#{build_command}\""
s3_upload(tmpdir, output)
end

Expand Down Expand Up @@ -178,7 +179,7 @@ task "ruby:install", :version do |t, args|
# build ruby
if major_ruby == "1.8"
output = "ruby-build-#{version}"
prefix = "/app/vendor/ruby-build-#{version}"
prefix = "/tmp/ruby-#{version}"
build_ruby_command(full_name, output, prefix, usr_dir, tmpdir, rubygems)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/language_pack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ def self.detect(*args)
require "language_pack/rack"
require "language_pack/rails2"
require "language_pack/rails3"

require "language_pack/disable_deploys"
3 changes: 1 addition & 2 deletions lib/language_pack/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def release

{
"addons" => default_addons,
"config_vars" => default_config_vars,
"default_process_types" => default_process_types
}.to_yaml
end
Expand Down Expand Up @@ -153,7 +152,7 @@ def run_stdout(command)
%x{ #{command} 2>/dev/null }
end

# run a shell command and stream the ouput
# run a shell command and stream the output
# @param [String] command to be run
def pipe(command)
output = ""
Expand Down
17 changes: 17 additions & 0 deletions lib/language_pack/disable_deploys.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require "language_pack"
require "language_pack/base"

class LanguagePack::DisableDeploys < LanguagePack::Base
def self.use?
File.exist?("Gemfile")
end

def name
"Ruby/DisableDeploys"
end

def compile
error "Ruby deploys have been temporarily disabled due to a Rubygems.org security breach.\nPlease see https://status.heroku.com/incidents/489 for more info and a workaround if you need to deploy."
end
end

2 changes: 1 addition & 1 deletion lib/language_pack/rails3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class LanguagePack::Rails3 < LanguagePack::Rails2
def self.use?
super &&
File.exists?("config/application.rb") &&
File.read("config/application.rb") =~ /Rails::Application/
File.read("config/application.rb").include?("Rails::Application")
end

def name
Expand Down
29 changes: 21 additions & 8 deletions lib/language_pack/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

# base Ruby Language Pack. This is for any base ruby app.
class LanguagePack::Ruby < LanguagePack::Base
BUILDPACK_VERSION = "v40"
BUILDPACK_VERSION = "v50"
LIBYAML_VERSION = "0.1.4"
LIBYAML_PATH = "libyaml-#{LIBYAML_VERSION}"
BUNDLER_VERSION = "1.2.1"
BUNDLER_VERSION = "1.3.0.pre.5"
BUNDLER_GEM_PATH = "bundler-#{BUNDLER_VERSION}"
NODE_VERSION = "0.4.7"
NODE_JS_BINARY_PATH = "node-#{NODE_VERSION}"
Expand Down Expand Up @@ -141,7 +141,7 @@ def bootstrap_bundler(&block)
# determine if we're using rbx
# @return [Boolean] true if we are and false if we aren't
def ruby_version_rbx?
ruby_version ? ruby_version.match(/^rbx-/) : false
ruby_version ? ruby_version.match(/rbx-/) : false
end

# determine if we're using jruby
Expand All @@ -159,7 +159,7 @@ def default_java_opts
# default JRUBY_OPTS
# return [String] string of JRUBY_OPTS
def default_jruby_opts
"-Xcompile.invokedynamic=false"
"-Xcompile.invokedynamic=true"
end

# list the available valid ruby versions
Expand Down Expand Up @@ -191,7 +191,7 @@ def setup_language_pack_environment

# sets up the profile.d script for this buildpack
def setup_profiled
set_env_default "GEM_PATH", "$HOME/#{slug_vendor_base}"
set_env_override "GEM_PATH", "$HOME/#{slug_vendor_base}:$GEM_PATH"
set_env_default "LANG", "en_US.UTF-8"
set_env_override "PATH", "$HOME/bin:$HOME/#{slug_vendor_base}/bin:$PATH"

Expand All @@ -204,7 +204,7 @@ def setup_profiled
# determines if a build ruby is required
# @return [Boolean] true if a build ruby is required
def build_ruby?
@build_ruby ||= !ruby_version_jruby? && ruby_version != "ruby-1.9.3"
@build_ruby ||= !ruby_version_rbx? && !ruby_version_jruby? && !%w{ruby-1.9.3 ruby-2.0.0}.include?(ruby_version)
end

# install the vendored ruby
Expand Down Expand Up @@ -362,13 +362,17 @@ def remove_vendor_bundle
def build_bundler
log("bundle") do
bundle_without = ENV["BUNDLE_WITHOUT"] || "development:test"
bundle_command = "bundle install --without #{bundle_without} --path vendor/bundle --binstubs bin/"
bundle_command = "bundle install --without #{bundle_without} --path vendor/bundle --binstubs vendor/bundle/bin"

unless File.exist?("Gemfile.lock")
error "Gemfile.lock is required. Please run \"bundle install\" locally\nand commit your Gemfile.lock."
end

if has_windows_gemfile_lock?
topic "WARNING: Removing `Gemfile.lock` because it was generated on Windows."
puts "Bundler will do a full resolve so native gems are handled properly."
puts "This may result in unexpected gem versions being used in your app."

log("bundle", "has_windows_gemfile_lock")
File.unlink("Gemfile.lock")
else
Expand Down Expand Up @@ -408,6 +412,13 @@ def build_bundler

# Keep gem cache out of the slug
FileUtils.rm_rf("#{slug_vendor_base}/cache")

# symlink binstubs
bin_dir = "bin"
FileUtils.mkdir_p bin_dir
Dir["#{slug_vendor_base}/bin/*"].each do |bin|
run("ln -s ../#{bin} #{bin_dir}") unless File.exist?("#{bin_dir}/#{bin}")
end
else
log "bundle", :status => "failure"
error_message = "Failed to install gems via Bundler."
Expand Down Expand Up @@ -597,8 +608,10 @@ def load_bundler_cache
elsif !File.exists?(buildpack_version_cache) && File.exists?(ruby_version_cache)
puts "Broken cache detected. Purging build cache."
purge_bundler_cache
elsif cache_exists?(bundler_cache) && !(File.exists?(ruby_version_cache) && full_ruby_version == File.read(ruby_version_cache).chomp)
elsif cache_exists?(bundler_cache) && File.exists?(ruby_version_cache) && full_ruby_version != File.read(ruby_version_cache).chomp
puts "Ruby version change detected. Clearing bundler cache."
puts "Old: #{File.read(ruby_version_cache).chomp}"
puts "New: #{full_ruby_version}"
purge_bundler_cache
end

Expand Down

0 comments on commit ed1db34

Please sign in to comment.