poise-languages 1.4.0 → 2.0.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
  SHA1:
3
- metadata.gz: 0b0b22c0e5713511a2467b58158f1675d591d1f0
4
- data.tar.gz: e4f1bcccbb1bcd84aa28919c03ecd6066f53e543
3
+ metadata.gz: a246857fd31c0cf4787253270c166b5093090e39
4
+ data.tar.gz: 7026c170387e885343071f282efab2bce450ae0b
5
5
  SHA512:
6
- metadata.gz: 7a42e47e7e0cd8815b61756e6bd933aeb1139a8181544b35ad8fe5b620655d107d5355aa9f27ad85040bec1bdc7765b10035860435464200d19d5b73d21de792
7
- data.tar.gz: 1006b3f1fc173a13c145d78bd3bbd96a9a4b0397eaa66505ea4d771b456fe37c634a024daf9b9a615e343cdf5e8dfcfb928002321403b732b23148b956057f77
6
+ metadata.gz: c8dff6c5c9d497b825cf3741d7d2fdb60efb6b5afa9b847dde104f2074d4d34a3b63b54ba2c575e1ec08b401ff446f7242b99183fa96efeb4a62add3b8b6daaf
7
+ data.tar.gz: 9c5d5994987986e48970e3f36d234a3fab8dcb10f8b139fb9e9afce0d7133cb7ba8ce2c86814522515ad1881114240eec368be7dc931de51ba76be8cf0881796
data/.travis.yml CHANGED
@@ -2,7 +2,7 @@ sudo: false
2
2
  cache: bundler
3
3
  language: ruby
4
4
  rvm:
5
- - '2.2'
5
+ - 2.3.1
6
6
  env:
7
7
  - secure: hBSCgjWddgLHgzkhAx1ItgA0joNdevIwYgo6B34fJ9meGVuntP1zbHgEJ/H4wzCnxumU7cvGo0DOy93nctrpy/El9YeQ8pqfqwt0vywDBY7FhNoRV2oW59+TsvOyUvdmO6YThv17qjzWf19Ag15A5X5LgfbCrFdubXpueOSMfgSsHzny3cjF+GTuh8Ykvs8U8914JlhLNc7k7Z/cyXog7i3sO83vaHEWUBytEsnBIc1YXbbp3d1B+7YiF2EDrFxMbyN2BjmjrWpkpl31SgiyneCmw8Vj8Q4T3seK9qRrLeX5HvIdtSa0YLTvxO4kfrsNlgcJgLOmVqqMo2EStT2LRDR1DdeP9Nj8RinqkNQ7lOl4InNK7IM6Kl56dgGmnt7ZVs2kVt1xhzqWQEcRYbP14kUocCzt6A9p4gLy9trQTkBGqgCIcxFqiyfXPLJv3yAYQovGemkv6WfPAViPum7GL+98pBj0TFbiRLLcOljijbAQOi7R2VTdgaHJVBDQ5u8R9mtcecTyiBJwgYn0INY7IjpGoL1mepRNBfG9gW1+awyfvGLeYXe3dISuaPUDKZHaRSKIvJIo2Pi/OxYUPsBLiF4cL8fg6DiB9Ly/AHmI2fgct+lvkByq6ec4NlSWpSyBRtBYF7uCEkXSeSo2MPCEmPxoY/S4pO6Jz6LPtzWRdRk=
8
8
  before_install: "gem install bundler"
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## v2.0.0
4
+
5
+ * Backwards-incompatible change to SCL management to comply with their new repo
6
+ packages and layout. Uses `centos-release-scl-rh` repo package or the
7
+ `rhel-variant-rhscl` RedHat subscription.
8
+
3
9
  ## v1.4.0
4
10
 
5
11
  * Use `poise-archive` to unpack static binary archives. This should work better
@@ -18,6 +18,7 @@ require 'shellwords'
18
18
 
19
19
  require 'poise'
20
20
 
