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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e321cef299b5304cbd2be799da02c91b6f8f27eb0e262874b6277641e54becf7
4
- data.tar.gz: 520fa85f14e29cce1e7d902854eabbabbf7151db348432cd41ace8b0803ce8b7
3
+ metadata.gz: 3f6bf89ff57ca268d0d16053349b8159e7a0b2373db8deca0a11e46487f784dc
4
+ data.tar.gz: b085db7e0f46a09fe08620c3c46cb7ee889c241d1dd63b2dde5ea6f733a3dbb9
5
5
  SHA512:
6
- metadata.gz: 4013fb3be50562a79f109b4e50caead9171b8d0cae3dbb966016c24c8c0148a940ea894ef62e961a12143765ed9dbb284899563b1639b68e254ad219962d241c
7
- data.tar.gz: ca5897fa506bedeadb3ef834ca4353713a747688c2d91d5758b0b61d54b07429872fc31fbf6ba079bcd7bdcb088eae745c90bdf90e66c0308a10dfe11b85301d
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 = nil
5
- release = nil
6
- if (lsb_release = run_command("lsb_release -ir")) && lsb_release.success?
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 = line.split(':').last.strip if line =~ /^Distributor ID:/
9
- release = line.split(':').last.strip if line =~ /^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 = line.split('=').last.strip if line =~ /^DISTRIB_ID=/
14
- release = line.split('=').last.strip if line =~ /^DISTRIB_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
@@ -0,0 +1,9 @@
1
+ module Specinfra
2
+ class HostInventory
3
+ class PlatformCodename < Base
4
+ def get
5
+ backend.os_info[:codename]
6
+ end
7
+ end
8
+ end
9
+ end
@@ -7,6 +7,7 @@ module Specinfra
7
7
  domain
8
8
  fqdn
9
9
  platform
10
+ platform_codename
10
11
  platform_version
11
12
  filesystem
12
13
  cpu
@@ -1,5 +1,5 @@
1
1
  module Specinfra
2
- VERSION = "2.93.0"
2
+ VERSION = "2.94.0"
3
3
 
4
4
  def self.ruby_is_older_than?(*version)
5
5
  (RUBY_VERSION.split('.').map(&:to_i) <=> version) < 0
@@ -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 -ir'].include? args
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 -ir') {
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 => 'debian',
19
- :release => '8.5'
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 -ir') {
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 => 'ubuntu',
34
- :release => '16.10'
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 -ir') {
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 => 'ubuntu',
49
- :release => '16.04'
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 -ir') {
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 => 'ubuntu',
64
- :release => '16.04'
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 -ir') {
72
- CommandResult.new(:stdout => "Distributor ID: Debian\nRelease: n/a\n", :exit_status => 0)
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 => 'debian',
79
- :release => 4294967295.0
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.93.0
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-03 00:00:00.000000000 Z
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