puppet 2.7.25 → 2.7.26

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (77) hide show
  1. data/bin/puppet +4 -0
  2. data/ext/build_defaults.yaml +4 -4
  3. data/ext/debian/control +1 -1
  4. data/ext/packaging/Gemfile +8 -0
  5. data/ext/packaging/Gemfile.lock +28 -0
  6. data/ext/packaging/README.md +31 -4
  7. data/ext/packaging/lib/packaging.rb +21 -0
  8. data/ext/packaging/lib/packaging/config.rb +277 -0
  9. data/ext/packaging/lib/packaging/config/params.rb +175 -0
  10. data/ext/packaging/lib/packaging/tar.rb +186 -0
  11. data/ext/packaging/lib/packaging/util.rb +44 -0
  12. data/ext/packaging/lib/packaging/util/date.rb +15 -0
  13. data/ext/packaging/lib/packaging/util/file.rb +60 -0
  14. data/ext/packaging/lib/packaging/util/jira.rb +83 -0
  15. data/ext/packaging/lib/packaging/util/net.rb +16 -0
  16. data/ext/packaging/lib/packaging/util/rake_utils.rb +57 -0
  17. data/ext/packaging/lib/packaging/util/serialization.rb +19 -0
  18. data/ext/packaging/lib/packaging/util/tool.rb +30 -0
  19. data/ext/packaging/lib/packaging/util/version.rb +300 -0
  20. data/ext/packaging/packaging.rake +10 -5
  21. data/ext/packaging/spec/fixtures/config/ext/build_defaults.yaml +2 -0
  22. data/ext/packaging/spec/fixtures/config/ext/project_data.yaml +2 -0
  23. data/ext/packaging/spec/fixtures/config/params.yaml +2 -0
  24. data/ext/packaging/spec/fixtures/util/pre_tasks.yaml +4 -0
  25. data/ext/packaging/spec/lib/packaging/config_spec.rb +330 -0
  26. data/ext/packaging/spec/lib/packaging/tar_spec.rb +122 -0
  27. data/ext/packaging/spec/lib/packaging/util/file_spec.rb +48 -0
  28. data/ext/packaging/spec/lib/packaging/util/jira_spec.rb +50 -0
  29. data/ext/packaging/spec/lib/packaging/util/net_spec.rb +23 -0
  30. data/ext/packaging/spec/lib/packaging/util/rake_utils_spec.rb +70 -0
  31. data/ext/packaging/spec/lib/packaging/util/version_spec.rb +67 -0
  32. data/ext/packaging/spec/lib/packaging_spec.rb +19 -0
  33. data/ext/packaging/spec/spec_helper.rb +10 -0
  34. data/ext/packaging/spec/tasks/00_utils_spec.rb +218 -88
  35. data/ext/packaging/tasks/00_utils.rake +63 -320
  36. data/ext/packaging/tasks/30_metrics.rake +4 -4
  37. data/ext/packaging/tasks/apple.rake +28 -13
  38. data/ext/packaging/tasks/build.rake +2 -176
  39. data/ext/packaging/tasks/deb.rake +61 -20
  40. data/ext/packaging/tasks/deb_repos.rake +12 -12
  41. data/ext/packaging/tasks/doc.rake +5 -5
  42. data/ext/packaging/tasks/fetch.rake +9 -9
  43. data/ext/packaging/tasks/gem.rake +59 -33
  44. data/ext/packaging/tasks/ips.rake +22 -23
  45. data/ext/packaging/tasks/jenkins.rake +34 -34
  46. data/ext/packaging/tasks/jenkins_dynamic.rake +22 -19
  47. data/ext/packaging/tasks/load_extras.rake +21 -0
  48. data/ext/packaging/tasks/mock.rake +16 -16
  49. data/ext/packaging/tasks/pe_deb.rake +2 -2
  50. data/ext/packaging/tasks/pe_remote.rake +9 -9
  51. data/ext/packaging/tasks/pe_rpm.rake +1 -1
  52. data/ext/packaging/tasks/pe_ship.rake +48 -37
  53. data/ext/packaging/tasks/pe_sign.rake +5 -5
  54. data/ext/packaging/tasks/release.rake +5 -5
  55. data/ext/packaging/tasks/remote_build.rake +27 -27
  56. data/ext/packaging/tasks/retrieve.rake +5 -5
  57. data/ext/packaging/tasks/rpm.rake +27 -10
  58. data/ext/packaging/tasks/rpm_repos.rake +13 -12
  59. data/ext/packaging/tasks/ship.rake +67 -45
  60. data/ext/packaging/tasks/sign.rake +37 -30
  61. data/ext/packaging/tasks/tar.rake +14 -69
  62. data/ext/packaging/tasks/tickets.rake +449 -0
  63. data/ext/packaging/tasks/update.rake +2 -2
  64. data/ext/packaging/tasks/vendor_gems.rake +2 -2
  65. data/ext/packaging/tasks/version.rake +8 -38
  66. data/ext/packaging/tasks/z_data_dump.rake +35 -3
  67. data/ext/packaging/templates/downstream.xml.erb +2 -2
  68. data/ext/packaging/templates/packaging.xml.erb +13 -13
  69. data/ext/packaging/templates/repo.xml.erb +9 -7
  70. data/lib/puppet/indirector/facts/facter.rb +1 -1
  71. data/lib/puppet/version.rb +1 -1
  72. data/spec/unit/indirector/facts/facter_spec.rb +2 -2
  73. metadata +38 -13
  74. data/ext/packaging/spec/tasks/build_object_spec.rb +0 -178
  75. data/ext/packaging/tasks/10_setupvars.rake +0 -135
  76. data/ext/packaging/tasks/20_setupextravars.rake +0 -53
  77. data/ext/packaging/tasks/template.rake +0 -27