21
+ require 'poise_languages/error'
21
22
  require 'poise_languages/utils'
22
23
 
23
24
 
@@ -179,12 +180,17 @@ module PoiseLanguages
179
180
  end
180
181
  # Inject other options.
181
182
  options[:timeout] ||= new_resource.timeout
183
+ # Find the actual binary to use. Raise an exception if we see false
184
+ # which happens if no parent resource is found, no explicit default
185
+ # binary was given, and which() fails to find a thing.
186
+ binary = new_resource.send(name)
187
+ raise Error.new("Unable to find a #{name} binary for command: #{command_args.is_a?(Array) ? Shellwords.shelljoin(command_args) : command_args}") unless binary
182
188
  command = if command_args.length == 1 && command_args.first.is_a?(String)
183
189
  # String mode, sigh.
184
- "#{Shellwords.escape(new_resource.send(name))} #{command_args.first}"
190
+ "#{Shellwords.escape(binary)} #{command_args.first}"
185
191
  else
186
192
  # Array mode. Handle both ('one', 'two') and (['one', 'two']).
187
- [new_resource.send(name)] + command_args.flatten
193
+ [binary] + command_args.flatten
188
194
  end
189
195
  Chef::Log.debug("[#{new_resource}] Running #{name} command: #{command.is_a?(Array) ? Shellwords.shelljoin(command) : command}")
190
196
  # Run the command
@@ -28,7 +28,6 @@ module PoiseLanguages
28
28
  action :upgrade if options[:package_upgrade]
29
29
  dev_package options[:dev_package] == true ? pkg[:devel_name] : options[:dev_package]
30
30
  parent new_resource
31
- url pkg[:url]
32
31
  version options[:package_version]
33
32
  end
34
33
  end
@@ -80,8 +79,8 @@ module PoiseLanguages
80
79
 
81
80
  module ClassMethods
82
81
  def provides_auto?(node, resource)
83
- # They don't build 32-bit versions for these.
84
- return false unless node['kernel']['machine'] == 'x86_64'
82
+ # They don't build 32-bit versions for these and only for RHEL/CentOS.
83
+ return false unless node['kernel']['machine'] == 'x86_64' && node.platform_family?('rhel')
85
84
  version = inversion_options(node, resource)['version']
86
85
  !!find_scl_package(node, version)
87
86
  end
@@ -104,11 +103,11 @@ module PoiseLanguages
104
103
  end
105
104
 
106
105
  def find_scl_package(node, version)
107
- pkg = scl_packages.find {|p| p[:version].start_with?(version) }
108
- return unless pkg
109
- pkg[:url] = node.value_for_platform(pkg[:urls])
110
- return unless pkg[:url]
111
- pkg
106
+ platform_version = ::Gem::Version.create(node['platform_version'])
107
+ # Filter out anything that doesn't match this EL version.
108
+ candidate_packages = scl_packages.select {|p| p[:platform_version].satisfied_by?(platform_version) }
109
+ # Find something with a prefix match on the Python version.
110
+ candidate_packages.find {|p| p[:version].start_with?(version) }
112
111
  end
113
112
 
114
113
  private
@@ -117,8 +116,8 @@ module PoiseLanguages
117
116
  @scl_packages ||= []
118
117
  end
119
118
 
120
- def scl_package(version, name, devel_name=nil, urls)
121
- scl_packages << {version: version, name: name, devel_name: devel_name, urls: urls}
119
+ def scl_package(version, name, devel_name=nil, platform_version='>= 6.0')
120
+ scl_packages << {version: version, name: name, devel_name: devel_name, platform_version: ::Gem::Requirement.create(platform_version)}
122
121
  end
123
122
 
124
123
  def included(klass)
@@ -39,11 +39,14 @@ module PoiseLanguages
39
39
  # Name of the SCL package for the language.
40
40
  # @return [String]
41
41
  attribute(:package_name, kind_of: String, name_attribute: true)
