simp-rake-helpers 5.12.3 → 5.12.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33beb8e656840401f0fb3a07f7aee982fe3931d53b2e233f2e0024398fd03d6c
4
- data.tar.gz: 81111ce62e4e8b3ca03a478d765e3944ee8b297af7b2ee1ef5e182e8bacf36f3
3
+ metadata.gz: 97111c5cebe9473b33a3ea7950af3cb1b26a48a67d46485435473bad9660cc46
4
+ data.tar.gz: b5e86d3cfad3b1a21300fef1ae99c81f38c87a7c41ce6304e9ceb2e48c1e6f5e
5
5
  SHA512:
6
- metadata.gz: 9589c0d228dc77b2e75a641f158ca878c56498566696039c71eca0c414078299c2a7c4951cf48d45e0388b9cb72a1615321381084a11837fbbc42259a65ea880
7
- data.tar.gz: 4267702fa365999433e673f26ff0896ad9a088ea7ce7ae26fff38bbc4d9c37b1c6239956bc016644ea8b2aa3b10925989f44fbb178a3d611380eb79db4b5cc6e
6
+ metadata.gz: eb8f742f59d39f13a22b79781a69c0ac2855bd8a57e1928e8cc8426d958b6f2724a53e9182cd7bc4139a808308cdeb668334fc707661f6a4576601a5ccbae191
7
+ data.tar.gz: 8b1e9f3584bec5a5c29397802d3c8048ea9552148934f230c15c0bdd226ca763c3a97801c8e98abdc45110bdc6527be68ba504ccd7e0c34c984322bb6b11c6a9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,27 @@
1
+ ### 5.12.7 / 2021-10-26
2
+ - Added:
3
+ - Env var `SIMP_PKG_progress_bar=no` to turn off pkg RPM build progress bars
4
+ - Env var `SIMP_PKG_fetch_published_rpm=no` to prevent downloading a
5
+ published package
6
+ - Fixed:
7
+ - RPM builds no longer fail with leftover generated
8
+ `build/rpm_metadata/releases` files
9
+ - Removed unused code, tidied up some confusing bits to make structure more
10
+ obvious
11
+
12
+ ### 5.12.6 / 2021-10-19
13
+ - Ensure that the `Updates` directory does not link to files in itself
14
+
15
+ ### 5.12.5 / 2021-10-07
16
+ - Fixed a bug where `build:auto` failed when building the SIMP ISO for EL7,
17
+ because the code attempted to move a directory onto itself.
18
+ - Ensured GPG keys in simp-gpgkeys are available in the DVD overlay tar file
19
+
20
+ ### 5.12.4 / 2021-10-05
21
+ - Ensure that the DIST qualifier is added to all built RPMs
22
+ - Use the new SimpRepos directory layout when building an ISO using externally
23
+ copied repos.
24
+
1
25
  ### 5.12.3 / 2021-09-15
2
26
  - Handle multiple options for required applications in build:auto
3
27
  - Allow users to populate a `reposync` directory in the YUM build space that
@@ -282,7 +282,7 @@ module Simp::Rake::Build
282
282
  Error: Could not find anything to do!
283
283
 
284
284
  In #{target_dir}:
285
- No packages in either packages.yaml or the packages/ directory
285
+ No packages in either packages.yaml or the packages/ directory and no repos found in the reposync/ directory
286
286
  EOM
287
287
  end
288
288
 
@@ -190,12 +190,20 @@ module Simp::Rake::Build
190
190
  end
191
191
  end
192
192
 
193
+
194
+ repo_target_dir = dir
195
+
193
196
  # If we've pulled in reposync directories, we expect them to
194
197
  # completely overwrite the directory of the same name in the
195
198
  # target ISO so no pruning is required
196
199
  #
197
200
  # Note: CASE MATTERS on the directory names
198
201
  if reposync_active
202
+ # We're working with the new EL8+ layout, so we need to target
203
+ # the SimpRepos subdirectory
204
+ repo_target_dir = File.join(dir,'SimpRepos')
205
+ mkdir_p(repo_target_dir, :verbose => verbose)
206
+
199
207
  repos_to_overwrite = Dir.glob(File.join(reposync_location, '*'))
200
208
  .delete_if{|x| !File.directory?(x)}
201
209
  .map{|x| File.basename(x)}
@@ -204,13 +212,18 @@ module Simp::Rake::Build
204
212
  src = File.join(reposync_location, repo)
205
213
  target = File.join(dir, repo)
206
214
 
207
- rm_rf(target, :verbose => verbose) if File.directory?(target)
208
- cp_r(src, dir, :verbose => verbose)
215
+ if File.directory?(target)
216
+ rm_rf(target, :verbose => verbose) if File.directory?(target)
217
+ else
218
+ target = File.join(repo_target_dir, repo)
219
+ end
220
+
221
+ cp_r(src, target, :verbose => verbose)
209
222
  end
210
223
  else
211
224
  # Prune unwanted packages
212
225
  begin
213
- system("tar --no-same-permissions -C #{dir} -xzf #{tball} *simp_pkglist.txt")
226
+ system("tar --no-same-permissions -C #{repo_target_dir} -xzf #{tball} *simp_pkglist.txt")
214
227
  rescue
215
228
  # Does not matter if the command fails
216
229
  end
