Skip to content

Commit f2286ab

Browse files
committed
Merge branch 'chrisumbel-master'
[resolves #183][resolves #185]
2 parents 673ce8b + 5183eb9 commit f2286ab

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

lib/java_buildpack/repository/repository_index.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ def platform
8585
redhat_release = Pathname.new('/etc/redhat-release')
8686

8787
if redhat_release.exist?
88-
"centos#{redhat_release.read.match(/CentOS release (\d)/)[1]}"
88+
tokens = redhat_release.read.match(/(\w+) (?:Linux )?release (\d+)/)
89+
"#{tokens[1].downcase}#{tokens[2]}"
8990
elsif `uname -s` =~ /Darwin/
9091
'mountainlion'
9192
elsif !`which lsb_release 2> /dev/null`.empty?

spec/java_buildpack/repository/repository_index_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@
8484
end
8585

8686
it 'handles Mac OS X' do
87+
allow(Pathname).to receive(:new).and_call_original
88+
non_redhat = double('non-redhat', exist?: false)
89+
allow(Pathname).to receive(:new).with('/etc/redhat-release').and_return(non_redhat)
90+
8791
allow_any_instance_of(described_class).to receive(:`).with('uname -s').and_return('Darwin')
8892
allow_any_instance_of(described_class).to receive(:`).with('uname -m').and_return('x86_64')
8993
allow(application_cache).to receive(:get).with('mountainlion/x86_64/test-uri/index.yml')
@@ -95,6 +99,10 @@
9599
end
96100

97101
it 'handles Ubuntu' do
102+
allow(Pathname).to receive(:new).and_call_original
103+
non_redhat = double('non-redhat', exist?: false)
104+
allow(Pathname).to receive(:new).with('/etc/redhat-release').and_return(non_redhat)
105+
98106
allow_any_instance_of(described_class).to receive(:`).with('uname -s').and_return('Linux')
99107
allow_any_instance_of(described_class).to receive(:`).with('uname -m').and_return('x86_64')
100108
allow_any_instance_of(described_class).to receive(:`).with('which lsb_release 2> /dev/null')
@@ -109,6 +117,10 @@
109117
end
110118

111119
it 'handles unknown OS' do
120+
allow(Pathname).to receive(:new).and_call_original
121+
non_redhat = double('non-redhat', exist?: false)
122+
allow(Pathname).to receive(:new).with('/etc/redhat-release').and_return(non_redhat)
123+
112124
allow_any_instance_of(File).to receive(:exists?).with('/etc/redhat-release').and_return(false)
113125
allow_any_instance_of(described_class).to receive(:`).with('uname -s').and_return('Linux')
114126
allow_any_instance_of(described_class).to receive(:`).with('which lsb_release 2> /dev/null').and_return('')

0 commit comments

Comments
 (0)