poise-languages 1.3.3 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 008fbb1c6b0f93e7579a1501d0bf326e1856a021
4
- data.tar.gz: 25b5176424836a53b9143d4b6d143a3c64d33cac
3
+ metadata.gz: 0b0b22c0e5713511a2467b58158f1675d591d1f0
4
+ data.tar.gz: e4f1bcccbb1bcd84aa28919c03ecd6066f53e543
5
5
  SHA512:
6
- metadata.gz: ecee153c5e3d81b2f310d0449c266be92573fb5558c5a3b3db3c548b3df3609a9845ce196ec0302a7a186213ef12d1f46f8bbb9a28376364efa84d68aea71a08
7
- data.tar.gz: 20812e074fac41b31241e9504f4b9084d312f30d831da11c82ccd6ec969579ccfbc64b56120329f6e498ee23ee1ba7b3a9d0c5eb5ff15262a9c22670039a57be
6
+ metadata.gz: 7a42e47e7e0cd8815b61756e6bd933aeb1139a8181544b35ad8fe5b620655d107d5355aa9f27ad85040bec1bdc7765b10035860435464200d19d5b73d21de792
7
+ data.tar.gz: 1006b3f1fc173a13c145d78bd3bbd96a9a4b0397eaa66505ea4d771b456fe37c634a024daf9b9a615e343cdf5e8dfcfb928002321403b732b23148b956057f77
data/.travis.yml CHANGED
@@ -17,4 +17,6 @@ gemfile:
17
17
  - test/gemfiles/chef-12.4.gemfile
18
18
  - test/gemfiles/chef-12.5.gemfile
19
19
  - test/gemfiles/chef-12.6.gemfile
20
+ - test/gemfiles/chef-12.7.gemfile
21
+ - test/gemfiles/chef-12.8.gemfile
20
22
  - test/gemfiles/master.gemfile
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.4.0
4
+
5
+ * Use `poise-archive` to unpack static binary archives. This should work better
6
+ on AIX and Solaris, as well as making it easier to add more archive formats in
7
+ the future.
8
+
3
9
  ## v1.3.3
4
10
 
5
11
  * [#3](https://github.com/poise/poise-languages/pull/3) Fix `static` binary
data/Gemfile CHANGED
@@ -29,5 +29,6 @@ end
29
29
 
30
30
  dev_gem 'halite'
31
31
  dev_gem 'poise'
32
+ dev_gem 'poise-archive'
32
33
  dev_gem 'poise-boiler'
33
34
  dev_gem 'poise-profiler'
@@ -52,7 +52,7 @@ module PoiseLanguages
52
52
  version: options['static_version'],
53
53
  kernel: node['kernel']['name'].downcase,
54
54
  machine: node['kernel']['machine'],
55
- machine_label: self.class.static_machine_label(node),
55
+ machine_label: self.class.static_machine_label_wrapper(node, new_resource),
56
56
  }
57
57
  end
58
58
 
@@ -67,7 +67,7 @@ module PoiseLanguages
67
67
  def provides_auto?(node, resource)
68
68
  # Check that the version starts with our project name and the machine
69
69
  # we are on is supported.
70
- resource.version.to_s =~ /^#{static_name}(-|$)/ && static_machines.include?(static_machine_label(node))
70
+ resource.version.to_s =~ /^#{static_name}(-|$)/ && static_machines.include?(static_machine_label_wrapper(node, resource))
71
71
  end
72
72
 
73
73
  # Set some default inversion provider options. Package name can't get
@@ -111,14 +111,26 @@ module PoiseLanguages
111
111
  end
112
112
  end
113
113
 
114
- def static_machine_label(node)
114
+ def static_machine_label(node, _resource=nil)
115
115
  "#{node['kernel']['name'].downcase}-#{node['kernel']['machine']}"
116
116
  end
117
117
 
118
+ # Wrapper for {#static_machine_label} because I need to add an argument.
119
+ # This preserves backwards compat.
120
+ #
121
+ # @api private
122
+ def static_machine_label_wrapper(node, resource)
123
+ args = [node]
124
+ arity = method(:static_machine_label).arity
125
+ args << resource if arity > 1 || arity < 0
126
+ static_machine_label(*args)
127
+ end
128
+
118
129
  def included(klass)
