simp-rake-helpers 3.0.1 → 3.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: efe677e7e859802df732b13dd3835d71b6c05dd0
4
- data.tar.gz: 488113e4842dea057ae1d719625505674c6474bc
3
+ metadata.gz: 01573252cbc7924049d14097e74487ef074840b4
4
+ data.tar.gz: 12952176495abd2d8a263e1bdd77db70bafa23b9
5
5
  SHA512:
6
- metadata.gz: 42c8e4e9b38aff156a4ff5aa493f03e4f5a1a1192fc10839dc5bc55b9469b526a278df8160fd3e9f1692c0a060923201d49346ad1bcb060ec6e26fde013ecb2b
7
- data.tar.gz: 0ca86b3f3c265d513dde50e16ad09543a91b6a544aa219d0acc3162403050ff3cfad28c5ef4a5e62d961b7aacf063d3d015c9e17a50c7aabd42d6568d02efb8c
6
+ metadata.gz: 897dea358f2b4348d5282a9cd6a270e8e03ce84b13276785539a9902f889960b7b76a20af49537cf6e4c31b3e167f072c8def1bd2e7affa7e1e38424d6919099
7
+ data.tar.gz: 15bb0923cfa63e241a8f3cbe3b14fc8a2ef777f2b2bd34acfa6b3177cb44f06c0222c3ac59541fec605912bc98073460204407e2270a9665c96371c8001b45aa
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### 3.0.2 / 2016-11-02
2
+ * Added a lot more parallel capability
3
+ * Added a 'pkg:single' task for building single RPMs from the top level
4
+ * Added the ability to build puppet module RPM packages without requiring a fork
5
+
1
6
  ### 3.0.1 / 2016-10-28
2
7
  * Updated to provide backwards compatibility for SIMP 4 and 5
3
8
 
@@ -186,7 +186,7 @@ module Simp::Rake::Build
186
186
  else
187
187
  puts
188
188
  puts '='*80
189
- puts "#### Running tar:build in all repos"
189
+ puts "#### Running tar:build"
190
190
  puts '='*80
191
191
  $simp_tarballs = {}
192
192
  Rake::Task['tar:build'].invoke(target_data['mock'],key_name,do_docs)
@@ -38,9 +38,9 @@ module Simp::Rake::Build
38
38
  args.with_defaults(:verbose => 'false')
39
39
  args.with_defaults(:method => 'tracking')
40
40
 
41
- verbose = args.verbose == 'false' ? false : true
41
+ verbose = args[:verbose] == 'false' ? false : true
42
42
 
43
- load_puppetfile(args.method)
43
+ load_puppetfile(args[:method])
44
44
 
45
45
  # Grab all currently tracked submodules.
46
46
  failed_mods = []
@@ -69,7 +69,7 @@ module Simp::Rake::Build
69
69
  # Clean env will give bundler the environment present before
70
70
  # Bundler is activated.
71
71
  ::Bundler.with_clean_env do
