specinfra 2.93.0 → 2.94.1

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: ca8a3fbef5b6ac5a7dc8eac3fef255b932f5352809870d8d1e314c2e9e8eca30
4
+ data.tar.gz: 637f4451ee3340f5ebc4ca6211d32fb0caa3d6818c0e78578f81bc992a6c87d3
5
5
  SHA512:
6
- metadata.gz: 4013fb3be50562a79f109b4e50caead9171b8d0cae3dbb966016c24c8c0148a940ea894ef62e961a12143765ed9dbb284899563b1639b68e254ad219962d241c
7
- data.tar.gz: ca5897fa506bedeadb3ef834ca4353713a747688c2d91d5758b0b61d54b07429872fc31fbf6ba079bcd7bdcb088eae745c90bdf90e66c0308a10dfe11b85301d
6
+ metadata.gz: 8cec42d4a9fa2b2edeafaa374a2c719ce23fb8527d90cb1bad61d60a461318c9928fca9ae60c85d74b71b90a2f3d3d9e8513395f1fa64f39b9eebc5d8439af59
7
+ data.tar.gz: 79ee89d04e8ab98cb107efa0cf3667bdc4cd65e3007e703a9b6181a54ea23abf639eb29f93b4fc00aa290c44f322d6d334199da4eecc9756bce24469df8fee91
@@ -1,11 +1,13 @@
1
1
  class Class
2
- def subclasses
3
- result = []
4
- ObjectSpace.each_object(Class) do |k|
5
- next unless k < self
6
- next if k.respond_to?(:singleton_class?) && k.singleton_class?
7
- result << k
2
+ if !self.method_defined?(:subclasses)
3
+ def subclasses
4
+ result = []
5
+ ObjectSpace.each_object(Class) do |k|
6
+ next unless k < self
7
+ next if k.respond_to?(:singleton_class?) && k.singleton_class?
8
+ result << k
9
+ end
10
+ result
8
11
  end
9
- result
10
12
  end
11
13
  end
@@ -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.1"
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,13 @@
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.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gosuke Miyashita
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-04-03 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: base64
@@ -529,6 +528,7 @@ files:
529
528
  - lib/specinfra/host_inventory/mount.rb
530
529
  - lib/specinfra/host_inventory/ohai.rb
531
530
  - lib/specinfra/host_inventory/platform.rb
531
+ - lib/specinfra/host_inventory/platform_codename.rb
532
532
  - lib/specinfra/host_inventory/platform_version.rb
533
533
  - lib/specinfra/host_inventory/user.rb
534
534
  - lib/specinfra/host_inventory/virtualization.rb
@@ -667,7 +667,6 @@ homepage: https://github.com/mizzy/specinfra
667
667
  licenses:
668
668
  - MIT
669
669
  metadata: {}
670
- post_install_message:
671
670
  rdoc_options: []
672
671
  require_paths:
673
672
  - lib
@@ -682,13 +681,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
682
681
  - !ruby/object:Gem::Version
683
682
  version: '0'
684
683
  requirements: []
685
- rubygems_version: 3.1.2
686
- signing_key:
684
+ rubygems_version: 3.6.7
687
685
  specification_version: 4
688
686
  summary: Common layer for serverspec and itamae
689
687
  test_files:
690
688
  - Gemfile
691
- - specinfra.gemspec
692
689
  - Rakefile
693
690
  - spec/backend/dockercli/build_command_spec.rb
694
691
  - spec/backend/exec/build_command_spec.rb
@@ -816,3 +813,4 @@ test_files:
816
813
  - spec/host_inventory/solaris/virtualization_spec.rb
817
814
  - spec/processor_spec.rb
818
815
  - spec/spec_helper.rb
816
+ - specinfra.gemspec