119
130
  super
120
131
  klass.extend ClassMethods
121
132
  end
133
+
122
134
  end
123
135
 
124
136
  extend ClassMethods
@@ -72,7 +72,6 @@ module PoiseLanguages
72
72
  # @return [void]
73
73
  def action_install
74
74
  notifying_block do
75
- install_utils unless node.platform_family?('mac_os_x', 'windows', 'aix', 'solaris2')
76
75
  download_archive
77
76
  create_directory
78
77
  # Unpack is handled as a notification from download_archive.
@@ -91,22 +90,13 @@ module PoiseLanguages
91
90
 
92
91
  private
93
92
 
94
- def install_utils
95
- package [].tap {|utils|
96
- utils << 'tar' if new_resource.cache_path =~ /\.t(ar|gz|bz|xz)/
97
- utils << 'bzip2' if new_resource.cache_path =~ /\.t?bz/
98
- # This probably won't work on RHEL?
99
- utils << 'xz-utils' if new_resource.cache_path =~ /\.t?xz/
100
- }
101
- end
102
-
103
93
  def create_directory
104
94
  unpack_resource = unpack_archive
105
95
  directory new_resource.path do
106
96
  user 0
107
97
  group 0
108
98
  mode '755'
109
- notifies :run, unpack_resource, :immediately
99
+ notifies :unpack, unpack_resource, :immediately
110
100
  end
111
101
  end
112
102
 
@@ -117,32 +107,17 @@ module PoiseLanguages
117
107
  owner 0
118
108
  group 0
119
109
  mode '644'
120
- notifies :run, unpack_resource, :immediately if ::File.exist?(new_resource.path)
110
+ notifies :unpack, unpack_resource, :immediately if ::File.exist?(new_resource.path)
121
111
  retries new_resource.download_retries
122
112
  end
123
113
  end
124
114
 
125
115
  def unpack_archive
126
- # Build up the unpack command. Someday this will probably need to
127
- # support unzip too.
128
- cmd = %w{tar}
129
- cmd << "--strip-components=#{new_resource.strip_components}" if new_resource.strip_components && new_resource.strip_components > 0
130
- cmd << if new_resource.cache_path =~ /\.t?gz/
131
- '-xzvf'
132
- elsif new_resource.cache_path =~ /\.t?bz/
133
- '-xjvf'
134
- elsif new_resource.cache_path =~ /\.t?xz/
135
- '-xJvf'
136
- else
137
- '-xvf'
138
- end
139
- cmd << new_resource.cache_path
140
-
141
- @unpack_archive ||= execute 'unpack archive' do
142
- # Run via notification from #download_archive.
116
+ @unpack_archive ||= poise_archive new_resource.cache_path do
117
+ # Run via notification from #download_archive and #create_directory.
143
118
  action :nothing
144
- command cmd
145
- cwd new_resource.path
119
+ destination new_resource.path
120
+ strip_components new_resource.strip_components
146
121
  end
147
122
  end
148
123
 
@@ -29,7 +29,7 @@ module PoiseLanguages
29
29
  # @return [PoiseLanguages::System::Resource]
30
30
  def install_system_packages
31
31
  dev_package_overrides = system_dev_package_overrides
32
- poise_languages_system options['package_name'] || system_package_name do
32
+ poise_languages_system system_package_name do
33
33
  # Otherwise use the default install action.
34
34
  action(:upgrade) if options['package_upgrade']
35
35
  parent new_resource
@@ -68,6 +68,8 @@ module PoiseLanguages
68
68
  # @api public
69
69
  # @return [String]
70
70
  def system_package_name
71
+ # If we have an override, just use that.
72
+ return options['package_name'] if options['package_name']
71
73
  # Look up all packages for this language on this platform.
72
74
  system_packages = self.class.packages && node.value_for_platform(self.class.packages)
73
75
  if !system_packages && self.class.default_package
@@ -16,5 +16,5 @@
16
16
 
17
17
 
18
18
  module PoiseLanguages
19
- VERSION = '1.3.3'
19
+ VERSION = '1.4.0'
20
20
  end
@@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
35
35
 
36
36
  spec.add_dependency 'halite', '~> 1.0'
37
37
  spec.add_dependency 'poise', '~> 2.5'
