specinfra 1.11.0 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/specinfra/backend/exec.rb +23 -21
- data/lib/specinfra/configuration.rb +9 -0
- data/lib/specinfra/helper/detect_os.rb +11 -4
- data/lib/specinfra/version.rb +1 -1
- data/spec/backend/exec/build_command_spec.rb +30 -25
- data/spec/configuration_spec.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f67f6404a72167028cc78c1347bd67da39f57205
|
4
|
+
data.tar.gz: d6fe99bbcc3f6b80d18319bb85b472ee0dd37abf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d73b47ee671274ed47e26b7d1a4b1dad79a7dd701fdc0af0fee4ba067425d30fd8608c29b7412884cd53b583733fc0d111545ed2cfd7021613bfd090a2b53a90
|
7
|
+
data.tar.gz: 647c9fbd5a46351fc3ff195d21ddc9f9dde50b5e6631429ec4c71aa46ee16711aa2a932af0a0dd7578a3f1fa7a2ee83313de7d030b32931f770341e23f09dc3a
|
@@ -181,6 +181,7 @@ module SpecInfra
|
|
181
181
|
|
182
182
|
def check_os
|
183
183
|
return SpecInfra.configuration.os if SpecInfra.configuration.os
|
184
|
+
arch = run_command('uname -m').stdout.strip
|
184
185
|
# Fedora also has an /etc/redhat-release so the Fedora check must
|
185
186
|
# come before the RedHat check
|
186
187
|
if run_command('ls /etc/fedora-release').success?
|
@@ -194,19 +195,20 @@ module SpecInfra
|
|
194
195
|
if line =~ /release (\d[\d.]*)/
|
195
196
|
release = $1
|
196
197
|
end
|
198
|
+
|
197
199
|
if release =~ /7./
|
198
|
-
{ :family => 'RedHat7', :release => release }
|
200
|
+
{ :family => 'RedHat7', :release => release, :arch => arch }
|
199
201
|
else
|
200
|
-
{ :family => 'RedHat', :release => release }
|
202
|
+
{ :family => 'RedHat', :release => release, :arch => arch }
|
201
203
|
end
|
202
204
|
elsif run_command('ls /etc/system-release').success?
|
203
|
-
{ :family => 'RedHat', :release => nil } # Amazon Linux
|
205
|
+
{ :family => 'RedHat', :release => nil, :arch => arch } # Amazon Linux
|
204
206
|
elsif run_command('ls /etc/SuSE-release').success?
|
205
207
|
line = run_command('cat /etc/SuSE-release').stdout
|
206
208
|
if line =~ /SUSE Linux Enterprise Server (\d+)/
|
207
209
|
release = $1
|
208
210
|
end
|
209
|
-
{ :family => 'SuSE', :release => release }
|
211
|
+
{ :family => 'SuSE', :release => release, :arch => arch }
|
210
212
|
elsif run_command('ls /etc/debian_version').success?
|
211
213
|
lsb_release = run_command("lsb_release -ir")
|
212
214
|
if lsb_release.success?
|
@@ -225,37 +227,37 @@ module SpecInfra
|
|
225
227
|
end
|
226
228
|
distro ||= 'Debian'
|
227
229
|
release ||= nil
|
228
|
-
{ :family => distro.strip, :release => release }
|
230
|
+
{ :family => distro.strip, :release => release, :arch => arch }
|
229
231
|
elsif run_command('ls /etc/gentoo-release').success?
|
230
|
-
{ :family => 'Gentoo', :release => nil }
|
232
|
+
{ :family => 'Gentoo', :release => nil, :arch => arch }
|
231
233
|
elsif run_command('ls /usr/lib/setup/Plamo-*').success?
|
232
|
-
{ :family => 'Plamo', :release => nil }
|
234
|
+
{ :family => 'Plamo', :release => nil, :arch => arch }
|
233
235
|
elsif run_command('uname -s').stdout =~ /AIX/i
|
234
|
-
{ :family => 'AIX', :release => nil }
|
235
|
-
elsif (
|
236
|
-
if
|
237
|
-
{ :family => 'Solaris10', :release => nil }
|
236
|
+
{ :family => 'AIX', :release => nil, :arch => arch }
|
237
|
+
elsif ( uname = run_command('uname -sr').stdout) && uname =~ /SunOS/i
|
238
|
+
if uname =~ /5.10/
|
239
|
+
{ :family => 'Solaris10', :release => nil, :arch => arch }
|
238
240
|
elsif run_command('grep -q "Oracle Solaris 11" /etc/release').success?
|
239
|
-
{ :family => 'Solaris11', :release => nil }
|
241
|
+
{ :family => 'Solaris11', :release => nil, :arch => arch }
|
240
242
|
elsif run_command('grep -q SmartOS /etc/release').success?
|
241
|
-
{ :family => 'SmartOS', :release => nil }
|
243
|
+
{ :family => 'SmartOS', :release => nil, :arch => arch }
|
242
244
|
else
|
243
|
-
{ :family => 'Solaris', :release => nil }
|
245
|
+
{ :family => 'Solaris', :release => nil, :arch => arch }
|
244
246
|
end
|
245
247
|
elsif run_command('uname -s').stdout =~ /Darwin/i
|
246
248
|
{ :family => 'Darwin', :release => nil }
|
247
|
-
elsif (
|
248
|
-
if
|
249
|
-
{ :family => 'FreeBSD10', :release => nil }
|
249
|
+
elsif ( uname = run_command('uname -sr').stdout ) && uname =~ /FreeBSD/i
|
250
|
+
if uname =~ /10./
|
251
|
+
{ :family => 'FreeBSD10', :release => nil, :arch => arch }
|
250
252
|
else
|
251
|
-
{ :family => 'FreeBSD', :release => nil }
|
253
|
+
{ :family => 'FreeBSD', :release => nil, :arch => arch }
|
252
254
|
end
|
253
255
|
elsif run_command('uname -sr').stdout =~ /Arch/i
|
254
|
-
{ :family => 'Arch', :release => nil }
|
256
|
+
{ :family => 'Arch', :release => nil, :arch => arch }
|
255
257
|
elsif run_command('uname -s').stdout =~ /OpenBSD/i
|
256
|
-
{ :family => 'OpenBSD', :release => nil }
|
258
|
+
{ :family => 'OpenBSD', :release => nil, :arch => arch }
|
257
259
|
else
|
258
|
-
{ :family => 'Base', :release => nil }
|
260
|
+
{ :family => 'Base', :release => nil, :arch => arch }
|
259
261
|
end
|
260
262
|
end
|
261
263
|
|
@@ -19,6 +19,15 @@ module SpecInfra
|
|
19
19
|
VALID_OPTIONS_KEYS.inject({}) { |o, k| o.merge!(k => send(k)) }
|
20
20
|
end
|
21
21
|
|
22
|
+
# Define os method explicitly to avoid stack level
|
23
|
+
# too deep caused by Helpet::DetectOS#os
|
24
|
+
def os
|
25
|
+
if @os.nil? && defined?(RSpec) && RSpec.configuration.respond_to?(:os)
|
26
|
+
@os = RSpec.configuration.os
|
27
|
+
end
|
28
|
+
@os
|
29
|
+
end
|
30
|
+
|
22
31
|
def method_missing(meth, val=nil)
|
23
32
|
key = meth.to_s
|
24
33
|
key.gsub!(/=$/, '')
|
@@ -2,17 +2,24 @@ module SpecInfra
|
|
2
2
|
module Helper
|
3
3
|
module DetectOS
|
4
4
|
def commands
|
5
|
+
self.class.const_get('SpecInfra').const_get('Command').const_get(os[:family]).new
|
6
|
+
end
|
7
|
+
|
8
|
+
def os
|
5
9
|
property[:os_by_host] = {} if ! property[:os_by_host]
|
6
10
|
host = SpecInfra.configuration.ssh ? SpecInfra.configuration.ssh.host : 'localhost'
|
7
11
|
|
8
12
|
if property[:os_by_host][host]
|
9
|
-
|
13
|
+
os_by_host = property[:os_by_host][host]
|
10
14
|
else
|
11
15
|
# Set command object explicitly to avoid `stack too deep`
|
12
|
-
|
13
|
-
|
16
|
+
raise "crash me" if caller.length > 500
|
17
|
+
os_by_host = backend(SpecInfra::Command::Base.new).check_os
|
18
|
+
|
19
|
+
property[:os_by_host][host] = os_by_host
|
14
20
|
end
|
15
|
-
|
21
|
+
|
22
|
+
os_by_host
|
16
23
|
end
|
17
24
|
end
|
18
25
|
end
|
data/lib/specinfra/version.rb
CHANGED
@@ -35,56 +35,61 @@ describe 'check_os' do
|
|
35
35
|
context 'test ubuntu with lsb_release command' do
|
36
36
|
subject { backend.check_os }
|
37
37
|
it do
|
38
|
-
mock_success_response = double(
|
39
|
-
:run_command_response,
|
40
|
-
:success? => true,
|
41
|
-
:stdout => "Distributor ID:\tUbuntu\nRelease:\t12.04\n"
|
42
|
-
)
|
43
|
-
mock_failure_response = double :run_command_response, :success? => false
|
44
38
|
backend.should_receive(:run_command).at_least(1).times do |args|
|
45
39
|
if ['ls /etc/debian_version', 'lsb_release -ir'].include? args
|
46
|
-
|
40
|
+
double(
|
41
|
+
:run_command_response,
|
42
|
+
:success? => true,
|
43
|
+
:stdout => "Distributor ID:\tUbuntu\nRelease:\t12.04\n"
|
44
|
+
)
|
45
|
+
elsif args == 'uname -m'
|
46
|
+
double :run_command_response, :success? => true, :stdout => "x86_64\n"
|
47
47
|
else
|
48
|
-
|
48
|
+
double :run_command_response, :success? => false
|
49
49
|
end
|
50
50
|
end
|
51
|
-
should eq({:family => 'Ubuntu', :release => '12.04'})
|
51
|
+
should eq({:family => 'Ubuntu', :release => '12.04', :arch => 'x86_64' })
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
55
|
context 'test ubuntu with /etc/lsb-release' do
|
56
56
|
subject { backend.check_os }
|
57
57
|
it do
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
58
|
+
backend.should_receive(:run_command).at_least(1).times do |args|
|
59
|
+
if ['ls /etc/debian_version', 'cat /etc/lsb-release'].include? args
|
60
|
+
double(
|
61
|
+
:run_command_response,
|
62
|
+
:success? => true,
|
63
|
+
:stdout => <<-EOF
|
64
|
+
DISTRIB_ID=Ubuntu
|
62
65
|
DISTRIB_RELEASE=12.04
|
63
66
|
DISTRIB_CODENAME=precise
|
64
67
|
DISTRIB_DESCRIPTION="Ubuntu 12.04.2 LTS"
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
if ['ls /etc/debian_version', 'cat /etc/lsb-release'].include? args
|
70
|
-
mock_success_response
|
68
|
+
EOF
|
69
|
+
)
|
70
|
+
elsif args == 'uname -m'
|
71
|
+
double :run_command_response, :success? => true, :stdout => "x86_64\n"
|
71
72
|
else
|
72
|
-
|
73
|
+
double :run_command_response, :success? => false
|
73
74
|
end
|
74
75
|
end
|
75
|
-
should eq({:family => 'Ubuntu', :release => '12.04'})
|
76
|
+
should eq({:family => 'Ubuntu', :release => '12.04', :arch => 'x86_64' })
|
76
77
|
end
|
77
78
|
end
|
78
79
|
|
79
80
|
context 'test debian (no lsb_release or lsb-release)' do
|
80
81
|
subject { backend.check_os }
|
81
82
|
it do
|
82
|
-
mock_success_response = double :run_command_response, :success? => true
|
83
|
-
mock_failure_response = double :run_command_response, :success? => false
|
84
83
|
backend.should_receive(:run_command).at_least(1).times do |args|
|
85
|
-
args == 'ls /etc/debian_version'
|
84
|
+
if args == 'ls /etc/debian_version'
|
85
|
+
double :run_command_response, :success? => true
|
86
|
+
elsif args == 'uname -m'
|
87
|
+
double :run_command_response, :success? => true, :stdout => "x86_64\n"
|
88
|
+
else
|
89
|
+
double :run_command_response, :success? => false
|
90
|
+
end
|
86
91
|
end
|
87
|
-
should eq({:family => 'Debian', :release => nil})
|
92
|
+
should eq({:family => 'Debian', :release => nil, :arch => 'x86_64' })
|
88
93
|
end
|
89
94
|
end
|
90
95
|
end
|
data/spec/configuration_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: specinfra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gosuke Miyashita
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|