@@ -1,43 +1,39 @@
1
- # Utility methods used by the various rake tasks
1
+ #######################################################################
2
+ # #
3
+ # #
4
+ # #
5
+ # #
6
+ # #
7
+ # #
8
+ # ! DO NOT ADD TO THIS FILE ! #
9
+ # #
10
+ # Usage of this file to store utilities is deprecated. Any new #
11
+ # utilities should be added to new or existing classes in #
12
+ # lib/packaging/util. Any modified utilities should be migrated #
13
+ # to new or existing classes in lib/packaging/util as well. #
14
+ # #
15
+ # #
16
+ # #
17
+ # #
18
+ # #
19
+ # #
20
+ #######################################################################
21
+
2
22
 
3
- def check_tool(tool)
4
- return true if has_tool(tool)
5
- fail "#{tool} tool not found...exiting"
6
- end
7
23
 
8
- def find_tool(tool)
9
- ENV['PATH'].split(File::PATH_SEPARATOR).each do |root|
10
- location = File.join(root, tool)
11
- return location if FileTest.executable? location
12
- end
13
- return nil
14
- end
15
- alias :has_tool :find_tool
16
24
 
17
- def check_file(file)
18
- File.exist?(file) or fail "#{file} file not found!"
19
- end
25
+
26
+ # Utility methods used by the various rake tasks
20
27
 
21
28
  def check_var(varname,var=nil)
22
29
  var.nil? and fail "Requires #{varname} be set!"
30
+ var
23
31
  end
24
32
 
25
33
  def check_host(host)
26
34
  host == %x{hostname}.chomp! or fail "Requires host to be #{host}!"
27
35
  end
28
36
 
29
- def erb_string(erbfile)
30
- template = File.read(erbfile)
31
- message = ERB.new(template, nil, "-")
32
- message.result(binding)
33
- end
34
-
35
- def erb(erbfile, outfile)
36
- output = erb_string(erbfile)
37
- File.open(outfile, 'w') { |f| f.write output }
38
- puts "Generated: #{outfile}"
39
- end
40
-
41
37
  def cp_pr(src, dest, options={})
42
38
  mandatory = {:preserve => true}
43
39
  cp_r(src, dest, options.merge(mandatory))
@@ -53,46 +49,14 @@ def mv_f(src, dest, options={})
53
49
  mv(src, dest, options.merge(mandatory))
54
50
  end
55
51
 