38
+ spec.add_dependency 'poise-archive', '~> 1.0'
38
39
 
39
40
  spec.add_development_dependency 'poise-boiler', '~> 1.0'
40
41
  end
@@ -0,0 +1,19 @@
1
+ #
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
+
19
+ gem 'chef', '~> 12.7.2'
@@ -0,0 +1,19 @@
1
+ #
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
+
19
+ gem 'chef', '~> 12.8.1'
@@ -19,5 +19,6 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
19
19
  gem 'chef', github: 'chef/chef'
20
20
  gem 'halite', github: 'poise/halite'
21
21
  gem 'poise', github: 'poise/poise'
22
+ gem 'poise-archive', github: 'poise/poise-archive'
22
23
  gem 'poise-boiler', github: 'poise/poise-boiler'
23
24
  gem 'poise-profiler', github: 'poise/poise-profiler'
@@ -16,3 +16,4 @@
16
16
 
17
17
  require 'poise_boiler/spec_helper'
18
18
  require 'poise_languages'
19
+ require 'poise_archive/cheftie'
@@ -23,120 +23,16 @@ describe PoiseLanguages::Static::Resource do
23
23
  chef_run.execute('unpack archive')
24
24
  end
25
25
 
26
- context 'on Ubuntu' do
26
+ context 'action :install' do
27
27
  recipe do
28
28
  poise_languages_static '/opt/myapp' do
29
29
  source 'http://example.com/myapp.tar'
30
30
  end
31
31
  end
32
32
 