42
+ # @!attribute dev_package
43
+ # Name of the -devel package with headers and whatnot.
44
+ # @return [String, nil]
42
45
  attribute(:dev_package, kind_of: [String, NilClass])
43
- # @!attribute url
44
- # URL to the SCL repository package for the language.
45
- # @return [String]
46
- attribute(:url, kind_of: String, required: true)
46
+ # @!attribute version
47
+ # Version of the SCL package(s) to install. If unset, follows the same
48
+ # semantics as the core `package` resource.
49
+ # @return [String, nil]
47
50
  attribute(:version, kind_of: [String, NilClass])
48
51
  # @!attribute parent
49
52
  # Resource for the language runtime. Used only for messages.
@@ -66,8 +69,7 @@ module PoiseLanguages
66
69
  # @return [void]
67
70
  def action_install
68
71
  notifying_block do
69
- install_scl_utils
70
- install_scl_repo_package
72
+ install_scl_repo
71
73
  flush_yum_cache
72
74
  install_scl_package(:install)
73
75
  install_scl_devel_package(:install) if new_resource.dev_package
@@ -79,8 +81,7 @@ module PoiseLanguages
79
81
  # @return [void]
80
82
  def action_upgrade
81
83
  notifying_block do
82
- install_scl_utils
83
- install_scl_repo_package
84
+ install_scl_repo
84
85
  flush_yum_cache
85
86
  install_scl_package(:upgrade)
86
87
  install_scl_devel_package(:upgrade) if new_resource.dev_package
@@ -92,25 +93,30 @@ module PoiseLanguages
92
93
  # @return [void]
93
94
  def action_uninstall
94
95
  notifying_block do
95
- uninstall_scl_utils
96
- uninstall_scl_repo_package
97
96
  uninstall_scl_devel_package if new_resource.dev_package
98
97
  uninstall_scl_package
99
- flush_yum_cache
100
98
  end
101
99
  end
102
100
 
103
101
  private
104
102
 
105
- def install_scl_utils
106
- package 'scl-utils' do
107
- action :upgrade # This shouldn't be a problem. Famous last words.
108
- end
109
- end
110
-
111
- def install_scl_repo_package
112
- rpm_package 'rhscl-' + new_resource.package_name do
113
- source new_resource.url
103
+ def install_scl_repo
104
+ if node.platform?('redhat')
105
+ # Set up the real RHSCL subscription.
106
+ # NOTE: THIS IS NOT TESTED BECAUSE REDHAT DOESN'T OFFER ANY WAY TO DO
107
+ # AUTOMATED TESTING. IF YOU USE REDHAT AND THIS BREAKS, PLEASE LET ME
108
+ # KNOW BY FILING A GITHUB ISSUE AT http://github.com/poise/poise-languages/issues/new.
109
+ repo_name = "rhel-variant-rhscl-#{node['platform_version'][0]}-rpms"
110
+ execute "subscription-manager repos --enable #{repo_name}" do
111
+ not_if { shell_out!('subscription-manager repos --list').stdout.include?(repo_name) }
112
+ end
113
+ else
114
+ package 'centos-release-scl-rh' do
115
+ # Using upgrade here because changes very very rare and always
116
+ # important when they happen. If this breaks your prod infra, I'm
117
+ # sorry :-(
118
+ action :upgrade
119
+ end
114
120
  end
115
121
  end
116
122
 
@@ -124,27 +130,16 @@ module PoiseLanguages
124
130
  end
125
131
 
126
132
  def install_scl_package(action)
127
- yum_package new_resource.package_name do
133
+ package new_resource.package_name do
128
134
  action action
129
135
  version new_resource.version
130
136
  end
131
137
  end
132
138
 
133
139
  def install_scl_devel_package(action)
134
- yum_package new_resource.dev_package do
140
+ package new_resource.dev_package do
135
141
  action action
