packaging 0.88.77

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +17 -0
  3. data/README-Solaris.md +117 -0
  4. data/README.md +977 -0
  5. data/lib/packaging.rb +32 -0
  6. data/lib/packaging/archive.rb +126 -0
  7. data/lib/packaging/artifactory.rb +651 -0
  8. data/lib/packaging/artifactory/extensions.rb +94 -0
  9. data/lib/packaging/config.rb +492 -0
  10. data/lib/packaging/config/params.rb +387 -0
  11. data/lib/packaging/config/validations.rb +13 -0
  12. data/lib/packaging/deb.rb +28 -0
  13. data/lib/packaging/deb/repo.rb +264 -0
  14. data/lib/packaging/gem.rb +70 -0
  15. data/lib/packaging/metrics.rb +15 -0
  16. data/lib/packaging/nuget.rb +39 -0
  17. data/lib/packaging/paths.rb +376 -0
  18. data/lib/packaging/platforms.rb +507 -0
  19. data/lib/packaging/repo.rb +155 -0
  20. data/lib/packaging/retrieve.rb +75 -0
  21. data/lib/packaging/rpm.rb +5 -0
  22. data/lib/packaging/rpm/repo.rb +254 -0
  23. data/lib/packaging/sign.rb +8 -0
  24. data/lib/packaging/sign/deb.rb +9 -0
  25. data/lib/packaging/sign/dmg.rb +41 -0
  26. data/lib/packaging/sign/ips.rb +57 -0
  27. data/lib/packaging/sign/msi.rb +124 -0
  28. data/lib/packaging/sign/rpm.rb +115 -0
  29. data/lib/packaging/tar.rb +163 -0
  30. data/lib/packaging/util.rb +146 -0
  31. data/lib/packaging/util/date.rb +20 -0
  32. data/lib/packaging/util/execution.rb +85 -0
  33. data/lib/packaging/util/file.rb +125 -0
  34. data/lib/packaging/util/git.rb +174 -0
  35. data/lib/packaging/util/git_tags.rb +73 -0
  36. data/lib/packaging/util/gpg.rb +66 -0
  37. data/lib/packaging/util/jenkins.rb +95 -0
  38. data/lib/packaging/util/misc.rb +69 -0
  39. data/lib/packaging/util/net.rb +410 -0
  40. data/lib/packaging/util/os.rb +17 -0
  41. data/lib/packaging/util/platform.rb +40 -0
  42. data/lib/packaging/util/rake_utils.rb +112 -0
  43. data/lib/packaging/util/serialization.rb +19 -0
  44. data/lib/packaging/util/ship.rb +300 -0
  45. data/lib/packaging/util/tool.rb +41 -0
  46. data/lib/packaging/util/version.rb +334 -0
  47. data/spec/fixtures/config/ext/build_defaults.yaml +2 -0
  48. data/spec/fixtures/config/ext/project_data.yaml +2 -0
  49. data/spec/fixtures/configs/components/test_file.json +1 -0
  50. data/spec/fixtures/configs/components/test_file_2.json +0 -0
  51. data/spec/fixtures/configs/components/test_file_not_tagged.json +1 -0
  52. data/spec/fixtures/configs/components/test_file_wrong_ext.txt +0 -0
  53. data/spec/fixtures/configs/components/test_file_wrong_ext.wrong +0 -0
  54. data/spec/fixtures/util/pre_tasks.yaml +4 -0
  55. data/spec/lib/packaging/artifactory_spec.rb +221 -0
  56. data/spec/lib/packaging/config_spec.rb +576 -0
  57. data/spec/lib/packaging/deb/repo_spec.rb +157 -0
  58. data/spec/lib/packaging/deb_spec.rb +52 -0
  59. data/spec/lib/packaging/gem_spec.rb +86 -0
  60. data/spec/lib/packaging/paths_spec.rb +418 -0
  61. data/spec/lib/packaging/platforms_spec.rb +178 -0
  62. data/spec/lib/packaging/repo_spec.rb +135 -0
  63. data/spec/lib/packaging/retrieve_spec.rb +100 -0
  64. data/spec/lib/packaging/rpm/repo_spec.rb +133 -0
  65. data/spec/lib/packaging/sign_spec.rb +133 -0
  66. data/spec/lib/packaging/tar_spec.rb +116 -0
  67. data/spec/lib/packaging/util/execution_spec.rb +56 -0
  68. data/spec/lib/packaging/util/file_spec.rb +139 -0
  69. data/spec/lib/packaging/util/git_spec.rb +160 -0
  70. data/spec/lib/packaging/util/git_tag_spec.rb +36 -0
  71. data/spec/lib/packaging/util/gpg_spec.rb +64 -0
  72. data/spec/lib/packaging/util/jenkins_spec.rb +112 -0
  73. data/spec/lib/packaging/util/misc_spec.rb +31 -0
  74. data/spec/lib/packaging/util/net_spec.rb +259 -0
  75. data/spec/lib/packaging/util/os_spec.rb +31 -0
  76. data/spec/lib/packaging/util/rake_utils_spec.rb +70 -0
  77. data/spec/lib/packaging/util/ship_spec.rb +199 -0
  78. data/spec/lib/packaging/util/version_spec.rb +123 -0
  79. data/spec/lib/packaging_spec.rb +19 -0
  80. data/spec/spec_helper.rb +22 -0
  81. data/static_artifacts/PackageInfo.plist +3 -0
  82. data/tasks/00_utils.rake +214 -0
  83. data/tasks/30_metrics.rake +33 -0
  84. data/tasks/apple.rake +268 -0
  85. data/tasks/archive.rake +69 -0
  86. data/tasks/build.rake +12 -0
  87. data/tasks/clean.rake +5 -0
  88. data/tasks/config.rake +35 -0
  89. data/tasks/deb.rake +129 -0
  90. data/tasks/deb_repos.rake +28 -0
  91. data/tasks/deprecated.rake +130 -0
  92. data/tasks/doc.rake +20 -0
  93. data/tasks/education.rake +57 -0
  94. data/tasks/fetch.rake +60 -0
  95. data/tasks/gem.rake +159 -0
  96. data/tasks/jenkins.rake +538 -0
  97. data/tasks/jenkins_dynamic.rake +202 -0
  98. data/tasks/load_extras.rake +21 -0
  99. data/tasks/mock.rake +348 -0
  100. data/tasks/nightly_repos.rake +286 -0
  101. data/tasks/pe_deb.rake +12 -0
  102. data/tasks/pe_rpm.rake +13 -0
  103. data/tasks/pe_ship.rake +226 -0
  104. data/tasks/pe_sign.rake +13 -0
  105. data/tasks/pe_tar.rake +5 -0
  106. data/tasks/retrieve.rake +52 -0
  107. data/tasks/rpm.rake +66 -0
  108. data/tasks/rpm_repos.rake +29 -0
  109. data/tasks/ship.rake +692 -0
  110. data/tasks/sign.rake +154 -0
  111. data/tasks/tag.rake +8 -0
  112. data/tasks/tar.rake +28 -0
  113. data/tasks/update.rake +16 -0
  114. data/tasks/vanagon.rake +35 -0
  115. data/tasks/vendor_gems.rake +117 -0
  116. data/tasks/version.rake +33 -0
  117. data/tasks/z_data_dump.rake +65 -0
  118. data/templates/README +1 -0
  119. data/templates/downstream.xml.erb +47 -0
  120. data/templates/msi.xml.erb +197 -0
  121. data/templates/packaging.xml.erb +346 -0
  122. data/templates/repo.xml.erb +117 -0
  123. metadata +287 -0