33
- it { is_expected.to install_package('tar') }
34
- it { is_expected.to create_directory('/opt/myapp') }
35
- it { is_expected.to create_remote_file("#{Chef::Config[:file_cache_path]}/myapp.tar").with(source: 'http://example.com/myapp.tar') }
36
- end # /context on Ubuntu
37
-
38
- context 'on Solaris' do
39
- let(:chefspec_options) { {platform: 'solaris2', version: '5.11'} }
40
- recipe do
41
- poise_languages_static '/opt/myapp' do
42
- source 'http://example.com/myapp.tar'
43
- end
44
- end
45
-
46
- it { is_expected.to_not install_package('tar') }
47
- it { is_expected.to create_directory('/opt/myapp') }
48
- it { is_expected.to create_remote_file("#{Chef::Config[:file_cache_path]}/myapp.tar").with(source: 'http://example.com/myapp.tar') }
49
- end # /context on Solaris
50
-
51
- context 'on AIX' do
52
- let(:chefspec_options) { {platform: 'aix', version: '7.1'} }
53
- recipe do
54
- poise_languages_static '/opt/myapp' do
55
- source 'http://example.com/myapp.tar'
56
- end
57
- end
58
-
59
- it { is_expected.to_not install_package('tar') }
60
- it { is_expected.to create_directory('/opt/myapp') }
61
- it { is_expected.to create_remote_file("#{Chef::Config[:file_cache_path]}/myapp.tar").with(source: 'http://example.com/myapp.tar') }
62
- end # /context on AIX
63
-
64
- context 'with a .tar URL' do
65
- recipe do
66
- poise_languages_static '/opt/myapp' do
67
- source 'http://example.com/myapp.tar'
68
- end
69
- end
70
-
71
- it { is_expected.to install_package('tar') }
72
- it { expect(unpack_resource.command).to eq %W{tar --strip-components=1 -xvf #{Chef::Config[:file_cache_path]}/myapp.tar} }
73
- end # /context with a .tar URL
74
-
75
- context 'with a .tar.gz URL' do
76
- recipe do
77
- poise_languages_static '/opt/myapp' do
78
- source 'http://example.com/myapp.tar.gz'
79
- end
80
- end
81
-
82
- it { is_expected.to install_package('tar') }
83
- it { expect(unpack_resource.command).to eq %W{tar --strip-components=1 -xzvf #{Chef::Config[:file_cache_path]}/myapp.tar.gz} }
84
- end # /context with a .tar.gz URL
85
-
86
- context 'with a .tgz URL' do
87
- recipe do
88
- poise_languages_static '/opt/myapp' do
89
- source 'http://example.com/myapp.tgz'
90
- end
91
- end
92
-
93
- it { is_expected.to install_package('tar') }
94
- it { expect(unpack_resource.command).to eq %W{tar --strip-components=1 -xzvf #{Chef::Config[:file_cache_path]}/myapp.tgz} }
95
- end # /context with a .tgz URL
96
-
97
- context 'with a .tar.bz2 URL' do
98
- recipe do
99
- poise_languages_static '/opt/myapp' do
100
- source 'http://example.com/myapp.tar.bz2'
101
- end
102
- end
103
-
104
- it { is_expected.to install_package(%w{tar bzip2}) }
105
- it { expect(unpack_resource.command).to eq %W{tar --strip-components=1 -xjvf #{Chef::Config[:file_cache_path]}/myapp.tar.bz2} }
106
- end # /context with a .tar.bz2 URL
107
-
108
- context 'with a .tbz URL' do
109
- recipe do
110
- poise_languages_static '/opt/myapp' do
111
- source 'http://example.com/myapp.tbz'
112
- end
113
- end
114
-
115
- it { is_expected.to install_package(%w{tar bzip2}) }
116
- it { expect(unpack_resource.command).to eq %W{tar --strip-components=1 -xjvf #{Chef::Config[:file_cache_path]}/myapp.tbz} }
117
- end # /context with a .tbz URL
118
-
119
- context 'with a .tar.xz URL' do
120
- recipe do
121
- poise_languages_static '/opt/myapp' do
122
- source 'http://example.com/myapp.tar.xz'
123
- end
124
- end
125
-
126
- it { is_expected.to install_package(%w{tar xz-utils}) }
127
- it { expect(unpack_resource.command).to eq %W{tar --strip-components=1 -xJvf #{Chef::Config[:file_cache_path]}/myapp.tar.xz} }
128
- end # /context with a .tar.xz URL
129
-
130
- context 'with a .txz URL' do
131
- recipe do
132
- poise_languages_static '/opt/myapp' do
133
- source 'http://example.com/myapp.txz'
134
- end
135
- end
136
-
137
- it { is_expected.to install_package(%w{tar xz-utils}) }
138
- it { expect(unpack_resource.command).to eq %W{tar --strip-components=1 -xJvf #{Chef::Config[:file_cache_path]}/myapp.txz} }
139
- end # /context with a .txz URL
33
+ it { is_expected.to create_directory('/opt/myapp').with(user: 0, group: 0, mode: '755') }
34
+ it { is_expected.to create_remote_file("#{Chef::Config[:file_cache_path]}/myapp.tar").with(user: 0, group: 0, mode: '644', source: 'http://example.com/myapp.tar', retries: 5) }
35
+ end # /context 'action :install
140
36
 
141
37
  context 'action :uninstall' do
142
38
  recipe do
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.3.3
4
+ version: 1.4.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-15 00:00:00.000000000 Z
11
+ date: 2016-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: halite
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: poise-archive
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: poise-boiler
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -91,6 +105,8 @@ files:
91
105
  - test/gemfiles/chef-12.4.gemfile
92
106
  - test/gemfiles/chef-12.5.gemfile
93
107
  - test/gemfiles/chef-12.6.gemfile
108
+ - test/gemfiles/chef-12.7.gemfile
109
+ - test/gemfiles/chef-12.8.gemfile
94
110
  - test/gemfiles/chef-12.gemfile
95
111
  - test/gemfiles/master.gemfile
96
112
  - test/spec/command/mixin_spec.rb
@@ -122,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
138
  version: '0'
123
139
  requirements: []
124
140
  rubyforge_project:
125
- rubygems_version: 2.5.2
141
+ rubygems_version: 2.6.2
126
142
  signing_key:
127
143
  specification_version: 4
128
144
  summary: A Chef cookbook to help writing language cookbooks.
@@ -135,6 +151,8 @@ test_files:
135
151
  - test/gemfiles/chef-12.4.gemfile
136
152
  - test/gemfiles/chef-12.5.gemfile
137
153
  - test/gemfiles/chef-12.6.gemfile
154
+ - test/gemfiles/chef-12.7.gemfile
155
+ - test/gemfiles/chef-12.8.gemfile
138
156
  - test/gemfiles/chef-12.gemfile
139
157
  - test/gemfiles/master.gemfile
140
158
  - test/spec/command/mixin_spec.rb