136
- end
137
- end
138
-
139
- def uninstall_scl_utils
140
- install_scl_utils.tap do |r|
141
- r.action(:remove)
142
- end
143
- end
144
-
145
- def uninstall_scl_repo_package
146
- install_scl_repo_package.tap do |r|
147
- r.action(:remove)
142
+ version new_resource.version
148
143
  end
149
144
  end
150
145
 
@@ -16,5 +16,5 @@
16
16
 
17
17
 
18
18
  module PoiseLanguages
19
- VERSION = '1.4.0'
19
+ VERSION = '2.0.0'
20
20
  end
@@ -27,7 +27,7 @@ describe PoiseLanguages::Scl::Mixin do
27
27
  include Poise
28
28
  include described_class
29
29
  def scl_package
30
- {name: 'python34', url: 'http://something.rpm'}
30
+ {name: 'python34', platform_version: ::Gem::Requirement.create('> 0')}
31
31
  end
32
32
  def options
33
33
  {dev_package: true}
@@ -40,7 +40,7 @@ describe PoiseLanguages::Scl::Mixin do
40
40
  poise_test 'test'
41
41
  end
42
42
 
43
- it { is_expected.to install_poise_languages_scl('python34').with(parent: chef_run.poise_test('test'), url: 'http://something.rpm') }
43
+ it { is_expected.to install_poise_languages_scl('python34').with(parent: chef_run.poise_test('test')) }
44
44
  end # /describe #install_scl_package
45
45
 
46
46
  describe '#uninstall_scl_package' do
@@ -48,7 +48,7 @@ describe PoiseLanguages::Scl::Mixin do
48
48
  include Poise
49
49
  include described_class
50
50
  def scl_package
51
- {name: 'python34', url: 'http://something.rpm'}
51
+ {name: 'python34', platform_version: ::Gem::Requirement.create('> 0')}
52
52
  end
53
53
  def options
54
54
  {dev_package: true}
@@ -61,7 +61,7 @@ describe PoiseLanguages::Scl::Mixin do
61
61
  poise_test 'test'
62
62
  end
63
63
 
64
- it { is_expected.to uninstall_poise_languages_scl('python34').with(parent: chef_run.poise_test('test'), url: 'http://something.rpm') }
64
+ it { is_expected.to uninstall_poise_languages_scl('python34').with(parent: chef_run.poise_test('test')) }
65
65
  end # /describe #uninstall_scl_package
66
66
 
67
67
  describe '#scl_package' do
@@ -203,6 +203,7 @@ EOH
203
203
  let(:new_resource) { double('resource') }
204
204
  subject { provider(:poise_test).provides_auto?(node, new_resource) }
205
205
  before do
206
+ allow(node).to receive(:platform_family?) {|name| name == 'rhel' }
206
207
  allow(provider(:poise_test)).to receive(:inversion_options).with(node, new_resource).and_return({})
207
208
  allow(provider(:poise_test)).to receive(:find_scl_package).with(node, nil).and_return({})
208
209
  end
@@ -213,22 +214,8 @@ EOH
213
214
  let(:version) { '' }
214
215
  provider(:poise_test) do
215
216
  include described_class