56
- def git_co(ref)
57
- %x{git reset --hard ; git checkout #{ref}}
58
- $?.success? or fail "Could not checkout #{ref} git branch to build package from...exiting"
59
- end
60
-
61
- def git_describe
62
- %x{git describe}.strip
63
- end
64
-
65
- # return the sha of HEAD on the current branch
66
- def git_sha
67
- %x{git rev-parse HEAD}.strip
68
- end
69
-
70
- # Return the ref type of HEAD on the current branch
71
- def git_ref_type
72
- %x{git cat-file -t #{git_describe}}.strip
73
- end
74
-
75
- # If HEAD is a tag, return the tag. Otherwise return the sha of HEAD.
76
- def git_sha_or_tag
77
- if git_ref_type == "tag"
78
- git_describe
79
- else
80
- git_sha
81
- end
82
- end
83
-
84
- def get_temp
85
- `mktemp -d -t pkgXXXXXX`.strip
86
- end
87
-
88
52
  def remote_ssh_cmd target, command
89
- check_tool('ssh')
53
+ Pkg::Util::Tool.check_tool('ssh')
90
54
  puts "Executing '#{command}' on #{target}"
91
55
  sh "ssh -t #{target} '#{command.gsub("'", "'\\\\''")}'"
92
56
  end
93
57
 
94
58
  def rsync_to *args
95
- check_tool('rsync')
59
+ Pkg::Util::Tool.check_tool('rsync')
96
60
  flags = "-rHlv -O --no-perms --no-owner --no-group --ignore-existing"
97
61
  source = args[0]
98
62
  target = args[1]
@@ -102,7 +66,7 @@ def rsync_to *args
102
66
  end
103
67
 
104
68
  def rsync_from *args
105
- check_tool('rsync')
69
+ Pkg::Util::Tool.check_tool('rsync')
106
70
  flags = "-rHlv -O --no-perms --no-owner --no-group"
107
71
  source = args[0]
108
72
  target = args[1]
@@ -119,113 +83,6 @@ def scp_file_to(host,path,file)
119
83
  %x{scp #{@tempdir}/#{file} #{host}:#{path}}
120
84
  end
121
85
 
122
- def timestamp(separator=nil)
123
- if s = separator
124
- format = "%Y#{s}%m#{s}%d#{s}%H#{s}%M#{s}%S"
125
- else
126
- format = "%Y-%m-%d %H:%M:%S"
127
- end
128
- Time.now.strftime(format)
129
- end
130
-
131
- # Return information about the current tree, using `git describe`, ready for
132
- # further processing.
133
- #
134
- # Returns an array of one to four elements, being:
135
- # * version (three dot-joined numbers, leading `v` stripped)
136
- # * the string 'rcX' (if the last tag was an rc release, where X is the rc number)
137
- # * commits (string containing integer, number of commits since that version was tagged)
138
- # * dirty (string 'dirty' if local changes exist in the repo)
139
- def git_describe_version
140
- return nil unless is_git_repo and raw = run_git_describe_internal
141
- # reprocess that into a nice set of output data
142
- # The elements we select potentially change if this is an rc
143
- # For an rc with added commits our string will be something like '0.7.0-rc1-63-g51ccc51'
144
- # and our return will be [0.7.0, rc1, 63, <dirty>]
145
- # For a final with added commits, it will look like '0.7.0-63-g51ccc51'
146
- # and our return will be [0.7.0, 64, <dirty>]
147
- info = raw.chomp.sub(/^v/, '').split('-')
148
- if info[1].to_s.match('^[\d]+')
149
- version_string = info.values_at(0,1,3).compact
150
- else
151
- version_string = info.values_at(0,1,2,4).compact
152
- end
153
- version_string
154
- end
155
-
156
- # This is a stub to ease testing...
157
- def run_git_describe_internal
158
- raw = %x{git describe --tags --dirty 2>/dev/null}
159
- $?.success? ? raw : nil
160
- end
161
-
162
- def get_dash_version
163
- if info = git_describe_version
164
- info.join('-')
165
- else
166
- get_pwd_version
167
- end
168
- end
169
-
170
- def uname_r
171
- %x{uname -r}.chomp
172
- end
173
-
174
- def get_ips_version
175
- if info = git_describe_version
176
- version, commits, dirty = info
177
- if commits.to_s.match('^rc[\d]+')
178
- commits = info[2]
179
- dirty = info[3]
180
- end
181
- osrelease = uname_r
182
- "#{version},#{osrelease}-#{commits.to_i}#{dirty ? '-dirty' : ''}"
183
- else
184
- get_pwd_version
185
- end
186
- end
187
-
188
- def get_dot_version
189
- get_dash_version.gsub('-', '.')
190
- end
191
-
192
- def get_pwd_version
193
- %x{pwd}.strip.split('.')[-1]
194
- end
195
-
196
- def get_base_pkg_version
197
- dash = get_dash_version
198
- if dash.include?("rc")
199
- # Grab the rc number
200
- rc_num = dash.match(/rc(\d+)/)[1]
201
- ver = dash.sub(/-?rc[0-9]+/, "-0.#{@build.release}rc#{rc_num}").gsub(/(rc[0-9]+)-(\d+)?-?/, '\1.\2')
202
- else
203
- ver = dash.gsub('-','.') + "-#{@build.release}"
204
- end
205
-
206
- ver.split('-')
207
- end
208
-
209
- def get_debversion
210
- get_base_pkg_version.join('-') << "#{@build.packager}1"
211
- end
212
-
213
- def get_origversion
214
- @build.debversion.split('-')[0]
215
- end
216
-
217
- def get_rpmversion
218
- get_base_pkg_version[0]
219
- end
220
-
221
- def get_release
222
- ENV['RELEASE'] || '1'
223
- end
224
-
225
- def get_rpmrelease
226
- get_base_pkg_version[1]
227
- end
228
-
229
86
  def load_keychain
230
87
  unless @keychain_loaded
231
88
  unless ENV['RPM_GPG_AGENT']
@@ -236,59 +93,47 @@ def load_keychain
236
93
  end
237
94
  end
238
95
 
239
- def source_dirty?
240
- git_describe_version.include?('dirty')
241
- end
242
-
243
- def fail_on_dirty_source
244
- if source_dirty?
245
- fail "
246
- The source tree is dirty, e.g. there are uncommited changes. Please
247
- commit/discard changes and try again."
248
- end
249
- end
250
-
251
96
  def kill_keychain
252
97
  %x{keychain -k mine}
253
98
  end
254
99
 
255
100
  def start_keychain
256
- keychain = %x{/usr/bin/keychain -q --agents gpg --eval #{@build.gpg_key}}.chomp
101
+ keychain = %x{/usr/bin/keychain -q --agents gpg --eval #{Pkg::Config.gpg_key}}.chomp
257
102
  new_env = keychain.match(/(GPG_AGENT_INFO)=([^;]*)/)
258
103
  ENV[new_env[1]] = new_env[2]
259
104
  end
260
105
 
261
106
  def gpg_sign_file(file)
262
- gpg ||= find_tool('gpg')
107
+ gpg ||= Pkg::Util::Tool.find_tool('gpg')
263
108
 
264
109
  if gpg
265
110
  use_tty = "--no-tty --use-agent" if ENV['RPM_GPG_AGENT']
266
- sh "#{gpg} #{use_tty} --armor --detach-sign -u #{@build.gpg_key} #{file}"
111
+ sh "#{gpg} #{use_tty} --armor --detach-sign -u #{Pkg::Config.gpg_key} #{file}"
267
112
  else
268
113
  fail "No gpg available. Cannot sign #{file}."
269
114
  end
270
115
  end
271
116
 
272
117
  def mkdir_pr *args
273
- args.each do |arg|
274
- mkdir_p arg
275
- end
118
+ deprecate('mkdir_pr', 'FileUtils.mkdir_p')
119
+ FileUtils.mkdir_p args
276
120
  end
277
121
 
278
122
  def set_cow_envs(cow)
279
123
  elements = cow.split('-')
280
124
  if elements.size != 3
281
125
  fail "Expecting a cow name split on hyphens, e.g. 'base-squeeze-i386'"
282
- else
283
- dist = elements[1]
284
- arch = elements[2]
285
- if dist.nil? or arch.nil?
286
- fail "Couldn't get the arg and dist from cow name. Expecting something like 'base-dist-arch'"
287
- end
288
- arch = arch.split('.')[0] if arch.include?('.')
289
126
  end
290
- if @build.build_pe
291
- ENV['PE_VER'] = @build.pe_version
127
+ dist = elements[1]
128
+ arch = elements[2]
129
+ arch = arch.split('.')[0] if arch.include?('.')
130
+ if Pkg::Config.build_pe
131
+ ENV['PE_VER'] = Pkg::Config.pe_version
132
+ end
133
+ if Pkg::Config.deb_build_mirrors
134
+ ENV['BUILDMIRROR'] = Pkg::Config.deb_build_mirrors.map do |mirror|
135
+ mirror.gsub(/__DIST__/, dist)
136
+ end.join(' | ')
292
137
  end
293
138
  ENV['DIST'] = dist
294
139
  ENV['ARCH'] = arch
@@ -298,15 +143,17 @@ def set_cow_envs(cow)
298
143
  end
299
144
 
300
145
  def ln(target, name)
146
+ deprecate('ln', 'FileUtils.ln')
301
147
  FileUtils.ln(name, target, :force => true, :verbose => true)
302
148
  end
303
149
 
304
150
  def ln_sfT(src, dest)
151
+ deprecate('ln_sfT')
305
152
  sh "ln -sfT #{src} #{dest}"
306
153
  end
307
154
 
308
155
  def git_commit_file(file, message=nil)
309
- if has_tool('git') and File.exist?('.git')
156
+ if Pkg::Util::Tool.find_tool('git') and File.exist?('.git')
310
157
  message ||= "changes"
311
158
  puts "Commiting changes:"
312
159
  puts
@@ -317,12 +164,12 @@ def git_commit_file(file, message=nil)
317
164
  end
318
165
 
319
166
  def ship_gem(file)
320
- check_file("#{ENV['HOME']}/.gem/credentials")
167
+ Pkg::Util::File.file_exists?("#{ENV['HOME']}/.gem/credentials", :required => true)
321
168
  %x{gem push #{file}}
322
169
  end
323
170
 
324
171
  def ask_yes_or_no
325
- return boolean_value(ENV['ANSWER_OVERRIDE']) unless ENV['ANSWER_OVERRIDE'].nil?
172
+ return Pkg::Util.boolean_value(ENV['ANSWER_OVERRIDE']) unless ENV['ANSWER_OVERRIDE'].nil?
326
173
  answer = STDIN.gets.downcase.chomp
327
174
  return TRUE if answer =~ /^y$|^yes$/
328
175
  return FALSE if answer =~ /^n$|^no$/
@@ -353,13 +200,8 @@ def confirm_ship(files)
353
200
  ask_yes_or_no
354
201
  end
355
202
 
356
- def boolean_value(var)
357
- return TRUE if (var == TRUE || ( var.is_a?(String) && ( var.downcase == 'true' || var.downcase =~ /^y$|^yes$/ )))
358
- FALSE
359
- end
360
-
361
203
  def git_tag(version)
362
- sh "git tag -s -u #{@build.gpg_key} -m '#{version}' #{version}"
204
+ sh "git tag -s -u #{Pkg::Config.gpg_key} -m '#{version}' #{version}"
363
205
  $?.success or fail "Unable to tag repo at #{version}"
364
206
  end
365
207
 
@@ -368,14 +210,14 @@ def rand_string
368
210
  end
369
211
 
370
212
  def git_bundle(treeish, appendix=nil, output_dir=nil)
371
- temp = output_dir || get_temp
213
+ temp = output_dir || Pkg::Util::File.mktemp
372
214
  appendix ||= rand_string
373
- sh "git bundle create #{temp}/#{@build.project}-#{@build.version}-#{appendix} #{treeish} --tags"
215
+ sh "git bundle create #{temp}/#{Pkg::Config.project}-#{Pkg::Config.version}-#{appendix} #{treeish} --tags"
374
216
  cd temp do
375
- sh "tar -czf #{@build.project}-#{@build.version}-#{appendix}.tar.gz #{@build.project}-#{@build.version}-#{appendix}"
376
- rm_rf "#{@build.project}-#{@build.version}-#{appendix}"
217
+ sh "tar -czf #{Pkg::Config.project}-#{Pkg::Config.version}-#{appendix}.tar.gz #{Pkg::Config.project}-#{Pkg::Config.version}-#{appendix}"
218
+ rm_rf "#{Pkg::Config.project}-#{Pkg::Config.version}-#{appendix}"
377
219
  end
378
- "#{temp}/#{@build.project}-#{@build.version}-#{appendix}.tar.gz"
220
+ "#{temp}/#{Pkg::Config.project}-#{Pkg::Config.version}-#{appendix}.tar.gz"
379
221
  end
380
222
 
381
223
  # We take a tar argument for cases where `tar` isn't best, e.g. Solaris. We
@@ -389,46 +231,31 @@ def remote_bootstrap(host, treeish, tar_cmd=nil, tarball=nil)
389
231
  tarball_name = File.basename(tarball).gsub('.tar.gz','')
390
232
  rsync_to(tarball, host, '/tmp')
391
233
  appendix = rand_string
392
- sh "ssh -t #{host} '#{tar} -zxvf /tmp/#{tarball_name}.tar.gz -C /tmp/ ; git clone --recursive /tmp/#{tarball_name} /tmp/#{@build.project}-#{appendix} ; cd /tmp/#{@build.project}-#{appendix} ; rake package:bootstrap'"
393
- "/tmp/#{@build.project}-#{appendix}"
234
+ sh "ssh -t #{host} '#{tar} -zxvf /tmp/#{tarball_name}.tar.gz -C /tmp/ ; git clone --recursive /tmp/#{tarball_name} /tmp/#{Pkg::Config.project}-#{appendix} ; cd /tmp/#{Pkg::Config.project}-#{appendix} ; rake package:bootstrap'"
235
+ "/tmp/#{Pkg::Config.project}-#{appendix}"
394
236
  end
395
237
 
396
238
  # Given a BuildInstance object and a host, send its params to the host. Return
397
239
  # the remote path to the params.
398
240
  def remote_buildparams(host, build)
399
- params_file = build.params_to_yaml
241
+ params_file = build.config_to_yaml
400
242
  params_file_name = File.basename(params_file)
401
243
  params_dir = rand_string
402
244
  rsync_to(params_file, host, "/tmp/#{params_dir}/")
403
245
  "/tmp/#{params_dir}/#{params_file_name}"
404
246
  end
405
247
 
406
- def is_git_repo
407
- %x{git rev-parse --git-dir > /dev/null 2>&1}
408
- return $?.success?
409
- end
410
-
411
248
  def git_pull(remote, branch)
412
249
  sh "git pull #{remote} #{branch}"
413
250
  end
414
251
 
415
- def create_rpm_repo(dir)
416
- check_tool('createrepo')
417
- cd dir do
418
- sh "createrepo -d ."
419
- end
420
- end
421
-
422
252
  def update_rpm_repo(dir)
423
- check_tool('createrepo')
253
+ Pkg::Util::Tool.check_tool('createrepo')
424
254
  cd dir do
425
- sh "createrepo -d --update ."
255
+ sh "createrepo --checksum=sha --database --update ."
426
256
  end
427
257
  end
428
-
429
- def empty_dir?(dir)
430
- File.exist?(dir) and File.directory?(dir) and Dir["#{dir}/**/*"].empty?
431
- end
258
+ alias :create_rpm_repo :update_rpm_repo
432
259
 
433
260
  def hostname
434
261
  require 'socket'
@@ -465,82 +292,6 @@ def deprecate(old_cmd, new_cmd=nil)
465
292
  STDOUT.puts
466
293
  end
467
294
 
468
- # Determines if this package is a final package via the
469
- # selected version_strategy.
470
- # There are currently two supported version strategies.
471
- #
472
- # This method calls down to the version strategy indicated, defaulting to the
473
- # rc_final strategy. The methods themselves will return false if it is a final
474
- # release, so their return values are collected and then inverted before being
475
- # returned.
476
- def is_final?
477
- ret = nil
478
- case @build.version_strategy
479
- when "rc_final"
480
- ret = is_rc?
481
- when "odd_even"
482
- ret = is_odd?
483
- when nil
484
- ret = is_rc?
485
- end
486
- return (! ret)
487
- end
488
-
489
- # the rc_final strategy (default)
490
- # Assumes version strings in the formats:
491
- # final:
492
- # '0.7.0'
493
- # '0.7.0-63'
494
- # '0.7.0-63-dirty'
495
- # development:
496
- # '0.7.0rc1 (we don't actually use this format anymore, but once did)
497
- # '0.7.0-rc1'
498
- # '0.7.0-rc1-63'
499
- # '0.7.0-rc1-63-dirty'
500
- def is_rc?
501
- return TRUE if get_dash_version =~ /^\d+\.\d+\.\d+-*rc\d+/
502
- return FALSE
503
- end
504
-
505
- # the odd_even strategy (mcollective)
506
- # final:
507
- # '0.8.0'
508
- # '1.8.0-63'
509
- # '0.8.1-63-dirty'
510
- # development:
511
- # '0.7.0'
512
- # '1.7.0-63'
513
- # '0.7.1-63-dirty'
514
- def is_odd?
515
- return TRUE if get_dash_version.match(/^\d+\.(\d+)\.\d+/)[1].to_i.odd?
516
- return FALSE
517
- end
518
-
519
- # Utility method to return the dist method if this is a redhat box. We use this
520
- # in rpm packaging to define a dist macro, and we use it in the pl:fetch task
521
- # to disable ssl checking for redhat 5 because it has a certs bundle so old by
522
- # default that it's useless for our purposes.
523
- def el_version
524
- if File.exists?('/etc/fedora-release')
525
- nil
526
- elsif File.exists?('/etc/redhat-release')
527
- return %x{rpm -q --qf \"%{VERSION}\" $(rpm -q --whatprovides /etc/redhat-release )}
528
- end
529
- end
530
-
531
- # Given the path to a yaml file, load the yaml file into an object and return
532
- # the object.
533
- def data_from_yaml(file)
534
- file = File.expand_path(file)
535
- begin
536
- input_data = YAML.load_file(file) || {}
537
- rescue => e
538
- STDERR.puts "There was an error loading data from #{file}."
539
- fail e.backtrace.join("\n")
540
- end
541
- input_data
542
- end
543
-
544
295
  # This is fairly absurd. We're implementing curl by shelling out. What do I
545
296
  # wish we were doing? Using a sweet ruby wrapper around curl, such as Curb or
546
297
  # Curb-fu. However, because we're using clean build systems and trying to
@@ -555,7 +306,7 @@ end
555
306
  # 1) String - the URL to post to
556
307
  # 2) Array - Ordered array of name=VALUE curl form parameters
557
308
  def curl_form_data(uri, form_data=[], options={})
558
- curl = find_tool("curl") or fail "Couldn't find curl. Curl is required for posting jenkins to trigger a build. Please install curl and try again."
309
+ curl = Pkg::Util::Tool.find_tool("curl") or fail "Couldn't find curl. Curl is required for posting jenkins to trigger a build. Please install curl and try again."
559
310
  #
560
311
  # Begin constructing the post string.
561
312
  # First, assemble the form_data arguments
@@ -585,10 +336,10 @@ end
585
336
  # configuration file.
586
337
  # Returns the URL to the job
587
338
  def create_jenkins_job(name, xml_file)
588
- create_url = "http://#{@build.jenkins_build_host}/createItem?name=#{name}"
339
+ create_url = "http://#{Pkg::Config.jenkins_build_host}/createItem?name=#{name}"
589
340
  form_args = ["-H", '"Content-Type: application/xml"', "--data-binary", "@#{xml_file}"]
590
341
  curl_form_data(create_url, form_args)
591
- "http://#{@build.jenkins_build_host}/job/#{name}"
342
+ "http://#{Pkg::Config.jenkins_build_host}/job/#{name}"
592
343
  end
593
344
 
594
345
  # Use the curl to check of a named job is defined on the jenkins server. We
@@ -596,19 +347,11 @@ end
596
347
  # the job url and passing --head because jenkins will mistakenly return 200 OK
597
348
  # if you issue multiple very fast requests just requesting the header.
598
349
  def jenkins_job_exists?(name)
599
- job_url = "http://#{@build.jenkins_build_host}/job/#{name}/config.xml"
350
+ job_url = "http://#{Pkg::Config.jenkins_build_host}/job/#{name}/config.xml"
600
351
  form_args = ["--silent", "--fail"]
601
352
  curl_form_data(job_url, form_args, :quiet => true)
602
353
  end
603
354
 
604
- def require_library_or_fail(library)
605
- begin
606
- require library
607
- rescue LoadError
608
- fail "Could not load #{library}. #{library} is required by the packaging repo for this task"
609
- end
610
- end
611
-
612
355
  # Use the provided URL string to print important information with
613
356
  # ASCII emphasis
614
357
  def print_url_info(url_string)