ohai 17.7.8 → 17.7.12

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: 9624a58f805a1092cf71a19d5cc1501104c297df8b5f5cb9dafc8f288a77a62b
4
- data.tar.gz: fa2839c8ca0d39f53629fc186b77addb1ef02e8783dba59a10f94d94406388ce
3
+ metadata.gz: 152ee2a1456b0508eeb740837c37169e101f860d4398ed71dc2be86207aa9e75
4
+ data.tar.gz: ff72078f7fb2e6eab1207659eb0a66b4bfed98cbf66ca82778830ecfe545e5f4
5
5
  SHA512:
6
- metadata.gz: 4252161549ecd67b7bfd91c7b01673071b54d76179472ac2824965281147a5b40b14b2cc120fc8d2d1a41bc1956041c1c39bf820f3d538f2ee85b61771d11c66
7
- data.tar.gz: 3f1be719448a8c6cb39be6b5cb2f1c9017e05abd223d3b2bc23aedb4891a8663e259f6a3f2828a8a7e5809f52dde821fcefaeeb534af80cc4729ba19bcc63514
6
+ metadata.gz: e0bd1cc8142814db7d670a19cb6c49d7ccbfa7e029ae33ec79d194f27c03abdf07c215e155e50cc052893f9b3aef15a1c4de414e40e370753595fb877fa2c574
7
+ data.tar.gz: 23424895d514fe8ca3384e1155a75cbaba60a684aac6f4e53c924bb34733194691642a3b877f09c8e377b8a0fe59075bb2380d0bba9c8ed0c8abb59eea758aa2
data/Gemfile CHANGED
@@ -9,14 +9,14 @@ gem "chef-utils", git: "https://github.com/chef/chef", branch: "main", glob: "ch
9
9
 
10
10
  # NOTE: do not submit PRs to add pry as a dep, add to your Gemfile.local
11
11
  group :development do
12
- gem "chefstyle", "2.1.2"
12
+ gem "chefstyle", "2.1.3"
13
13
  gem "ipaddr_extensions"
14
14
  gem "rake", ">= 10.1.0"
15
15
  gem "rspec-collection_matchers", "~> 1.0"
16
16
  gem "rspec-core", "~> 3.0"
17
17
  gem "rspec-expectations", "~> 3.0"
18
18
  gem "rspec-mocks", "~> 3.0"
19
- gem "rubocop-performance", "1.11.5"
19
+ gem "rubocop-performance", "1.12.0"
20
20
  gem "rubocop-rspec"
21
21
  end
22
22
 
@@ -0,0 +1,109 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # Author:: Davide Cavalca <dcavalca@fb.com>
5
+ # Copyright:: Copyright (c) 2021 Meta Platforms, Inc. and affiliates.
6
+ # License:: Apache License, Version 2.0
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+
21
+ Ohai.plugin(:Rpm) do
22
+ provides "rpm"
23
+ optional "true"
24
+
25
+ MACROS_MARKER = /========================/.freeze
26
+
27
+ DO_NOT_SPLIT = %w{
28
+ build_arch
29
+ build_os
30
+ install_arch
31
+ install_os
32
+ archcolor
33
+ optflags
34
+ }.freeze
35
+
36
+ collect_data(:aix, :darwin, :dragonflybsd, :freebsd, :linux, :netbsd, :openbsd, :solaris2) do
37
+ rpm_path = which("rpm")
38
+ if rpm_path
39
+ rpm_version_out = shell_out("#{rpm_path} --version")
40
+ rpm_showrc_out = shell_out("#{rpm_path} --showrc")
41
+
42
+ rpm Mash.new unless rpm
43
+ rpm[:macros] ||= Mash.new
44
+
45
+ m = rpm_version_out.stdout.match(/\w+ (\d.*)/)
46
+ if m
47
+ rpm[:version] = m[1]
48
+ end
49
+
50
+ lines = rpm_showrc_out.stdout.split("\n")
51
+ # there's a marker to separate the beginning and end of the macros list
52
+ macros_start_idx = lines.index { |x| x.match(MACROS_MARKER) }
53
+ macros_end_idx = lines.rindex { |x| x.match(MACROS_MARKER) }
54
+ section = nil
55
+ lines[0..macros_start_idx - 1].each do |line|
56
+ if line.start_with?("ARCHITECTURE AND OS")
57
+ section = :arch_os
58
+ rpm[section] ||= Mash.new
59
+ elsif line.start_with?("RPMRC VALUES")
60
+ section = :rpmrc
61
+ rpm[section] ||= Mash.new
62
+ elsif line.start_with?("Features supported by rpmlib")
63
+ section = :features
64
+ rpm[section] ||= Mash.new
65
+ elsif line.start_with?("Macro path")
66
+ fields = line.split(":", 2)
67
+ if fields
68
+ rpm[:macro_path] = fields[1].strip.split(":")
69
+ end
70
+ section = nil
71
+ elsif %i{arch_os rpmrc}.include?(section)
72
+ fields = line.split(":")
73
+ if fields && fields[0] && fields[1]
74
+ key = fields[0].strip.sub("'s", "es").tr(" ", "_")
75
+ if DO_NOT_SPLIT.include?(key)
76
+ values = fields[1].strip
77
+ else
78
+ values = fields[1].strip.split(" ")
79
+ end
80
+ rpm[section][key] = values
81
+ end
82
+ elsif section == :features
83
+ fields = line.split("=")
84
+ if fields && fields[0] && fields[1]
85
+ rpm[section][fields[0].strip] = fields[1].strip
86
+ end
87
+ end
88
+ end
89
+
90
+ name = nil
91
+ value = ""
92
+ lines[macros_start_idx + 1..macros_end_idx - 1].each do |line|
93
+ if line.start_with?("-")
94
+ if name
95
+ rpm[:macros][name] = value
96
+ name = nil
97
+ value = ""
98
+ else
99
+ _prefix, name, value = line.split(" ", 3)
100
+ end
101
+ else
102
+ value += "\n#{line}"
103
+ end
104
+ end
105
+ else
106
+ logger.trace("Plugin RPM: Could not find rpm. Skipping plugin.")
107
+ end
108
+ end
109
+ end
data/lib/ohai/version.rb CHANGED
@@ -19,5 +19,5 @@
19
19
 
20
20
  module Ohai
21
21
  OHAI_ROOT = File.expand_path(__dir__)
22
- VERSION = "17.7.8"
22
+ VERSION = "17.7.12"
23
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ohai
3
3
  version: !ruby/object:Gem::Version
4
- version: 17.7.8
4
+ version: 17.7.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-28 00:00:00.000000000 Z
11
+ date: 2021-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-config
@@ -341,6 +341,7 @@ files:
341
341
  - lib/ohai/plugins/python.rb
342
342
  - lib/ohai/plugins/rackspace.rb
343
343
  - lib/ohai/plugins/root_group.rb
344
+ - lib/ohai/plugins/rpm.rb
344
345
  - lib/ohai/plugins/ruby.rb
345
346
  - lib/ohai/plugins/rust.rb
346
347
  - lib/ohai/plugins/scala.rb