Skip to content

Commit a7b0b1b

Browse files
Merge pull request #1004 from cloudfoundry/no-lsb-release
Don't use lsb_release to find platform
2 parents 990a896 + b8e54e3 commit a7b0b1b

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

lib/java_buildpack/repository/repository_index.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ def platform
8989
"#{tokens[1].downcase}#{tokens[2]}"
9090
elsif `uname -s` =~ /Darwin/
9191
'mountainlion'
92-
elsif !`which lsb_release 2> /dev/null`.empty?
93-
`lsb_release -cs`.strip
92+
elsif `cat /etc/os-release | grep '^ID=' | cut -d'=' -f 2` =~ /ubuntu/
93+
`cat /etc/os-release | grep '^VERSION_CODENAME=' | cut -d'=' -f 2`.strip
9494
else
9595
raise 'Unable to determine platform'
9696
end

spec/java_buildpack/repository/repository_index_spec.rb

+8-5
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@
7373

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

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

@@ -124,7 +126,8 @@
124126

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

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

0 commit comments

Comments
 (0)