216
- scl_package('3.4.2', 'rh-python34', 'rh-python34-python-devel', {
217
- ['redhat', 'centos'] => {
218
- '~> 7.0' => 'https://www.softwarecollections.org/en/scls/rhscl/rh-python34/epel-7-x86_64/download/rhscl-rh-python34-epel-7-x86_64.noarch.rpm',
219
- '~> 6.0' => 'https://www.softwarecollections.org/en/scls/rhscl/rh-python34/epel-6-x86_64/download/rhscl-rh-python34-epel-6-x86_64.noarch.rpm',
220
- },
221
- })
222
- scl_package('3.3.2', 'python33', 'python33-python-devel', {
223
- ['redhat', 'centos'] => {
224
- '~> 7.0' => 'https://www.softwarecollections.org/en/scls/rhscl/python33/epel-7-x86_64/download/rhscl-python33-epel-7-x86_64.noarch.rpm',
225
- '~> 6.0' => 'https://www.softwarecollections.org/en/scls/rhscl/python33/epel-6-x86_64/download/rhscl-python33-epel-6-x86_64.noarch.rpm',
226
- },
227
- 'fedora' => {
228
- '~> 21.0' => 'https://www.softwarecollections.org/en/scls/rhscl/python33/fedora-21-x86_64/download/rhscl-python33-fedora-21-x86_64.noarch.rpm',
229
- '~> 20.0' => 'https://www.softwarecollections.org/en/scls/rhscl/python33/fedora-20-x86_64/download/rhscl-python33-fedora-20-x86_64.noarch.rpm',
230
- },
231
- })
217
+ scl_package('3.4.2', 'rh-python34', 'rh-python34-python-devel', '>= 7.0')
218
+ scl_package('3.3.2', 'python33', 'python33-python-devel')
232
219
  end
233
220
  subject { provider(:poise_test).send(:find_scl_package, chef_run.node, version) }
234
221
 
@@ -239,11 +226,33 @@ EOH
239
226
  version: '3.4.2',
240
227
  name: 'rh-python34',
241
228
  devel_name: 'rh-python34-python-devel',
242
- url: 'https://www.softwarecollections.org/en/scls/rhscl/rh-python34/epel-7-x86_64/download/rhscl-rh-python34-epel-7-x86_64.noarch.rpm',
243
229
  })
244
230
  end
245
231
  end # /context on CentOS 7 with no version
246
232
 
233
+ context 'on CentOS 7 with a version' do
234
+ let(:version) { '3.3' }
235
+ let(:chefspec_options) { {platform: 'centos', version: '7.0'} }
236
+ it do
237
+ is_expected.to include({
238
+ version: '3.3.2',
239
+ name: 'python33',
240
+ devel_name: 'python33-python-devel',
241
+ })
242
+ end
243
+ end # /context on CentOS 7 with a version
244
+
245
+ context 'on CentOS 6 with no version' do
246
+ let(:chefspec_options) { {platform: 'centos', version: '6.0'} }
247
+ it do
248
+ is_expected.to include({
249
+ version: '3.3.2',
250
+ name: 'python33',
251
+ devel_name: 'python33-python-devel',
252
+ })
253
+ end
254
+ end # /context on CentOS 6 with no version
255
+
247
256
  context 'on CentOS 6 with a version' do
248
257
  let(:version) { '3.3' }
249
258
  let(:chefspec_options) { {platform: 'centos', version: '6.0'} }
@@ -252,25 +261,14 @@ EOH
252
261
  version: '3.3.2',
253
262
  name: 'python33',
254
263
  devel_name: 'python33-python-devel',
255
- url: 'https://www.softwarecollections.org/en/scls/rhscl/python33/epel-6-x86_64/download/rhscl-python33-epel-6-x86_64.noarch.rpm',
256
264
  })
257
265
  end
258
266
  end # /context on CentOS 6 with a version
259
267
 
260
- context 'on Ubuntu' do
261
- let(:chefspec_options) { {platform: 'ubuntu', version: '12.04'} }
262
- it { is_expected.to be_nil }
263
- end # /context on Ubuntu
264
-
265
268
  context 'with no devel package' do
266
269
  provider(:poise_test) do
267
270
  include described_class
268
- scl_package('3.4.2', 'rh-python34', {
269
- ['redhat', 'centos'] => {
270
- '~> 7.0' => 'https://www.softwarecollections.org/en/scls/rhscl/rh-python34/epel-7-x86_64/download/rhscl-rh-python34-epel-7-x86_64.noarch.rpm',
271
- '~> 6.0' => 'https://www.softwarecollections.org/en/scls/rhscl/rh-python34/epel-6-x86_64/download/rhscl-rh-python34-epel-6-x86_64.noarch.rpm',
272
- },
273
- })
271
+ scl_package('3.4.2', 'rh-python34')
274
272
  end
