Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create export file for subsequent processes #319

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion lib/language_pack/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,21 @@ def set_env_override(key, val)
add_to_profiled %{export #{key}="#{val.gsub('"','\"')}"}
end

def add_to_export(string)
export = File.expand_path("../../../export", __FILE__)
File.open(export, "a") do |file|
file.puts string
end
end

def set_export_default(key, val)
add_to_export "export #{key}=${#{key}:-#{val}}"
end

def set_export_override(key, val)
add_to_export %{export #{key}="#{val.gsub('"','\"')}"}
end

def log_internal(*args)
message = build_log_message(args)
%x{ logger -p user.notice -t "slugc[$$]" "buildpack-ruby #{message}" }
Expand All @@ -170,4 +185,3 @@ def build_log_message(args)
end.join(" ")
end
end

11 changes: 11 additions & 0 deletions lib/language_pack/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def compile
install_ruby
install_jvm
setup_language_pack_environment
setup_export
setup_profiled
allow_git do
install_bundler_in_app
Expand Down Expand Up @@ -221,6 +222,16 @@ def setup_language_pack_environment
end
end

# sets up the environment variables for subsequent processes
def setup_export
instrument 'ruby.setup_export' do
paths = ENV["PATH"].split(":")
set_export_override "GEM_PATH", "#{build_path}/#{slug_vendor_base}:$GEM_PATH"
set_export_default "LANG", "en_US.UTF-8"
set_export_override "PATH", paths.map {|path| /^\/.*/ !~ path ? "#{build_path}/#{path}" : path}.join(":")
end
end

# sets up the profile.d script for this buildpack
def setup_profiled
instrument 'setup_profiled' do
Expand Down