Skip to content
Merged
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
4 changes: 2 additions & 2 deletions lib/java_buildpack/repository/repository_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ def platform
"#{tokens[1].downcase}#{tokens[2]}"
elsif `uname -s` =~ /Darwin/
'mountainlion'
elsif !`which lsb_release 2> /dev/null`.empty?
`lsb_release -cs`.strip
elsif `cat /etc/os-release | grep '^ID=' | cut -d'=' -f 2` =~ /ubuntu/
`cat /etc/os-release | grep '^VERSION_CODENAME=' | cut -d'=' -f 2`.strip
else
raise 'Unable to determine platform'
end
Expand Down
13 changes: 8 additions & 5 deletions spec/java_buildpack/repository/repository_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@

allow_any_instance_of(described_class).to receive(:`).with('uname -s').and_return('Linux')
allow_any_instance_of(described_class).to receive(:`).with('uname -m').and_return('x86_64')
allow_any_instance_of(described_class).to receive(:`).with('which lsb_release 2> /dev/null').and_return('')
allow_any_instance_of(described_class).to receive(:`)
.with("cat /etc/os-release | grep '^ID=' | cut -d'=' -f 2").and_return('')
allow(redhat_release).to receive(:exist?).and_return(true)
allow(redhat_release).to receive(:read).and_return('CentOS release 6.4 (Final)')
allow(application_cache).to receive(:get).with('centos6/x86_64/test-uri/index.yml')
Expand Down Expand Up @@ -106,9 +107,10 @@

allow_any_instance_of(described_class).to receive(:`).with('uname -s').and_return('Linux')
allow_any_instance_of(described_class).to receive(:`).with('uname -m').and_return('x86_64')
allow_any_instance_of(described_class).to receive(:`).with('which lsb_release 2> /dev/null')
.and_return('/usr/bin/lsb_release')
allow_any_instance_of(described_class).to receive(:`).with('lsb_release -cs').and_return('precise')
allow_any_instance_of(described_class).to receive(:`).with("cat /etc/os-release | grep '^ID=' | cut -d'=' -f 2")
.and_return('ubuntu')
allow_any_instance_of(described_class).to receive(:`)
.with("cat /etc/os-release | grep '^VERSION_CODENAME=' | cut -d'=' -f 2").and_return('precise')
allow(application_cache).to receive(:get).with('precise/x86_64/test-uri/index.yml')
.and_yield(Pathname.new('spec/fixtures/test-index.yml').open)

Expand All @@ -124,7 +126,8 @@

allow_any_instance_of(File).to receive(:exists?).with('/etc/redhat-release').and_return(false)
allow_any_instance_of(described_class).to receive(:`).with('uname -s').and_return('Linux')
allow_any_instance_of(described_class).to receive(:`).with('which lsb_release 2> /dev/null').and_return('')
allow_any_instance_of(described_class).to receive(:`)
.with("cat /etc/os-release | grep '^ID=' | cut -d'=' -f 2").and_return('')

expect { described_class.new('{platform}/{architecture}/test-uri') }
.to raise_error('Unable to determine platform')
Expand Down