Skip to content

Commit

Permalink
Merge pull request #12 from opiethehokie/mozroots
Browse files Browse the repository at this point in the history
add mozroots certs to cache and droplet
  • Loading branch information
jgawor committed Jul 13, 2015
2 parents d35e1db + 629bcab commit efb0e4e
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/buildpack/compile/dnu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def initialize(shell)

def restore(dir, out)
@shell.env['HOME'] = dir
@shell.path << '/app/mono/bin'
cmd = "bash -c 'source #{dir}/.dnx/dnvm/dnvm.sh; dnvm use default -r mono -a x64; cd #{dir}; dnu restore'"
@shell.exec(cmd, out)
end
Expand Down
1 change: 1 addition & 0 deletions lib/buildpack/compile/dnx_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def initialize(shell)

def install(dir, out)
@shell.env['HOME'] = dir
@shell.path << '/app/mono/bin'
version = dnx_version(dir, out)
@shell.exec("bash -c 'source #{dir}/.dnx/dnvm/dnvm.sh; dnvm install #{version} -p -r mono'", out)
end
Expand Down
8 changes: 7 additions & 1 deletion lib/buildpack/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,17 @@ def copy_nowin(out)
end

def install_mozroot_certs(out)
mozroots.import(out)
dest_dir = File.join(build_dir, '..')
unless File.exist? File.join(dest_dir, '.config', '.mono', 'certs')
mozroots.import(out)
copier.cp(File.join(Dir.home, '.config', '.mono', 'certs'), File.join(dest_dir, '.config', '.mono'), out)
end
end

def restore_cache(out)
copier.cp(File.join(cache_dir, '.dnx'), build_dir, out) if File.exist? File.join(cache_dir, '.dnx')
copier.cp(File.join(cache_dir, 'mono'), File.join('/', 'app'), out) if File.exist? File.join(cache_dir, 'mono')
copier.cp(File.join(cache_dir, 'certs'), File.join(build_dir, '..', '.config', '.mono'), out) if File.exist? File.join(cache_dir, 'certs')
end

def install_dnvm(out)
Expand All @@ -106,6 +111,7 @@ def move_to_app_dir(out)
def save_cache(out)
copier.cp(File.join(build_dir, '.dnx'), cache_dir, out)
copier.cp(File.join('/app', 'mono'), cache_dir, out) unless File.exists? File.join(cache_dir, 'mono')
copier.cp(File.join(Dir.home, '.config', '.mono', 'certs'), cache_dir, out) unless File.exists? File.join(cache_dir, 'certs')
end

def write_release_yml(out)
Expand Down
16 changes: 15 additions & 1 deletion spec/buildpack/compile/compile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,17 @@

it 'imports the certificates' do
expect(mozroots).to receive(:import)
expect(copier).to receive(:cp).with(File.join(Dir.home, '.config', '.mono', 'certs'), File.join(build_dir, '..', '.config', '.mono'), anything)
compiler.compile
end

context 'when the certificates are already downloaded' do
it 'does not re-download then' do
allow(File).to receive(:exist?).and_return(true)
expect(copier).not_to receive(:cp).with(File.join(Dir.home, '.config', '.mono', 'certs'), anything)
compiler.compile
end
end
end

describe 'Installing DNVM' do
Expand All @@ -181,11 +190,13 @@
before(:each) do
Dir.mkdir(File.join(cache_dir, '.dnx'))
Dir.mkdir(File.join(cache_dir, 'mono'))
FileUtils.mkdir_p(File.join(cache_dir, 'certs'))
end

it 'restores all files from the cache to build dir' do
expect(copier).to receive(:cp).with(File.join(cache_dir, '.dnx'), build_dir, anything)
expect(copier).to receive(:cp).with(File.join(cache_dir, 'mono'), '/app', anything)
expect(copier).to receive(:cp).with(File.join(cache_dir, 'certs'), File.join(build_dir, '..', '.config', '.mono'), anything)
compiler.compile
end
end
Expand Down Expand Up @@ -215,12 +226,15 @@
it 'copies .dnx and mono to cache dir' do
expect(copier).to receive(:cp).with("#{build_dir}/.dnx", cache_dir, anything)
expect(copier).to receive(:cp).with('/app/mono', cache_dir, anything)
expect(copier).to receive(:cp).with(File.join(Dir.home, '.config', '.mono', 'certs'), cache_dir, anything)
compiler.compile
end

context 'when mono is already cached' do
context 'when the cache already exists' do
before(:each) do
Dir.mkdir(File.join(cache_dir, '.dnx'))
Dir.mkdir(File.join(cache_dir, 'mono'))
FileUtils.mkdir_p(File.join(cache_dir, '.config', '.mono', 'certs'))
end
it 'copies only .dnx to cache dir' do
expect(copier).to receive(:cp).with("#{build_dir}/.dnx", cache_dir, anything)
Expand Down
9 changes: 8 additions & 1 deletion spec/buildpack/compile/dnu_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

describe AspNet5Buildpack::DNU do
let(:shell) do
double(:shell, env: {})
double(:shell, env: {}, path: [])
end

let(:out) do
Expand All @@ -37,6 +37,12 @@
expect(shell.env).to include('HOME' => 'app-dir')
end

it 'adds /app/mono/bin to the path' do
allow(shell).to receive(:exec)
dnu.restore('app-dir', out)
expect(shell.path).to include('/app/mono/bin')
end

it 'adds dnu to the PATH' do
allow(shell).to receive(:exec)
expect(shell).to receive(:exec).with(match('dnvm use default'), out)
Expand All @@ -54,4 +60,5 @@
expect(shell).to receive(:exec).with(match('dnu restore'), out)
dnu.restore('app-dir', out)
end

end
8 changes: 7 additions & 1 deletion spec/buildpack/compile/dnx_install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

describe AspNet5Buildpack::DnxInstaller do
let(:shell) do
double(:shell, env: {})
double(:shell, env: {}, path: [])
end

let(:out) do
Expand All @@ -41,6 +41,12 @@
expect(shell.env).to include('HOME' => dir)
end

it 'adds /app/mono/bin to the path' do
allow(shell).to receive(:exec)
installer.install(dir, out)
expect(shell.path).to include('/app/mono/bin')
end

it 'sources the dnvm script' do
allow(shell).to receive(:exec)
expect(shell).to receive(:exec).with(match("source #{dir}/.dnx/dnvm/dnvm.sh"), out)
Expand Down

0 comments on commit efb0e4e

Please sign in to comment.