@@ -235,14 +248,25 @@ module Simp::Rake::Build
235
248
  next if line =~ /^(\s+|#.*)$/
236
249
  exclude_pkgs.push(line.chomp)
237
250
  end
238
- prune_packages(dir,['SIMP'],exclude_pkgs,mkrepo)
251
+ prune_packages(dir,['SIMP','SimpRepos'],exclude_pkgs,mkrepo)
239
252
  end
240
253
  end
241
254
 
242
255
  # Add the SIMP code
243
256
  system("tar --no-same-permissions -C #{dir} -xzf #{tball}")
244
257
 
245
- Dir.chdir("#{dir}/SIMP") do
258
+ # Pop the SIMP directory from the tarball into the correct spot
259
+ # FIXME: This is a hack
260
+ unless dir == repo_target_dir
261
+ simpdir = File.join(dir,'SIMP')
262
+
263
+ if File.directory?(simpdir)
264
+ cp_r(simpdir, repo_target_dir, :verbose => verbose)
265
+ rm_rf(simpdir, :verbose => verbose)
266
+ end
267
+ end
268
+
269
+ Dir.chdir("#{repo_target_dir}/SIMP") do
246
270
  # Add the SIMP Dependencies
247
271
  simp_base_ver = simpver.split('-').first
248
272
 
@@ -285,26 +309,81 @@ module Simp::Rake::Build
285
309
  cp(rpm,rpm_arch, :verbose => verbose)
286
310
  end
287
311
 
288
- ln_s('noarch', arch, :verbose => verbose) if (!File.directory?(arch) && File.directory?('noarch'))
289
- fail("Could not find architecture '#{arch}' in the SIMP distribution") unless (File.directory?(arch) || File.symlink?(arch))
312
+ if reposync_active
313
+ fail("Error: Could not run createrepo in #{Dir.pwd}") unless system(%(#{mkrepo} .))
314
+ else
315
+ ln_sf('noarch', arch, :verbose => verbose) if (!File.directory?(arch) && File.directory?('noarch'))
316
+ fail("Could not find architecture '#{arch}' in the SIMP distribution") unless (File.directory?(arch) || File.symlink?(arch))
317
+
318
+ # Get everything set up properly...
319
+ Dir.chdir(arch) do
320
+ Dir.glob('../*') do |rpm_dir|
321
+ # Don't dive into ourselves
322
+ next if File.basename(rpm_dir) == arch
323
+
324
+ Dir.glob(%(#{rpm_dir}/*.rpm)) do |source_rpm|
325
+ link_target = File.basename(source_rpm)
326
+ if File.exist?(source_rpm) && File.exist?(link_target)
327
+ next if Pathname.new(source_rpm).realpath == Pathname.new(link_target).realpath
328
+ end
329
+
330
+ ln_sf(source_rpm,link_target, :verbose => verbose)
331
+ end
332
+ end
333
+
334
+ fail("Error: Could not run createrepo in #{Dir.pwd}") unless system(%(#{mkrepo} .))
335
+ end
336
+ end
337
+ end
338
+
339
+ ### Munge the Repos
290
340
 
291
- # Get everything set up properly...
292
- Dir.chdir(arch) do
293
- Dir.glob('../*') do |rpm_dir|
294
- # Don't dive into ourselves
295
- next if File.basename(rpm_dir) == arch
341
+ # Create an Updates directory that is properly populated
342
+ updates_readme = <<~README
343
+ This directory houses updates to NON-MODULAR RPMs.
296
344
 
297
- Dir.glob(%(#{rpm_dir}/*.rpm)) do |source_rpm|
298
- link_target = File.basename(source_rpm)
299
- if File.exist?(source_rpm) && File.exist?(link_target)
300
- next if Pathname.new(source_rpm).realpath == Pathname.new(link_target).realpath
301
- end
345
+ DO NOT put modular RPMs in this directory or you will break your
346
+ system updates!
347
+ README
348
+
349
+ updates_dir = File.join(dir, 'Updates')
350
+ mkdir_p(updates_dir)
351
+
352
+ Dir.chdir(updates_dir) do
353
+ File.open('README','w'){|fh| fh.puts(updates_readme) }
354
+
355
+ repos = Dir.glob(File.join('..','**','repodata'))
356
+ modular_repos = Dir.glob(File.join('..','**','repodata','*-modules.*'))
357
+ non_modular_repos = repos.select{|x| modular_repos.grep(%r{^#{Regexp.escape(x)}}).empty? }
358
+ non_modular_repos.map!{|x| File.split(x).first}
359
+ non_modular_repos.delete_if{|x| x.match(%r{/SimpRepos|/SIMP}) }
360
+ non_modular_repos.each do |non_modular_repo|
361
+ Dir.glob(File.join(non_modular_repo, '**', '*.rpm')).each do |rpm|
362
+ # when non_modular_repo is '..', can still find RPMs we need
363
+ # to exclude
364
+ next if rpm.match(%r{/SimpRepos|/SIMP})
302
365
 
303
- ln_sf(source_rpm,link_target, :verbose => verbose)
366
+ rpm_dest = File.basename(rpm)
367
+ if File.exist?(rpm) && File.exist?(rpm_dest)
368
+ next if (File.realpath(rpm) == File.realpath(rpm_dest))
304
369
  end
370
+
371
+ ln_sf(rpm, rpm_dest, :verbose => verbose)
305
372
  end
373
+ end
374
+
375
+ fail("Error: Could not run createrepo in #{Dir.pwd}") unless system(%(#{mkrepo} .))
376
+ end
306
377
 
307
- fail("Error: Could not run createrepo in #{Dir.pwd}") unless system(%(#{mkrepo} .))
378
+ # New ISO Layout
379
+ if reposync_active
380
+ Dir.chdir(repo_target_dir) do
381
+ gpgkeysdir = File.join('SIMP','GPGKEYS')
382
+
383
+ if File.directory?(gpgkeysdir)
384
+ cp_r(gpgkeysdir, '.', :verbose => verbose)
385
+ rm_rf(gpgkeysdir, :verbose => verbose)
386
+ end
308
387
  end
309
388
  end
310
389
 
@@ -21,13 +21,17 @@ module Simp::Rake::Build
21
21
  @rpm_build_metadata = 'last_rpm_build_metadata.yaml'
22
22
  @rpm_dependency_file = File.join(@base_dir, 'build', 'rpm', 'dependencies.yaml')
23
23
  @build_keys_dir = ENV.fetch('SIMP_PKG_build_keys_dir', File.join(@base_dir, '.dev_gpgkeys'))
24
- @long_gpg_socket_err_msg = <<~EOM
24
+ @long_gpg_socket_err_msg = <<~MSG
25
25
  If the problem is 'socket name <xxx> is too long', use SIMP_PKG_build_keys_dir
26
26
  to override
27
27
  #{@build_keys_dir}
28
28
  with a shorter path. The socket name must be < 108 characters.
29
29
 
30
- EOM
30
+ MSG
31
+ # nil = default not set; use local preference
32
+ @fetch_published_rpm_default = ENV['SIMP_PKG_fetch_published_rpm'] ? (
33
+ ENV['SIMP_PKG_fetch_published_rpm'] =~ /\A(yes|true)\Z/i ? true : false
34
+ ) : nil
31
35
 
32
36
  define_tasks
33
37
  end
@@ -114,7 +118,7 @@ module Simp::Rake::Build
114
118
  end
115
119
  end
116
120
 
117
- desc <<-EOM
121
+ desc <<~DESC
118
122
  Prepare a GPG signing key to sign build packages
119
123
 
120
124
  * :key - the name of the build keys subdirectory to prepare
@@ -142,7 +146,7 @@ module Simp::Rake::Build
142
146
  ENV vars:
143
147
  - Set `SIMP_PKG_verbose=yes` to report file operations as they happen.
144
148
  - Set `SIMP_PKG_build_keys_dir` to override the default build keys path.
145
- EOM
149
+ DESC
146
150
  task :key_prep,[:key] => [:prep] do |t,args|
147
151
  args.with_defaults(:key => 'dev')
148
152
  key = args.key
@@ -251,7 +255,7 @@ module Simp::Rake::Build
251
255
 
252
256
 
253
257
  =begin
254
- desc <<-EOM
258
+ desc <<~DESC
255
259
  Build the entire SIMP release.
256
260
 
257
261
  * :docs - Build the docs. Set this to false if you wish to skip building the docs.
@@ -261,7 +265,7 @@ module Simp::Rake::Build
261
265
  - Set `SIMP_PKG_verbose=yes` to report file operations as they happen.
262
266
  - Set `SIMP_YUM_makecache=no` if you do NOT want to rebuild the
263
267
  build-specific YUM cache
264
- EOM
268
+ DESC
265
269
  =end
266
270
  task :build,[:docs,:key] => [:prep,:key_prep] do |t,args|
267
271
  args.with_defaults(:key => 'dev')
@@ -269,12 +273,7 @@ module Simp::Rake::Build
269
273
 
270
274
  check_dvd_env
271
275
 
272
- begin
273
- yum_helper = Simp::YUM.new(
274
- Simp::YUM.generate_yum_conf(File.join(@distro_build_dir, 'yum_data')),
275
- ENV.fetch('SIMP_YUM_makecache','yes') == 'yes')
276
- rescue Simp::YUM::Error
277
- end
276
+ get_yum_helper
278
277
 
279
278
  Rake::Task['pkg:aux'].invoke
280
279
  if "#{args.docs}" == 'true'
@@ -287,7 +286,7 @@ module Simp::Rake::Build
287
286
  Rake::Task['pkg:signrpms'].invoke(args[:key])
288
287
  end
289
288
 
290
- desc <<-EOM
289
+ desc <<~DESC
291
290
  Build the Puppet module RPMs.
292
291
 
293
292
  * :method - The Puppetfile from which the repository information
@@ -295,12 +294,12 @@ module Simp::Rake::Build
295
294
 
296
295
  ENV vars:
297
296
  - Set `SIMP_PKG_verbose=yes` to report file operations as they happen.
298
- EOM
297
+ DESC
299
298
  task :modules,[:method] => [:prep] do |t,args|
300
299
  build(@build_dirs[:modules],t)
301
300
  end
302
301
 
303
- desc <<-EOM
302
+ desc <<~DESC
304
303
  Build a single Puppet Module RPM.
305
304
 
306
305
  * :name - The path, or name, of the module to build. If a name is
@@ -314,11 +313,12 @@ module Simp::Rake::Build
314
313
  - Set `SIMP_PKG_verbose=yes` to report file operations as they happen.
315
314
  - Set `SIMP_YUM_makecache=no` if you do NOT want to rebuild the
316
315
  build-specific YUM cache
317
- EOM
316
+ DESC
318
317
  task :single,[:name,:method] => [:prep] do |t,args|
319
318
  fail("You must pass :name to '#{t.name}'") unless args[:name]
320
319
 
321
320
  mod_path = File.absolute_path(args[:name])
321
+ get_yum_helper
322
322
 
323
323
  if args[:name].include?('/')
324
324
  fail("'#{args[:name]}' does not exist!") unless File.directory?(mod_path)
@@ -333,35 +333,27 @@ module Simp::Rake::Build
333
333
  mod_path = local_module[:path]
334
334
  end
335
335
 
336
- begin
337
- yum_helper = Simp::YUM.new(
338
- Simp::YUM.generate_yum_conf(File.join(@distro_build_dir, 'yum_data')),
339
- ENV.fetch('SIMP_YUM_makecache','yes') == 'yes')
340
- rescue Simp::YUM::Error
341
- end
342
-
343
- ENV['SIMP_PKG_rand_name'] = 'yes'
344
336
  build(Array(mod_path), t)
345
337
 
346
338
  puts("Your packages can be found in '#{mod_path}/dist'")
347
339
  end
348
340
 
349
- desc <<-EOM
341
+ desc <<~DESC
350
342
  Build the SIMP non-module RPMs.
351
343
 
352
344
  ENV vars:
353
345
  - Set `SIMP_PKG_verbose=yes` to report file operations as they happen.
354
- EOM
346
+ DESC
355
347
  task :aux => [:prep] do |t,args|
356
348
  build(@build_dirs[:aux],t)
357
349
  end
358
350
 
359
- desc <<-EOM
351
+ desc <<~DESC
360
352
  Build the SIMP documentation.
361
353
 
362
354
  ENV vars:
363
355
  - Set `SIMP_PKG_verbose=yes` to report file operations as they happen.
364
- EOM
356
+ DESC
365
357
  task :doc => [:prep] do |t,args|
366
358
  # Need to make sure that the docs have the version updated
367
359
  # appropriately prior to building
@@ -373,7 +365,7 @@ module Simp::Rake::Build
373
365
  build(@build_dirs[:doc],t)
374
366
  end
375
367
 
376
- desc <<-EOM
368
+ desc <<~DESC
377
369
  Sign a set of RPMs.
378
370
 
379
371
  Signs any unsigned RPMs in the specified directory
@@ -394,7 +386,7 @@ module Simp::Rake::Build
394
386
  * Set `SIMP_PKG_rpmsign_timeout` to override the maximum time in seconds
395
387
  to wait for an individual RPM signing operation to complete.
396
388
  - Defaults to 60 seconds.
397
- EOM
389
+ DESC
398
390
  task :signrpms,[:key,:rpm_dir,:force,:digest_algo] => [:prep,:key_prep] do |t,args|
399
391
  require 'simp/rpm_signer'
400
392
 
@@ -455,13 +447,13 @@ module Simp::Rake::Build
455
447
  end
456
448
 
457
449
  =begin
458
- desc <<-EOM
450
+ desc <<~DESC
459
451
  Check that RPMs are signed.
460
452
 
461
453
  Checks all RPM files in a directory to see if they are trusted.
462
454
  * :rpm_dir - A directory containing RPM files to check. Default #{@build_dir}/SIMP
463
455
  * :key_dir - The path to the GPG keys you want to check the packages against. Default #{@src_dir}/assets/gpgkeys/
464
- EOM
456
+ DESC
465
457
  =end
466
458
  task :checksig,[:rpm_dir,:key_dir] => [:prep] do |t,args|
467
459
  begin
@@ -547,7 +539,7 @@ module Simp::Rake::Build
547
539
  end
548
540
  end
549
541
 
550
- desc <<-EOM
542
+ desc <<~DESC
551
543
  Run repoclosure on RPM files.
552
544
 
553
545
  Finds all rpm files in the target dir and all of its subdirectories, then
@@ -561,7 +553,7 @@ module Simp::Rake::Build
561
553
  - Set `SIMP_PKG_verbose=yes` to report file operations as they happen.
562
554
  - Set `SIMP_PKG_repoclose_pe=yes` to enable repoclosure on PE-related RPMs.
563
555
 
564
- EOM
556
+ DESC
565
557
  task :repoclosure,[:target_dir,:aux_dir] => [:prep] do |t,args|
566
558
  default_target = @pkg_dirs[:simp]
567
559
  args.with_defaults(:target_dir => File.expand_path(default_target))
@@ -572,31 +564,31 @@ module Simp::Rake::Build
572
564
 
573
565
  _repoclose_pe = ENV.fetch('SIMP_PKG_repoclose_pe','no') == 'yes'
574
566
 
575
- yum_conf_template = <<-EOF
576
- [main]
577
- keepcache=0
578
- exactarch=1
579
- obsoletes=1
580
- gpgcheck=0
581
- plugins=1
582
- installonly_limit=5
583
- <% unless #{_repoclose_pe} -%>
584
- exclude=*-pe-*
585
- <% end -%>
586
-
587
- <% repo_files.each do |repo| -%>
588
- include=file://<%= repo %>
589
- <% end -%>
590
- EOF
591
-
592
- yum_repo_template = <<-EOF
593
- [<%= repo_name %>]
594
- name=<%= repo_name %>
595
- baseurl=file://<%= repo_path %>
596
- enabled=1
597
- gpgcheck=0
598
- protect=1
599
- EOF
567
+ yum_conf_template = <<~YUM_CONF
568
+ [main]
569
+ keepcache=0
570
+ exactarch=1
571
+ obsoletes=1
572
+ gpgcheck=0
573
+ plugins=1
574
+ installonly_limit=5
575
+ <% unless #{_repoclose_pe} -%>
576
+ exclude=*-pe-*
577
+ <% end -%>
578
+
579
+ <% repo_files.each do |repo| -%>
580
+ include=file://<%= repo %>
581
+ <% end -%>
582
+ YUM_CONF
583
+
584
+ yum_repo_template = <<~YUM_REPO
585
+ [<%= repo_name %>]
586
+ name=<%= repo_name %>
587
+ baseurl=file://<%= repo_path %>
588
+ enabled=1
589
+ gpgcheck=0
590
+ protect=1
591
+ YUM_REPO
600
592
 
601
593
  fail("#{args[:target_dir]} does not exist!") unless File.directory?(args[:target_dir])
602
594
 
@@ -610,7 +602,7 @@ protect=1
610
602
  .delete_if{|x| x =~ /\.src\.rpm$/}
611
603
  .each do |path|
612
604
  sym_path = "repos/base/#{File.basename(path)}"
613
- ln_s(path,sym_path, :verbose => @verbose) unless File.exists?(sym_path)
605
+ ln_sf(path,sym_path, :verbose => @verbose) unless File.exists?(sym_path)
614
606
  end
615
607
 
616
608
  if args[:aux_dir]
@@ -618,7 +610,7 @@ protect=1
618
610
  .delete_if{|x| x =~ /\.src\.rpm$/}
619
611
  .each do |path|
620
612
  sym_path = "repos/lookaside/#{File.basename(path)}"
621
- ln_s(path,sym_path, :verbose => @verbose) unless File.exists?(sym_path)
613
+ ln_sf(path,sym_path, :verbose => @verbose) unless File.exists?(sym_path)
622
614
  end
623
615
  end
624
616
 
@@ -643,7 +635,8 @@ protect=1
643
635
  file.write(ERB.new(yum_conf_template,nil,'-').result(binding))
644
636
  end
645
637
 
646
- if which('dnf')
638
+ dnf_system = which('dnf')
639
+ if dnf_system
647
640
  cmd = 'repoclosure -c base.conf --disablerepo=* --enablerepo=base'
648
641
  else
649
642
  cmd = 'repoclosure -c repodata -n -t -r base -l lookaside -c yum.conf'
@@ -661,15 +654,24 @@ protect=1
661
654
  if (!$?.success? || (repoclosure_output =~ /nresolved/))
662
655
  errmsg = ['Error: REPOCLOSURE FAILED:']
663
656
  errmsg << [repoclosure_output]
664
- fail(errmsg.join("\n"))
657
+ puts(errmsg.join("\n"))
658
+
659
+ if dnf_system
660
+ if ENV.fetch('SIMP_BUILD_prompt', 'yes') != 'no'
661
+ puts('- Press any key to continue or ^C to abort -')
662
+ $stdin.gets
663
+ end
664
+ else
665
+ fail('Repoclosure Failed')
666
+ end
665
667
  end
666
668
  end
667
669
  end
668
670
  end
669
671
 
670
- desc <<-EOM
672
+ desc <<~DESC
671
673
  Print published status of all project RPMs
672
- EOM
674
+ DESC
673
675
  task :check_published => [:prep] do |t,args|
674
676
  begin
675
677
  yum_helper = Simp::YUM.new(
@@ -687,7 +689,12 @@ protect=1
687
689
 
688
690
  if Dir.exist?(dir)
689
691
  begin
690
- require_rebuild?(dir, yum_helper, { :verbose => true, :check_git => true, :prefix => '' })
692
+ require_rebuild?(dir, yum_helper, {
693
+ fetch: false,
694
+ verbose: true,
695
+ check_git: true,
696
+ prefix: ''
697
+ })
691
698
  rescue => e
692
699
  _errmsg = "Error: require_rebuild?(): Status check failed on '#{dir}' => #{e}"
693
700
  end
@@ -714,9 +721,24 @@ protect=1
714
721
  return (0...24).map{ (65 + rand(26)).chr }.join.downcase
715
722
  end
716
723
 
724
+ # Return a SIMP::YUM object configured for the local build dir or nil
725
+ #
726
+ # ENV vars:
727
+ # - Set `SIMP_PKG_verbose=yes` to report file operations as they happen.
728
+ # - Set `SIMP_YUM_makecache=no` if you do NOT want to rebuild the
729
+ # build-specific YUM cache
730
+ def get_yum_helper( makecache = (ENV.fetch('SIMP_YUM_makecache','yes') == 'yes') )
731
+ begin
732
+ build_yum_data = File.join(@distro_build_dir, 'yum_data')
733
+ return Simp::YUM.new(Simp::YUM.generate_yum_conf(build_yum_data), makecache)
734
+ rescue Simp::YUM::Error => e
735
+ $stderr.puts "Simp::YUM::Error: #{e}" if @verbose
736
+ end
737
+ end
738
+
717
739
  # Check and see if 'dir' requires a rebuild based on published packages
718
740
  #
719
- # If 'fetch' is true => Download the RPM
741
+ # If 'fetch' is true => Download the published RPM
720
742
  # If 'verbose' is true => Print helpful information to stderr
721
743
  # If 'check_git' is true => Print the git tag status if 'verbose' is true
722
744
  # 'prefix' is used to prepend verbose messages
@@ -725,7 +747,13 @@ protect=1
725
747
  # - Method is too long
726
748
  # - Method needs to be passed in class variables (@xxx) so that it
727
749
  # can be pulled out into a library that is easily unit-testable
728
- def require_rebuild?(dir, yum_helper, opts={ :unique_namespace => generate_namespace, :fetch => false, :verbose => @verbose, :check_git => false, :prefix => '' })
750
+ def require_rebuild?(dir, yum_helper, opts={
751
+ unique_namespace: generate_namespace,
752
+ fetch: false,
753
+ verbose: @verbose,
754
+ check_git: false,
755
+ prefix: ''
756
+ })
729
757
  result = false
730
758
  rpm_metadata = File.exist?(@rpm_dependency_file) ? YAML.load(File.read(@rpm_dependency_file)) : {}
731
759
  dir_relpath = Pathname.new(dir).relative_path_from(Pathname.new(Dir.pwd)).to_path
@@ -860,7 +888,8 @@ protect=1
860
888
  else
861
889
  $stderr.puts "#{opts[:prefix]}Found Existing Remote RPM: #{published_rpm}" if opts[:verbose]
862
890
  if opts[:fetch]
863
- # Download remote RPM, unless already downloaded it.
891
+ # Download published RPM, unless it's already been downloaded.
892
+ # TODO Unhandled edge case: Validate that downloaded RPM is valid
864
893
  if File.exist?(File.join('dist', published_rpm))
865
894
  $stderr.puts "#{opts[:prefix]}#{published_rpm} previously downloaded" if opts[:verbose]
866
895
  else
@@ -904,101 +933,107 @@ protect=1
904
933
  return result
905
934
  end
906
935
 
936
+ def build_pupmod_rpm(dir, yum_helper, dbg_prefix = ' ')
937
+ unique_namespace = generate_namespace
938
+ if require_rebuild?(dir, yum_helper, {
939
+ unique_namespace: unique_namespace,
940
+ fetch: @fetch_published_rpm.nil? ? true : @fetch_published_rpm,
941
+ verbose: @verbose,
942
+ prefix: dbg_prefix,
943
+ })
944
+ $stderr.puts("#{dbg_prefix}Running 'rake pkg:rpm' on #{File.basename(dir)}") if @verbose
945
+ Rake::Task["#{unique_namespace}:pkg:rpm"].invoke
946
+ else
947
+ # Record metadata for the downloaded RPM
948
+ Simp::RPM::create_rpm_build_metadata(File.expand_path(dir))
949
+ end
950
+ true
951
+ end
952
+
953
+
954
+ def build_rakefile_rpm(dir, yum_helper, dbg_prefix = ' ')
955
+ if require_rebuild?(dir, yum_helper, {
956
+ fetch: @fetch_published_rpm.nil? ? true : @fetch_published_rpm,
957
+ verbose: @verbose,
958
+ prefix: dbg_prefix
959
+ })
960
+ $stderr.puts("#{dbg_prefix}Running 'rake pkg:rpm' in #{File.basename(dir)}") if @verbose
961
+ rake_flags = Rake.application.options.trace ? '--trace' : ''
962
+ cmd = %{SIMP_BUILD_version=#{@simp_version} rake pkg:rpm #{rake_flags} 2>&1}
963
+
964
+ build_success = true
965
+ begin
966
+ %x{#{cmd}}
967
+ build_success = $?.success?
968
+
969
+ built_rpm = true
970
+ rescue
971
+ build_success = false
972
+ end
973
+
974
+ unless build_success
975
+ if @verbose
976
+ $stderr.puts("First 'rake pkg:rpm' attempt for #{dir} failed, running bundle and trying again.")
977
+ end
978
+
979
+ if Bundler.respond_to?(:with_unbundled_env)
980
+ # Bundler 2.1+
981
+ clean_env_method = :with_unbundled_env
982
+ bundle_install_cmd = %{bundle config set with 'development' && bundle install}
983
+ else
984
+ # Old Bundler
985
+ clean_env_method = :with_clean_env
986
+ bundle_install_cmd = %{bundle install --with development}
987
+ end
988
+
989
+ ::Bundler.send(clean_env_method) do
990
+ %x{#{bundle_install_cmd}}
991
+
992
+ output = %x{#{cmd} 2>&1}
993
+
994
+ unless $?.success?
995
+ raise("Error in #{dir} running #{cmd}\n#{output}")
996
+ end
997
+ end
998
+ end
999
+ else
1000
+ # Record metadata for the downloaded RPM
1001
+ Simp::RPM::create_rpm_build_metadata(File.expand_path(dir))
1002
+ built_rpm = true
1003
+ end
1004
+ end
1005
+
1006
+
907
1007
  # Takes a list of directories to hop into and perform builds within
908
1008
  #
909
1009
  # The task must be passed so that we can output the calling name in the
910
1010
  # status bar.
911
1011
  def build(dirs, task, rebuild_for_arch=false, remake_yum_cache = false)
912
- _verbose = ENV.fetch('SIMP_PKG_verbose','no') == 'yes'
913
- dbg_prefix = ' ' # prefix for debug messages
914
-
915
1012
  fail("Could not find RPM dependency file '#{@rpm_dependency_file}'") unless File.exist?(@rpm_dependency_file)
916
-
917
- begin
918
- yum_helper = Simp::YUM.new(
919
- Simp::YUM.generate_yum_conf(File.join(@distro_build_dir, 'yum_data'))
920
- )
921
- rescue Simp::YUM::Error
922
- end
1013
+ yum_helper = get_yum_helper( remake_yum_cache )
923
1014
 
924
1015
  Parallel.map(
925
1016
  # Allow for shell globs
926
- Array(dirs),
927
- :in_processes => @cpu_limit,
928
- :progress => task.name
1017
+ Array(dirs), {
1018
+ in_processes: @cpu_limit,
1019
+ progress: (ENV.fetch('SIMP_PKG_progress_bar','yes') == 'yes') ? task.name : nil,
1020
+ }
929
1021
  ) do |dir|
930
1022
  fail("Could not find directory #{dir}") unless Dir.exist?(dir)
931
1023
 
932
1024
  Dir.chdir(dir) do
933
1025
  built_rpm = false
1026
+ $stderr.puts("\nPackaging #{File.basename(dir)}") if @verbose
934
1027
 
935
- if @verbose
936
- $stderr.puts("\nPackaging #{File.basename(dir)}")
937
- end
938
-
939
- # We're building a module, override anything down there
940
1028
  if File.exist?('metadata.json')
941
- unique_namespace = generate_namespace
942
- if require_rebuild?(dir, yum_helper, { :unique_namespace => unique_namespace, :fetch => true, :verbose => @verbose, :prefix => dbg_prefix})
943
- $stderr.puts("#{dbg_prefix}Running 'rake pkg:rpm' on #{File.basename(dir)}") if @verbose
944
- Rake::Task["#{unique_namespace}:pkg:rpm"].invoke
945
- else
946
- # Record metadata for the downloaded RPM
947
- Simp::RPM::create_rpm_build_metadata(File.expand_path(dir))
948
- end
949
-
950
- built_rpm = true
951
-
952
- # We're building one of the extra assets and should honor its Rakefile
953
- # and RPM spec file.
1029
+ # We're building a module, override anything down there
1030
+ built_rpm = build_pupmod_rpm(dir, yum_helper)
954
1031
  elsif File.exist?('Rakefile')
955
- if require_rebuild?(dir, yum_helper, { :fetch => true, :verbose => @verbose, :prefix => dbg_prefix })
956
- $stderr.puts("#{dbg_prefix}Running 'rake pkg:rpm' in #{File.basename(dir)}") if @verbose
957
- rake_flags = Rake.application.options.trace ? '--trace' : ''
958
- cmd = %{SIMP_BUILD_version=#{@simp_version} rake pkg:rpm #{rake_flags} 2>&1}
959
-
960
- build_success = true
961
- begin
962
- %x{#{cmd}}
963
- build_success = $?.success?
964
-
965
- built_rpm = true
966
- rescue
967
- build_success = false
968
- end
969
-
970
- unless build_success
971
- if @verbose
972
- $stderr.puts("First 'rake pkg:rpm' attempt for #{dir} failed, running bundle and trying again.")
973
- end
974
-
975
- if Bundler.respond_to?(:with_unbundled_env)
976
- # Bundler 2.1+
977
- clean_env_method = :with_unbundled_env
978
- bundle_install_cmd = %{bundle config set with 'development' && bundle install}
979
- else
980
- # Old Bundler
981
- clean_env_method = :with_clean_env
982
- bundle_install_cmd = %{bundle install --with development}
983
- end
984
-
985
- ::Bundler.send(clean_env_method) do
986
- %x{#{bundle_install_cmd}}
987
-
988
- output = %x{#{cmd} 2>&1}
989
-
990
- unless $?.success?
991
- raise("Error in #{dir} running #{cmd}\n#{output}")
992
- end
993
- end
994
- end
995
- else
996
- # Record metadata for the downloaded RPM
997
- Simp::RPM::create_rpm_build_metadata(File.expand_path(dir))
998
- built_rpm = true
999
- end
1032
+ # We're building one of the extra assets and should honor its Rakefile
1033
+ # and RPM spec file.
1034
+ built_rpm = build_rakefile_rpm(dir, yum_helper)
1000
1035
  else
1001
- puts "Warning: '#{dir}' could not be built via Rake"
1036
+ puts "Warning: '#{dir}' could not be built (not a pupmod & no Rakefile!)"
1002
1037
  end
1003
1038
 
1004
1039
  if built_rpm
@@ -1014,12 +1049,7 @@ protect=1
1014
1049
 
1015
1050
  raise("No RPMs generated for #{dir}") if rpms.empty?
1016
1051
  end
1017
-
1018
- if @verbose
1019
- rpms = Dir.glob('dist/*.rpm')
1020
- # $stderr.puts("#{dbg_prefix}RPMS: #{rpms.join("\n#{dbg_prefix} ")}")
1021
- $stderr.puts("Finished #{File.basename(dir)}")
1022
- end
1052
+ $stderr.puts("Finished #{File.basename(dir)}") if @verbose
1023
1053
  end
1024
1054
  end
1025
1055
  end
@@ -267,7 +267,13 @@ module Simp::Rake::Build::RpmDeps
267
267
  def self.release_file_up_to_date?(new_release_info, rpm_release_file)
268
268
  return false unless File.exist?(rpm_release_file)
269
269
 
270
- return File.read(rpm_release_file).strip == new_release_info.strip
270
+ # remove comments like "# release set by simp-core dependencies.yaml"
271
+ release_file_content = File.readlines(rpm_release_file).reject{|x| x =~ /^ *#/}.join("\n").strip
272
+
273
+ # sanitize numerics, etc.
274
+ new_release_content = "#{new_release_info}".strip
275
+
276
+ return release_file_content == new_release_content
271
277
  end
272
278
 
273
279
  # Generate 'build/rpm_metadata/release' file containing release qualifier
@@ -51,7 +51,8 @@ module Simp::Rake::Build
51
51
  'rubygem-simp-cli',
52
52
  'simp',
53
53
  'simp-gpgkeys',
54
- 'simp-utils'
54
+ 'simp-utils',
55
+ 'simp-vendored-r10k'
55
56
  ]
56
57
  }
57
58
 
@@ -83,8 +84,11 @@ module Simp::Rake::Build
83
84
  end
84
85
 
85
86
  unless failures.empty?
86
- msg = ['Error: Could not find the following packages:']
87
- fail((msg + failures).join("\n"))
87
+ msg = ['Error: Could not find the following packages:'] +
88
+ failures +
89
+ ['Did "dist/logs/last_rpm_build_metadata.yaml" get generated in the build directory?']
90
+
91
+ fail(msg.join("\n"))
88
92
  end
89
93
  end
90
94
  end
@@ -126,10 +130,16 @@ module Simp::Rake::Build
126
130
 
127
131
  Simp::RPM.copy_wo_vcs(@dvd_src,".",base_dir)
128
132
 
129
- # Copy in the GPG Public Keys
133
+ # Copy in the GPG Public Keys from @build_dir
130
134
  mkdir_p("#{destdir}/GPGKEYS")
131
135
  ln(Dir.glob("#{@build_dir}/GPGKEYS/RPM-GPG-KEY*"), "#{destdir}/GPGKEYS", { :force => true })
132
136
 
137
+ # Copy in the GPG Public Keys packaged by simp-gpgkeys
138
+ simp_gpgkeys = File.join(@src_dir, 'assets', 'gpgkeys', 'GPGKEYS')
139
+ if Dir.exist?(simp_gpgkeys)
140
+ ln(Dir.glob("#{simp_gpgkeys}/RPM-GPG-KEY*"), "#{destdir}/GPGKEYS", { :force => true })
141
+ end
142
+
133
143
  # Copy in the auto-build RPMs
134
144
  Dir.chdir("#{@build_dir}/SIMP/RPMS") do
135
145
  Dir.glob('*').each do |type|
@@ -301,7 +301,7 @@ end
301
301
 
302
302
  if req_file then
303
303
  for line in req_file:lines() do
304
- valid_line = (line:match("^Requires: ") or line:match("^Obsoletes: ") or line:match("^Provides: "))
304
+ valid_line = (line:match("^Requires: ") or line:match("^Obsoletes: ") or line:match("^Provides: ") or line:match("^Recommends: "))
305
305
 
306
306
  if valid_line then
307
307
  module_requires = (module_requires .. "\n" .. line)
@@ -319,7 +319,7 @@ Summary: %{module_name} Puppet Module
319
319
  Name: %{package_name}
320
320
 
321
321
  Version: %{lua: print(package_version)}
322
- Release: %{lua: print(package_release)}
322
+ Release: %{lua: print(package_release)}%{?dist}
323
323
  License: %{lua: print(module_license)}
324
324
  Group: Applications/System
325
325
  Source0: %{package_name}-%{version}-%{release}.tar.gz
@@ -301,7 +301,7 @@ end
301
301
 
302
302
  if req_file then
303
303
  for line in req_file:lines() do
304
- valid_line = (line:match("^Requires: ") or line:match("^Obsoletes: ") or line:match("^Provides: "))
304
+ valid_line = (line:match("^Requires: ") or line:match("^Obsoletes: ") or line:match("^Provides: ") or line:match("^Recommends: "))
305
305
 
306
306
  if valid_line then
307
307
  module_requires = (module_requires .. "\n" .. line)
@@ -319,7 +319,7 @@ Summary: %{module_name} Puppet Module
319
319
  Name: %{package_name}
320
320
 
321
321
  Version: %{lua: print(package_version)}
322
- Release: %{lua: print(package_release)}
322
+ Release: %{lua: print(package_release)}%{?dist}
323
323
  License: %{lua: print(module_license)}
324
324
  Group: Applications/System
325
325
  Source0: %{package_name}-%{version}-%{release}.tar.gz
@@ -2,5 +2,5 @@ module Simp; end
2
2
  module Simp::Rake; end
3
3
 
4
4
  class Simp::Rake::Helpers
5
- VERSION = '5.12.3'
5
+ VERSION = '5.12.7'
6
6
  end
@@ -195,8 +195,13 @@ class Simp::RpmSigner
195
195
  # the first RPM to be signed with the key after the gpg-agent is
196
196
  # started and the key's passphrase has not been cleared from the
197
197
  # agent's cache.
198
- read.expect(/pass\s?phrase:.*/) do |text|
199
- write.puts(gpgkey[:password])
198
+ read.expect(/(pass\s?phrase:|verwrite).*/) do |text|
199
+ if text.last.include?('verwrite')
200
+ write.puts('y')
201
+ else
202
+ write.puts(gpgkey[:password])
203
+ end
204
+
200
205
  write.flush
201
206
  end
202
207
  end
@@ -287,7 +292,7 @@ class Simp::RpmSigner
287
292
  begin
288
293
  results = Parallel.map(
289
294
  to_sign,
290
- :in_processes => opts[:max_concurrent],
295
+ :in_processes => 1,
291
296
  :progress => opts[:progress_bar_title]
292
297
  ) do |rpm|
293
298
  _result = nil
@@ -11,7 +11,7 @@ shared_examples_for 'an RPM generator with customized scriptlets' do
11
11
  scriptlets = rpm_scriptlets_for(
12
12
  host,
13
13
  "#{pkg_root_dir}/testpackage_custom_scriptlet/dist/" +
14
- 'pupmod-simp-testpackage-0.0.1-1.noarch.rpm'
14
+ "pupmod-simp-testpackage-0.0.1-1#{rpm_dist}.noarch.rpm"
15
15
  )
16
16
 
17
17
  comment '...the expected scriptlet types are present'
@@ -69,7 +69,7 @@ shared_examples_for 'an RPM generator with customized triggers' do
69
69
  triggers = rpm_triggers_for(
70
70
  host,
71
71
  "#{pkg_root_dir}/testpackage_custom_scriptlet/dist/" +
72
- 'pupmod-simp-testpackage-0.0.1-1.noarch.rpm'
72
+ "pupmod-simp-testpackage-0.0.1-1#{rpm_dist}.noarch.rpm"
73
73
  )
74
74
 
75
75
 
@@ -107,6 +107,7 @@ describe 'rake pkg:rpm with customized content' do
107
107
  hosts.each do |_host|
108
108
  context "on #{_host}" do
109
109
  let!(:host){ _host }
110
+ let(:rpm_dist){ on(host, %{rpm --eval '%{dist}'}).output.strip.gsub(/\.centos$/, '') }
110
111
 
111
112
  it 'can prep the package directories' do
112
113
  testpackages = [
@@ -10,7 +10,7 @@ shared_examples_for 'an RPM generator with edge cases' do
10
10
  it 'should use specified release number for the RPM' do
11
11
  on host, %(#{run_cmd} "cd #{pkg_root_dir}/testpackage_with_release; #{rake_cmd} pkg:rpm")
12
12
  release_test_rpm = File.join(pkg_root_dir, 'testpackage_with_release',
13
- 'dist', 'pupmod-simp-testpackage-0.0.1-42.noarch.rpm')
13
+ 'dist', "pupmod-simp-testpackage-0.0.1-42#{rpm_dist}.noarch.rpm")
14
14
  on host, %(test -f #{release_test_rpm})
15
15
  end
16
16
 
@@ -73,10 +73,10 @@ describe 'rake pkg:rpm' do
73
73
  copy_host_files_into_build_user_homedir(hosts)
74
74
  end
75
75
 
76
-
77
76
  hosts.each do |_host|
78
77
  context "on #{_host}" do
79
78
  let!(:host){ _host }
79
+ let(:rpm_dist){ on(host, %{rpm --eval '%{dist}'}).output.strip.gsub(/\.centos$/, '') }
80
80
 
81
81
  context 'rpm building' do
82
82
 
@@ -107,7 +107,7 @@ describe 'rake pkg:rpm' do
107
107
  context 'using simpdefault.spec' do
108
108
 
109
109
  let(:build_type) {:default}
110
- let(:testpackage_rpm) { File.join(testpackage_dir, 'dist/pupmod-simp-testpackage-0.0.1-1.noarch.rpm') }
110
+ let(:testpackage_rpm) { File.join(testpackage_dir, "dist/pupmod-simp-testpackage-0.0.1-1#{rpm_dist}.noarch.rpm") }
111
111
 
112
112
  it 'should create an RPM' do
113
113
  comment "produces RPM on #{host}"
@@ -320,7 +320,7 @@ describe 'rake pkg:signrpms and pkg:checksig' do
320
320
 
321
321
  it 'should corrupt the password of new key' do
322
322
  key_gen_file = File.join(dev_keydir, 'gengpgkey')
323
- on(hosts, "sed -i -e \"s/^Passphrase: /Passphrase: OOPS/\" #{key_gen_file}")
323
+ on(hosts, "sed -ci -e \"s/^Passphrase: /Passphrase: OOPS/\" #{key_gen_file}")
324
324
  end
325
325
 
326
326
  include_examples('it begins with unsigned RPMs')
@@ -342,7 +342,7 @@ describe 'rake pkg:signrpms and pkg:checksig' do
342
342
  end
343
343
 
344
344
  hosts.each do |host|
345
- os_major = fact_on(host,'operatingsystemmajrelease')
345
+ os_major = fact_on(host,'os.release.major')
346
346
  if os_major > '7'
347
347
  # this problem only happens on EL > 7 in a docker container
348
348
  describe "when gpg-agent's socket path is too long on #{host}" do
@@ -378,7 +378,7 @@ describe 'rake pkg:signrpms and pkg:checksig' do
378
378
  :acceptable_exit_codes => [1]
379
379
  )
380
380
 
381
- err_msg = %r(Failed to sign #{test_rpm} in 5 seconds)
381
+ err_msg = %r(Failed to sign)
382
382
  expect(result.stderr).to match(err_msg)
383
383
 
384
384
  signature_check = on(host, "rpm -qip '#{test_rpm}' | grep ^Signature", run_opts)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simp-rake-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.12.3
4
+ version: 5.12.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Tessmer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-09-28 00:00:00.000000000 Z
12
+ date: 2021-10-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: simp-beaker-helpers