packaging 0.99.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.
Files changed (114) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +17 -0
  3. data/README-Solaris.md +117 -0
  4. data/README.md +1031 -0
  5. data/lib/packaging.rb +32 -0
  6. data/lib/packaging/artifactory.rb +278 -0
  7. data/lib/packaging/config.rb +392 -0
  8. data/lib/packaging/config/params.rb +366 -0
  9. data/lib/packaging/deb.rb +28 -0
  10. data/lib/packaging/deb/repo.rb +263 -0
  11. data/lib/packaging/gem.rb +112 -0
  12. data/lib/packaging/ips.rb +57 -0
  13. data/lib/packaging/msi.rb +89 -0
  14. data/lib/packaging/nuget.rb +39 -0
  15. data/lib/packaging/osx.rb +36 -0
  16. data/lib/packaging/paths.rb +238 -0
  17. data/lib/packaging/platforms.rb +480 -0
  18. data/lib/packaging/repo.rb +55 -0
  19. data/lib/packaging/retrieve.rb +46 -0
  20. data/lib/packaging/rpm.rb +5 -0
  21. data/lib/packaging/rpm/repo.rb +257 -0
  22. data/lib/packaging/tar.rb +154 -0
  23. data/lib/packaging/util.rb +146 -0
  24. data/lib/packaging/util/date.rb +15 -0
  25. data/lib/packaging/util/execution.rb +85 -0
  26. data/lib/packaging/util/file.rb +125 -0
  27. data/lib/packaging/util/git.rb +174 -0
  28. data/lib/packaging/util/git_tags.rb +73 -0
  29. data/lib/packaging/util/gpg.rb +62 -0
  30. data/lib/packaging/util/jenkins.rb +95 -0
  31. data/lib/packaging/util/misc.rb +69 -0
  32. data/lib/packaging/util/net.rb +368 -0
  33. data/lib/packaging/util/os.rb +17 -0
  34. data/lib/packaging/util/platform.rb +40 -0
  35. data/lib/packaging/util/rake_utils.rb +111 -0
  36. data/lib/packaging/util/serialization.rb +19 -0
  37. data/lib/packaging/util/ship.rb +171 -0
  38. data/lib/packaging/util/tool.rb +41 -0
  39. data/lib/packaging/util/version.rb +326 -0
  40. data/spec/fixtures/config/ext/build_defaults.yaml +2 -0
  41. data/spec/fixtures/config/ext/project_data.yaml +2 -0
  42. data/spec/fixtures/config/params.yaml +2 -0
  43. data/spec/fixtures/configs/components/test_file.json +1 -0
  44. data/spec/fixtures/configs/components/test_file_2.json +0 -0
  45. data/spec/fixtures/configs/components/test_file_not_tagged.json +1 -0
  46. data/spec/fixtures/configs/components/test_file_wrong_ext.txt +0 -0
  47. data/spec/fixtures/configs/components/test_file_wrong_ext.wrong +0 -0
  48. data/spec/fixtures/util/pre_tasks.yaml +4 -0
  49. data/spec/lib/packaging/artifactory_spec.rb +171 -0
  50. data/spec/lib/packaging/config_spec.rb +556 -0
  51. data/spec/lib/packaging/deb/repo_spec.rb +148 -0
  52. data/spec/lib/packaging/deb_spec.rb +52 -0
  53. data/spec/lib/packaging/paths_spec.rb +153 -0
  54. data/spec/lib/packaging/platforms_spec.rb +153 -0
  55. data/spec/lib/packaging/repo_spec.rb +97 -0
  56. data/spec/lib/packaging/retrieve_spec.rb +61 -0
  57. data/spec/lib/packaging/rpm/repo_spec.rb +133 -0
  58. data/spec/lib/packaging/tar_spec.rb +122 -0
  59. data/spec/lib/packaging/util/execution_spec.rb +56 -0
  60. data/spec/lib/packaging/util/file_spec.rb +139 -0
  61. data/spec/lib/packaging/util/git_spec.rb +160 -0
  62. data/spec/lib/packaging/util/git_tag_spec.rb +36 -0
  63. data/spec/lib/packaging/util/gpg_spec.rb +64 -0
  64. data/spec/lib/packaging/util/jenkins_spec.rb +112 -0
  65. data/spec/lib/packaging/util/misc_spec.rb +31 -0
  66. data/spec/lib/packaging/util/net_spec.rb +239 -0
  67. data/spec/lib/packaging/util/os_spec.rb +31 -0
  68. data/spec/lib/packaging/util/rake_utils_spec.rb +70 -0
  69. data/spec/lib/packaging/util/ship_spec.rb +117 -0
  70. data/spec/lib/packaging/util/version_spec.rb +123 -0
  71. data/spec/lib/packaging_spec.rb +19 -0
  72. data/spec/spec_helper.rb +36 -0
  73. data/static_artifacts/PackageInfo.plist +3 -0
  74. data/tasks/00_utils.rake +216 -0
  75. data/tasks/30_metrics.rake +33 -0
  76. data/tasks/apple.rake +266 -0
  77. data/tasks/build.rake +12 -0
  78. data/tasks/clean.rake +5 -0
  79. data/tasks/config.rake +30 -0
  80. data/tasks/deb.rake +129 -0
  81. data/tasks/deb_repos.rake +28 -0
  82. data/tasks/deprecated.rake +130 -0
  83. data/tasks/doc.rake +20 -0
  84. data/tasks/education.rake +57 -0
  85. data/tasks/fetch.rake +57 -0
  86. data/tasks/gem.rake +146 -0
  87. data/tasks/jenkins.rake +494 -0
  88. data/tasks/jenkins_dynamic.rake +202 -0
  89. data/tasks/load_extras.rake +21 -0
  90. data/tasks/mock.rake +348 -0
  91. data/tasks/nightly_repos.rake +335 -0
  92. data/tasks/pe_deb.rake +12 -0
  93. data/tasks/pe_rpm.rake +13 -0
  94. data/tasks/pe_ship.rake +221 -0
  95. data/tasks/pe_sign.rake +13 -0
  96. data/tasks/pe_tar.rake +5 -0
  97. data/tasks/retrieve.rake +45 -0
  98. data/tasks/rpm.rake +66 -0
  99. data/tasks/rpm_repos.rake +29 -0
  100. data/tasks/ship.rake +752 -0
  101. data/tasks/sign.rake +226 -0
  102. data/tasks/tag.rake +8 -0
  103. data/tasks/tar.rake +34 -0
  104. data/tasks/update.rake +16 -0
  105. data/tasks/vanagon.rake +35 -0
  106. data/tasks/vendor_gems.rake +117 -0
  107. data/tasks/version.rake +33 -0
  108. data/tasks/z_data_dump.rake +65 -0
  109. data/templates/README +1 -0
  110. data/templates/downstream.xml.erb +47 -0
  111. data/templates/msi.xml.erb +197 -0
  112. data/templates/packaging.xml.erb +344 -0
  113. data/templates/repo.xml.erb +114 -0
  114. metadata +234 -0
@@ -0,0 +1,480 @@
1
+ require 'set'
2
+
3
+ # Data plus utilities surrounding platforms that the automation in this repo
4
+ # explicitly supports
5
+ module Pkg::Platforms # rubocop:disable Metrics/ModuleLength
6
+ module_function
7
+
8
+ DEBIAN_SOURCE_FORMATS = ['debian.tar.gz', 'orig.tar.gz', 'dsc', 'changes']
9
+
10
+ # Each element in this hash
11
+ PLATFORM_INFO = {
12
+ 'aix' => {
13
+ '6.1' => {
14
+ architectures: ['power'],
15
+ source_architecture: 'SRPMS',
16
+ package_format: 'rpm',
17
+ source_package_formats: ['src.rpm'],
18
+ repo: false,
19
+ },
20
+ '7.1' => {
21
+ architectures: ['power'],
22
+ source_architecture: 'SRPMS',
23
+ package_format: 'rpm',
24
+ source_package_formats: ['src.rpm'],
25
+ repo: false,
26
+ }
27
+ },
28
+
29
+ 'cisco-wrlinux' => {
30
+ '5' => {
31
+ architectures: ['x86_64'],
32
+ source_architecture: 'SRPMS',
33
+ package_format: 'rpm',
34
+ source_package_formats: ['src.rpm'],
35
+ signature_format: 'v4',
36
+ repo: true,
37
+ },
38
+ '7' => {
39
+ architectures: ['x86_64'],
40
+ source_architecture: 'SRPMS',
41
+ package_format: 'rpm',
42
+ source_package_formats: ['src.rpm'],
43
+ signature_format: 'v4',
44
+ repo: true,
45
+ }
46
+ },
47
+
48
+ 'cumulus' => {
49
+ '2.2' => {
50
+ codename: 'cumulus',
51
+ architectures: ['amd64'],
52
+ source_architecture: 'source',
53
+ package_format: 'deb',
54
+ source_package_formats: DEBIAN_SOURCE_FORMATS,
55
+ repo: true,
56
+ }
57
+ },
58
+
59
+ 'debian' => {
60
+ '7' => {
61
+ codename: 'wheezy',
62
+ architectures: ['i386', 'amd64'],
63
+ source_architecture: 'source',
64
+ package_format: 'deb',
65
+ source_package_formats: DEBIAN_SOURCE_FORMATS,
66
+ repo: true,
67
+ },
68
+ '8' => {
69
+ codename: 'jessie',
70
+ architectures: ['i386', 'amd64', 'powerpc'],
71
+ source_architecture: 'source',
72
+ package_format: 'deb',
73
+ source_package_formats: DEBIAN_SOURCE_FORMATS,
74
+ repo: true,
75
+ },
76
+ '9' => {
77
+ codename: 'stretch',
78
+ architectures: ['i386', 'amd64'],
79
+ source_architecture: 'source',
80
+ package_format: 'deb',
81
+ source_package_formats: DEBIAN_SOURCE_FORMATS,
82
+ repo: true,
83
+ }
84
+ },
85
+
86
+ 'el' => {
87
+ '5' => {
88
+ architectures: ['i386', 'x86_64'],
89
+ source_architecture: 'SRPMS',
90
+ package_format: 'rpm',
91
+ source_package_formats: ['src.rpm'],
92
+ signature_format: 'v3',
93
+ repo: true,
94
+ },
95
+ '6' => {
96
+ architectures: ['i386', 'x86_64', 's390x'],
97
+ source_architecture: 'SRPMS',
98
+ package_format: 'rpm',
99
+ source_package_formats: ['src.rpm'],
100
+ signature_format: 'v4',
101
+ repo: true,
102
+ },
103
+ '7' => {
104
+ architectures: ['x86_64', 's390x', 'ppc64le', 'aarch64'],
105
+ source_architecture: 'SRPMS',
106
+ package_format: 'rpm',
107
+ source_package_formats: ['src.rpm'],
108
+ signature_format: 'v4',
109
+ repo: true,
110
+ }
111
+ },
112
+
113
+ 'eos' => {
114
+ '4' => {
115
+ architectures: ['i386'],
116
+ package_format: 'swix',
117
+ repo: false,
118
+ }
119
+ },
120
+
121
+ 'fedora' => {
122
+ 'f25' => {
123
+ architectures: ['i386', 'x86_64'],
124
+ source_architecture: 'SRPMS',
125
+ package_format: 'rpm',
126
+ source_package_formats: ['src.rpm'],
127
+ signature_format: 'v4',
128
+ repo: true,
129
+ },
130
+ 'f26' => {
131
+ architectures: ['x86_64'],
132
+ source_architecture: 'SRPMS',
133
+ package_format: 'rpm',
134
+ source_package_formats: ['src.rpm'],
135
+ signature_format: 'v4',
136
+ repo: true,
137
+ },
138
+ '25' => {
139
+ architectures: ['i386', 'x86_64'],
140
+ source_architecture: 'SRPMS',
141
+ package_format: 'rpm',
142
+ source_package_formats: ['src.rpm'],
143
+ signature_format: 'v4',
144
+ repo: true,
145
+ },
146
+ '26' => {
147
+ architectures: ['x86_64'],
148
+ source_architecture: 'SRPMS',
149
+ package_format: 'rpm',
150
+ source_package_formats: ['src.rpm'],
151
+ signature_format: 'v4',
152
+ repo: true,
153
+ },
154
+ },
155
+
156
+ 'osx' => {
157
+ '10.10' => {
158
+ architectures: ['x86_64'],
159
+ package_format: 'dmg',
160
+ repo: false,
161
+ },
162
+ '10.11' => {
163
+ architectures: ['x86_64'],
164
+ package_format: 'dmg',
165
+ repo: false,
166
+ },
167
+ '10.12' => {
168
+ architectures: ['x86_64'],
169
+ package_format: 'dmg',
170
+ repo: false,
171
+ },
172
+ '10.13' => {
173
+ architectures: ['x86_64'],
174
+ package_format: 'dmg',
175
+ repo: false,
176
+ }
177
+ },
178
+
179
+ 'redhat-fips' => {
180
+ '7' => {
181
+ architectures: ['x86_64'],
182
+ source_architecture: 'SRPMS',
183
+ package_format: 'rpm',
184
+ source_package_formats: ['src.rpm'],
185
+ signature_format: 'v3',
186
+ repo: true,
187
+ }
188
+ },
189
+
190
+ 'sles' => {
191
+ '11' => {
192
+ architectures: ['i386', 'x86_64', 's390x'],
193
+ source_architecture: 'SRPMS',
194
+ package_format: 'rpm',
195
+ source_package_formats: ['src.rpm'],
196
+ signature_format: 'v3',
197
+ repo: true,
198
+ },
199
+ '12' => {
200
+ architectures: ['x86_64', 's390x', 'ppc64le'],
201
+ source_architecture: 'SRPMS',
202
+ package_format: 'rpm',
203
+ source_package_formats: ['src.rpm'],
204
+ signature_format: 'v4',
205
+ repo: true,
206
+ }
207
+ },
208
+
209
+ 'solaris' => {
210
+ '10' => {
211
+ architectures: ['i386', 'sparc'],
212
+ package_format: 'svr4',
213
+ repo: false,
214
+ },
215
+ '11' => {
216
+ architectures: ['i386', 'sparc'],
217
+ package_format: 'ips',
218
+ repo: false,
219
+ }
220
+ },
221
+
222
+ 'ubuntu' => {
223
+ '14.04' => {
224
+ codename: 'trusty',
225
+ architectures: ['i386', 'amd64'],
226
+ source_architecture: 'source',
227
+ package_format: 'deb',
228
+ source_package_formats: DEBIAN_SOURCE_FORMATS,
229
+ repo: true,
230
+ },
231
+ '16.04' => {
232
+ codename: 'xenial',
233
+ architectures: ['i386', 'amd64', 'ppc64el'],
234
+ source_architecture: 'source',
235
+ package_format: 'deb',
236
+ source_package_formats: DEBIAN_SOURCE_FORMATS,
237
+ repo: true,
238
+ },
239
+ },
240
+
241
+ 'windows' => {
242
+ '2012' => {
243
+ architectures: ['x86', 'x64'],
244
+ package_format: 'msi',
245
+ repo: false,
246
+ }
247
+ }
248
+ }.freeze
249
+
250
+ # @return [Array] An array of Strings, containing all of the supported
251
+ # platforms as defined in PLATFORM_INFO
252
+ def supported_platforms
253
+ PLATFORM_INFO.keys
254
+ end
255
+
256
+ # @return [Array] An Array of Strings, containing all the supported
257
+ # versions for the given platform
258
+ def versions_for_platform(platform)
259
+ PLATFORM_INFO[platform].keys
260
+ rescue
261
+ raise "No information found for '#{platform}'"
262
+ end
263
+
264
+ # @param platform_tag [String] May be either the two or three unit string
265
+ # that corresponds to a platform in the form of platform-version or
266
+ # platform-version-arch.
267
+ # @return [Array] An array of three elements: the platform name, the platform
268
+ # version, and the architecture. If the architecture was not included in
269
+ # the original platform tag, then nil is returned in place of the
270
+ # architecture
271
+ def parse_platform_tag(platform_tag)
272
+ platform_elements = platform_tag.split('-')
273
+
274
+ # Look for platform. This is probably the only place where we have to look
275
+ # for a combination of elements rather than a single element
276
+ platform = (platform_elements & supported_platforms).first
277
+ codename = (platform_elements & codenames).first
278
+
279
+ # This is probably a bad assumption, but I'm assuming if we find a codename,
280
+ # that's more reliable as it's less likely to give us a false match
281
+ if codename
282
+ platform, version = codename_to_platform_version(codename)
283
+ end
284
+
285
+ # There's a possibility that the platform name has a dash in it, in which
286
+ # case, our assumption that it's an element of the above array is false,
287
+ # since it would be a combination of elements in that array
288
+ platform ||= supported_platforms.find { |p| platform_tag =~ /#{p}-/ }
289
+
290
+ version ||= (platform_elements & versions_for_platform(platform)).first
291
+
292
+
293
+ # For platform names with a dash in them, because everything is special
294
+ supported_arches = arches_for_platform_version(platform, version)
295
+ architecture = platform_tag.sub(/^(#{platform}-#{version}|#{codename})-?/, '')
296
+
297
+ fail unless supported_arches.include?(architecture) || architecture.empty?
298
+ return [platform, version, architecture]
299
+ rescue
300
+ raise "Could not verify that '#{platform_tag}' is a valid tag"
301
+ end
302
+
303
+ # @param platform_tag [String] May be either the two or three unit string
304
+ # that corresponds to a platform in the form of platform-version or
305
+ # platform-version-arch
306
+ # @return [Hash] The hash of data associated with the given platform version
307
+ def platform_lookup(platform_tag)
308
+ platform, version, _ = parse_platform_tag(platform_tag)
309
+ PLATFORM_INFO[platform][version]
310
+ end
311
+
312
+ # @param platform_tag [String] May be either the two or three unit string
313
+ # that corresponds to a platform in the form of platform-version or
314
+ # platform-version-arch
315
+ # @param attribute_name [String, Symbol] The name of the requested attribute
316
+ # @return [String, Array] the contents of the requested attribute
317
+ def get_attribute(platform_tag, attribute_name)
318
+ info = platform_lookup(platform_tag)
319
+ raise "#{platform_tag} doesn't have information about #{attribute_name} available" unless info.key?(attribute_name)
320
+ info[attribute_name]
321
+ end
322
+
323
+ def get_attribute_for_platform_version(platform, version, attribute_name)
324
+ info = PLATFORM_INFO[platform][version]
325
+ raise "#{platform_tag} doesn't have information about #{attribute_name} available" unless info.key?(attribute_name)
326
+ info[attribute_name]
327
+ end
328
+
329
+ # @private List platforms that use a given package format
330
+ # @param format [String] The name of the packaging format to filter on
331
+ # @return [Array] An Array of Strings, containing all platforms that
332
+ # use <format> for their packages
333
+ def by_package_format(format)
334
+ PLATFORM_INFO.keys.select do |key|
335
+ formats = PLATFORM_INFO[key].values.collect { |v| v[:package_format] }
336
+ formats.include? format
337
+ end
338
+ end
339
+
340
+ # @return [Array] An Array of Strings, containing all of the package
341
+ # formats defined in Pkg::Platforms
342
+ def formats
343
+ fmts = PLATFORM_INFO.flat_map do |_, p|
344
+ p.collect do |_, r|
345
+ r[:package_format]
346
+ end
347
+ end
348
+ fmts.to_set.sort
349
+ end
350
+
351
+ # @return [Array] An Array of Strings, containing all the package formats
352
+ # and source package formats defined in Pkg::Platforms
353
+ def all_supported_package_formats
354
+ fmts = formats
355
+ source_fmts = PLATFORM_INFO.flat_map do |_, p|
356
+ p.collect do |_, r|
357
+ r[:source_package_formats]
358
+ end
359
+ end
360
+
361
+ (fmts + source_fmts).flatten.compact.uniq.to_set.sort
362
+ end
363
+
364
+ # @param platform [String] Optional, the platform to list all codenames for.
365
+ # Defaults to 'deb'
366
+ # @return [Array] An Array of Strings, containing all of the codenames
367
+ # defined for a given Platform
368
+ def codenames(platform = 'deb')
369
+ releases = by_package_format(platform).flat_map do |p|
370
+ PLATFORM_INFO[p].values.collect { |r| r[:codename] }
371
+ end
372
+ releases.sort
373
+ end
374
+
375
+ # Given a debian codename, return the platform and version it corresponds to
376
+ def codename_to_platform_version(codename)
377
+ PLATFORM_INFO.each do |platform, platform_versions|
378
+ platform_versions.each do |version, info|
379
+ return [platform, version] if info[:codename] && codename == info[:codename]
380
+ end
381
+ end
382
+ raise "Unable to find a platform and version for '#{codename}'"
383
+ end
384
+
385
+ # Given a debian platform and version, return the codename that corresponds to
386
+ # the set
387
+ def codename_for_platform_version(platform, version)
388
+ get_attribute_for_platform_version(platform, version, :codename)
389
+ end
390
+
391
+ # Given a debian codename, return the arches that we build for that codename
392
+ def arches_for_codename(codename)
393
+ platform, version = codename_to_platform_version(codename)
394
+ arches_for_platform_version(platform, version)
395
+ end
396
+
397
+ # Given a codename, return an array of associated tags
398
+ def codename_to_tags(codename)
399
+ platform_tags = []
400
+ platform, version = codename_to_platform_version(codename)
401
+ arches_for_codename(codename).each do |arch|
402
+ platform_tags << "#{platform}-#{version}-#{arch}"
403
+ end
404
+ platform_tags
405
+ end
406
+
407
+ # Given a platform and version, return the arches that we build for that
408
+ # platform
409
+ def arches_for_platform_version(platform, version)
410
+ get_attribute_for_platform_version(platform, version, :architectures)
411
+ end
412
+
413
+ # Returns an array of all currently valid platform tags
414
+ def platform_tags
415
+ tags = []
416
+ PLATFORM_INFO.each do |platform, platform_versions|
417
+ platform_versions.each do |version, info|
418
+ info[:architectures].each do |arch|
419
+ tags << "#{platform}-#{version}-#{arch}"
420
+ end
421
+ end
422
+ end
423
+ tags
424
+ end
425
+
426
+ def package_format_for_tag(platform_tag)
427
+ get_attribute(platform_tag, :package_format)
428
+ end
429
+
430
+ def signature_format_for_tag(platform_tag)
431
+ get_attribute(platform_tag, :signature_format)
432
+ end
433
+
434
+ def signature_format_for_platform_version(platform, version)
435
+ get_attribute_for_platform_version(platform, version, :signature_format)
436
+ end
437
+
438
+ def source_architecture_for_platform_tag(platform_tag)
439
+ get_attribute(platform_tag, :source_architecture)
440
+ end
441
+
442
+ def source_package_formats_for_platform_tag(platform_tag)
443
+ get_attribute(platform_tag, :source_package_formats)
444
+ end
445
+
446
+ # Return an array of platform tags associated with a given package format
447
+ def platform_tags_for_package_format(format)
448
+ platform_tags = []
449
+ PLATFORM_INFO.each do |platform, platform_versions|
450
+ platform_versions.each do |version, info|
451
+ info[:architectures].each do |architecture|
452
+ if info[:package_format] == format
453
+ platform_tags << "#{platform}-#{version}-#{architecture}"
454
+ end
455
+ end
456
+ end
457
+ end
458
+ platform_tags
459
+ end
460
+
461
+ # @method by_deb
462
+ # @return [Array] An Array of Strings, containing all platforms
463
+ # that use .deb packages
464
+ # Helper meta-method to return all platforms that use .deb packages
465
+ # @scope class
466
+ def by_deb
467
+ by_package_format('deb')
468
+ end
469
+
470
+ # @method by_rpm
471
+ # @return [Array] An Array of Strings, containing all platforms
472
+ # that use .rpm packages
473
+ # Helper meta-method to return all platforms that use .rpm packages
474
+ # @scope class
475
+ def by_rpm
476
+ by_package_format('rpm')
477
+ end
478
+
479
+ private :by_package_format
480
+ end