72
- out = %x(bundle #{args.action} 2>&1)
72
+ out = %x(bundle #{args[:action]} 2>&1)
73
73
  status = $?.success?
74
74
  puts out if verbose
75
75
  failed_mod_lock.synchronize do
@@ -80,7 +80,7 @@ module Simp::Rake::Build
80
80
  end
81
81
 
82
82
  failed_mods.compact!
83
- fail(%(The following modules failed bundle #{args.action}:\n * #{failed_mods.sort.join("\n *")})) unless failed_mods.empty?
83
+ fail(%(The following modules failed bundle #{args[:action]}:\n * #{failed_mods.sort.join("\n *")})) unless failed_mods.empty?
84
84
  end
85
85
 
86
86
  namespace :yum do
@@ -114,19 +114,19 @@ module Simp::Rake::Build
114
114
  # Return the target directory
115
115
  # Expects one argument wich is the 'arguments' hash to one of the tasks.
116
116
  def get_target_dir(args)
117
- fail("Error: You must specify 'os'") unless args.os
118
- fail("Error: You must specify 'os_version'") unless args.os_version
119
- fail("Error: You must specify both major and minor version for the OS") unless args.os_version =~ /^.+\..+$/
120
- fail("Error: You must specify 'simp_version'") unless args.simp_version
121
- fail("Error: You must specify 'arch'") unless args.arch
117
+ fail("Error: You must specify 'os'") unless args[:os]
118
+ fail("Error: You must specify 'os_version'") unless args[:os_version]
119
+ fail("Error: You must specify both major and minor version for the OS") unless args[:os_version] =~ /^.+\..+$/
120
+ fail("Error: You must specify 'simp_version'") unless args[:simp_version]
121
+ fail("Error: You must specify 'arch'") unless args[:arch]
122
122
 
123
123
  # Yes, this is a kluge but the amount of variable passing that would need
124
124
  # to be done to support this is silly.
125
- @build_arch = args.arch
125
+ @build_arch = args[:arch]
126
126
 
127
127
  return File.join(
128
128
  @base_dir,
129
- "SIMP#{args.simp_version}_#{args.os}#{args.os_version}_#{args.arch}"
129
+ "SIMP#{args[:simp_version]}_#{args[:os]}#{args[:os_version]}_#{args[:arch]}"
130
130
  )
131
131
  end
132
132
 
@@ -692,19 +692,19 @@ module Simp::Rake::Build
692
692
  args.with_defaults(:simp_version => @simp_version.split('-').first)
693
693
  args.with_defaults(:arch => @build_arch)
694
694
 
695
- fail("Error: You must specify 'pkg'") unless args.pkg
695
+ fail("Error: You must specify 'pkg'") unless args[:pkg]
696
696
 
697
697
  pkgs = []
698
698
  # Handle the output of build:yum_diff
699
- if File.readable?(args.pkg)
700
- File.read(args.pkg).each_line do |line|
699
+ if File.readable?(args[:pkg])
700
+ File.read(args[:pkg]).each_line do |line|
701
701
  if line =~ /\s+~\s+(.*)/
702
702
  pkgs << $1.split(/-\d+/).first
703
703
  end
704
704
  end
705
705
  else
706
706
  # Handle the default case
707
- pkgs = [args.pkg]
707
+ pkgs = [args[:pkg]]
708
708
  end
709
709
 
710
710
  Dir.chdir(get_target_dir(args)) do
@@ -172,6 +172,7 @@ module Simp::Rake::Build
172
172
 
173
173
  def initialize( base_dir )
174
174
  @base_dir = base_dir
175
+ @verbose = ENV.fetch('SIMP_PKG_verbose','no') == 'yes'
175
176
  define_tasks
176
177
  end
177
178
 
@@ -192,37 +193,66 @@ module Simp::Rake::Build
192
193
 
193
194
  r10k_helper = R10KHelper.new("Puppetfile.#{args[:method]}")
194
195
 
195
- r10k_helper.each_module do |mod|
196
- unless File.directory?(mod[:path])
197
- FileUtils.mkdir_p(mod[:path])
198
- end
196
+ r10k_issues = Parallel.map(
197
+ Array(r10k_helper.modules),
198
+ :in_processes => get_cpu_limit,
199
+ :progress => 'Submodule Checkout'
200
+ ) do |mod|
201
+ issues = []
199
202
 
200
- # Only for known modules...
201
- unless mod[:status] == :unknown
202
- # Since r10k is destructive, we're enumerating all valid states
203
- # here
204
- if [
205
- :absent,
206
- :mismatched,
207
- :outdated,
208
- :insync,
209
- :dirty
210
- ].include?(mod[:r10k_module].status)
211
- unless mod[:r10k_cache].synced?
212
- mod[:r10k_cache].sync
213
- end
203
+ Dir.chdir(@base_dir) do
204
+ unless File.directory?(mod[:path])
205
+ FileUtils.mkdir_p(mod[:path])
206
+ end
214
207
 
215
- if mod[:status] == :known
216
- mod[:r10k_module].sync
208
+ # Only for known modules...
209
+ unless mod[:status] == :unknown
210
+ # Since r10k is destructive, we're enumerating all valid states
211
+ if [
212
+ :absent,
213
+ :mismatched,
214
+ :outdated,
215
+ :insync,
216
+ :dirty
217
+ ].include?(mod[:r10k_module].status)
218
+ unless mod[:r10k_cache].synced?
219
+ mod[:r10k_cache].sync
220
+ end
221
+
222
+ if mod[:status] == :known
223
+ mod[:r10k_module].sync
224
+ else
225
+ # If we get here, the module was dirty and should be skipped
226
+ issues << "#{mod[:name]}: Skipped - #{mod[:status]}"
227
+ next
228
+ end
217
229
  else
218
- # If we get here, the module was dirty and should be skipped
219
- puts "#{mod[:name]}: Skipping - #{mod[:status]}"
220
- next
230
+ issues << "#{mod[:name]}: Skipped - Unknown status type #{mod[:r10k_module].status}"
221
231
  end
222
- else
223
- puts "#{mod[:name]}: Skipping - Unknown status type #{mod[:r10k_module].status}"
224
232
  end
225
233
  end
234
+
235
+ issues
236
+ end
237
+
238
+ r10k_issues.flatten!
239
+
240
+ unless r10k_issues.empty?
241
+ $stderr.puts('='*80)
242
+
243
+ unless @verbose
244
+ $stderr.puts('Warning: Some repositories were skipped!')
245
+ $stderr.puts(' * If this is a fresh build, this could be an issue')
246
+ $stderr.puts(' * This is expected if re-running a build')
247
+ $stderr.puts(' * Run with SIMP_PKG_verbose=yes for full details')
248
+ else
249
+ $stderr.puts("R10k Checkout Issues:")
250
+ r10k_issues.each do |issue|
251
+ $stderr.puts(" * #{issue}")
252
+ end
253
+ end
254
+
255
+ $stderr.puts('='*80)
226
256
  end
227
257
  end
228
258
 
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/rake -T
2
2
 
3
+ require 'simp/rake/pkg'
3
4
  require 'simp/rake/build/constants'
4
5
 
5
6
  module Simp; end
@@ -65,16 +66,56 @@ module Simp::Rake::Build
65
66
  chown_everything = ENV.fetch( 'SIMP_RAKE_CHOWN_EVERYTHING', 'Y' ).chomp.index( %r{^(1|Y|true|yes)$}i ) || false
66
67
 
67
68
  verbose(true) do
68
- next if not chown_everything
69
- # Set the permissions properly for mock to dig through your source
70
- # directories.
71
- chown_R(nil,'mock',@base_dir)
72
- # Ruby >= 1.9.3 chmod_R('g+rXs',@base_dir)
69
+ next unless chown_everything
70
+
71
+ dirs_to_mod = []
72
+ files_to_mod = []
73
+
73
74
  Find.find(@base_dir) do |path|
75
+ Find.prune if File.symlink?(path)
76
+ Find.prune if (File.basename(path) == '.git')
77
+ Find.prune if (File.basename(path) =~ /^\..*cache/)
78
+
79
+ safe_path = Shellwords.escape(path)
80
+
81
+ mock_gid = Etc.getgrnam('mock').gid
82
+
83
+ file_stat = File.stat(path)
84
+
85
+ file_mode = file_stat.mode.to_s(2)[-12..-1].scan(/.{3}/)
86
+ file_group_perms = file_mode[-2]
87
+ file_group_read = (file_group_perms[0] == '1')
88
+ file_group_execute = (file_group_perms[2] == '1')
89
+ file_sgid = (file_mode[-4][1] == '1')
90
+
74
91
  if File.directory?(path)
75
- %x{chmod g+rXs #{Shellwords.escape(path)}}
92
+ if (mock_gid != file_stat.gid) ||
93
+ !file_group_read ||!file_group_execute || !file_sgid
94
+ dirs_to_mod << safe_path
95
+ end
96
+ else
97
+ if (mock_gid != file_stat.gid) || !file_group_read
98
+ files_to_mod << safe_path
99
+ end
76
100
  end
77
101
  end
102
+
103
+ # Set the permissions properly for mock to dig through your source
104
+ Parallel.map(
105
+ dirs_to_mod,
106
+ :in_processes => get_cpu_limit,
107
+ :progress => 'Set "mock" dir perms'
108
+ ) do |dir|
109
+ %x{chgrp 'mock' #{dir} && chmod g+rXs #{dir}}
110
+ end
111
+
112
+ Parallel.map(
113
+ files_to_mod,
114
+ :in_processes => get_cpu_limit,
115
+ :progress => 'Set "mock" file perms'
116
+ ) do |file|
117
+ %x{chgrp 'mock' #{file} && chmod g+r #{file}}
118
+ end
78
119
  end
79
120
  end
80
121
 
@@ -93,7 +134,7 @@ module Simp::Rake::Build
93
134
  Dir.chdir(dir) do
94
135
  begin
95
136
  rake_flags = Rake.application.options.trace ? '--trace' : ''
96
- %x{rake clean[#{args.chroot}] #{rake_flags}}
137
+ %x{rake clean[#{args[:chroot]}] #{rake_flags}}
97
138
  clean_failures_lock.synchronize do
98
139
  clean_failures << dir unless $?.success?
99
140
  end
@@ -111,7 +152,7 @@ module Simp::Rake::Build
111
152
  fail(%(Error: The following directories had failures in #{task.name}:\n * #{clean_failures.join("\n * ")}))
112
153
  end
113
154
 
114
- %x{mock -r #{args.chroot} --scrub=all} if args.chroot
155
+ %x{mock -r #{args[:chroot]} --scrub=all} if args[:chroot]
115
156
  end
116
157
 
117
158
  task :clobber,[:chroot] => [:prep] do |t,args|
@@ -124,7 +165,7 @@ module Simp::Rake::Build
124
165
  ) do |dir|
125
166
  Dir.chdir(dir) do
126
167
  rake_flags = Rake.application.options.trace ? '--trace' : ''
127
- sh %{rake clobber[#{args.chroot}] #{rake_flags}}
168
+ sh %{rake clobber[#{args[:chroot]}] #{rake_flags}}
128
169
  end
129
170
  end
130
171
  end
@@ -147,7 +188,7 @@ module Simp::Rake::Build
147
188
 
148
189
  Dir.chdir("#{@build_dir}/build_keys") {
149
190
  if (args.key != 'dev')
150
- fail("Could not find GPG keydir '#{args.key}' in '#{Dir.pwd}'") unless File.directory?(args.key)
191
+ fail("Could not find GPG keydir '#{args[:key]}' in '#{Dir.pwd}'") unless File.directory?(args[:key])
151
192
  end
152
193
 
153
194
  mkdir('dev') unless File.directory?('dev')
@@ -234,7 +275,7 @@ module Simp::Rake::Build
234
275
  gpg_agent_socket = gpg_agent_info[0]
235
276
  gpg_agent_pid = gpg_agent_info[1].strip.to_i
236
277
 
237
- if not File.exist? (%(#{Dir.pwd}/#{File.basename(gpg_agent_socket)})) then
278
+ unless File.exist?(%(#{Dir.pwd}/#{File.basename(gpg_agent_socket)}))
238
279
  ln_s(gpg_agent_socket,%(#{Dir.pwd}/#{File.basename(gpg_agent_socket)}))
239
280
  end
240
281
  end
@@ -257,7 +298,7 @@ module Simp::Rake::Build
257
298
  end
258
299
  }
259
300
 
260
- Dir.chdir(args.key) {
301
+ Dir.chdir(args[:key]) {
261
302
  rpm_build_keys = Dir.glob('RPM-GPG-KEY-*')
262
303
  target_dir = '../../GPGKEYS'
263
304
 
@@ -293,21 +334,21 @@ module Simp::Rake::Build
293
334
  _verbose = ENV.fetch('SIMP_PKG_verbose','no') == 'yes'
294
335
 
295
336
  args.with_defaults(:key => 'dev')
296
- args.with_defaults(:docs => true)
337
+ args.with_defaults(:docs => 'true')
297
338
 
298
339
  output_dir = @pkg_dirs[:simp]
299
340
 
300
341
  check_dvd_env
301
342
 
302
- Rake::Task['pkg:simp_cli'].invoke(args.chroot)
303
- Rake::Task['pkg:aux'].invoke(args.chroot)
343
+ Rake::Task['pkg:simp_cli'].invoke(args[:chroot])
344
+ Rake::Task['pkg:aux'].invoke(args[:chroot])
304
345
  if "#{args.docs}" == 'true'
305
- Rake::Task['pkg:doc'].invoke(args.chroot)
346
+ Rake::Task['pkg:doc'].invoke(args[:chroot])
306
347
  end
307
- Rake::Task['pkg:modules'].invoke(args.chroot)
348
+ Rake::Task['pkg:modules'].invoke(args[:chroot])
308
349
 
309
350
  # The main SIMP RPM must be built last!
310
- Rake::Task['pkg:simp'].invoke(args.chroot,args.snapshot_release)
351
+ Rake::Task['pkg:simp'].invoke(args[:chroot],args[:snapshot_release])
311
352
 
312
353
  # Prepare for the build!
313
354
  rm_rf(output_dir, :verbose => _verbose)
@@ -349,13 +390,12 @@ module Simp::Rake::Build
349
390
  end
350
391
  end
351
392
 
352
- Rake::Task['pkg:signrpms'].invoke(args.key)
393
+ Rake::Task['pkg:signrpms'].invoke(args[:key])
353
394
  end
354
395
 
355
396
  desc <<-EOM
356
397
  Build the Puppet module RPMs.
357
398
 
358
- This also builds the simp-mit RPM due to its location.
359
399
  Building this environment requires a working Mock setup (http://fedoraproject.org/wiki/Projects/Mock)
360
400
 
361
401
  * :chroot - The Mock chroot configuration to use. See the '--root' option in mock(1).
@@ -365,7 +405,47 @@ module Simp::Rake::Build
365
405
  - Set `SIMP_PKG_verbose=yes` to report file operations as they happen.
366
406
  EOM
367
407
  task :modules,[:chroot,:method] => [:prep,:mock_prep] do |t,args|
368
- build(args.chroot,@build_dirs[:modules],t)
408
+ build(args[:chroot],@build_dirs[:modules],t)
409
+ end
410
+
411
+ desc <<-EOM
412
+ Build a single Puppet Module RPM.
413
+
414
+ Building this environment requires a working Mock setup (http://fedoraproject.org/wiki/Projects/Mock)
415
+
416
+ * :name - The path, or name, of the module to build. If a name is
417
+ given, the Puppetfile.<method> will be used to find the
418
+ module.
419
+ Note: This is the *short* name. So, to build
420
+ puppetlabs-stdlib, you would just enter 'stdlib'
421
+ * :chroot - The Mock chroot configuration to use. See the '--root' option in mock(1).
422
+ * :method - The Puppetfile from which the repository information should be read. Defaults to 'tracking'
423
+
424
+ ENV vars:
425
+ - Set `SIMP_PKG_verbose=yes` to report file operations as they happen.
426
+ EOM
427
+ task :single,[:name,:chroot,:method] => [:prep, :mock_prep] do |t,args|
428
+ fail("You must pass :name to '#{t.name}'") unless args[:name]
429
+
430
+ mod_path = File.absolute_path(args[:name])
431
+
432
+ if args[:name].include?('/')
433
+ fail("'#{args[:name]}' does not exist!") unless File.directory?(mod_path)
434
+ else
435
+ load_puppetfile(args[:method])
436
+ local_module = puppetfile.modules.select{|m| m[:name] == args[:name]}.first
437
+
438
+ unless local_module
439
+ fail("'#{args[:name]}' was not found in the Puppetfile")
440
+ end
441
+
442
+ mod_path = local_module[:path]
443
+ end
444
+
445
+ ENV['SIMP_PKG_rand_name'] = 'yes'
446
+ build(args[:chroot], Array(mod_path), t)
447
+
448
+ puts("Your packages can be found in '#{mod_path}/dist'")
369
449
  end
370
450
 
371
451
  desc <<-EOM
@@ -377,7 +457,7 @@ module Simp::Rake::Build
377
457
  - Set `SIMP_PKG_verbose=yes` to report file operations as they happen.
378
458
  EOM
379
459
  task :simp_cli,[:chroot] => [:prep,:mock_prep] do |t,args|
380
- build(args.chroot,@build_dirs[:simp_cli],t)
460
+ build(args[:chroot], @build_dirs[:simp_cli], t)
381
461
  end
382
462
 
383
463
  desc <<-EOM
@@ -390,7 +470,7 @@ module Simp::Rake::Build
390
470
  * :chroot - The Mock chroot configuration to use. See the '--root' option in mock(1).
391
471
  EOM
392
472
  task :aux,[:chroot] => [:prep,:mock_prep] do |t,args|
393
- build(args.chroot,@build_dirs[:aux],t)
473
+ build(args[:chroot],@build_dirs[:aux],t)
394
474
  end
395
475
 
396
476
  desc <<-EOM
@@ -403,7 +483,7 @@ module Simp::Rake::Build
403
483
  - Set `SIMP_PKG_verbose=yes` to report file operations as they happen.
404
484
  EOM
405
485
  task :doc,[:chroot] => [:prep,:mock_prep] do |t,args|
406
- build(args.chroot,@build_dirs[:doc],t)
486
+ build(args[:chroot],@build_dirs[:doc],t)
407
487
  end
408
488
 
409
489
  desc <<-EOM
@@ -417,7 +497,7 @@ module Simp::Rake::Build
417
497
  - Set `SIMP_PKG_verbose=yes` to report file operations as they happen.
418
498
  EOM
419
499
  task :simp,[:chroot,:snapshot_release] => [:prep,:mock_prep] do |t,args|
420
- build(args.chroot,@build_dirs[:simp],t,false,args.snapshot_release)
500
+ build(args[:chroot],@build_dirs[:simp],t,false,args[:snapshot_release])
421
501
  end
422
502
 
423
503
  desc "Sign the RPMs."
@@ -426,11 +506,11 @@ module Simp::Rake::Build
426
506
 
427
507
  args.with_defaults(:key => 'dev')
428
508
  args.with_defaults(:rpm_dir => "#{@build_dir}/SIMP/*RPMS")
429
- args.with_default(:force => false)
509
+ args.with_default(:force => 'false')
430
510
 
431
- force = (args.force.to_s == 'false' ? false : true)
511
+ force = (args[:force].to_s == 'false' ? false : true)
432
512
 
433
- rpm_dirs = Dir.glob(args.rpm_dir)
513
+ rpm_dirs = Dir.glob(args[:rpm_dir])
434
514
  to_sign = []
435
515
 
436
516
  rpm_dirs.each do |rpm_dir|
@@ -447,7 +527,7 @@ module Simp::Rake::Build
447
527
  ) do |rpm|
448
528
  rpminfo = %x{rpm -qip #{rpm} 2>/dev/null}.split("\n")
449
529
  if (force || !rpminfo.grep(/Signature\s+:\s+\(none\)/).empty?)
450
- Simp::RPM.signrpm(rpm,"#{@build_dir}/build_keys/#{args.key}")
530
+ Simp::RPM.signrpm(rpm,"#{@build_dir}/build_keys/#{args[:key]}")
451
531
  end
452
532
  end
453
533
  end
@@ -464,9 +544,9 @@ module Simp::Rake::Build
464
544
  args.with_defaults(:rpm_dir => @pkg_dirs[:ext])
465
545
  args.with_defaults(:key_dir => "#{@build_dir}/GPGKEYS")
466
546
 
467
- rpm_dirs = Dir.glob(args.rpm_dir)
547
+ rpm_dirs = Dir.glob(args[:rpm_dir])
468
548
 
469
- fail("Could not find files at #{args.rpm_dir}!") if rpm_dirs.empty?
549
+ fail("Could not find files at #{args[:rpm_dir]}!") if rpm_dirs.empty?
470
550
 
471
551
  temp_gpg_dir = Dir.mktmpdir
472
552
 
@@ -475,7 +555,7 @@ module Simp::Rake::Build
475
555
  sh %{#{rpm_cmd} --initdb}
476
556
 
477
557
  # Only import thngs that look like GPG keys...
478
- Dir.glob("#{args.key_dir}/*").each do |key|
558
+ Dir.glob("#{args[:key_dir]}/*").each do |key|
479
559
  next if File.directory?(key) or not File.readable?(key)
480
560
 
481
561
  File.read(key).each_line do |line|
@@ -529,7 +609,7 @@ module Simp::Rake::Build
529
609
  task :repoclosure,[:target_dir,:aux_dir] => [:prep] do |t,args|
530
610
  default_target = @pkg_dirs[:simp]
531
611
  args.with_defaults(:target_dir => default_target)
532
- if args.target_dir == default_target
612
+ if args[:target_dir] == default_target
533
613
  args.with_defaults(:aux_dir => @pkg_dirs[:ext])
534
614
  else
535
615
  args.with_defaults(:aux_dir => '')
@@ -564,7 +644,7 @@ gpgcheck=0
564
644
  protect=1
565
645
  EOF
566
646
 
567
- fail("#{args.target_dir} does not exist!") unless File.directory?(args.target_dir)
647
+ fail("#{args[:target_dir]} does not exist!") unless File.directory?(args[:target_dir])
568
648
 
569
649
  begin
570
650
  temp_pkg_dir = Dir.mktmpdir
@@ -573,7 +653,7 @@ protect=1
573
653
  mkdir_p("#{temp_pkg_dir}/repos/lookaside")
574
654
  mkdir_p("#{temp_pkg_dir}/repodata")
575
655
 
576
- Dir.glob(args.target_dir).each do |base_dir|
656
+ Dir.glob(args[:target_dir]).each do |base_dir|
577
657
  Find.find(base_dir) do |path|
578
658
  if (path =~ /.*\.rpm$/) and (path !~ /.*.src\.rpm$/)
579
659
  sym_path = "#{temp_pkg_dir}/repos/base/#{File.basename(path)}"
@@ -582,7 +662,7 @@ protect=1
582
662
  end
583
663
  end
584
664
 
585
- Dir.glob(args.aux_dir).each do |aux_dir|
665
+ Dir.glob(args[:aux_dir]).each do |aux_dir|
586
666
  Find.find(aux_dir) do |path|
587
667
  if (path =~ /.*\.rpm$/) and (path !~ /.*.src\.rpm$/)
588
668
  sym_path = "#{temp_pkg_dir}/repos/lookaside/#{File.basename(path)}"
@@ -648,11 +728,11 @@ protect=1
648
728
  validate_in_mock_group?
649
729
  _verbose = ENV.fetch('SIMP_PKG_verbose','no') == 'yes'
650
730
 
651
- mock_pre_check(chroot)
652
-
653
731
  # Default package metadata for reference
654
732
  default_metadata = YAML.load(File.read("#{@src_dir}/build/package_metadata_defaults.yaml"))
655
733
 
734
+ reenable_lock = Mutex.new
735
+
656
736
  metadata = Parallel.map(
657
737
  # Allow for shell globs
658
738
  Array(dirs),
@@ -664,39 +744,66 @@ protect=1
664
744
  fail("Could not find directory #{dir}") unless Dir.exist?(dir)
665
745
 
666
746
  Dir.chdir(dir) do
667
- if File.exist?('Rakefile')
747
+ built_rpm = false
748
+ unique_build = (get_cpu_limit != 1).to_s
749
+
750
+ if _verbose
751
+ $stderr.puts("Running 'rake pkg:rpm' on #{File.basename(dir)}")
752
+ end
753
+
754
+ # We're building a module, override anything down there
755
+ if File.exist?('metadata.json')
756
+ unique_namespace = (0...24).map{ (65 + rand(26)).chr }.join.downcase
757
+
758
+ Simp::Rake::Pkg.new(Dir.pwd, nil, unique_namespace, @simp_version)
668
759
 
669
- unique_build = (get_cpu_limit != 1)
760
+ Rake::Task["#{unique_namespace}:pkg:rpm"].invoke(chroot, unique_build, snapshot_release)
761
+
762
+ built_rpm = true
763
+
764
+ # We're building one of the extra assets and should honor its Rakefile
765
+ elsif File.exist?('Rakefile')
670
766
 
671
767
  rake_flags = Rake.application.options.trace ? '--trace' : ''
672
768
 
673
- cmd = %{SIMP_BUILD_version=#{@simp_version} rake pkg:rpm[#{chroot},unique_build,#{snapshot_release}] #{rake_flags} 2>&1}
674
- begin
675
- if _verbose
676
- $stderr.puts("Running 'rake pkg:rpm'")
677
- end
769
+ cmd = %{SIMP_BUILD_version=#{@simp_version} rake pkg:rpm[#{chroot},#{unique_build},#{snapshot_release}] #{rake_flags} 2>&1}
678
770
 
771
+ build_success = true
772
+ begin
679
773
  ::Bundler.with_clean_env do
680
774
  %x{#{cmd}}
775
+ build_success = $?.success?
681
776
  end
777
+
778
+ built_rpm = true
682
779
  rescue
780
+ build_success = false
781
+ end
782
+
783
+ unless build_success
683
784
  if _verbose
684
785
  $stderr.puts("First 'rake pkg:rpm' attempt failed, running bundle and trying again.")
685
786
  end
686
787
 
687
788
  ::Bundler.with_clean_env do
688
- %x{bundle install}
789
+ %x{bundle install --with development}
689
790
  %x{#{cmd}}
690
791
  end
691
792
  end
793
+ else
794
+ puts "Warning: '#{dir}' could not be built via Rake"
795
+ end
692
796
 
797
+ if built_rpm
693
798
  tarballs = Dir.glob('dist/*.tar.gz')
694
799
  srpms = Dir.glob('dist/*.src.rpm')
695
800
  rpms = (Dir.glob('dist/*.rpm') - srpms)
696
801
 
697
802
  # Not all items generate tarballs
698
803
  tarballs.each do |pkg|
699
- raise("Empty Tarball '#{pkg}' generated for #{dir}") if (File.stat(pkg).size == 0)
804
+ if (File.stat(pkg).size == 0)
805
+ raise("Empty Tarball '#{pkg}' generated for #{dir}")
806
+ end
700
807
  end
701
808
  raise("No SRPMs generated for #{dir}") if srpms.empty?
702
809
  raise("No RPMs generated for #{dir}") if rpms.empty?
@@ -713,8 +820,10 @@ protect=1
713
820
 
714
821
  result << metadata
715
822
  end
716
- else
717
- puts "Warning: Could not find Rakefile in '#{dir}'"
823
+ end
824
+
825
+ if _verbose
826
+ $stderr.puts("Finshed 'rake pkg:rpm' on #{File.basename(dir)}")
718
827
  end
719
828
  end
720
829
 
@@ -763,51 +872,9 @@ protect=1
763
872
  # Return an Array of all puppet module directories
764
873
  def get_module_dirs(method='tracking')
765
874
  load_puppetfile(method)
766
- module_paths.select{|x| File.basename(File.dirname(x)) == 'modules'}
767
- end
768
-
769
- # Get a list of all of the mock configs available on the system.
770
- def get_mock_configs
771
- Dir.glob('/etc/mock/*.cfg').sort.map{ |x| x = File.basename(x,'.cfg')}
772
- end
773
-
774
- # Run some pre-checks to make sure that mock will work properly.
775
- # Pass init=false if you do not want the function to initialize.
776
- #
777
- # Returns 'true' if the space is already initialized.
778
- # FIXME: unique_name doesn't work
779
- # FIXME: unique_name is never called
780
- # FIXME: which is fortunate, because PKGNAME is never defined
781
- def mock_pre_check(chroot,unique_name=false,init=true)
782
- which('mock') || raise(Exception, 'Could not find mock on your system, exiting')
783
-
784
- mock_configs = get_mock_configs
785
-
786
- if not chroot
787
- fail("Error: No mock chroot provided. Your choices are:\n#{mock_configs.join("\n ")}"
788
- )
789
- end
790
- if not mock_configs.include?(chroot)
791
- fail("Error: Invalid mock chroot provided. Your choices are:\n#{mock_configs.join("\n ")}"
792
- )
793
- end
794
-
795
- # Allow for building all modules in parallel.
796
- @mock = "#{@mock} --uniqueext=#{PKGNAME}" if unique_name
797
-
798
- # A simple test to see if the chroot is initialized
799
- %x{#{@mock} -q --root #{chroot} --chroot "test -d /tmp" --quiet &> /dev/null}
800
- initialized = $?.success?
801
-
802
- if init and not initialized
803
- cmd = %{#{@mock} --root #{chroot} --init}
804
- sh cmd
805
- end
806
-
807
- initialized
875
+ module_paths.select{|x| File.basename(File.dirname(x)) == 'modules'}.sort
808
876
  end
809
877
  end
810
878
  end
811
879
  end
812
880
  end
813
-