@@ -0,0 +1,41 @@
1
+ # Utility methods for handling system binaries
2
+
3
+ module Pkg::Util::Tool
4
+
5
+ # Set up utility methods for handling system binaries
6
+ #
7
+ class << self
8
+ def check_tool(tool)
9
+ find_tool(tool, :required => true)
10
+ end
11
+
12
+ def find_tool(tool, args = { :required => false })
13
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |root|
14
+ location = File.join(root, tool)
15
+
16
+ if Pkg::Util::OS.windows? && File.extname(location).empty?
17
+ exts = ENV['PATHEXT']
18
+ exts = exts ? exts.split(File::PATH_SEPARATOR) : %w(.EXE .BAT .CMD .COM)
19
+ exts.each do |ext|
20
+ locationext = File.expand_path(location + ext)
21
+
22
+ return '"' + locationext + '"' if FileTest.executable?(locationext)
23
+ end
24
+ end
25
+
26
+ return location if FileTest.executable? location
27
+ end
28
+ fail "#{tool} tool not found...exiting" if args[:required]
29
+ return nil
30
+ end
31
+
32
+ alias :has_tool :find_tool
33
+
34
+ end
35
+
36
+ # Set up paths to system tools we use in the packaging repo
37
+ # no matter what distribution we're packaging for.
38
+
39
+ GIT = Pkg::Util::Tool.check_tool('git')
40
+
41
+ end
@@ -0,0 +1,334 @@
1
+ require 'json'
2
+
3
+ # Utility methods used for versioning projects for various kinds of packaging
4
+ module Pkg::Util::Version
5
+ class << self
6
+ def uname_r
7
+ uname = Pkg::Util::Tool.find_tool('uname', required: true)
8
+ stdout, = Pkg::Util::Execution.capture3("#{uname} -r")
9
+ stdout.chomp
10
+ end
11
+
12
+ def pwd_version
13
+ Dir.pwd.split('.')[-1]
14
+ end
15
+
16
+ def debversion
17
+ base_pkg_version.join('-') << "#{Pkg::Config.packager}1"
18
+ end
19
+
20
+ def origversion
21
+ Pkg::Config.debversion.split('-')[0]
22
+ end
23
+
24
+ def rpmversion
25
+ base_pkg_version[0]
26
+ end
27
+
28
+ def rpmrelease
29
+ base_pkg_version[1]
30
+ end
31
+
32
+ # This is used to set Pkg::Config.version
33
+ # describe can return a number of potential formats
34
+ # 5.3.0
35
+ # 5.3.0-18-gfbddc8f
36
+ # 5.3.0-18-gfbddc8f-dirty
37
+ # 0.7.0-rc1
38
+ # 0.7.0-rc1-63-g51ccc51
39
+ # 0.7.0-rc1-63-g51ccc51-dirty
40
+ #
41
+ # we want all of it except the `gfbddc8f` part.
42
+ def dash_version
43
+ describe = Pkg::Util::Git.describe
44
+ info = describe.split('-')
45
+
46
+ if Pkg::Util::Git.ref_type == "tag"
47
+ describe
48
+ else
49
+ info.reject { |d| d.match(/^g.{7}/) }.join('-')
50
+ end
51
+ end
52
+
53
+ def extended_dash_version
54
+ Pkg::Util::Git.describe(['--tags', '--dirty', '--abbrev=7'])
55
+ end
56
+
57
+ # This version is used for gems and platform types that do not support
58
+ # dashes in the package version
59
+ def dot_version(version = Pkg::Config.version)
60
+ version.tr('-', '.')
61
+ end
62
+
63
+ def extended_dot_version
64
+ dot_version(extended_dash_version)
65
+ end
66
+
67
+ # Given a version, reformat it to be appropriate for a final package
68
+ # version. This means we need to add a `0.` before the release version
69
+ # for non-final builds
70
+ #
71
+ # This only applies to packages that are built with the automation in this
72
+ # repo. This is invalid for all other build automation, like vanagon
73
+ #
74
+ # Examples of output:
75
+ # 4.99.0.22.gf64bc49-1
76
+ # 4.4.1-0.1SNAPSHOT.2017.05.16T1005
77
+ # 4.99.0-1
78
+ # 4.99.0.29.g431768c-1
79
+ # 2.7.1-1
80
+ # 5.3.0.rc4-1
81
+ # 3.0.5.rc6.24.g431768c-1
82
+ #
83
+ # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
84
+ def base_pkg_version(version = Pkg::Config.version)
85
+ return "#{dot_version(version)}-#{Pkg::Config.release}".split('-') if final?(version) || Pkg::Config.vanagon_project
86
+
87
+ if version.include?('SNAPSHOT')
88
+ new_version = dot_version(version).sub(/\.SNAPSHOT/, "-0.#{Pkg::Config.release}SNAPSHOT")
89
+ elsif version.include?('rc')
90
+ rc_ver = dot_version(version).match(/\.?rc(\d+)/)[1]
91
+ new_version = dot_version(version).sub(/\.?rc(\d+)/, '') + "-0.#{Pkg::Config.release}rc#{rc_ver}"
92
+ else
93
+ new_version = dot_version(version) + "-0.#{Pkg::Config.release}"
94
+ end
95
+
96
+ if new_version.include?('dirty')
97
+ new_version = new_version.sub(/\.?dirty/, '') + 'dirty'
98
+ end
99
+
100
+ new_version.split('-')
101
+ end
102
+
103
+ # Determines if the version we are working with is or is not final
104
+ #
105
+ # The version here does not include the release version. Therefore, we
106
+ # assume that any version that includes a `-\d+` was not built from a tag
107
+ # and is a non-final version.
108
+ # Examples:
109
+ # Final
110
+ # - 5.0.0
111
+ # - 2016.5.6.7
112
+ # Nonfinal
113
+ # - 4.99.0-22
114
+ # - 1.0.0-658-gabc1234
115
+ # - 5.0.0.master.SNAPSHOT.2017.05.16T1357
116
+ # - 5.9.7-rc4
117
+ # - 4.99.0-56-dirty
118
+ #
119
+ def final?(version = Pkg::Config.version)
120
+ case version
121
+ when /rc/
122
+ false
123
+ when /SNAPSHOT/
124
+ false
125
+ when /g[a-f0-9]{7}/
126
+ false
127
+ when /^(\d+\.)+\d+-\d+/
128
+ false
129
+ when /-dirty/
130
+ Pkg::Config.allow_dirty_tree
131
+ else
132
+ true
133
+ end
134
+ end
135
+
136
+ # This is to support packages that only burn-in the version number in the
137
+ # release artifact, rather than storing it two (or more) times in the
138
+ # version control system. Razor is a good example of that; see
139
+ # https://github.com/puppetlabs/Razor/blob/master/lib/project_razor/version.rb
140
+ # for an example of that this looks like.
141
+ #
142
+ # If you invoke this the version will only be modified in the temporary copy,
143
+ # with the intent that it never change the official source tree.
144
+ #
145
+ # rubocop:disable Metrics/AbcSize
146
+ # rubocop:disable Metrics/CyclomaticComplexity
147
+ # rubocop:disable Metrics/PerceivedComplexity
148
+ def versionbump(workdir = nil)
149
+ version = ENV['VERSION'] || Pkg::Config.version.to_s.strip
150
+ new_version = '"' + version + '"'
151
+
152
+ version_file = "#{workdir ? workdir + '/' : ''}#{Pkg::Config.version_file}"
153
+
154
+ # Read the previous version file in...
155
+ contents = IO.read(version_file)
156
+
157
+ # Match version files containing 'VERSION = "x.x.x"' and just x.x.x
158
+ if contents =~ /VERSION =.*/
159
+ old_version = contents.match(/VERSION =.*/).to_s.split[-1]
160
+ else
161
+ old_version = contents
162
+ end
163
+
164
+ puts "Updating #{old_version} to #{new_version} in #{version_file}"
165
+ if contents =~ /@DEVELOPMENT_VERSION@/
166
+ contents.gsub!('@DEVELOPMENT_VERSION@', version)
167
+ elsif contents =~ /version\s*=\s*[\'"]DEVELOPMENT[\'"]/
168
+ contents.gsub!(/version\s*=\s*['"]DEVELOPMENT['"]/, "version = '#{version}'")
169
+ elsif contents =~ /VERSION = #{old_version}/
170
+ contents.gsub!("VERSION = #{old_version}", "VERSION = #{new_version}")
171
+ elsif contents =~ /#{Pkg::Config.project.upcase}VERSION = #{old_version}/
172
+ contents.gsub!("#{Pkg::Config.project.upcase}VERSION = #{old_version}", "#{Pkg::Config.project.upcase}VERSION = #{new_version}")
173
+ else
174
+ contents.gsub!(old_version, Pkg::Config.version)
175
+ end
176
+
177
+ # ...and write it back on out.
178
+ File.open(version_file, 'w') { |f| f.write contents }
179
+ end
180
+
181
+ # Human readable output for json tags reporting. This will load the
182
+ # input json file and output if it "looks tagged" or not
183
+ #
184
+ # @param json_data [hash] json data hash containing the ref to check
185
+ def report_json_tags(json_data) # rubocop:disable Metrics/AbcSize
186
+ puts 'component: ' + File.basename(json_data['url'])
187
+ puts 'ref: ' + json_data['ref'].to_s
188
+ if Pkg::Util::Git.remote_tagged?(json_data['url'], json_data['ref'].to_s)
189
+ tagged = 'Tagged? [ Yes ]'
190
+ else
191
+ tagged = 'Tagged? [ No ]'
192
+ end
193
+ col_len = (ENV['COLUMNS'] || 70).to_i
194
+ puts format("\n%#{col_len}s\n\n", tagged)
195
+ puts '*' * col_len
196
+ end
197
+
198
+ ##########################################################################
199
+ # DEPRECATED METHODS
200
+ #
201
+ def git_co(ref)
202
+ Pkg::Util.deprecate('Pkg::Util::Version.git_co', 'Pkg::Util::Git.checkout')
203
+ Pkg::Util::Git.checkout(ref)
204
+ end
205
+
206
+ def git_tagged?
207
+ Pkg::Util.deprecate('Pkg::Util::Version.git_tagged?', 'Pkg::Util::Git.tagged?')
208
+ Pkg::Util::Git.tagged?
209
+ end
210
+
211
+ def git_describe
212
+ Pkg::Util.deprecate('Pkg::Util::Version.git_describe', 'Pkg::Util::Git.describe')
213
+ Pkg::Util::Git.describe
214
+ end
215
+
216
+ def git_sha(length = 40)
217
+ Pkg::Util.deprecate('Pkg::Util::Version.git_sha', 'Pkg::Util::Git.sha')
218
+ Pkg::Util::Git.sha(length)
219
+ end
220
+
221
+ def git_ref_type
222
+ Pkg::Util.deprecate('Pkg::Util::Version.git_ref_type', 'Pkg::Util::Git.ref_type')
223
+ Pkg::Util::Git.ref_type
224
+ end
225
+
226
+ def git_sha_or_tag(length = 40)
227
+ Pkg::Util.deprecate('Pkg::Util::Version.git_sha_or_tag', 'Pkg::Util::Git.sha_or_tag')
228
+ Pkg::Util::Git.sha_or_tag(length)
229
+ end
230
+
231
+ def is_git_repo?
232
+ Pkg::Util.deprecate('Pkg::Util::Version.is_git_repo?', 'Pkg::Util::Git.repo?')
233
+ Pkg::Util::Git.repo?
234
+ end
235
+
236
+ def git_project_name
237
+ Pkg::Util.deprecate('Pkg::Util::Version.git_project_name', 'Pkg::Util::Git.project_name')
238
+ Pkg::Util::Git.project_name
239
+ end
240
+
241
+ def git_describe_version
242
+ Pkg::Util.deprecate('Pkg::Util::Version.git_describe_version', 'Pkg::Util::Git.describe')
243
+ Pkg::Util::Git.describe
244
+ end
245
+
246
+ def run_git_describe_internal
247
+ Pkg::Util.deprecate('Pkg::Util::Version.git_describe_version', 'Pkg::Util::Git.describe')
248
+ Pkg::Util::Git.describe
249
+ end
250
+
251
+ def get_dash_version
252
+ Pkg::Util.deprecate('Pkg::Util::Version.get_dash_version', 'Pkg::Util::Version.dash_version')
253
+ Pkg::Util::Version.dash_version
254
+ end
255
+
256
+ def get_ips_version
257
+ raise "The IPS build tasks have been removed from puppetlabs/packaging. Please port all Solaris projects to vanagon (https://github.com/puppetlabs/vanagon)"
258
+ end
259
+
260
+ def get_dot_version
261
+ Pkg::Util.deprecate('Pkg::Util::Version.get_dot_version', 'Pkg::Util::Version.dot_version')
262
+ Pkg::Util::Version.dot_version
263
+ end
264
+
265
+ def get_pwd_version
266
+ Pkg::Util.deprecate('Pkg::Util::Version.get_pwd_version', 'Pkg::Util::Version.pwd_version')
267
+ Pkg::Util::Version.pwd_version
268
+ end
269
+
270
+ def get_base_pkg_version
271
+ Pkg::Util.deprecate('Pkg::Util::Version.get_base_pkg_version', 'Pkg::Util::Version.base_pkg_version')
272
+ Pkg::Util::Version.base_pkg_version
273
+ end
274
+
275
+ def get_debversion
276
+ Pkg::Util.deprecate('Pkg::Util::Version.get_debversion', 'Pkg::Util::Version.debversion')
277
+ Pkg::Util::Version.debversion
278
+ end
279
+
280
+ def get_origversion
281
+ Pkg::Util.deprecate('Pkg::Util::Version.get_origversion', 'Pkg::Util::Version.origversion')
282
+ Pkg::Util::Version.origversion
283
+ end
284
+
285
+ def get_rpmversion
286
+ Pkg::Util.deprecate('Pkg::Util::Version.get_rpmversion', 'Pkg::Util::Version.rpmversion')
287
+ Pkg::Util::Version.rpmversion
288
+ end
289
+
290
+ def get_rpmrelease
291
+ Pkg::Util.deprecate('Pkg::Util::Version.get_rpmrelease', 'Pkg::Util::Version.rpmrelease')
292
+ Pkg::Util::Version.rpmrelease
293
+ end
294
+
295
+ def source_dirty?
296
+ Pkg::Util.deprecate('Pkg::Util::Version.source_dirty?', 'Pkg::Util::Git.source_dirty?')
297
+ Pkg::Util::Git.source_dirty?
298
+ end
299
+
300
+ def fail_on_dirty_source
301
+ Pkg::Util.deprecate('Pkg::Util::Version.fail_on_dirty_source', 'Pkg::Util::Git.fail_on_dirty_source')
302
+ Pkg::Util::Git.fail_on_dirty_source
303
+ end
304
+
305
+ def is_final?
306
+ Pkg::Util.deprecate('Pkg::Util::Version.is_final?', 'Pkg::Util::Version.final?')
307
+ Pkg::Util::Version.final?
308
+ end
309
+
310
+ def is_rc?
311
+ Pkg::Util.deprecate('Pkg::Util::Version.is_rc?', 'Pkg::Util::Version.final?')
312
+ Pkg::Util::Version.final?
313
+ end
314
+
315
+ def is_odd?
316
+ Pkg::Util.deprecate('Pkg::Util::Version.is_odd?', 'Pkg::Util::Version.final?')
317
+ Pkg::Util::Version.final?
318
+ end
319
+
320
+ def is_less_than_one?
321
+ Pkg::Util.deprecate('Pkg::Util::Version.is_less_than_one?', 'Pkg::Util::Version.final?')
322
+ Pkg::Util::Version.final?
323
+ end
324
+
325
+ def el_version
326
+ raise "Pkg::Util::Version.el_version has been removed"
327
+ end
328
+
329
+ def tagged?(url, ref)
330
+ Pkg::Util.deprecate('Pkg::Util::Version.tagged?', 'Pkg::Util::Git.remote_tagged?')
331
+ Pkg::Util::Git.remote_tagged?(url, ref)
332
+ end
333
+ end
334
+ end
@@ -0,0 +1,2 @@
1
+ ---
2
+ :apt_host: foo
@@ -0,0 +1,2 @@
1
+ ---
2
+ :apt_host: foo
@@ -0,0 +1 @@
1
+ {"url": "git://github.com/puppetlabs/leatherman.git", "ref": "refs/tags/0.6.2"}
File without changes
@@ -0,0 +1 @@
1
+ {"url": "git://github.com/puppetlabs/leatherman.git", "ref": "4eef05389ebf418b62af17406c7f9f13fa51f975"}
@@ -0,0 +1,4 @@
1
+ ---
2
+ pre_tasks:
3
+ foo: 'bar'
4
+
@@ -0,0 +1,221 @@
1
+ # -*- ruby -*-
2
+ require 'spec_helper'
3
+ require 'packaging/artifactory'
4
+
5
+ describe 'artifactory.rb' do
6
+
7
+ project = 'puppet-agent'
8
+ project_version = 'ashawithlettersandnumbers'
9
+ default_repo_name = 'testing'
10
+ artifactory_uri = 'https://artifactory.url'
11
+
12
+ let(:platform_data) {
13
+ {
14
+ 'el-6-x86_64' => {
15
+ :artifact => "./el/6/PC1/x86_64/puppet-agent-5.3.1.34.gf65f9ef-1.el6.x86_64.rpm",
16
+ :repo_config => "../repo_configs/rpm/pl-puppet-agent-f65f9efbb727c3d2d72d6799c0fc345a726f27b5-el-6-x86_64.repo",
17
+ :additional_artifacts => ["./el/6/PC1/x86_64/puppet-agent-extras-5.3.1.34.gf65f9ef-1.el6.x86_64.rpm"],
18
+ },
19
+ 'ubuntu-16.04-amd64' => {
20
+ :artifact => "./deb/xenial/PC1/puppet-agent_5.3.1.34.gf65f9ef-1xenial_amd64.deb",
21
+ :repo_config => "../repo_configs/deb/pl-puppet-agent-f65f9efbb727c3d2d72d6799c0fc345a726f27b5-xenial.list",
22
+ :additional_artifacts => ["./deb/xenial/PC1/puppet-agent-extras_5.3.1.34.gf65f9ef-1xenial_amd64.deb"],
23
+ },
24
+ 'debian-10-amd64' => {
25
+ :artifact => "./deb/buster/PC1/puppetdb_5.3.1.34.gf65f9ef-1buster_all.deb",
26
+ :repo_config => "../repo_configs/deb/pl-puppetdb-f65f9efbb727c3d2d72d6799c0fc345a726f27b5-buster.list",
27
+ :additional_artifacts => ["./deb/buster/PC1/puppetdb-termini_5.3.1.34.gf65f9ef-1buster_all.deb"],
28
+ },
29
+ 'windows-2012-x86' => {
30
+ :artifact => "./windows/puppet-agent-5.3.1.34-x86.msi",
31
+ :repo_config => '',
32
+ :additional_artifacts => ["./windows/puppet-agent-extras-5.3.1.34-x86.msi"],
33
+ },
34
+ 'windowsfips-2012-x64' => {
35
+ :artifact => "./windowsfips/puppet-agent-5.3.1.34-x64.msi",
36
+ :repo_config => '',
37
+ :additional_artifacts => ["./windowsfips/puppet-agent-extras-5.3.1.34-x64.msi"],
38
+ },
39
+ 'osx-10.15-x86_64' => {
40
+ :artifact => "./apple/10.15/PC1/x86_64/puppet-agent-5.3.1.34.gf65f9ef-1.osx10.15.dmg",
41
+ :repo_config => '',
42
+ :additional_artifacts => ["./apple/10.15/PC1/x86_64/puppet-agent-extras-5.3.1.34.gf65f9ef-1.osx10.15.dmg"],
43
+ },
44
+ 'osx-11-x86_64' => {
45
+ :artifact => "./apple/11/PC1/x86_64/puppet-agent-5.3.1.34.gf65f9ef-1.osx11.dmg",
46
+ :repo_config => '',
47
+ :additional_artifacts => ["./apple/11/PC1/x86_64/puppet-agent-extras-5.3.1.34.gf65f9ef-1.osx11.dmg"],
48
+ },
49
+ 'solaris-10-sparc' => {
50
+ :artifact => "./solaris/10/PC1/puppet-agent-5.3.1.34.gf65f9ef-1.sparc.pkg.gz",
51
+ :repo_config => '',
52
+ },
53
+ }
54
+ }
55
+
56
+ platform_tags = {
57
+ 'el-6-x86_64' => {
58
+ :toplevel_repo => 'rpm',
59
+ :repo_subdirectories => "#{default_repo_name}/#{project}/#{project_version}/el-6-x86_64",
60
+ :package_format => 'rpm',
61
+ :package_name => 'path/to/a/el/6/package/puppet-agent-5.3.1.34.gf65f9ef-1.el6.x86_64.rpm',
62
+ :all_package_names => ['puppet-agent-5.3.1.34.gf65f9ef-1.el6.x86_64.rpm', 'puppet-agent-extras-5.3.1.34.gf65f9ef-1.el6.x86_64.rpm']
63
+ },
64
+ 'ubuntu-16.04-amd64' => {
65
+ :toplevel_repo => 'debian__local',
66
+ :repo_subdirectories => "#{default_repo_name}/#{project}/#{project_version}/ubuntu-16.04",
67
+ :codename => 'xenial',
68
+ :arch => 'amd64',
69
+ :package_name => 'path/to/a/xenial/package/puppet-agent_5.3.1.34.gf65f9ef-1xenial_amd64.deb',
70
+ :all_package_names => ['puppet-agent_5.3.1.34.gf65f9ef-1xenial_amd64.deb', 'puppet-agent-extras_5.3.1.34.gf65f9ef-1xenial_amd64.deb']
71
+ },
72
+ 'debian-10-amd64' => {
73
+ :toplevel_repo => 'debian__local',
74
+ :repo_subdirectories => "#{default_repo_name}/#{project}/#{project_version}/debian-10",
75
+ :codename => 'buster',
76
+ :arch => 'all',
77
+ :package_name => 'path/to/a/buster/package/puppetdb_5.3.1.34.gf65f9ef-1buster_all.deb',
78
+ :all_package_names => ['puppetdb_5.3.1.34.gf65f9ef-1buster_all.deb', 'puppetdb-termini_5.3.1.34.gf65f9ef-1buster_all.deb']
79
+ },
80
+ 'windows-2012-x86' => {
81
+ :toplevel_repo => 'generic',
82
+ :repo_subdirectories => "#{default_repo_name}/#{project}/#{project_version}/windows-x86",
83
+ :package_name => 'path/to/a/windows/package/puppet-agent-5.3.1.34-x86.msi',
84
+ :all_package_names => ['puppet-agent-5.3.1.34-x86.msi','puppet-agent-extras-5.3.1.34-x86.msi']
85
+ },
86
+ 'windowsfips-2012-x64' => {
87
+ :toplevel_repo => 'generic',
88
+ :repo_subdirectories => "#{default_repo_name}/#{project}/#{project_version}/windowsfips-x64",
89
+ :package_name => 'path/to/a/windowsfips/package/puppet-agent-5.3.1.34-x64.msi',
90
+ :all_package_names => ['puppet-agent-5.3.1.34-x64.msi','puppet-agent-extras-5.3.1.34-x64.msi']
91
+ },
92
+ 'osx-10.15-x86_64' => {
93
+ :toplevel_repo => 'generic',
94
+ :repo_subdirectories => "#{default_repo_name}/#{project}/#{project_version}/osx-10.15-x86_64",
95
+ :package_name => 'path/to/an/osx/10.15/package/puppet-agent-5.3.1.34.gf65f9ef-1.osx10.15.dmg',
96
+ :all_package_names => ['puppet-agent-5.3.1.34.gf65f9ef-1.osx10.15.dmg', 'puppet-agent-extras-5.3.1.34.gf65f9ef-1.osx10.15.dmg']
97
+ },
98
+ 'osx-11-x86_64' => {
99
+ :toplevel_repo => 'generic',
100
+ :repo_subdirectories => "#{default_repo_name}/#{project}/#{project_version}/osx-11-x86_64",
101
+ :package_name => 'path/to/an/osx/11/package/puppet-agent-5.3.1.34.gf65f9ef-1.osx11.dmg',
102
+ :all_package_names => ['puppet-agent-5.3.1.34.gf65f9ef-1.osx11.dmg', 'puppet-agent-extras-5.3.1.34.gf65f9ef-1.osx11.dmg']
103
+ },
104
+ 'solaris-10-sparc' => {
105
+ :toplevel_repo => 'generic',
106
+ :repo_subdirectories => "#{default_repo_name}/#{project}/#{project_version}/solaris-10-sparc",
107
+ :package_name => 'path/to/a/solaris/10/package/puppet-agent-5.3.1.34.gf65f9ef-1.sparc.pkg.gz',
108
+ :all_package_names => ['puppet-agent-5.3.1.34.gf65f9ef-1.sparc.pkg.gz']
109
+ },
110
+ }
111
+
112
+ let(:artifact) { Pkg::ManageArtifactory.new(project, project_version, {:repo_base => default_repo_name, :artifactory_uri => artifactory_uri})}
113
+
114
+ around(:each) do |example|
115
+ original_artifactory_api_key = ENV['ARTIFACTORY_API_KEY']
116
+ ENV['ARTIFACTORY_API_KEY'] = 'anapikeythatdefinitelyworks'
117
+ example.run
118
+ ENV['ARTIFACTORY_API_KEY'] = original_artifactory_api_key
119
+ end
120
+
121
+ platform_tags.each do |platform_tag, platform_tag_data|
122
+ describe '#location_for' do
123
+ if platform_tag_data[:codename]
124
+ it 'returns the expected repo name and paths by default, prepending `pool` for debian-ish platforms' do
125
+ expect(artifact.location_for(platform_tag)).to match_array([
126
+ platform_tag_data[:toplevel_repo],
127
+ platform_tag_data[:repo_subdirectories],
128
+ ])
129
+ end
130
+ else
131
+ it 'returns the expected repo name and paths by default' do
132
+ expect(artifact.location_for(platform_tag)).to match_array([
133
+ platform_tag_data[:toplevel_repo],
134
+ platform_tag_data[:repo_subdirectories],
135
+ ])
136
+ end
137
+ end
138
+
139
+ it 'returns the correct paths for the passed in format' do
140
+ expect(artifact.location_for('generic')).to match_array([
141
+ 'generic',
142
+ File.join(default_repo_name, project, project_version),
143
+ ])
144
+ end
145
+ end
146
+
147
+ describe '#package_name' do
148
+ it 'parses the retrieved yaml file and returns the correct package name' do
149
+ expect(artifact.package_name(platform_data, platform_tag)).to eq(File.basename(platform_tag_data[:package_name]))
150
+ end
151
+
152
+ it 'fails if it cannot find a valid platform name' do
153
+ new_platform_data = platform_data
154
+ new_platform_data.delete_if { |k| k.match(platform_tag) }
155
+ expect{artifact.package_name(new_platform_data, platform_tag)}.to raise_error
156
+ end
157
+ end
158
+
159
+ describe '#all_package_names' do
160
+ it 'parses the retrieved yaml file and returns the correct package name' do
161
+ all_package_names = artifact.all_package_names(platform_data, platform_tag)
162
+ all_package_names_data = [platform_tag_data[:additional_artifacts], platform_tag_data[:all_package_names]].flatten.compact
163
+ all_package_names.map! { |p| File.basename(p) }
164
+ all_package_names_data.map! { |p| File.basename(p) }
165
+ expect(all_package_names.size).to eq(all_package_names_data.size)
166
+ expect(all_package_names.sort).to eq(all_package_names_data.sort)
167
+ end
168
+
169
+ it 'fails if it cannot find a valid platform name' do
170
+ new_platform_data = platform_data
171
+ new_platform_data.delete_if { |k| k.match(platform_tag) }
172
+ expect{artifact.package_name(new_platform_data, platform_tag)}.to raise_error
173
+ end
174
+ end
175
+
176
+ describe '#deb_list_contents' do
177
+ it "returns the correct contents for the debian list file for #{platform_tag}" do
178
+ if platform_tag_data[:codename]
179
+ expect(artifact.deb_list_contents(platform_tag)).to eq("deb #{artifactory_uri}/#{platform_tag_data[:toplevel_repo].chomp('/pool')} #{platform_tag_data[:codename]} #{platform_tag_data[:repo_subdirectories]}")
180
+ else
181
+ expect{artifact.deb_list_contents(platform_tag)}.to raise_error
182
+ end
183
+ end
184
+ end
185
+
186
+ describe '#rpm_repo_contents' do
187
+ it "returns the correct contents for the rpm repo file for #{platform_tag}" do
188
+ if platform_tag_data[:package_format] == 'rpm'
189
+ expect(artifact.rpm_repo_contents(platform_tag)).to include("baseurl=#{artifactory_uri}\/#{platform_tag_data[:toplevel_repo]}\/#{platform_tag_data[:repo_subdirectories]}")
190
+ else
191
+ expect{artifact.rpm_repo_contents(platform_tag)}.to raise_error
192
+ end
193
+ end
194
+ end
195
+
196
+ describe '#deploy_properties' do
197
+ it "returns the correct contents for the deploy properties for #{platform_tag}" do
198
+ if platform_tag_data[:codename]
199
+ expect(artifact.deploy_properties(platform_tag, File.basename(platform_tag_data[:package_name]))).to include({
200
+ 'deb.distribution' => platform_tag_data[:codename],
201
+ 'deb.component' => platform_tag_data[:repo_subdirectories],
202
+ 'deb.architecture' => platform_tag_data[:arch]
203
+ })
204
+ else
205
+ expect(artifact.deploy_properties(platform_tag, File.basename(platform_tag_data[:package_name]))).not_to include({
206
+ 'deb.component' => platform_tag_data[:repo_subdirectories]
207
+ })
208
+ end
209
+ end
210
+ end
211
+ end
212
+
213
+ describe '#check_authorization' do
214
+ it 'fails gracefully if authorization is not set' do
215
+ original_artifactory_api_key = ENV['ARTIFACTORY_API_KEY']
216
+ ENV['ARTIFACTORY_API_KEY'] = nil
217
+ expect { artifact.deploy_package('path/to/el/7/x86_64/package.rpm') }.to raise_error
218
+ ENV['ARTIFACTORY_API_KEY'] = original_artifactory_api_key
219
+ end
220
+ end
221
+ end