275
273
  let(:chefspec_options) { {platform: 'centos', version: '7.0'} }
276
274
  it do
@@ -278,7 +276,6 @@ EOH
278
276
  version: '3.4.2',
279
277
  name: 'rh-python34',
280
278
  devel_name: nil,
281
- url: 'https://www.softwarecollections.org/en/scls/rhscl/rh-python34/epel-7-x86_64/download/rhscl-rh-python34-epel-7-x86_64.noarch.rpm',
282
279
  })
283
280
  end
284
281
  end # /context with no devel package
@@ -33,14 +33,12 @@ describe PoiseLanguages::Scl::Resource do
33
33
  poise_languages_scl 'mylang' do
34
34
  dev_package 'mylang-devel'
35
35
  parent r
36
- url 'http://mylang.rpm'
37
36
  end
38
37
  end
39
38
 
40
- it { is_expected.to upgrade_package('scl-utils') }
41
- it { is_expected.to install_rpm_package('rhscl-mylang').with(source: 'http://mylang.rpm') }
42
- it { is_expected.to install_yum_package('mylang') }
43
- it { is_expected.to install_yum_package('mylang-devel') }
39
+ it { is_expected.to upgrade_package('centos-release-scl-rh') }
40
+ it { is_expected.to install_package('mylang') }
41
+ it { is_expected.to install_package('mylang-devel') }
44
42
  it { expect(yum_cache).to receive(:reload); run_chef }
45
43
  end # /context action :install
46
44
 
@@ -53,14 +51,12 @@ describe PoiseLanguages::Scl::Resource do
53
51
  action :upgrade
54
52
  dev_package 'mylang-devel'
55
53
  parent r
56
- url 'http://mylang.rpm'
57
54
  end
58
55
  end
59
56
 
60
- it { is_expected.to upgrade_package('scl-utils') }
61
- it { is_expected.to install_rpm_package('rhscl-mylang').with(source: 'http://mylang.rpm') }
62
- it { is_expected.to upgrade_yum_package('mylang') }
63
- it { is_expected.to upgrade_yum_package('mylang-devel') }
57
+ it { is_expected.to upgrade_package('centos-release-scl-rh') }
58
+ it { is_expected.to upgrade_package('mylang') }
59
+ it { is_expected.to upgrade_package('mylang-devel') }
64
60
  it { expect(yum_cache).to receive(:reload); run_chef }
65
61
  end # /context action :upgrade
66
62
 
@@ -73,14 +69,10 @@ describe PoiseLanguages::Scl::Resource do
73
69
  action :uninstall
74
70
  dev_package 'mylang-devel'
75
71
  parent r
76
- url 'http://mylang.rpm'
77
72
  end
78
73
  end
79
74
 
80
- it { is_expected.to remove_package('scl-utils') }
81
- it { is_expected.to remove_rpm_package('rhscl-mylang') }
82
- it { is_expected.to remove_yum_package('mylang') }
83
- it { is_expected.to remove_yum_package('mylang-devel') }
84
- it { expect(yum_cache).to receive(:reload); run_chef }
75
+ it { is_expected.to remove_package('mylang') }
76
+ it { is_expected.to remove_package('mylang-devel') }
85
77
  end # /context action :uninstall
86
78
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poise-languages
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noah Kantrowitz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-29 00:00:00.000000000 Z
11
+ date: 2016-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: halite
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  version: '0'
139
139
  requirements: []
140
140
  rubyforge_project:
141
- rubygems_version: 2.6.2
141
+ rubygems_version: 2.6.4
142
142
  signing_key:
143
143
  specification_version: 4
144
144
  summary: A Chef cookbook to help writing language cookbooks.
@@ -164,4 +164,3 @@ test_files:
164
164
  - test/spec/system/resource_spec.rb
165
165
  - test/spec/utils/which_spec.rb
166
166
  - test/spec/utils_spec.rb
167
- has_rdoc: