specinfra 2.93.0 → 2.94.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/specinfra/helper/detect_os/debian.rb +27 -8
- data/lib/specinfra/host_inventory/platform_codename.rb +9 -0
- data/lib/specinfra/host_inventory.rb +1 -0
- data/lib/specinfra/version.rb +1 -1
- data/spec/backend/exec/build_command_spec.rb +5 -5
- data/spec/helper/detect_os/debian_spec.rb +57 -18
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f6bf89ff57ca268d0d16053349b8159e7a0b2373db8deca0a11e46487f784dc
|
4
|
+
data.tar.gz: b085db7e0f46a09fe08620c3c46cb7ee889c241d1dd63b2dde5ea6f733a3dbb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7992f64477c89f097647475e0d85835e5a11e99c869f0c561aeb7542a2bd6d7385646a8ff131aefb2851d32296da8c6cd8e20029d1b80eadbbb977f9b19c76b4
|
7
|
+
data.tar.gz: 123e61ee049f8ec1cd853739bea854175441ddc29caacabcb223d7e3fd5c2fc372738f03e5dae870af85e0f95ead1d0186165b1a5ee3892616c0a1cdeb1be260
|
@@ -1,17 +1,36 @@
|
|
1
1
|
class Specinfra::Helper::DetectOs::Debian < Specinfra::Helper::DetectOs
|
2
2
|
def detect
|
3
3
|
if (debian_version = run_command('cat /etc/debian_version')) && debian_version.success?
|
4
|
-
distro
|
5
|
-
release
|
6
|
-
|
4
|
+
distro = nil
|
5
|
+
release = nil
|
6
|
+
codename = nil
|
7
|
+
if (lsb_release = run_command("lsb_release -irc")) && lsb_release.success?
|
7
8
|
lsb_release.stdout.each_line do |line|
|
8
|
-
distro
|
9
|
-
release
|
9
|
+
distro = line.split(':').last.strip if line =~ /^Distributor ID:/
|
10
|
+
release = line.split(':').last.strip if line =~ /^Release:/
|
11
|
+
codename = line.split(':').last.strip if line =~ /^Codename:/
|
10
12
|
end
|
11
13
|
elsif (lsb_release = run_command("cat /etc/lsb-release")) && lsb_release.success?
|
12
14
|
lsb_release.stdout.each_line do |line|
|
13
|
-
distro
|
14
|
-
release
|
15
|
+
distro = line.split('=').last.strip if line =~ /^DISTRIB_ID=/
|
16
|
+
release = line.split('=').last.strip if line =~ /^DISTRIB_RELEASE=/
|
17
|
+
codename = line.split('=').last.strip if line =~ /^DISTRIB_CODENAME=/
|
18
|
+
end
|
19
|
+
elsif (lsb_release = run_command("cat /etc/os-release")) && lsb_release.success?
|
20
|
+
lsb_release.stdout.each_line do |line|
|
21
|
+
distro = line.split('=').last.delete('"').strip if line =~ /^ID=/
|
22
|
+
release = line.split('=').last.delete('"').strip if line =~ /^VERSION_ID=/
|
23
|
+
codename = line.split('=').last.delete('"').strip if line =~ /^VERSION_CODENAME=/
|
24
|
+
end
|
25
|
+
# There is no codename notation until Debian Jessie
|
26
|
+
if codename.nil?
|
27
|
+
lsb_release.stdout.each_line do |line|
|
28
|
+
version = line.split('=').last.delete('"').strip if line =~ /^VERSION=/
|
29
|
+
# For debian releases
|
30
|
+
if m = /^[0-9]+ \((\w+)\)$/.match(version)
|
31
|
+
codename = m[1]
|
32
|
+
end
|
33
|
+
end
|
15
34
|
end
|
16
35
|
end
|
17
36
|
distro ||= 'debian'
|
@@ -27,7 +46,7 @@ class Specinfra::Helper::DetectOs::Debian < Specinfra::Helper::DetectOs
|
|
27
46
|
nil
|
28
47
|
end
|
29
48
|
end
|
30
|
-
{ :family => distro.gsub(/[^[:alnum:]]/, '').downcase, :release => release }
|
49
|
+
{ :family => distro.gsub(/[^[:alnum:]]/, '').downcase, :release => release, :codename => codename }
|
31
50
|
end
|
32
51
|
end
|
33
52
|
end
|
data/lib/specinfra/version.rb
CHANGED
@@ -124,11 +124,11 @@ describe 'os' do
|
|
124
124
|
context 'test ubuntu with lsb_release command' do
|
125
125
|
before do
|
126
126
|
allow(Specinfra.backend).to receive(:run_command) do |args|
|
127
|
-
if ['cat /etc/debian_version', 'lsb_release -
|
127
|
+
if ['cat /etc/debian_version', 'lsb_release -irc'].include? args
|
128
128
|
double(
|
129
129
|
:run_command_response,
|
130
130
|
:success? => true,
|
131
|
-
:stdout => "Distributor ID:\tUbuntu\nRelease:\t12.04\n"
|
131
|
+
:stdout => "Distributor ID:\tUbuntu\nRelease:\t12.04\nCodename:\tprecise\n"
|
132
132
|
)
|
133
133
|
elsif args == 'uname -m'
|
134
134
|
double :run_command_response, :success? => true, :stdout => "x86_64\n"
|
@@ -140,7 +140,7 @@ describe 'os' do
|
|
140
140
|
subject! { os }
|
141
141
|
it do
|
142
142
|
expect(Specinfra.backend).to have_received(:run_command).at_least(1).times
|
143
|
-
should eq({:family => 'ubuntu', :release => '12.04', :arch => 'x86_64' })
|
143
|
+
should eq({:family => 'ubuntu', :release => '12.04', :codename => 'precise', :arch => 'x86_64' })
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
@@ -168,7 +168,7 @@ EOF
|
|
168
168
|
subject! { os }
|
169
169
|
it do
|
170
170
|
expect(Specinfra.backend).to have_received(:run_command).at_least(1).times
|
171
|
-
should eq({:family => 'ubuntu', :release => '12.04', :arch => 'x86_64' })
|
171
|
+
should eq({:family => 'ubuntu', :release => '12.04', :codename => 'precise', :arch => 'x86_64' })
|
172
172
|
end
|
173
173
|
end
|
174
174
|
|
@@ -187,7 +187,7 @@ EOF
|
|
187
187
|
subject! { os }
|
188
188
|
it do
|
189
189
|
expect(Specinfra.backend).to have_received(:run_command).at_least(1).times
|
190
|
-
should eq({:family => 'debian', :release => '8.5', :arch => 'x86_64' })
|
190
|
+
should eq({:family => 'debian', :release => '8.5', :codename => nil, :arch => 'x86_64' })
|
191
191
|
end
|
192
192
|
end
|
193
193
|
end
|
@@ -4,79 +4,118 @@ require 'specinfra/helper/detect_os/debian'
|
|
4
4
|
describe Specinfra::Helper::DetectOs::Debian do
|
5
5
|
debian = Specinfra::Helper::DetectOs::Debian.new(Specinfra.backend)
|
6
6
|
|
7
|
+
it 'Should return debian 7 wheezy is installed.' do
|
8
|
+
allow(debian).to receive(:run_command).with('cat /etc/debian_version') {
|
9
|
+
CommandResult.new(:stdout => "", :exit_status => 0)
|
10
|
+
}
|
11
|
+
allow(debian).to receive(:run_command).with('lsb_release -irc') {
|
12
|
+
CommandResult.new(:stdout => "", :exit_status => 1)
|
13
|
+
}
|
14
|
+
allow(debian).to receive(:run_command).with('cat /etc/lsb-release') {
|
15
|
+
CommandResult.new(:stdout => "", :exit_status => 1)
|
16
|
+
}
|
17
|
+
allow(debian).to receive(:run_command).with('cat /etc/os-release') {
|
18
|
+
CommandResult.new(:stdout => "VERSION_ID=\"7\"\nVERSION=\"7 (wheezy)\"\nID=debian\n", :exit_status => 0)
|
19
|
+
}
|
20
|
+
expect(debian.detect).to include(
|
21
|
+
:family => 'debian',
|
22
|
+
:release => '7',
|
23
|
+
:codename => 'wheezy'
|
24
|
+
)
|
25
|
+
end
|
7
26
|
it 'Should return debian 8.5 when jessie is installed.' do
|
8
27
|
allow(debian).to receive(:run_command).with('cat /etc/debian_version') {
|
9
28
|
CommandResult.new(:stdout => "8.5\n", :exit_status => 0)
|
10
29
|
}
|
11
|
-
allow(debian).to receive(:run_command).with('lsb_release -
|
30
|
+
allow(debian).to receive(:run_command).with('lsb_release -irc') {
|
12
31
|
CommandResult.new(:stdout => "8.5\n", :exit_status => 1)
|
13
32
|
}
|
14
33
|
allow(debian).to receive(:run_command).with('cat /etc/lsb-release') {
|
15
34
|
CommandResult.new(:stdout => "8.5\n", :exit_status => 1)
|
16
35
|
}
|
36
|
+
allow(debian).to receive(:run_command).with('cat /etc/os-release') {
|
37
|
+
CommandResult.new(:stdout => "8.5\n", :exit_status => 1)
|
38
|
+
}
|
17
39
|
expect(debian.detect).to include(
|
18
|
-
:family
|
19
|
-
:release
|
40
|
+
:family => 'debian',
|
41
|
+
:release => '8.5',
|
42
|
+
:codename => nil
|
20
43
|
)
|
21
44
|
end
|
22
45
|
it 'Should return ubuntu 16.10 when yakkety is installed.' do
|
23
46
|
allow(debian).to receive(:run_command).with('cat /etc/debian_version') {
|
24
47
|
CommandResult.new(:stdout => "stretch/sid", :exit_status => 0)
|
25
48
|
}
|
26
|
-
allow(debian).to receive(:run_command).with('lsb_release -
|
27
|
-
CommandResult.new(:stdout => "Distributor ID:Ubuntu\nRelease:16.10\n", :exit_status => 0)
|
49
|
+
allow(debian).to receive(:run_command).with('lsb_release -irc') {
|
50
|
+
CommandResult.new(:stdout => "Distributor ID:Ubuntu\nRelease:16.10\nCodename:yakkety\n", :exit_status => 0)
|
28
51
|
}
|
29
52
|
allow(debian).to receive(:run_command).with('cat /etc/lsb-release') {
|
30
53
|
CommandResult.new(:stdout => "DISTRIB_ID=Ubuntu\nDISTRIB_RELEASE=16.10\nDISTRIB_CODENAME=yakkety\nDISTRIB_DESCRIPTION=\"Ubuntu 16.10\"", :exit_status => 0)
|
31
54
|
}
|
55
|
+
allow(debian).to receive(:run_command).with('cat /etc/os-release') {
|
56
|
+
CommandResult.new(:stdout => "", :exit_status => 1)
|
57
|
+
}
|
32
58
|
expect(debian.detect).to include(
|
33
|
-
:family
|
34
|
-
:release
|
59
|
+
:family => 'ubuntu',
|
60
|
+
:release => '16.10',
|
61
|
+
:codename => 'yakkety'
|
35
62
|
)
|
36
63
|
end
|
37
64
|
it 'Should return ubuntu 16.04 when xenial is installed.' do
|
38
65
|
allow(debian).to receive(:run_command).with('cat /etc/debian_version') {
|
39
66
|
CommandResult.new(:stdout => "stretch/sid", :exit_status => 0)
|
40
67
|
}
|
41
|
-
allow(debian).to receive(:run_command).with('lsb_release -
|
42
|
-
CommandResult.new(:stdout => "Distributor ID:Ubuntu\nRelease:16.04\n", :exit_status => 0)
|
68
|
+
allow(debian).to receive(:run_command).with('lsb_release -irc') {
|
69
|
+
CommandResult.new(:stdout => "Distributor ID:Ubuntu\nRelease:16.04\nCodename:xenial\n", :exit_status => 0)
|
43
70
|
}
|
44
71
|
allow(debian).to receive(:run_command).with('cat /etc/lsb-release') {
|
45
72
|
CommandResult.new(:stdout => "DISTRIB_ID=Ubuntu\nDISTRIB_RELEASE=16.04\nDISTRIB_CODENAME=xenial\nDISTRIB_DESCRIPTION=\"Ubuntu 16.04.2 LTS\"", :exit_status => 0)
|
46
73
|
}
|
74
|
+
allow(debian).to receive(:run_command).with('cat /etc/os-release') {
|
75
|
+
CommandResult.new(:stdout => "", :exit_status => 1)
|
76
|
+
}
|
47
77
|
expect(debian.detect).to include(
|
48
|
-
:family
|
49
|
-
:release
|
78
|
+
:family => 'ubuntu',
|
79
|
+
:release => '16.04',
|
80
|
+
:codename => 'xenial'
|
50
81
|
)
|
51
82
|
end
|
52
83
|
it 'Should return ubuntu 16.04 when xenial is installed in docker.' do
|
53
84
|
allow(debian).to receive(:run_command).with('cat /etc/debian_version') {
|
54
85
|
CommandResult.new(:stdout => "stretch/sid", :exit_status => 0)
|
55
86
|
}
|
56
|
-
allow(debian).to receive(:run_command).with('lsb_release -
|
87
|
+
allow(debian).to receive(:run_command).with('lsb_release -irc') {
|
57
88
|
CommandResult.new(:stdout => 'lsb-release is not installed in docker image by default', :exit_status => 1)
|
58
89
|
}
|
59
90
|
allow(debian).to receive(:run_command).with('cat /etc/lsb-release') {
|
60
91
|
CommandResult.new(:stdout => "DISTRIB_ID=Ubuntu\nDISTRIB_RELEASE=16.04\nDISTRIB_CODENAME=xenial\nDISTRIB_DESCRIPTION=\"Ubuntu 16.04.2 LTS\"", :exit_status => 0)
|
61
92
|
}
|
93
|
+
allow(debian).to receive(:run_command).with('cat /etc/os-release') {
|
94
|
+
CommandResult.new(:stdout => "", :exit_status => 1)
|
95
|
+
}
|
62
96
|
expect(debian.detect).to include(
|
63
|
-
:family
|
64
|
-
:release
|
97
|
+
:family => 'ubuntu',
|
98
|
+
:release => '16.04',
|
99
|
+
:codename => 'xenial'
|
65
100
|
)
|
66
101
|
end
|
67
102
|
it 'Should return debian testing when lsb_release says release = n/a' do
|
68
103
|
allow(debian).to receive(:run_command).with('cat /etc/debian_version') {
|
69
104
|
CommandResult.new(:stdout => "bookworm/sid", :exit_status => 0)
|
70
105
|
}
|
71
|
-
allow(debian).to receive(:run_command).with('lsb_release -
|
72
|
-
CommandResult.new(:stdout => "Distributor ID: Debian\nRelease
|
106
|
+
allow(debian).to receive(:run_command).with('lsb_release -irc') {
|
107
|
+
CommandResult.new(:stdout => "Distributor ID: Debian\nRelease:\tn/a\nCodename:\ttrixie\n", :exit_status => 0)
|
73
108
|
}
|
74
109
|
allow(debian).to receive(:run_command).with('cat /etc/lsb-release') {
|
75
110
|
CommandResult.new(:stdout => "", :exit_status => 1)
|
76
111
|
}
|
112
|
+
allow(debian).to receive(:run_command).with('cat /etc/os-release') {
|
113
|
+
CommandResult.new(:stdout => "", :exit_status => 1)
|
114
|
+
}
|
77
115
|
expect(debian.detect).to include(
|
78
|
-
:family
|
79
|
-
:release
|
116
|
+
:family => 'debian',
|
117
|
+
:release => 4294967295.0,
|
118
|
+
:codename => 'trixie'
|
80
119
|
)
|
81
120
|
end
|
82
121
|
end
|
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: 2.
|
4
|
+
version: 2.94.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: 2025-04-
|
11
|
+
date: 2025-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base64
|
@@ -529,6 +529,7 @@ files:
|
|
529
529
|
- lib/specinfra/host_inventory/mount.rb
|
530
530
|
- lib/specinfra/host_inventory/ohai.rb
|
531
531
|
- lib/specinfra/host_inventory/platform.rb
|
532
|
+
- lib/specinfra/host_inventory/platform_codename.rb
|
532
533
|
- lib/specinfra/host_inventory/platform_version.rb
|
533
534
|
- lib/specinfra/host_inventory/user.rb
|
534
535
|
- lib/specinfra/host_inventory/virtualization.rb
|