omnibus 3.1.1 → 3.2.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +71 -0
  3. data/Gemfile +0 -7
  4. data/README.md +108 -36
  5. data/Rakefile +1 -5
  6. data/docs/omnibus-build-cache.md +5 -5
  7. data/features/commands/_deprecated.feature +21 -3
  8. data/features/step_definitions/generator_steps.rb +7 -7
  9. data/lib/omnibus.rb +232 -171
  10. data/lib/omnibus/build_version.rb +2 -2
  11. data/lib/omnibus/builder.rb +38 -19
  12. data/lib/omnibus/cleaner.rb +5 -5
  13. data/lib/omnibus/cleanroom.rb +141 -0
  14. data/lib/omnibus/cli.rb +6 -9
  15. data/lib/omnibus/cli/base.rb +2 -1
  16. data/lib/omnibus/cli/cache.rb +15 -21
  17. data/lib/omnibus/cli/deprecated.rb +40 -4
  18. data/lib/omnibus/cli/publish.rb +61 -0
  19. data/lib/omnibus/config.rb +350 -189
  20. data/lib/omnibus/digestable.rb +131 -0
  21. data/lib/omnibus/exceptions.rb +163 -83
  22. data/lib/omnibus/fetcher.rb +1 -1
  23. data/lib/omnibus/fetchers/net_fetcher.rb +19 -13
  24. data/lib/omnibus/fetchers/path_fetcher.rb +8 -1
  25. data/lib/omnibus/fetchers/s3_cache_fetcher.rb +16 -7
  26. data/lib/omnibus/generator.rb +2 -2
  27. data/lib/omnibus/generator_files/Gemfile.erb +4 -1
  28. data/lib/omnibus/generator_files/README.md.erb +10 -0
  29. data/lib/omnibus/generator_files/{omnibus.rb.example.erb → omnibus.rb.erb} +20 -11
  30. data/lib/omnibus/generator_files/package_scripts/makeselfinst.erb +1 -1
  31. data/lib/omnibus/generator_files/project.rb.erb +2 -2
  32. data/lib/omnibus/generator_files/windows_msi/localization-en-us.wxl.erb +3 -3
  33. data/lib/omnibus/git_cache.rb +192 -0
  34. data/lib/omnibus/health_check.rb +171 -116
  35. data/lib/omnibus/library.rb +4 -2
  36. data/lib/omnibus/logger.rb +60 -1
  37. data/lib/omnibus/null_argumentable.rb +51 -0
  38. data/lib/omnibus/ohai.rb +29 -8
  39. data/lib/omnibus/package.rb +240 -0
  40. data/lib/omnibus/packagers/base.rb +21 -42
  41. data/lib/omnibus/packagers/mac_dmg.rb +5 -5
  42. data/lib/omnibus/packagers/mac_pkg.rb +20 -19
  43. data/lib/omnibus/packagers/windows_msi.rb +7 -7
  44. data/lib/omnibus/project.rb +969 -486
  45. data/lib/omnibus/publisher.rb +76 -0
  46. data/lib/omnibus/publishers/artifactory_publisher.rb +168 -0
  47. data/lib/omnibus/publishers/null_publisher.rb +23 -0
  48. data/lib/omnibus/publishers/s3_publisher.rb +99 -0
  49. data/lib/omnibus/s3_cache.rb +150 -63
  50. data/lib/omnibus/software.rb +749 -321
  51. data/lib/omnibus/{sugar.rb → sugarable.rb} +11 -6
  52. data/lib/omnibus/version.rb +1 -1
  53. data/omnibus.gemspec +8 -8
  54. data/spec/data/complicated/config/projects/angrychef.rb +1 -1
  55. data/spec/data/complicated/config/projects/chef-windows.rb +1 -1
  56. data/spec/data/complicated/config/projects/chef.rb +1 -1
  57. data/spec/data/complicated/config/projects/chefdk-windows.rb +1 -1
  58. data/spec/data/complicated/config/projects/chefdk.rb +1 -1
  59. data/spec/data/complicated/config/software/cacerts.rb +1 -1
  60. data/spec/data/complicated/config/software/chef-client-msi.rb +1 -1
  61. data/spec/data/complicated/config/software/libgcc.rb +1 -1
  62. data/spec/data/complicated/config/software/libiconv.rb +0 -11
  63. data/spec/data/complicated/config/software/libpng.rb +2 -2
  64. data/spec/data/complicated/config/software/openssl.rb +1 -1
  65. data/spec/data/complicated/config/software/ruby.rb +1 -1
  66. data/spec/data/complicated/config/software/runit.rb +4 -4
  67. data/spec/data/projects/chefdk.rb +1 -1
  68. data/spec/data/projects/sample.rb +1 -1
  69. data/spec/data/software/erchef.rb +3 -1
  70. data/spec/functional/packagers/mac_spec.rb +25 -24
  71. data/spec/functional/packagers/windows_spec.rb +21 -20
  72. data/spec/spec_helper.rb +43 -4
  73. data/spec/unit/build_version_spec.rb +14 -16
  74. data/spec/unit/cleanroom_spec.rb +63 -0
  75. data/spec/unit/config_spec.rb +36 -30
  76. data/spec/unit/digestable_spec.rb +38 -0
  77. data/spec/unit/fetchers/net_fetcher_spec.rb +98 -87
  78. data/spec/unit/{install_path_cache_spec.rb → git_cache_spec.rb} +67 -56
  79. data/spec/unit/health_check_spec.rb +73 -0
  80. data/spec/unit/library_spec.rb +166 -159
  81. data/spec/unit/ohai_spec.rb +19 -0
  82. data/spec/unit/omnibus_spec.rb +43 -41
  83. data/spec/unit/package_spec.rb +178 -0
  84. data/spec/unit/packagers/base_spec.rb +17 -47
  85. data/spec/unit/packagers/mac_pkg_spec.rb +104 -126
  86. data/spec/unit/project_spec.rb +176 -25
  87. data/spec/unit/publisher_spec.rb +49 -0
  88. data/spec/unit/publishers/artifactory_publisher_spec.rb +80 -0
  89. data/spec/unit/publishers/s3_publisher_spec.rb +120 -0
  90. data/spec/unit/s3_cacher_spec.rb +84 -19
  91. data/spec/unit/software_spec.rb +397 -170
  92. data/spec/unit/sugarable_spec.rb +43 -0
  93. metadata +62 -50
  94. data/Guardfile +0 -10
  95. data/lib/omnibus/artifact.rb +0 -165
  96. data/lib/omnibus/cli/release.rb +0 -40
  97. data/lib/omnibus/generator_files/Vagrantfile.erb +0 -75
  98. data/lib/omnibus/install_path_cache.rb +0 -105
  99. data/lib/omnibus/overrides.rb +0 -88
  100. data/lib/omnibus/package_release.rb +0 -154
  101. data/lib/omnibus/software_s3_urls.rb +0 -50
  102. data/spec/unit/artifact_spec.rb +0 -91
  103. data/spec/unit/overrides_spec.rb +0 -102
  104. data/spec/unit/package_release_spec.rb +0 -180
  105. data/spec/unit/sugar_spec.rb +0 -17
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ module Omnibus
4
+ describe Software do
5
+ it 'is a sugarable' do
6
+ expect(described_class.ancestors).to include(Sugarable)
7
+ end
8
+ end
9
+
10
+ describe Project do
11
+ it 'is a sugarable' do
12
+ expect(described_class.ancestors).to include(Sugarable)
13
+ end
14
+ end
15
+
16
+ describe Sugarable do
17
+ context 'in a cleanroom' do
18
+ let(:klass) do
19
+ Class.new do
20
+ include Cleanroom
21
+ include Sugarable
22
+ end
23
+ end
24
+
25
+ let(:instance) { klass.new }
26
+
27
+ it 'includes the DSL methods' do
28
+ expect(klass).to be_method_defined(:windows?)
29
+ expect(klass).to be_method_defined(:vagrant?)
30
+ expect(klass).to be_method_defined(:_64_bit?)
31
+ end
32
+
33
+ it 'makes the DSL methods available in the cleanroom' do
34
+ expect {
35
+ instance.evaluate <<-EOH.gsub(/^ {12}/, '')
36
+ windows?
37
+ vagrant?
38
+ EOH
39
+ }.to_not raise_error
40
+ end
41
+ end
42
+ end
43
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omnibus
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.2.0.rc.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef Software, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-20 00:00:00.000000000 Z
11
+ date: 2014-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-sugar
@@ -30,56 +30,42 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.3'
33
+ version: '1.4'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.3'
41
- - !ruby/object:Gem::Dependency
42
- name: mixlib-config
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '2.1'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '2.1'
40
+ version: '1.4'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: ohai
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
45
  - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: '6.12'
47
+ version: 7.2.0.rc
62
48
  type: :runtime
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: '6.12'
54
+ version: 7.2.0.rc
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: fpm
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - "~>"
74
60
  - !ruby/object:Gem::Version
75
- version: 1.0.0
61
+ version: '0.4'
76
62
  type: :runtime
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
66
  - - "~>"
81
67
  - !ruby/object:Gem::Version
82
- version: 1.0.0
68
+ version: '0.4'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: uber-s3
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +94,20 @@ dependencies:
108
94
  - - "~>"
109
95
  - !ruby/object:Gem::Version
110
96
  version: '0.18'
97
+ - !ruby/object:Gem::Dependency
98
+ name: artifactory
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.2'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.2'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: aruba
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -151,19 +151,19 @@ dependencies:
151
151
  - !ruby/object:Gem::Version
152
152
  version: '2.14'
153
153
  - !ruby/object:Gem::Dependency
154
- name: rubocop
154
+ name: rspec-its
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - '='
157
+ - - ">="
158
158
  - !ruby/object:Gem::Version
159
- version: 0.21.0
159
+ version: '0'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - '='
164
+ - - ">="
165
165
  - !ruby/object:Gem::Version
166
- version: 0.21.0
166
+ version: '0'
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: rake
169
169
  requirement: !ruby/object:Gem::Requirement
@@ -204,7 +204,6 @@ files:
204
204
  - ".travis.yml"
205
205
  - CHANGELOG.md
206
206
  - Gemfile
207
- - Guardfile
208
207
  - LICENSE
209
208
  - NOTICE
210
209
  - README.md
@@ -224,19 +223,20 @@ files:
224
223
  - features/step_definitions/generator_steps.rb
225
224
  - features/support/env.rb
226
225
  - lib/omnibus.rb
227
- - lib/omnibus/artifact.rb
228
226
  - lib/omnibus/assets/README-logo.png
229
227
  - lib/omnibus/assets/logo.psd
230
228
  - lib/omnibus/build_version.rb
231
229
  - lib/omnibus/build_version_dsl.rb
232
230
  - lib/omnibus/builder.rb
233
231
  - lib/omnibus/cleaner.rb
232
+ - lib/omnibus/cleanroom.rb
234
233
  - lib/omnibus/cli.rb
235
234
  - lib/omnibus/cli/base.rb
236
235
  - lib/omnibus/cli/cache.rb
237
236
  - lib/omnibus/cli/deprecated.rb
238
- - lib/omnibus/cli/release.rb
237
+ - lib/omnibus/cli/publish.rb
239
238
  - lib/omnibus/config.rb
239
+ - lib/omnibus/digestable.rb
240
240
  - lib/omnibus/exceptions.rb
241
241
  - lib/omnibus/fetcher.rb
242
242
  - lib/omnibus/fetchers/git_fetcher.rb
@@ -249,14 +249,13 @@ files:
249
249
  - lib/omnibus/generator_files/Berksfile.erb
250
250
  - lib/omnibus/generator_files/Gemfile.erb
251
251
  - lib/omnibus/generator_files/README.md.erb
252
- - lib/omnibus/generator_files/Vagrantfile.erb
253
252
  - lib/omnibus/generator_files/gitignore.erb
254
253
  - lib/omnibus/generator_files/mac_dmg/background.png
255
254
  - lib/omnibus/generator_files/mac_dmg/icon.png
256
255
  - lib/omnibus/generator_files/mac_pkg/background.png
257
256
  - lib/omnibus/generator_files/mac_pkg/license.html.erb
258
257
  - lib/omnibus/generator_files/mac_pkg/welcome.html.erb
259
- - lib/omnibus/generator_files/omnibus.rb.example.erb
258
+ - lib/omnibus/generator_files/omnibus.rb.erb
260
259
  - lib/omnibus/generator_files/package_scripts/makeselfinst.erb
261
260
  - lib/omnibus/generator_files/package_scripts/postinst.erb
262
261
  - lib/omnibus/generator_files/package_scripts/postrm.erb
@@ -275,25 +274,28 @@ files:
275
274
  - lib/omnibus/generator_files/windows_msi/localization-en-us.wxl.erb
276
275
  - lib/omnibus/generator_files/windows_msi/parameters.wxi.erb
277
276
  - lib/omnibus/generator_files/windows_msi/source.wxs.erb
277
+ - lib/omnibus/git_cache.rb
278
278
  - lib/omnibus/health_check.rb
279
- - lib/omnibus/install_path_cache.rb
280
279
  - lib/omnibus/library.rb
281
280
  - lib/omnibus/logger.rb
282
281
  - lib/omnibus/logging.rb
282
+ - lib/omnibus/null_argumentable.rb
283
283
  - lib/omnibus/null_builder.rb
284
284
  - lib/omnibus/ohai.rb
285
- - lib/omnibus/overrides.rb
286
- - lib/omnibus/package_release.rb
285
+ - lib/omnibus/package.rb
287
286
  - lib/omnibus/packagers/base.rb
288
287
  - lib/omnibus/packagers/mac_dmg.rb
289
288
  - lib/omnibus/packagers/mac_pkg.rb
290
289
  - lib/omnibus/packagers/windows_msi.rb
291
290
  - lib/omnibus/project.rb
291
+ - lib/omnibus/publisher.rb
292
+ - lib/omnibus/publishers/artifactory_publisher.rb
293
+ - lib/omnibus/publishers/null_publisher.rb
294
+ - lib/omnibus/publishers/s3_publisher.rb
292
295
  - lib/omnibus/reports.rb
293
296
  - lib/omnibus/s3_cache.rb
294
297
  - lib/omnibus/software.rb
295
- - lib/omnibus/software_s3_urls.rb
296
- - lib/omnibus/sugar.rb
298
+ - lib/omnibus/sugarable.rb
297
299
  - lib/omnibus/util.rb
298
300
  - lib/omnibus/version.rb
299
301
  - omnibus.gemspec
@@ -444,23 +446,28 @@ files:
444
446
  - spec/functional/packagers/mac_spec.rb
445
447
  - spec/functional/packagers/windows_spec.rb
446
448
  - spec/spec_helper.rb
447
- - spec/unit/artifact_spec.rb
448
449
  - spec/unit/build_version_dsl_spec.rb
449
450
  - spec/unit/build_version_spec.rb
451
+ - spec/unit/cleanroom_spec.rb
450
452
  - spec/unit/config_spec.rb
453
+ - spec/unit/digestable_spec.rb
451
454
  - spec/unit/fetchers/git_fetcher_spec.rb
452
455
  - spec/unit/fetchers/net_fetcher_spec.rb
453
- - spec/unit/install_path_cache_spec.rb
456
+ - spec/unit/git_cache_spec.rb
457
+ - spec/unit/health_check_spec.rb
454
458
  - spec/unit/library_spec.rb
459
+ - spec/unit/ohai_spec.rb
455
460
  - spec/unit/omnibus_spec.rb
456
- - spec/unit/overrides_spec.rb
457
- - spec/unit/package_release_spec.rb
461
+ - spec/unit/package_spec.rb
458
462
  - spec/unit/packagers/base_spec.rb
459
463
  - spec/unit/packagers/mac_pkg_spec.rb
460
464
  - spec/unit/project_spec.rb
465
+ - spec/unit/publisher_spec.rb
466
+ - spec/unit/publishers/artifactory_publisher_spec.rb
467
+ - spec/unit/publishers/s3_publisher_spec.rb
461
468
  - spec/unit/s3_cacher_spec.rb
462
469
  - spec/unit/software_spec.rb
463
- - spec/unit/sugar_spec.rb
470
+ - spec/unit/sugarable_spec.rb
464
471
  homepage: https://github.com/opscode/omnibus-ruby
465
472
  licenses:
466
473
  - Apache 2.0
@@ -476,12 +483,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
476
483
  version: 1.9.1
477
484
  required_rubygems_version: !ruby/object:Gem::Requirement
478
485
  requirements:
479
- - - ">="
486
+ - - ">"
480
487
  - !ruby/object:Gem::Version
481
- version: '0'
488
+ version: 1.3.1
482
489
  requirements: []
483
490
  rubyforge_project:
484
- rubygems_version: 2.2.2
491
+ rubygems_version: 2.3.0
485
492
  signing_key:
486
493
  specification_version: 4
487
494
  summary: Omnibus helps you build self-installing, full-stack software builds.
@@ -641,21 +648,26 @@ test_files:
641
648
  - spec/functional/packagers/mac_spec.rb
642
649
  - spec/functional/packagers/windows_spec.rb
643
650
  - spec/spec_helper.rb
644
- - spec/unit/artifact_spec.rb
645
651
  - spec/unit/build_version_dsl_spec.rb
646
652
  - spec/unit/build_version_spec.rb
653
+ - spec/unit/cleanroom_spec.rb
647
654
  - spec/unit/config_spec.rb
655
+ - spec/unit/digestable_spec.rb
648
656
  - spec/unit/fetchers/git_fetcher_spec.rb
649
657
  - spec/unit/fetchers/net_fetcher_spec.rb
650
- - spec/unit/install_path_cache_spec.rb
658
+ - spec/unit/git_cache_spec.rb
659
+ - spec/unit/health_check_spec.rb
651
660
  - spec/unit/library_spec.rb
661
+ - spec/unit/ohai_spec.rb
652
662
  - spec/unit/omnibus_spec.rb
653
- - spec/unit/overrides_spec.rb
654
- - spec/unit/package_release_spec.rb
663
+ - spec/unit/package_spec.rb
655
664
  - spec/unit/packagers/base_spec.rb
656
665
  - spec/unit/packagers/mac_pkg_spec.rb
657
666
  - spec/unit/project_spec.rb
667
+ - spec/unit/publisher_spec.rb
668
+ - spec/unit/publishers/artifactory_publisher_spec.rb
669
+ - spec/unit/publishers/s3_publisher_spec.rb
658
670
  - spec/unit/s3_cacher_spec.rb
659
671
  - spec/unit/software_spec.rb
660
- - spec/unit/sugar_spec.rb
672
+ - spec/unit/sugarable_spec.rb
661
673
  has_rdoc:
