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