Skip to content

Commit

Permalink
Merge tag 'v268' into deps/63/upstream_v268
Browse files Browse the repository at this point in the history
  • Loading branch information
Frzk committed Apr 18, 2024
2 parents 098101f + 5ce2c2e commit 4ad3421
Show file tree
Hide file tree
Showing 24 changed files with 270 additions and 326 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
## [Unreleased]


## [v268] - 2024-04-17

- Heroku-24 stack initial support. Includes multi-architecture (arm64/amd64) logic that has not been tested on the platform (https://github.com/heroku/heroku-buildpack-ruby/pull/1439)
- Remove unused Rubinius and Ruby 1.9.2 codepaths (https://github.com/heroku/heroku-buildpack-ruby/pull/1440)

## [v267] - 2024-02-28

- Bundler version installation is now based on both major and minor version (https://github.com/heroku/heroku-buildpack-ruby/pull/1428)
Expand Down Expand Up @@ -1510,7 +1515,8 @@ Bugfixes:
* Change gem detection to use lockfile parser
* use `$RACK_ENV` when thin is detected for rack apps

[unreleased]: https://github.com/heroku/heroku-buildpack-ruby/compare/v267...main
[unreleased]: https://github.com/heroku/heroku-buildpack-ruby/compare/v268...main
[v268]: https://github.com/heroku/heroku-buildpack-ruby/compare/v267...v268
[v267]: https://github.com/heroku/heroku-buildpack-ruby/compare/v266...v267
[v266]: https://github.com/heroku/heroku-buildpack-ruby/compare/v265...v266
[v265]: https://github.com/heroku/heroku-buildpack-ruby/compare/v264...v265
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ RUBY VERSION
ruby 3.1.4p223

BUNDLED WITH
2.3.10
2.5.8
15 changes: 0 additions & 15 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,6 @@ task "gem:install", :gem, :version do |t, args|
install_gem(gem, version)
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.#{S3_BUCKET_REGION}.amazonaws.com`)
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'
File.open(name, 'w') {|file| file.puts(rubies.to_yaml) }
sh("#{s3_tools_dir}/s3 put #{S3_BUCKET_NAME} #{name} #{name}")
end
end

begin
require 'rspec/core/rake_task'

Expand Down
1 change: 0 additions & 1 deletion config/cdn.yml

This file was deleted.

8 changes: 1 addition & 7 deletions hatchet.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"sharpstone/default_with_rakefile"
],
"bundler": [
"sharpstone/bad_gemfile_on_platform",
"sharpstone/problem_gemfile_version",
"sharpstone/git_gemspec",
"sharpstone/no_lockfile",
Expand All @@ -17,10 +16,7 @@
],
"ruby": [
"sharpstone/ruby_version_does_not_exist",
"sharpstone/ruby_193_jruby_173",
"sharpstone/ruby_193_jruby_176",
"sharpstone/ruby_193_jruby_17161_jdk7",
"sharpstone/ruby_193_bad_patch_cedar_14",
"sharpstone/ruby_25",
"sharpstone/jruby-minimal",
"sharpstone/empty-procfile",
Expand All @@ -34,9 +30,7 @@
"rack": [
"sharpstone/default_ruby",
"sharpstone/mri_187_nokogiri",
"sharpstone/mri_192",
"sharpstone/mri_193",
"sharpstone/mri_200"
"sharpstone/mri_192"
],
"rails_versions": [
"sharpstone/rails_lts_23_default_ruby",
Expand Down
12 changes: 0 additions & 12 deletions hatchet.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
---
- - "./repos/bundler/bad_gemfile_on_platform"
- 5dd45c83631f58d121afb48b513016cc9e2d3432
- - "./repos/bundler/git_gemspec"
- 7755e19caf122e1373bce73ffe9b333e9411d732
- - "./repos/bundler/no_lockfile"
Expand Down Expand Up @@ -33,10 +31,6 @@
- 3fcce9c85bf560dba285cc385ae9845729195826
- - "./repos/rack/mri_192"
- ef6b5ccf8aa2a8f5e3745934e3580dc0bd2d6d4b
- - "./repos/rack/mri_193"
- 2e9ed455517c57b0dc953f54fbf9fef641c7aadb
- - "./repos/rack/mri_200"
- f9922cbd9c6f44fdded54912f66038db37cb4b8f
- - "./repos/rails_versions/active_storage_local"
- 18853ba7dda61745995740b4ca6f5f90bbd8afba
- - "./repos/rails_versions/active_storage_non_local"
Expand Down Expand Up @@ -77,14 +71,8 @@
- f79860bc2866449fe065484f1542aaadd3f7cfd2
- - "./repos/ruby/libpq_connection_error"
- c211c245f09d8335a520cd7a0b5360897d4988eb
- - "./repos/ruby/ruby_193_bad_patch_cedar_14"
- 6948c1460c596f08c4642d616ae73a45dc0ae51a
- - "./repos/ruby/ruby_193_jruby_17161_jdk7"
- c1b632f8a96cf9b902f5cdcd7a190d46544a8144
- - "./repos/ruby/ruby_193_jruby_173"
- a08e8b2cc61d08bd611accaa455dbcbfff80f831
- - "./repos/ruby/ruby_193_jruby_176"
- 9fcbc184cb386abc8784e9935d52d403e35c532c
- - "./repos/ruby/ruby_25"
- 0cb3df80d55b61e9417f2ac00adb06e15ae37982
- - "./repos/ruby/ruby_version_does_not_exist"
Expand Down
2 changes: 0 additions & 2 deletions lib/language_pack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ def self.detect(*args)
require "language_pack/helpers/bundler_wrapper"
require "language_pack/helpers/outdated_ruby_version"
require "language_pack/helpers/download_presence"
require "language_pack/installers/ruby_installer"
require "language_pack/installers/heroku_ruby_installer"
require "language_pack/installers/rbx_installer"

require "language_pack/ruby"
require "language_pack/rack"
Expand Down
17 changes: 17 additions & 0 deletions lib/language_pack/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class LanguagePack::Base
VENDOR_URL = ENV['BUILDPACK_VENDOR_URL'] || "https://ruby-binaries.scalingo.com"
DEFAULT_LEGACY_STACK = "scalingo"
ROOT_DIR = File.expand_path("../../..", __FILE__)
MULTI_ARCH_STACKS = ["heroku-24"]
KNOWN_ARCHITECTURES = ["amd64", "arm64"]

attr_reader :build_path, :cache, :stack

Expand All @@ -36,10 +38,25 @@ def initialize(build_path, cache_path = nil, layer_dir=nil)
@id = Digest::SHA1.hexdigest("#{Time.now.to_f}-#{rand(1000000)}")[0..10]
@fetchers = {:buildpack => LanguagePack::Fetcher.new(VENDOR_URL) }
@layer_dir = layer_dir
@arch = get_arch

Dir.chdir build_path
end

def get_arch
command = "dpkg --print-architecture"
arch = run!(command, silent: true).strip

if !KNOWN_ARCHITECTURES.include?(arch)
raise <<~EOF
Architecture '#{arch}' returned from command `#{command}` is unknown.
Known architectures include: #{KNOWN_ARCHITECTURES.inspect}"
EOF
end

arch
end

def self.===(build_path)
raise "must subclass"
end
Expand Down
17 changes: 4 additions & 13 deletions lib/language_pack/fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ class Fetcher
class FetchError < StandardError; end

include ShellHelpers
CDN_YAML_FILE = File.expand_path("../../../config/cdn.yml", __FILE__)

def initialize(host_url, stack = nil)
@config = load_config
@host_url = fetch_cdn(host_url)
def initialize(host_url, stack: nil, arch: nil)
@host_url = Pathname.new(host_url)
# File.basename prevents accidental directory traversal
@host_url += File.basename(stack) if stack
@host_url += File.basename(arch) if arch
end

def exists?(path, max_attempts = 1)
Expand Down Expand Up @@ -50,14 +50,5 @@ def curl_timeout_in_seconds
def curl_connect_timeout_in_seconds
env('CURL_CONNECT_TIMEOUT') || 10
end

def load_config
YAML.load_file(CDN_YAML_FILE) || {}
end

def fetch_cdn(url)
url = @config[url] || url
Pathname.new(url)
end
end
end
1 change: 0 additions & 1 deletion lib/language_pack/helpers/bundler_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -256,5 +256,4 @@ def parse_gemfile_lock
gemfile_contents = File.read(@gemfile_lock_path)
Bundler::LockfileParser.new(gemfile_contents)
end

end
14 changes: 9 additions & 5 deletions lib/language_pack/helpers/download_presence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@
class LanguagePack::Helpers::DownloadPresence
STACKS = ['scalingo-18', 'scalingo-20', 'scalingo-22']

def initialize(path, stacks: STACKS)
@path = path
def initialize(file_name:, arch: , multi_arch_stacks:, stacks: STACKS )
@file_name = file_name
@stacks = stacks
@fetchers = []
@threads = []
@stacks.each do |stack|
@fetchers << LanguagePack::Fetcher.new(LanguagePack::Base::VENDOR_URL, stack)
if multi_arch_stacks.include?(stack)
@fetchers << LanguagePack::Fetcher.new(LanguagePack::Base::VENDOR_URL, stack: stack, arch: arch)
else
@fetchers << LanguagePack::Fetcher.new(LanguagePack::Base::VENDOR_URL, stack: stack)
end
end
end

Expand All @@ -43,7 +47,7 @@ def exists_on_next_stack?(current_stack: )
return false unless supported_stack?(current_stack: current_stack)

next_index = @stacks.index(current_stack) + 1
@threads[next_index]
@threads[next_index].value
end

def valid_stack_list
Expand All @@ -67,7 +71,7 @@ def does_not_exist?
def call
@fetchers.map do |fetcher|
@threads << Thread.new do
fetcher.exists?(@path, 3)
fetcher.exists?(@file_name, 3)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/language_pack/helpers/outdated_ruby_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
# ruby_version = LanguagePack::RubyVersion.new("ruby-2.2.5")
# outdated = LanguagePack::Helpers::OutdatedRubyVersion.new(
# current_ruby_version: ruby_version,
# fetcher: LanguagePack::Fetcher.new(LanguagePack::Base::VENDOR_URL, "heroku-20")
# fetcher: LanguagePack::Fetcher.new(LanguagePack::Base::VENDOR_URL, stack: "heroku-22")
# fetcher: LanguagePack::Fetcher.new(LanguagePack::Base::VENDOR_URL, stack: "heroku-22", arch: "amd64")
# )
#
# outdated.call
Expand All @@ -34,7 +35,6 @@ def initialize(current_ruby_version: , fetcher:)

def can_check?
return false if current_ruby_version.patchlevel_is_significant?
return false if current_ruby_version.rbx?
return false if current_ruby_version.jruby?

true
Expand Down
56 changes: 45 additions & 11 deletions lib/language_pack/installers/heroku_ruby_installer.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,59 @@
require 'language_pack/installers/ruby_installer'
require 'language_pack/base'
require 'language_pack/shell_helpers'

class LanguagePack::Installers::HerokuRubyInstaller
include LanguagePack::ShellHelpers, LanguagePack::Installers::RubyInstaller
module LanguagePack::Installers; end

class LanguagePack::Installers::HerokuRubyInstaller
BASE_URL = LanguagePack::Base::VENDOR_URL
BIN_DIR = Pathname("bin")

def initialize(stack)
@fetcher = LanguagePack::Fetcher.new(BASE_URL, stack)
include LanguagePack::ShellHelpers
attr_reader :fetcher

def initialize(stack: , multi_arch_stacks: , arch: )
if multi_arch_stacks.include?(stack)
@fetcher = LanguagePack::Fetcher.new(BASE_URL, stack: stack, arch: arch)
else
@fetcher = LanguagePack::Fetcher.new(BASE_URL, stack: stack)
end
end

def fetch_unpack(ruby_version, install_dir, build = false)
def install(ruby_version, install_dir)
fetch_unpack(ruby_version, install_dir)
setup_binstubs(install_dir)
end

def fetch_unpack(ruby_version, install_dir)
FileUtils.mkdir_p(install_dir)
Dir.chdir(install_dir) do
file = "#{ruby_version.version_for_download}.tgz"
if build
file.sub!("ruby", "ruby-build")
@fetcher.fetch_untar("#{ruby_version.version_for_download}.tgz")
end
end

private def setup_binstubs(install_dir)
BIN_DIR.mkpath
run("ln -s ruby #{install_dir}/bin/ruby.exe")

install_pathname = Pathname.new(install_dir)
Dir["#{install_dir}/bin/*"].each do |vendor_bin|
# for Ruby 2.6.0+ don't symlink the Bundler bin so our shim works
next if vendor_bin.include?("bundle")

# The bin/rake binstub generated when compiling ruby does not load bundler
# which can cause unexpected failures. Deleting this binstub allows two things:
#
# - If the app includes a custom binstub allows it to be used
# - If the app does not include a custom binstub, then it will fall back to vendor/bundle/bin/rake
# which is generated by bundler
#
# Discussion: https://github.com/heroku/heroku-buildpack-ruby/issues/1025#issuecomment-653102430
next if vendor_bin.include?("rake")

if install_pathname.absolute?
run("ln -s #{vendor_bin} #{BIN_DIR}")
else
run("ln -s ../#{vendor_bin} #{BIN_DIR}")
end
@fetcher.fetch_untar(file)
end
end
end

20 changes: 0 additions & 20 deletions lib/language_pack/installers/rbx_installer.rb

This file was deleted.

Loading

0 comments on commit 4ad3421

Please sign in to comment.