mixlib-install 1.2.4 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +41 -0
  3. data/CHANGELOG.md +6 -2
  4. data/README.md +4 -15
  5. data/Rakefile +2 -12
  6. data/acceptance/.gitignore +7 -1
  7. data/acceptance/Gemfile +0 -8
  8. data/acceptance/README.md +6 -0
  9. data/acceptance/bourne/.acceptance/acceptance-cookbook/.gitignore +8 -0
  10. data/acceptance/{unstable → bourne}/.acceptance/acceptance-cookbook/metadata.rb +1 -0
  11. data/acceptance/bourne/.acceptance/acceptance-cookbook/recipes/destroy.rb +3 -0
  12. data/acceptance/bourne/.acceptance/acceptance-cookbook/recipes/provision.rb +11 -0
  13. data/acceptance/bourne/.acceptance/acceptance-cookbook/recipes/verify.rb +11 -0
  14. data/acceptance/bourne/inspec/verify.rb +3 -0
  15. data/acceptance/bourne/terraform/application.tf +78 -0
  16. data/acceptance/bourne/terraform/aws.tf +8 -0
  17. data/acceptance/bourne/terraform/variables.tf +27 -0
  18. data/acceptance/{current → powershell}/.acceptance/acceptance-cookbook/.gitignore +1 -1
  19. data/acceptance/{current → powershell}/.acceptance/acceptance-cookbook/metadata.rb +1 -0
  20. data/acceptance/powershell/.acceptance/acceptance-cookbook/recipes/destroy.rb +3 -0
  21. data/acceptance/powershell/.acceptance/acceptance-cookbook/recipes/provision.rb +12 -0
  22. data/acceptance/powershell/.acceptance/acceptance-cookbook/recipes/verify.rb +12 -0
  23. data/acceptance/powershell/inspec/verify.rb +3 -0
  24. data/acceptance/powershell/terraform/application.tf +89 -0
  25. data/acceptance/powershell/terraform/aws.tf +8 -0
  26. data/acceptance/powershell/terraform/variables.tf +16 -0
  27. data/ci/before-script.sh +31 -0
  28. data/ci/es-infrastructure.pem.enc +0 -0
  29. data/lib/mixlib/install.rb +0 -10
  30. data/lib/mixlib/install/backend.rb +2 -7
  31. data/lib/mixlib/install/backend/{artifactory.rb → package_router.rb} +52 -100
  32. data/lib/mixlib/install/generator/base.rb +1 -2
  33. data/lib/mixlib/install/generator/bourne.rb +1 -13
  34. data/lib/mixlib/install/generator/powershell.rb +2 -25
  35. data/lib/mixlib/install/generator/powershell/scripts/get_project_metadata.ps1.erb +1 -1
  36. data/lib/mixlib/install/options.rb +3 -17
  37. data/lib/mixlib/install/script_generator.rb +1 -0
  38. data/lib/mixlib/install/version.rb +1 -1
  39. data/mixlib-install.gemspec +4 -3
  40. metadata +51 -32
  41. data/acceptance/current/.acceptance/acceptance-cookbook/recipes/destroy.rb +0 -3
  42. data/acceptance/current/.acceptance/acceptance-cookbook/recipes/provision.rb +0 -3
  43. data/acceptance/current/.acceptance/acceptance-cookbook/recipes/verify.rb +0 -3
  44. data/acceptance/current/.kitchen.yml +0 -41
  45. data/acceptance/unstable/.acceptance/acceptance-cookbook/.gitignore +0 -2
  46. data/acceptance/unstable/.acceptance/acceptance-cookbook/recipes/destroy.rb +0 -3
  47. data/acceptance/unstable/.acceptance/acceptance-cookbook/recipes/provision.rb +0 -3
  48. data/acceptance/unstable/.acceptance/acceptance-cookbook/recipes/verify.rb +0 -3
  49. data/acceptance/unstable/.kitchen.yml +0 -41
  50. data/config.ru +0 -7
  51. data/lib/mixlib/install/backend/bintray.rb +0 -298
  52. data/lib/mixlib/install/backend/omnitruck.rb +0 -75
  53. data/lib/mixlib/install/generator/bourne/scripts/artifactory_urls.sh.erb +0 -28
  54. data/lib/mixlib/install/generator/powershell/scripts/get_project_metadata_for_artifactory.ps1.erb +0 -75
@@ -29,7 +29,7 @@ function Get-ProjectMetadata {
29
29
  [string]
30
30
  $version,
31
31
  # Release channel to install from
32
- [validateset('current', 'stable')]
32
+ [validateset('current', 'stable', 'unstable')]
33
33
  [string]
34
34
  $channel = 'stable',
35
35
  # The following legacy switches are just aliases for the current channel
@@ -26,9 +26,7 @@ module Mixlib
26
26
 
27
27
  attr_reader :options
28
28
 
29
- OMNITRUCK_CHANNELS = [:stable, :current]
30
- ARTIFACTORY_CHANNELS = [:unstable]
31
- ALL_SUPPORTED_CHANNELS = OMNITRUCK_CHANNELS + ARTIFACTORY_CHANNELS
29
+ SUPPORTED_CHANNELS = [:stable, :current, :unstable]
32
30
  SUPPORTED_PRODUCT_NAMES = PRODUCT_MATRIX.products
33
31
  SUPPORTED_SHELL_TYPES = [:ps1, :sh]
34
32
  SUPPORTED_OPTIONS = [
@@ -70,18 +68,6 @@ module Mixlib
70
68
  end
71
69
  end
72
70
 
73
- def for_artifactory?
74
- Mixlib::Install.unified_backend? || ARTIFACTORY_CHANNELS.include?(channel)
75
- end
76
-
77
- def for_unstable?
78
- channel == :unstable
79
- end
80
-
81
- def for_omnitruck?
82
- OMNITRUCK_CHANNELS.include?(channel)
83
- end
84
-
85
71
  def for_ps1?
86
72
  platform == "windows" || shell_type == :ps1
87
73
  end
@@ -123,10 +109,10 @@ Must be one of: #{SUPPORTED_PRODUCT_NAMES.join(", ")}
123
109
  end
124
110
 
125
111
  def validate_channels
126
- unless ALL_SUPPORTED_CHANNELS.include? channel
112
+ unless SUPPORTED_CHANNELS.include? channel
127
113
  <<-EOS
128
114
  Unknown channel #{channel}.
129
- Must be one of: #{ALL_SUPPORTED_CHANNELS.join(", ")}
115
+ Must be one of: #{SUPPORTED_CHANNELS.join(", ")}
130
116
  EOS
131
117
  end
132
118
  end
@@ -132,6 +132,7 @@ module Mixlib
132
132
  def install_command_vars_for_powershell
133
133
  [
134
134
  shell_var("chef_omnibus_root", root),
135
+ shell_var("msi", "$env:TEMP\\chef-#{version}.msi"),
135
136
  ].tap do |vars|
136
137
  if install_msi_url
137
138
  vars << shell_var("chef_msi_url", install_msi_url)
@@ -1,5 +1,5 @@
1
1
  module Mixlib
2
2
  class Install
3
- VERSION = "1.2.4"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
@@ -22,11 +22,12 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency "mixlib-shellout"
23
23
 
24
24
  spec.add_development_dependency "bundler"
25
- spec.add_development_dependency "rake", "~> 10.0"
26
- spec.add_development_dependency "rspec", "~> 3.3"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "rspec"
27
27
  spec.add_development_dependency "pry"
28
28
  spec.add_development_dependency "rb-readline"
29
29
  spec.add_development_dependency "vcr"
30
30
  spec.add_development_dependency "webmock", "~> 1.0"
31
- spec.add_development_dependency "chefstyle", "~> 0.3"
31
+ spec.add_development_dependency "chefstyle"
32
+ spec.add_development_dependency "simplecov"
32
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mixlib-install
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thom May
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-12-30 00:00:00.000000000 Z
12
+ date: 2016-09-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: artifactory
@@ -71,30 +71,30 @@ dependencies:
71
71
  name: rake
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - "~>"
74
+ - - ">="
75
75
  - !ruby/object:Gem::Version
76
- version: '10.0'
76
+ version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - "~>"
81
+ - - ">="
82
82
  - !ruby/object:Gem::Version
83
- version: '10.0'
83
+ version: '0'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: rspec
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - "~>"
88
+ - - ">="
89
89
  - !ruby/object:Gem::Version
90
- version: '3.3'
90
+ version: '0'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - "~>"
95
+ - - ">="
96
96
  - !ruby/object:Gem::Version
97
- version: '3.3'
97
+ version: '0'
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: pry
100
100
  requirement: !ruby/object:Gem::Requirement
@@ -155,16 +155,30 @@ dependencies:
155
155
  name: chefstyle
156
156
  requirement: !ruby/object:Gem::Requirement
157
157
  requirements:
158
- - - "~>"
158
+ - - ">="
159
159
  - !ruby/object:Gem::Version
160
- version: '0.3'
160
+ version: '0'
161
161
  type: :development
162
162
  prerelease: false
163
163
  version_requirements: !ruby/object:Gem::Requirement
164
164
  requirements:
165
- - - "~>"
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ - !ruby/object:Gem::Dependency
169
+ name: simplecov
170
+ requirement: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
166
173
  - !ruby/object:Gem::Version
167
- version: '0.3'
174
+ version: '0'
175
+ type: :development
176
+ prerelease: false
177
+ version_requirements: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
168
182
  description:
169
183
  email:
170
184
  - thom@chef.io
@@ -176,6 +190,7 @@ files:
176
190
  - ".gitattributes"
177
191
  - ".gitignore"
178
192
  - ".rspec"
193
+ - ".travis.yml"
179
194
  - CHANGELOG.md
180
195
  - CONTRIBUTING.md
181
196
  - Gemfile
@@ -185,30 +200,35 @@ files:
185
200
  - Rakefile
186
201
  - acceptance/.gitignore
187
202
  - acceptance/Gemfile
188
- - acceptance/current/.acceptance/acceptance-cookbook/.gitignore
189
- - acceptance/current/.acceptance/acceptance-cookbook/metadata.rb
190
- - acceptance/current/.acceptance/acceptance-cookbook/recipes/destroy.rb
191
- - acceptance/current/.acceptance/acceptance-cookbook/recipes/provision.rb
192
- - acceptance/current/.acceptance/acceptance-cookbook/recipes/verify.rb
193
- - acceptance/current/.kitchen.yml
194
- - acceptance/unstable/.acceptance/acceptance-cookbook/.gitignore
195
- - acceptance/unstable/.acceptance/acceptance-cookbook/metadata.rb
196
- - acceptance/unstable/.acceptance/acceptance-cookbook/recipes/destroy.rb
197
- - acceptance/unstable/.acceptance/acceptance-cookbook/recipes/provision.rb
198
- - acceptance/unstable/.acceptance/acceptance-cookbook/recipes/verify.rb
199
- - acceptance/unstable/.kitchen.yml
200
- - config.ru
203
+ - acceptance/README.md
204
+ - acceptance/bourne/.acceptance/acceptance-cookbook/.gitignore
205
+ - acceptance/bourne/.acceptance/acceptance-cookbook/metadata.rb
206
+ - acceptance/bourne/.acceptance/acceptance-cookbook/recipes/destroy.rb
207
+ - acceptance/bourne/.acceptance/acceptance-cookbook/recipes/provision.rb
208
+ - acceptance/bourne/.acceptance/acceptance-cookbook/recipes/verify.rb
209
+ - acceptance/bourne/inspec/verify.rb
210
+ - acceptance/bourne/terraform/application.tf
211
+ - acceptance/bourne/terraform/aws.tf
212
+ - acceptance/bourne/terraform/variables.tf
213
+ - acceptance/powershell/.acceptance/acceptance-cookbook/.gitignore
214
+ - acceptance/powershell/.acceptance/acceptance-cookbook/metadata.rb
215
+ - acceptance/powershell/.acceptance/acceptance-cookbook/recipes/destroy.rb
216
+ - acceptance/powershell/.acceptance/acceptance-cookbook/recipes/provision.rb
217
+ - acceptance/powershell/.acceptance/acceptance-cookbook/recipes/verify.rb
218
+ - acceptance/powershell/inspec/verify.rb
219
+ - acceptance/powershell/terraform/application.tf
220
+ - acceptance/powershell/terraform/aws.tf
221
+ - acceptance/powershell/terraform/variables.tf
222
+ - ci/before-script.sh
223
+ - ci/es-infrastructure.pem.enc
201
224
  - lib/mixlib/install.rb
202
225
  - lib/mixlib/install/artifact_info.rb
203
226
  - lib/mixlib/install/backend.rb
204
- - lib/mixlib/install/backend/artifactory.rb
205
227
  - lib/mixlib/install/backend/base.rb
206
- - lib/mixlib/install/backend/bintray.rb
207
- - lib/mixlib/install/backend/omnitruck.rb
228
+ - lib/mixlib/install/backend/package_router.rb
208
229
  - lib/mixlib/install/generator.rb
209
230
  - lib/mixlib/install/generator/base.rb
210
231
  - lib/mixlib/install/generator/bourne.rb
211
- - lib/mixlib/install/generator/bourne/scripts/artifactory_urls.sh.erb
212
232
  - lib/mixlib/install/generator/bourne/scripts/fetch_metadata.sh.erb
213
233
  - lib/mixlib/install/generator/bourne/scripts/fetch_package.sh
214
234
  - lib/mixlib/install/generator/bourne/scripts/helpers.sh
@@ -217,7 +237,6 @@ files:
217
237
  - lib/mixlib/install/generator/bourne/scripts/script_cli_parameters.sh
218
238
  - lib/mixlib/install/generator/powershell.rb
219
239
  - lib/mixlib/install/generator/powershell/scripts/get_project_metadata.ps1.erb
220
- - lib/mixlib/install/generator/powershell/scripts/get_project_metadata_for_artifactory.ps1.erb
221
240
  - lib/mixlib/install/generator/powershell/scripts/helpers.ps1
222
241
  - lib/mixlib/install/generator/powershell/scripts/install_project.ps1
223
242
  - lib/mixlib/install/generator/powershell/scripts/platform_detection.ps1
@@ -1,3 +0,0 @@
1
- execute "bundle exec kitchen destroy #{ENV["KITCHEN_INSTANCES"]}" do
2
- cwd node['chef-acceptance']['suite-dir']
3
- end
@@ -1,3 +0,0 @@
1
- execute "bundle exec kitchen converge #{ENV["KITCHEN_INSTANCES"]}" do
2
- cwd node['chef-acceptance']['suite-dir']
3
- end
@@ -1,3 +0,0 @@
1
- execute "bundle exec kitchen verify #{ENV["KITCHEN_INSTANCES"]}" do
2
- cwd node['chef-acceptance']['suite-dir']
3
- end
@@ -1,41 +0,0 @@
1
- driver:
2
- name: vagrant
3
- provider: vmware_fusion
4
- forward_agent: yes
5
- customize:
6
- numvcpus: 2
7
- memsize: 1048
8
-
9
- provisioner:
10
- name: chef_zero
11
-
12
- platforms:
13
- - name: centos-6.5
14
- run_list:
15
- - name: debian-7.4
16
- run_list:
17
- - name: freebsd-10.0
18
- run_list:
19
- - name: ubuntu-14.04
20
- run_list:
21
- - name: macosx-10.10
22
- driver:
23
- box: chef/macosx-10.10 # private
24
- - name: windows-server-2012r2-standard
25
- driver:
26
- box: chef/windows-server-2012r2-standard # private
27
-
28
- suites:
29
- - name: chef-current-install
30
- provisioner:
31
- product_name: chef
32
- product_version: latest
33
- channel: current
34
- run_list:
35
- - name: chefdk-current-install
36
- excludes: [ 'freebsd-10.0' ]
37
- provisioner:
38
- product_name: chefdk
39
- product_version: latest
40
- channel: current
41
- run_list:
@@ -1,3 +0,0 @@
1
- execute "bundle exec kitchen destroy #{ENV["KITCHEN_INSTANCES"]}" do
2
- cwd node['chef-acceptance']['suite-dir']
3
- end
@@ -1,3 +0,0 @@
1
- execute "bundle exec kitchen converge #{ENV["KITCHEN_INSTANCES"]}" do
2
- cwd node['chef-acceptance']['suite-dir']
3
- end
@@ -1,3 +0,0 @@
1
- execute "bundle exec kitchen verify #{ENV["KITCHEN_INSTANCES"]}" do
2
- cwd node['chef-acceptance']['suite-dir']
3
- end
@@ -1,41 +0,0 @@
1
- driver:
2
- name: vagrant
3
- provider: vmware_fusion
4
- forward_agent: yes
5
- customize:
6
- numvcpus: 2
7
- memsize: 1048
8
-
9
- provisioner:
10
- name: chef_zero
11
-
12
- platforms:
13
- - name: centos-6.5
14
- run_list:
15
- - name: debian-7.4
16
- run_list:
17
- - name: freebsd-10.0
18
- run_list:
19
- - name: ubuntu-14.04
20
- run_list:
21
- - name: macosx-10.10
22
- driver:
23
- box: chef/macosx-10.10 # private
24
- - name: windows-server-2012r2-standard
25
- driver:
26
- box: chef/windows-server-2012r2-standard # private
27
-
28
- suites:
29
- - name: chef-unstable-install
30
- provisioner:
31
- product_name: chef
32
- product_version: latest
33
- channel: unstable
34
- run_list:
35
- - name: chefdk-unstable-install
36
- excludes: [ 'freebsd-10.0' ]
37
- provisioner:
38
- product_name: chefdk
39
- product_version: latest
40
- channel: unstable
41
- run_list:
data/config.ru DELETED
@@ -1,7 +0,0 @@
1
- require "rubygems"
2
- require "bundler"
3
-
4
- Bundler.require
5
-
6
- require_relative "spec/support/bintray_server"
7
- run BintrayServer
@@ -1,298 +0,0 @@
1
- #
2
- # Author:: Patrick Wright (<patrick@chef.io>)
3
- # Copyright:: Copyright (c) 2016 Chef, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require "json"
20
- require "mixlib/install/backend/base"
21
- require "mixlib/install/artifact_info"
22
-
23
- #
24
- # Add method to Array class to support
25
- # searching for substrings that match against
26
- # the items in the Array
27
- #
28
- class Array
29
- def fuzzy_include?(search_value, regex_format = "%s")
30
- inject(false) do |is_found, array_value|
31
- is_found || !!(search_value =~ /#{regex_format % array_value}/)
32
- end
33
- end
34
- end
35
-
36
- module Mixlib
37
- class Install
38
- class Backend
39
- class Bintray < Base
40
- class UnknownArchitecture < StandardError; end
41
- class VersionNotFound < StandardError; end
42
- # Bintray credentials for api read access. These are here intentionally.
43
- BINTRAY_USERNAME = "mixlib-install@chef".freeze
44
- BINTRAY_PASSWORD = "a83d3a2ffad50eb9a2230f281a2e19b70fe0db2d".freeze
45
-
46
- ENDPOINT = "https://bintray.com/api/v1/".freeze
47
- DOWNLOAD_URL_ENDPOINT = "https://packages.chef.io".freeze
48
- COMPAT_DOWNLOAD_URL_ENDPOINT = "http://chef.bintray.com".freeze
49
-
50
- def endpoint
51
- @endpoint ||= ENV.fetch("BINTRAY_ENDPOINT", ENDPOINT)
52
- end
53
-
54
- #
55
- # Makes a GET request to bintray for the given path.
56
- #
57
- # @param [String] path
58
- # "/api/v1/packages/chef" is prepended to the given path.
59
- #
60
- # @return [String] JSON parsed string of the bintray response
61
- #
62
- def bintray_get(path)
63
- uri = URI.parse(endpoint)
64
- http = Net::HTTP.new(uri.host, uri.port)
65
- http.use_ssl = (uri.scheme == "https")
66
-
67
- full_path = File.join(uri.path, "packages/chef", path)
68
- request = Net::HTTP::Get.new(full_path)
69
- request.basic_auth(BINTRAY_USERNAME, BINTRAY_PASSWORD)
70
-
71
- res = http.request(request)
72
-
73
- # Raise if response is not 2XX
74
- res.value
75
- JSON.parse(res.body)
76
- end
77
-
78
- #
79
- # Get latest version for product/channel
80
- #
81
- # @return [String] latest version value
82
- #
83
- def latest_version
84
- result = bintray_get("#{options.channel}/#{bintray_product_name}/versions/_latest")
85
- result["name"]
86
- end
87
-
88
- #
89
- # Get artifacts for a given version, channel and product_name
90
- #
91
- # @return [Array<ArtifactInfo>] Array of info about found artifacts
92
- #
93
- def available_artifacts
94
- version = options.latest_version? ? latest_version : options.product_version
95
- begin
96
- results = bintray_get("#{options.channel}/#{bintray_product_name}/versions/#{version}/files")
97
- rescue Net::HTTPServerException => e
98
- if e.message =~ /404 "Not Found"/
99
- raise VersionNotFound,
100
- "Specified version (#{version}) not found for #{bintray_product_name} in #{options.channel} channel."
101
- else
102
- raise
103
- end
104
- end
105
-
106
- #
107
- # Delete files that we don't want as part of the artifact info array
108
- # Windows: .asc files
109
- # MAC OS _X: .pkg files which are uploaded along with dmg files for
110
- # some chef versions.
111
- #
112
- %w{ asc pkg }.each do |ext|
113
- results.reject! { |r| r["name"].end_with?(".#{ext}") }
114
- end
115
-
116
- # Convert results to build records
117
- results.map! { |a| create_artifact(a) }
118
-
119
- windows_artifact_fixup!(results)
120
- end
121
-
122
- #
123
- # Creates an instance of ArtifactInfo
124
- #
125
- # @param artifact_map
126
- # {
127
- # "name" => "chef-12.8.1-1.powerpc.bff",
128
- # "path" => "aix/6.1/chef-12.8.1-1.powerpc.bff",
129
- # "version" => "12.8.1",
130
- # "sha1" => "1206f7be7be8bbece1e9943dcdc0d22fe538718b",
131
- # "sha256" => "e49321095a04f51385a59b3f3d7223cd1bddefc2e2f4280edfb0934d00a4fa3f"
132
- # }
133
- #
134
- # @return [ArtifactInfo] ArtifactInfo instance
135
- #
136
- def create_artifact(artifact_map)
137
- platform_info = parse_platform_info(artifact_map)
138
-
139
- ArtifactInfo.new(
140
- sha1: artifact_map["sha1"],
141
- sha256: artifact_map["sha256"],
142
- version: artifact_map["version"],
143
- platform: platform_info[:platform],
144
- platform_version: platform_info[:platform_version],
145
- architecture: platform_info[:architecture],
146
- url: url(artifact_map)
147
- )
148
- end
149
-
150
- #
151
- # Creates the URL for the artifact.
152
- #
153
- # For some older platform & platform_version combinations we need to
154
- # use COMPAT_DOWNLOAD_URL_ENDPOINT since these versions have an
155
- # OpenSSL version that can not verify the DOWNLOAD_URL_ENDPOINT
156
- # based urls
157
- #
158
- # @param artifact_map
159
- # see #create_artifact for details.
160
- #
161
- # @return [String] url for the artifact
162
- #
163
- def url(artifact_map)
164
- platform_info = parse_platform_info(artifact_map)
165
-
166
- base_url = case "#{platform_info[:platform]}-#{platform_info[:platform_version]}"
167
- when "freebsd-9", "el-5", "solaris2-5.9", "solaris2-5.10"
168
- COMPAT_DOWNLOAD_URL_ENDPOINT
169
- else
170
- DOWNLOAD_URL_ENDPOINT
171
- end
172
-
173
- "#{base_url}/#{options.channel}/#{artifact_map["path"]}"
174
- end
175
-
176
- #
177
- # Parses platform info
178
- #
179
- # @param artifact_map
180
- # {
181
- # "name" => "chef-12.8.1-1.powerpc.bff",
182
- # "path" => "aix/6.1/chef-12.8.1-1.powerpc.bff",
183
- # "version" => "12.8.1",
184
- # "sha1" => "1206f7be7be8bbece1e9943dcdc0d22fe538718b",
185
- # "sha256" => "e49321095a04f51385a59b3f3d7223cd1bddefc2e2f4280edfb0934d00a4fa3f"
186
- # }
187
- #
188
- # @return [Hash] platform, platform_version, architecture
189
- #
190
- def parse_platform_info(artifact_map)
191
- # platform/platform_version/filename
192
- path = artifact_map["path"].split("/")
193
- platform = path[0]
194
- platform_version = path[1]
195
- platform, platform_version = normalize_platform(platform, platform_version)
196
-
197
- filename = artifact_map["name"]
198
- architecture = parse_architecture_from_file_name(filename)
199
-
200
- {
201
- platform: platform,
202
- platform_version: platform_version,
203
- architecture: architecture,
204
- }
205
- end
206
-
207
- #
208
- # Determines the architecture for which a file is published from from
209
- # filename.
210
- #
211
- # We determine the architecture based on the filename of the artifact
212
- # since architecture the artifact is published for is not available
213
- # in bintray.
214
- #
215
- # IMPORTANT: This function is heavily used by omnitruck poller. Make
216
- # sure you test with `./poller` if you change this function.
217
- #
218
- # @param [String] filename
219
- #
220
- # @return [String]
221
- # one of the standardized architectures for Chef packages:
222
- # x86_64, i386, powerpc, sparc, ppc64, ppc64le
223
- def parse_architecture_from_file_name(filename)
224
- #
225
- # We first map the different variations of architectures that we have
226
- # used historically to our final set.
227
- #
228
- if %w{ x86_64 amd64 x64 }.fuzzy_include?(filename)
229
- "x86_64"
230
- elsif %w{ i386 x86 i86pc i686 }.fuzzy_include?(filename)
231
- "i386"
232
- elsif %w{ powerpc }.fuzzy_include?(filename)
233
- "powerpc"
234
- elsif %w{ sparc sun4u sun4v }.fuzzy_include?(filename)
235
- "sparc"
236
- elsif %w{ s390x }.fuzzy_include?(filename)
237
- "s390x"
238
- # Note that ppc64le should come before ppc64 otherwise our search
239
- # will think ppc64le matches ppc64. Ubuntu also calls it ppc64el.
240
- elsif %w{ ppc64le ppc64el }.fuzzy_include?(filename)
241
- "ppc64le"
242
- elsif %w{ ppc64 }.fuzzy_include?(filename)
243
- "ppc64"
244
- #
245
- # From here on we need to deal with historical versions
246
- # that we have published without any architecture in their
247
- # names.
248
- #
249
- #
250
- # All dmg files are published for x86_64
251
- elsif filename.end_with?(".dmg")
252
- "x86_64"
253
- #
254
- # The msi files we catch here are versions that are older than the
255
- # ones which we introduced 64 builds. Therefore they should map to
256
- # i386
257
- elsif filename.end_with?(".msi")
258
- "i386"
259
- #
260
- # sh files are the packaging format we were using before dmg on Mac.
261
- # They map to x86_64
262
- elsif filename.end_with?(".sh")
263
- "x86_64"
264
- #
265
- # We have two common file names for solaris packages. E.g:
266
- # chef-11.12.8-2.solaris2.5.10.solaris
267
- # chef-11.12.8-2.solaris2.5.9.solaris
268
- # These were build on two boxes:
269
- # Solaris 9 => sparc
270
- # Solaris 10 => i386
271
- elsif filename.end_with?(".solaris2.5.10.solaris")
272
- "i386"
273
- elsif filename.end_with?(".solaris2.5.9.solaris")
274
- "sparc"
275
- else
276
- raise UnknownArchitecture,
277
- "architecture can not be determined for '#{filename}'"
278
- end
279
- end
280
-
281
- private
282
-
283
- #
284
- # This is a temporary workaround until we move to the unified backend
285
- # for all channels. Some products are published to Bintray using their
286
- # Omnibus project name as opposed to their mixlib-install product key.
287
- #
288
- def bintray_product_name
289
- if %w{automate}.include?(options.product_name)
290
- PRODUCT_MATRIX.lookup(options.product_name).omnibus_project
291
- else
292
- options.product_name
293
- end
294
- end
295
- end
296
- end
297
- end
298
- end