Skip to content

Commit

Permalink
Pass ENV_DIR to compile script
Browse files Browse the repository at this point in the history
  • Loading branch information
crohr committed Jan 6, 2016
1 parent 00f30df commit aafdeac
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
10 changes: 8 additions & 2 deletions lib/pkgr/builder.rb
Expand Up @@ -110,10 +110,11 @@ def compile
puts "-----> #{buildpack_for_app.banner} app"

FileUtils.mkdir_p(compile_cache_dir)
FileUtils.mkdir_p(compile_env_dir)

run_hook config.before_hook
buildpack_for_app.compile(source_dir, compile_cache_dir)
buildpack_for_app.release(source_dir, compile_cache_dir)
buildpack_for_app.compile(source_dir, compile_cache_dir, compile_env_dir)
buildpack_for_app.release(source_dir)
run_hook config.after_hook
else
raise Errors::UnknownAppType, "Can't find a buildpack for your app"
Expand Down Expand Up @@ -263,6 +264,11 @@ def compile_cache_dir
config.compile_cache_dir || File.join(source_dir, ".git/cache")
end

# Directory where the buildpacks can store config envs.
def compile_env_dir
config.compile_env_dir ||= Dir.mktmpdir
end

# Returns the current distribution we're packaging for.
def distribution
@distribution ||= Distributions.current(config)
Expand Down
8 changes: 4 additions & 4 deletions lib/pkgr/buildpack.rb
Expand Up @@ -35,8 +35,8 @@ def detect(path)
buildpack_detect.exitstatus == 0
end

def compile(path, compile_cache_dir)
cmd = %{env -i PATH="$PATH"#{env} #{dir}/bin/compile "#{path}" "#{compile_cache_dir}" }
def compile(path, compile_cache_dir, compile_env_dir)
cmd = %{env -i PATH="$PATH"#{env} #{dir}/bin/compile "#{path}" "#{compile_cache_dir}" "#{compile_env_dir}" }
Pkgr.debug "Running #{cmd.inspect}"

Dir.chdir(path) do
Expand All @@ -52,8 +52,8 @@ def compile(path, compile_cache_dir)
true
end

def release(path, compile_cache_dir)
buildpack_release = Mixlib::ShellOut.new("#{dir}/bin/release \"#{path}\" \"#{compile_cache_dir}\" > #{path}/.release")
def release(path)
buildpack_release = Mixlib::ShellOut.new("#{dir}/bin/release \"#{path}\" > #{path}/.release")
buildpack_release.logger = Pkgr.logger
buildpack_release.run_command
buildpack_release.exitstatus == 0
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/pkgr/builder_spec.rb
Expand Up @@ -116,15 +116,15 @@
it "raises an error if something occurs during buildpack compilation" do
buildpack = double(Pkgr::Buildpack, :banner => "Ruby/Rails")
builder.stub(:buildpack_for_app => buildpack)
buildpack.should_receive(:compile).with(builder.source_dir, builder.compile_cache_dir).and_raise(Pkgr::Errors::Base)
buildpack.should_receive(:compile).with(builder.source_dir, builder.compile_cache_dir, builder.compile_env_dir).and_raise(Pkgr::Errors::Base)

expect{ builder.compile }.to raise_error(Pkgr::Errors::Base)
end

it "raises an error if something occurs during buildpack release" do
buildpack = double(Pkgr::Buildpack, :banner => "Ruby/Rails", :compile => true)
builder.stub(:buildpack_for_app => buildpack)
buildpack.should_receive(:release).with(builder.source_dir, builder.compile_cache_dir).and_raise(Pkgr::Errors::Base)
buildpack.should_receive(:release).with(builder.source_dir).and_raise(Pkgr::Errors::Base)

expect{ builder.compile }.to raise_error(Pkgr::Errors::Base)
end
Expand Down

0 comments on commit aafdeac

Please sign in to comment.