simp-rake-helpers 5.12.4 → 5.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d79c389d3f40c038b0ba81fe8351e4f71b256bd1eaeeef52eb0af07239ec793b
4
- data.tar.gz: 1025900b3bbfa941429f228c7952bf79ccfec9a0b388a5a8fcfaf670b3c6f590
3
+ metadata.gz: 5686fa0464ed4e47817e43609d4aa2ec52ccab1a9facd6429d73ec39b321f487
4
+ data.tar.gz: f787b34312ad9033c21811615adb5eb8d069655038e309109fab82560f1e0b81
5
5
  SHA512:
6
- metadata.gz: 9c2e9f763a211891553cde62a1963f9fd603f1ce9bfed11b828b36206fe5ec73e1b55f7d1f570c5d1df79cdc00c534d57cc8df24cd205e4cabe946895e820d47
7
- data.tar.gz: 818c69dcf5bab3bba5516539852abc856973f97275bc186d46ef268c2878d6a4e0542d179a47fd3ed6e48266ff819fc7c70127953694f92b6b7c1b5c03377e98
6
+ metadata.gz: 64c644cf1b04dbceaface541e8b6d219a7d6d9f93ed863a18062b25dece5307d62715a1fee0351e444c3f00e9c8ce476b7455a08f2b76291184949796e1770cf
7
+ data.tar.gz: 18663a6da6f497810c0d505d2fd73109cd97355b664deaa3609f60787dd280fb6a6bee6f3e0f2fa473dacffc696bb369994396b271f48bebeae6fb1a31fabdc4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,26 @@
1
+ ### 5.13.0 /2021-11-14
2
+ - Added:
3
+ - Output the full `mkisofs` command when building an ISO
4
+
5
+ ### 5.12.7 / 2021-10-26
6
+ - Added:
7
+ - Env var `SIMP_PKG_progress_bar=no` to turn off pkg RPM build progress bars
8
+ - Env var `SIMP_PKG_fetch_published_rpm=no` to prevent downloading a
9
+ published package
10
+ - Fixed:
11
+ - RPM builds no longer fail with leftover generated
12
+ `build/rpm_metadata/releases` files
13
+ - Removed unused code, tidied up some confusing bits to make structure more
14
+ obvious
15
+
16
+ ### 5.12.6 / 2021-10-19
17
+ - Ensure that the `Updates` directory does not link to files in itself
18
+
19
+ ### 5.12.5 / 2021-10-07
20
+ - Fixed a bug where `build:auto` failed when building the SIMP ISO for EL7,
21
+ because the code attempted to move a directory onto itself.
22
+ - Ensured GPG keys in simp-gpgkeys are available in the DVD overlay tar file
23
+
1
24
  ### 5.12.4 / 2021-10-05
2
25
  - Ensure that the DIST qualifier is added to all built RPMs
3
26
  - Use the new SimpRepos directory layout when building an ISO using externally
@@ -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,6 +190,7 @@ module Simp::Rake::Build
190
190
  end
191
191
  end
192
192
 
193
+
193
194
  repo_target_dir = dir
194
195
 
195
196
  # If we've pulled in reposync directories, we expect them to
@@ -256,7 +257,14 @@ module Simp::Rake::Build
256
257
 
257
258
  # Pop the SIMP directory from the tarball into the correct spot
258
259
  # FIXME: This is a hack
259
- FileUtils.mv("#{dir}/SIMP", repo_target_dir) if File.directory?("#{dir}/SIMP")
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
260
268
 
261
269
  Dir.chdir("#{repo_target_dir}/SIMP") do
262
270
  # Add the SIMP Dependencies
@@ -301,8 +309,10 @@ module Simp::Rake::Build
301
309
  cp(rpm,rpm_arch, :verbose => verbose)
302
310
  end
303
311
 
304
- unless reposync_active
305
- ln_s('noarch', arch, :verbose => verbose) if (!File.directory?(arch) && File.directory?('noarch'))
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'))
306
316
  fail("Could not find architecture '#{arch}' in the SIMP distribution") unless (File.directory?(arch) || File.symlink?(arch))
307
317
 
308
318
  # Get everything set up properly...
@@ -320,6 +330,45 @@ module Simp::Rake::Build
320
330
  ln_sf(source_rpm,link_target, :verbose => verbose)
321
331
  end
322
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
340
+
341
+ # Create an Updates directory that is properly populated
342
+ updates_readme = <<~README
343
+ This directory houses updates to NON-MODULAR RPMs.
344
+
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})
365
+
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))
369
+ end
370
+
371
+ ln_sf(rpm, rpm_dest, :verbose => verbose)
323
372
  end
324
373
  end
325
374
 
@@ -372,9 +421,11 @@ module Simp::Rake::Build
372
421
  '-x ./lost+found',
373
422
  "-o #{@simp_output_iso}",
374
423
  dir
375
- ]
424
+ ].join(' ')
425
+
426
+ $stdout.puts "Running: #{mkisofs_cmd}"
376
427
 
377
- system(mkisofs_cmd.join(' '))
428
+ system(mkisofs_cmd)
378
429
  end
379
430
  end # End of tarfiles loop
380
431
 
@@ -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|
@@ -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.4'
5
+ VERSION = '5.13.0'
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
@@ -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.4
4
+ version: 5.13.0
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-10-06 00:00:00.000000000 Z
12
+ date: 2022-01-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: simp-beaker-helpers