data/Guardfile DELETED
@@ -1,10 +0,0 @@
1
- guard :rspec do
2
- watch(%r{^spec/.+_spec\.rb$})
3
- watch(%r{^lib/omnibus/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
- watch('spec/spec_helper.rb') { 'spec' }
5
- end
6
-
7
- guard :rubocop do
8
- watch(%r{.+\.rb$})
9
- watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
10
- end
@@ -1,165 +0,0 @@
1
- #
2
- # Copyright 2014 Chef Software, Inc.
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
- module Omnibus
18
- class Artifact
19
- attr_reader :path
20
- attr_reader :platforms
21
- attr_reader :config
22
-
23
- # @param path [String] relative or absolute path to a package file.
24
- # @param platforms [Array<Array<String, String, String>>] an Array of
25
- # distro, distro version, architecture tuples. By convention, the first
26
- # platform is the platform on which the artifact was built.
27
- # @param config [#Hash<Symbol, Object>] configuration for the release.
28
- # Artifact only uses `:build_version => String`.
29
- def initialize(path, platforms, config)
30
- @path = path
31
- @platforms = platforms
32
- @config = config
33
- end
34
-
35
- # Adds this artifact to the `release_manifest`, which is mutated. Intended
36
- # to be used in a visitor-pattern fashion over a collection of Artifacts to
37
- # generate a final release manifest.
38
- #
39
- # @param release_manifest [Hash{ String => Hash }] a version 1 style release
40
- # manifest Hash (see example)
41
- #
42
- # @example Add the package to release_manifest:
43
- # add_to_release_manifest!( {} )
44
- # "el" => {
45
- # "5" => { "x86_64" => { "11.4.0-1" => "/el/5/x86_64/demoproject-11.4.0-1.el5.x86_64.rpm" } }
46
- # }
47
- # @return [Hash{String=>Hash}] the updated release manifest.
48
- def add_to_release_manifest!(release_manifest)
49
- platforms.each do |distro, version, arch|
50
- release_manifest[distro] ||= {}
51
- release_manifest[distro][version] ||= {}
52
- release_manifest[distro][version][arch] = { build_version => relpath }
53
- # TODO: when adding checksums, the desired format is like this:
54
- # build_support_json[platform][platform_version][machine_architecture][options[:version]]["relpath"] = build_location
55
- end
56
- release_manifest
57
- end
58
-
59
- # Adds this artifact to the `release_manifest`, which is mutated. Intended
60
- # to be used in a visitor-pattern fashion over a collection of Artifacts to
61
- # generate a final release manifest.
62
- #
63
- # @param release_manifest [Hash{ String => Hash }] a version 2 style release
64
- # manifest Hash (see example)
65
- #
66
- # @example Add the package to release_manifest:
67
- # add_to_release_manifest!( {} )
68
- # "el" => {
69
- # "5" => {
70
- # "x86_64" => {
71
- # "11.4.0-1" => {
72
- # "relpath" => "/el/5/x86_64/demoproject-11.4.0-1.el5.x86_64.rpm",
73
- # "md5" => "123f00d...",
74
- # "sha256" => 456beef..."
75
- # }
76
- # }
77
- # }
78
- # }
79
- # @return [Hash{String=>Hash}] the updated release manifest.
80
- def add_to_v2_release_manifest!(release_manifest)
81
- platforms.each do |distro, version, arch|
82
- pkg_info = {
83
- 'relpath' => relpath,
84
- 'md5' => md5,
85
- 'sha256' => sha256,
86
- }
87
-
88
- release_manifest[distro] ||= {}
89
- release_manifest[distro][version] ||= {}
90
- release_manifest[distro][version][arch] = { build_version => pkg_info }
91
- end
92
- release_manifest
93
- end
94
-
95
- # Metadata about the artifact as a flat Hash.
96
- #
97
- # @example For a RHEL/CentOS 6, 64-bit package of project version 11.4.0-1
98
- # flat_metadata
99
- # { "platform" => "el",
100
- # "platform_version" => "6",
101
- # "arch" => "x86_64",
102
- # "version" => "11.4.0-1",
103
- # "md5" => "d41d8cd98f00b204e9800998ecf8427e",
104
- # "sha256" => "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" }
105
- #
106
- # @return [Hash{String=>String}] the artifact metadata
107
- def flat_metadata
108
- distro, version, arch = build_platform
109
- {
110
- 'platform' => distro,
111
- 'platform_version' => version,
112
- 'arch' => arch,
113
- 'version' => build_version,
114
- 'basename' => File.basename(path),
115
- 'md5' => md5,
116
- 'sha256' => sha256,
117
- }
118
- end
119
-
120
- # Platform on which the artifact was built. By convention, this is the
121
- # first in the list of platforms passed to {#initialize}.
122
- # @return [Array<String, String, String>] an Array of distro, distro
123
- # version, architecture.
124
- def build_platform
125
- platforms.first
126
- end
127
-
128
- # @return [String] build version of the project.
129
- def build_version
130
- config[:version]
131
- end
132
-
133
- # @return [String] relative path at which the artifact should be located
134
- # when uploaded to artifact repo.
135
- # @example Chef 11.4.0-1 on 64 bit RHEL 6:
136
- # relpath
137
- # "/el/6/x86_64/chef-11.4.0-1.el5.x86_64.rpm"
138
- def relpath
139
- # upload build to build platform directory
140
- "/#{build_platform.join('/')}/#{path.split('/').last}"
141
- end
142
-
143
- # @return [String] hex encoded MD5 of the package
144
- def md5
145
- @md5 ||= digest(Digest::MD5)
146
- end
147
-
148
- # @return [String] hex encoded SHA2-256 of the package
149
- def sha256
150
- @sha256 ||= digest(Digest::SHA256)
151
- end
152
-
153
- private
154
-
155
- def digest(digest_class)
156
- digest = digest_class.new
157
- File.open(path) do |io|
158
- while (chunk = io.read(1024 * 8))
159
- digest.update(chunk)
160
- end
161
- end
162
- digest.hexdigest
163
- end
164
- end
165
- end