simp-rake-helpers 4.1.1 → 5.0.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
  SHA1:
3
- metadata.gz: f75d80c343427ef7c599ede4745e3130fbbb139a
4
- data.tar.gz: 1b26121177b51da14a44b84eebf86bad97996160
3
+ metadata.gz: 6c00ca9b785a703a809b933b2466a10a93ce6b84
4
+ data.tar.gz: ef20f00f91346b70604ce682f7305eee2406ba9e
5
5
  SHA512:
6
- metadata.gz: 07f0e3a239091d9293de3d3fb882e42b0edd0f31348366298abad181905fb649e8b11cae4ac34fd81444edd557b71284e096fa1a5675b6fba68b66f12d872dba
7
- data.tar.gz: 3b9d4028fd866e73073f0d8b90460a7f25a4c57a1312b014abc678064ac7401b0f83d8863cd35a9ccbf61386b8248077db46c7b03e3e97b65c647f9f21a9e92b
6
+ metadata.gz: 736f27200e550c12e7d5f489a45d37a636af1df6318ac7f04837df3122298107e08242fc6859b29c0467fb815bcefa486a36c92995feedd33e6690ab680a8755
7
+ data.tar.gz: f5b19fd4ac8200bb365959b44ec4f6db2b0f920c88ec6763abda087be3c5772c5a7e4ff55f473dda3f365744ea45991575a204b05340be42e0b9b0e988083e8d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ### 5.0.0 / 2017-09-12
2
+ * Removed all 'mock' support
3
+ * Bound the build to only the OS upon which you are building
4
+ * Removed legacy support code
5
+ * Designed for use within a Docker environment
6
+ * Technically, you can install and run it inside mock but it's not
7
+ going to do any of the heavy lifting for you any longer
8
+ * Is *NOT* backwards compatible with anything for the most part
9
+ * Ensure that published RPMs are used before rebuilding
10
+ * Cleaned up the git checking of subdirectories
11
+
1
12
  ### 4.1.1 / 2017-08-31
2
13
  * Added the ability to read RPM release qualifier for checked out
3
14
  module from `simp-core/build/rpm/dependencies.yaml`
data/lib/simp/rake.rb CHANGED
@@ -8,6 +8,7 @@ module Simp::Rake
8
8
  require 'shellwords'
9
9
  require 'parallel'
10
10
  require 'tempfile'
11
+ require 'facter'
11
12
  require 'simp/rpm'
12
13
  require 'simp/rake/pkg'
13
14
 
@@ -98,27 +99,11 @@ module Simp::Rake
98
99
  # Originally snarfed from
99
100
  # http://stackoverflow.com/questions/2108727/which-in-ruby-checking-if-program-exists-in-path-from-ruby
100
101
  def which(cmd)
101
- File.executable?(cmd) and return cmd
102
+ command = Facter::Core::Execution.which(cmd)
102
103
 
103
- cmd = File.basename(cmd)
104
+ warn "Warning: Command #{cmd} not found on the system." unless command
104
105
 
105
- exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
106
- ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
107
- exts.each { |ext|
108
- exe = File.join(path, "#{cmd}#{ext}")
109
- return exe if File.executable? exe
110
- }
111
- end
112
-
113
- warn "Warning: Command #{cmd} not found on the system."
114
- return nil
115
- end
116
-
117
- # Return whether or not the user is in the mock group
118
- def validate_in_mock_group?
119
- if not %x{groups}.split.include?('mock')
120
- raise(Exception,"You need to be in the 'mock' group.")
121
- end
106
+ return command
122
107
  end
123
108
 
124
109
  def help
@@ -3,6 +3,7 @@
3
3
  require 'simp/rake'
4
4
  require 'json'
5
5
  require 'simp/rake/build/constants'
6
+ require 'simp/rake/helpers'
6
7
 
7
8
  include Simp::Rake
8
9
 
@@ -14,6 +15,58 @@ module Simp; end
14
15
  module Simp::Rake; end
15
16
  module Simp::Rake::Build
16
17
  class Auto < ::Rake::TaskLib
18
+
19
+ # Commands that are required by some part of the rake stack
20
+ BUILD_REQUIRED_COMMANDS = [
21
+ 'basename',
22
+ 'cat',
23
+ 'checkmodule',
24
+ 'chmod',
25
+ 'cp',
26
+ 'cpio',
27
+ 'createrepo',
28
+ 'date',
29
+ 'diff',
30
+ 'dirname',
31
+ 'file',
32
+ 'find',
33
+ 'gawk',
34
+ 'git',
35
+ 'gpg',
36
+ 'grep',
37
+ 'gzip',
38
+ 'install',
39
+ 'isoinfo',
40
+ 'm4',
41
+ 'make',
42
+ 'mkdir',
43
+ 'mktemp',
44
+ 'python',
45
+ 'readlink',
46
+ 'repoclosure',
47
+ 'rm',
48
+ 'rpm',
49
+ 'rpmbuild',
50
+ 'rpmdb',
51
+ 'rpmkeys',
52
+ 'rpmsign',
53
+ 'rpmspec',
54
+ 'sed',
55
+ 'semodule_package',
56
+ 'setfacl',
57
+ 'sh',
58
+ 'sort',
59
+ 'tail',
60
+ 'tar',
61
+ 'uname',
62
+ 'uniq',
63
+ 'wc',
64
+ 'which',
65
+ 'xargs',
66
+ 'yum',
67
+ 'yumdownloader'
68
+ ]
69
+
17
70
  include Simp::Rake::Build::Constants
18
71
 
19
72
  def initialize( run_dir )
@@ -26,522 +79,153 @@ module Simp::Rake::Build
26
79
  def define
27
80
  namespace :build do
28
81
 
29
- # SIMP 6 Style
30
- if @os_build_metadata
31
- desc <<-EOM
32
- Automatically detect and build a SIMP ISO for a target SIMP release.
33
-
34
- This task runs all other build tasks
35
-
36
- Arguments:
37
- * :iso_paths => Path to source ISO(s) and/or directories [Default: '.']
38
- NOTE: colon-delimited list
39
- If not set, will build all enabled distributions
40
- * :release => SIMP release to build (e.g., '6.X')
41
- The Full list can be found in '#{File.join(@build_dir, 'release_mappings.yaml')}'
42
- Default: #{[@simp_version.split('.').first, 'X'].join('.')}
43
- * :output_dir => path to write SIMP ISO. [Default: './SIMP_ISO']
44
- * :do_checksum => Use sha256sum checksum to compare each ISO. [Default: 'false']
45
- * :key_name => Key name to sign packages [Default: 'dev']
46
-
47
- ENV vars:
48
- - SIMP_BUILD_isos => Path to the base OS ISO images
49
- - SIMP_BUILD_distro => Distribution to build
50
- See '#{File.join(@distro_build_dir, 'build_metadata.yaml')}'}
51
- - SIMP_BUILD_prompt => 'no' disables asking questions.
52
- Will default to a full build and *will* erase existing artifacts.
53
- - SIMP_BUILD_staging_dir => Path to stage big build assets
54
- [Default: './SIMP_ISO_STAGING']
55
- - SIMP_BUILD_rm_staging_dir => 'no' do not forcibly remove the staging dir before starting
56
- - SIMP_BUILD_force_dirty => 'yes' tries to checks out subrepos even if dirty
57
- - SIMP_BUILD_docs => 'yes' builds & includes documentation
58
- - SIMP_BUILD_checkout => 'no' will skip the git repo checkouts
59
- - SIMP_BUILD_bundle => 'no' skips running bundle in each subrepo
60
- - SIMP_BUILD_unpack => 'no' skips the unpack section
61
- - SIMP_BUILD_unpack_merge => 'no' prevents auto-merging the unpacked DVD
62
- - SIMP_BUILD_prune => 'no' passes :prune=>false to iso:build
63
- - SIMP_BUILD_iso_name => Renames the output ISO filename [Default: false]
64
- - SIMP_BUILD_iso_tag => Appended to the output ISO's filename [Default: false]
65
- - SIMP_BUILD_verbose => 'yes' enables verbose reporting. [Default: 'no']
66
- - SIMP_BUILD_packer_vars => Write a packer vars.json to go with this ISO [Default: 'yes']
67
- - SIMP_BUILD_signing_key => The name of the GPG key to use to sign packages. [Default: 'dev']
68
- EOM
69
-
70
- task :auto, [:iso_paths,
71
- :release,
72
- :output_dir,
73
- :do_checksum,
74
- :key_name
75
- ] do |t, args|
76
-
77
- args.with_defaults(
78
- :iso_paths => ENV['SIMP_BUILD_isos'] || Dir.pwd,
79
- :distribution => 'ALL',
80
- :release => [@simp_version.split('.').first, 'X'].join('.'),
81
- :output_dir => '',
82
- :do_checksum => 'false',
83
- :key_name => ENV['SIMP_BUILD_signing_key'] || 'dev'
84
- )
85
-
86
- iso_paths = File.expand_path(args[:iso_paths])
87
- target_release = args[:release]
88
- do_checksum = (args.do_checksum = ~ /^$/ ? 'false' : args.do_checksum)
89
- key_name = args[:key_name]
90
- do_packer_vars = ENV.fetch('SIMP_BUILD_packer_vars', 'yes') == 'yes'
91
- verbose = ENV.fetch('SIMP_BUILD_verbose', 'no') == 'yes'
92
- prompt = ENV.fetch('SIMP_BUILD_prompt', 'yes') != 'no'
93
- method = ENV.fetch('SIMP_BUILD_puppetfile','tracking')
94
- do_rm_staging = ENV.fetch('SIMP_BUILD_rm_staging_dir', 'yes') == 'yes'
95
- do_docs = ENV['SIMP_BUILD_docs'] == 'yes' ? 'true' : 'false'
96
- do_merge = ENV['SIMP_BUILD_unpack_merge'] != 'no'
97
- do_prune = ENV['SIMP_BUILD_prune'] != 'no' ? 'true' : 'false'
98
- do_checkout = ENV['SIMP_BUILD_checkout'] != 'no'
99
- do_bundle = ENV['SIMP_BUILD_bundle'] == 'yes' ? true : false
100
- do_unpack = ENV['SIMP_BUILD_unpack'] != 'no'
101
- full_iso_name = ENV.fetch('SIMP_BUILD_iso_name', false)
102
- iso_name_tag = ENV.fetch('SIMP_BUILD_iso_tag', false)
103
-
104
- iso_status = {}
105
-
106
- @os_build_metadata['distributions'].keys.sort.each do |distro|
107
- @os_build_metadata['distributions'][distro].keys.sort.each do |version|
108
- unless @os_build_metadata['distributions'][distro][version]['build']
109
- if verbose
110
- $stderr.puts("Skipping build for #{distro} #{version}")
111
- end
112
-
113
- next
114
- end
115
-
116
- @os_build_metadata['distributions'][distro][version]['arch'].sort.each do |arch|
117
- tarball = false
118
- repo_root_dir = File.expand_path( @base_dir )
119
-
120
- begin
121
- distro_build_dir = File.join(@distro_build_dir, distro, version, arch)
122
-
123
- # For subtask mangling
124
- $simp6_build_dir = distro_build_dir
125
- $simp6_build_metadata = {
126
- :distro => distro,
127
- :version => version,
128
- :arch => arch
129
- }
130
-
131
- output_dir = args[:output_dir].sub(/^$/, File.expand_path( 'SIMP_ISO', distro_build_dir ))
132
-
133
- staging_dir = ENV.fetch('SIMP_BUILD_staging_dir', File.expand_path( 'SIMP_ISO_STAGING', distro_build_dir ))
134
-
135
- yaml_file = File.expand_path('release_mappings.yaml', distro_build_dir)
136
-
137
- tar_file = File.join(distro_build_dir, 'DVD_Overlay', "SIMP-#{@simp_version}-#{distro}-#{version}-#{arch}.tar.gz")
138
-
139
- if File.exist?(tar_file)
140
- if prompt
141
- valid_entry = false
142
- while !valid_entry do
143
- puts("Existing tar file found at #{tar_file}")
144
- print("Do you want to overwrite it? (y|N): ")
145
-
146
- resp = $stdin.gets.chomp
147
-
148
- if resp.empty? || (resp =~ /^(n|N)/)
149
- tarball = tar_file
150
- valid_entry = true
151
- elsif resp =~ /^(y|Y)/
152
- tarball = false
153
- valid_entry = true
154
-
155
- if verbose
156
- $stderr.puts("Notice: Overwriting existing tarball at #{tar_file}")
157
- $stderr.puts("Notice: PRESS CTRL-C WITHIN 5 SECONDS TO CANCEL")
158
- end
159
-
160
- sleep(5)
161
- else
162
- puts("Invalid input: '#{resp}', please try again")
163
- end
164
- end
165
- end
166
- end
167
-
168
- if tarball
169
- do_docs = false
170
- do_checkout = false
171
- do_bundle = false
172
- end
173
-
174
- @dirty_repos = nil
175
- @simp_output_iso = nil
176
-
177
- # Build environment sanity checks
178
- # --------------------
179
- if do_rm_staging && !do_unpack
180
- fail SIMPBuildException, "ERROR: Mixing `SIMP_BUILD_rm_staging_dir=yes` and `SIMP_BUILD_unpack=no` is silly."
181
- end
182
-
183
- if File.exists?(output_dir) && !File.directory?(output_dir)
184
- fail SIMPBuildException, "ERROR: ISO output dir exists but is not a directory:\n\n" +
185
- " '#{output_dir}'\n\n"
186
- end
187
-
188
- unless File.directory?(output_dir)
189
- FileUtils.mkdir_p(output_dir)
190
- end
82
+ desc <<-EOM
83
+ Automatically detect and build a SIMP ISO for a target SIMP release.
84
+
85
+ This task runs all other build tasks
86
+
87
+ Arguments:
88
+ * :iso_paths => Path to source ISO(s) and/or directories [Default: '.']
89
+ NOTE: colon-delimited list
90
+ If not set, will build all enabled distributions
91
+ * :release => SIMP release to build (e.g., '6.X')
92
+ The Full list can be found in '#{File.join(@build_dir, 'release_mappings.yaml')}'
93
+ Default: #{[@simp_version.split('.').first, 'X'].join('.')}
94
+ * :output_dir => path to write SIMP ISO. [Default: './SIMP_ISO']
95
+ * :do_checksum => Use sha256sum checksum to compare each ISO. [Default: 'false']
96
+ * :key_name => Key name to sign packages [Default: 'dev']
97
+
98
+ ENV vars:
99
+ - SIMP_BUILD_isos => Path to the base OS ISO images
100
+ - SIMP_BUILD_distro => Distribution to build
101
+ See '#{File.join(@distro_build_dir, 'build_metadata.yaml')}'}
102
+ - SIMP_BUILD_prompt => 'no' disables asking questions.
103
+ Will default to a full build and *will* erase existing artifacts.
104
+ - SIMP_BUILD_staging_dir => Path to stage big build assets
105
+ [Default: './SIMP_ISO_STAGING']
106
+ - SIMP_BUILD_rm_staging_dir => 'no' do not forcibly remove the staging dir before starting
107
+ - SIMP_BUILD_force_dirty => 'yes' tries to checks out subrepos even if dirty
108
+ - SIMP_BUILD_docs => 'yes' builds & includes documentation
109
+ - SIMP_BUILD_checkout => 'no' will skip the git repo checkouts
110
+ - SIMP_BUILD_bundle => 'no' skips running bundle in each subrepo
111
+ - SIMP_BUILD_unpack => 'no' skips the unpack section
112
+ - SIMP_BUILD_unpack_merge => 'no' prevents auto-merging the unpacked DVD
113
+ - SIMP_BUILD_prune => 'no' passes :prune=>false to iso:build
114
+ - SIMP_BUILD_iso_name => Renames the output ISO filename [Default: false]
115
+ - SIMP_BUILD_iso_tag => Appended to the output ISO's filename [Default: false]
116
+ - SIMP_BUILD_verbose => 'yes' enables verbose reporting. [Default: 'no']
117
+ - SIMP_BUILD_packer_vars => Write a packer vars.json to go with this ISO [Default: 'yes']
118
+ - SIMP_BUILD_signing_key => The name of the GPG key to use to sign packages. [Default: 'dev']
119
+ EOM
120
+
121
+ task :auto, [:iso_paths,
122
+ :release,
123
+ :output_dir,
124
+ :do_checksum,
125
+ :key_name
126
+ ] do |t, args|
127
+
128
+ Simp::Rake::Helpers.check_required_commands(BUILD_REQUIRED_COMMANDS)
129
+
130
+ args.with_defaults(
131
+ :iso_paths => ENV['SIMP_BUILD_isos'] || Dir.pwd,
132
+ :distribution => 'ALL',
133
+ :release => [@simp_version.split('.').first, 'X'].join('.'),
134
+ :output_dir => '',
135
+ :do_checksum => 'false',
136
+ :key_name => ENV['SIMP_BUILD_signing_key'] || 'dev'
137
+ )
138
+
139
+ iso_paths = File.expand_path(args[:iso_paths])
140
+ target_release = args[:release]
141
+ do_checksum = (args.do_checksum = ~ /^$/ ? 'false' : args.do_checksum)
142
+ key_name = args[:key_name]
143
+ do_packer_vars = ENV.fetch('SIMP_BUILD_packer_vars', 'yes') == 'yes'
144
+ verbose = ENV.fetch('SIMP_BUILD_verbose', 'no') == 'yes'
145
+ prompt = ENV.fetch('SIMP_BUILD_prompt', 'yes') != 'no'
146
+ method = ENV.fetch('SIMP_BUILD_puppetfile','tracking')
147
+ do_rm_staging = ENV.fetch('SIMP_BUILD_rm_staging_dir', 'yes') == 'yes'
148
+ do_docs = ENV['SIMP_BUILD_docs'] == 'yes' ? 'true' : 'false'
149
+ do_merge = ENV['SIMP_BUILD_unpack_merge'] != 'no'
150
+ do_prune = ENV['SIMP_BUILD_prune'] != 'no' ? 'true' : 'false'
151
+ do_checkout = ENV['SIMP_BUILD_checkout'] != 'no'
152
+ do_bundle = ENV['SIMP_BUILD_bundle'] == 'yes' ? true : false
153
+ do_unpack = ENV['SIMP_BUILD_unpack'] != 'no'
154
+ full_iso_name = ENV.fetch('SIMP_BUILD_iso_name', false)
155
+ iso_name_tag = ENV.fetch('SIMP_BUILD_iso_tag', false)
156
+
157
+ iso_status = {}
158
+
159
+ distro = @build_distro
160
+ version = @build_version
161
+ arch = @build_arch
162
+
163
+ tarball = false
164
+ repo_root_dir = File.expand_path( @base_dir )
165
+
166
+ fail("Cannot Build: No directory '#{@distro_build_dir}' found") unless File.directory?(@distro_build_dir)
167
+
168
+ begin
169
+ # For subtask mangling
170
+ $simp6_build_dir = @distro_build_dir
171
+ $simp6_build_metadata = {
172
+ :distro => distro,
173
+ :version => version,
174
+ :arch => arch
175
+ }
191
176
 
192
- # Look up ISOs against known build assets
193
- # --------------------
194
- target_data = get_target_data(target_release, iso_paths, yaml_file, do_checksum, verbose )
177
+ output_dir = args[:output_dir].sub(/^$/, File.expand_path( 'SIMP_ISO', @distro_build_dir ))
195
178
 
196
- simp6_mock_cfg = File.join($simp6_build_dir, 'mock.cfg')
179
+ staging_dir = ENV.fetch('SIMP_BUILD_staging_dir', File.expand_path( 'SIMP_ISO_STAGING', @distro_build_dir ))
197
180
 
198
- if File.exist?(simp6_mock_cfg)
199
- target_data['mock'] = simp6_mock_cfg
181
+ overlay_dir = File.join(@distro_build_dir, 'DVD_Overlay')
200
182
 
201
- if verbose
202
- $stderr.puts("Notice: Using mock config at #{simp6_mock_cfg}")
203
- end
204
- end
183
+ yaml_file = File.expand_path('release_mappings.yaml', @distro_build_dir)
205
184
 
206
- # check out subrepos
207
- # --------------------
208
- if do_checkout && !tarball
209
- puts
210
- puts '='*80
211
- puts "## Checking out subrepositories"
212
- puts
213
- puts " (skip with `SIMP_BUILD_checkout=no`)"
214
- puts '='*80
215
-
216
- Dir.chdir repo_root_dir
217
- Rake::Task['deps:status'].reenable
218
- Rake::Task['deps:status'].invoke
219
-
220
- if @dirty_repos && !ENV['SIMP_BUILD_force_dirty'] == 'yes'
221
- raise SIMPBuildException, "ERROR: Dirty repos detected! I refuse to destroy uncommitted work."
222
- else
223
- puts
224
- puts '-'*80
225
- puts "#### Checking out subrepositories using method '#{method}'"
226
- puts '-'*80
227
- Rake::Task['deps:checkout'].reenable
228
- Rake::Task['deps:checkout'].invoke(method)
229
- end
230
-
231
- if do_bundle
232
- puts
233
- puts '-'*80
234
- puts "#### Running bundler in all repos"
235
- puts ' (Disable with `SIMP_BUILD_bundle=no`)'
236
- puts '-'*80
237
- Rake::Task['build:bundle'].reenable
238
- Rake::Task['build:bundle'].invoke
239
- else
240
- puts
241
- puts '-'*80
242
- puts "#### SKIPPED: bundler in all repos"
243
- puts ' (Force with `SIMP_BUILD_bundle=yes`)'
244
- puts '-'*80
245
- end
246
- else
247
- puts
248
- puts '='*80
249
- puts "#### skipping sub repository checkout (because `SIMP_BUILD_checkout=no`)"
250
- puts
251
- end
185
+ tar_file = File.join(overlay_dir, "SIMP-#{@simp_version}-#{distro}-#{version}-#{arch}.tar.gz")
252
186
 
253
- # build tarball
254
- # --------------------
255
- if tarball
256
- puts
257
- puts '-'*80
258
- puts "#### Using pre-existing tarball:"
259
- puts " '#{tarball}'"
260
- puts
261
- puts '-'*80
262
-
263
- else
264
- puts
265
- puts '='*80
266
- puts "#### Running tar:build"
267
- puts '='*80
268
-
269
- # Horrible state passing magic vars
270
- $tarball_tgt = File.join(distro_build_dir, 'DVD_Overlay', "SIMP-#{@simp_version}-#{distro}-#{version}-#{arch}.tar.gz")
271
-
272
- Rake::Task['tar:build'].reenable
273
- Rake::Task['tar:build'].invoke(target_data['mock'],key_name,do_docs)
274
-
275
- tarball = $tarball_tgt
276
- end
187
+ $simp6_clean_dirs << output_dir
188
+ $simp6_clean_dirs << staging_dir
189
+ $simp6_clean_dirs << overlay_dir
277
190
 
278
- # yum sync
279
- # --------------------
280
- puts
281
- puts '-'*80
282
- puts "#### rake build:yum:sync[#{target_data['flavor']},#{target_data['os_version']}]"
283
- puts '-'*80
284
- Rake::Task['build:yum:sync'].reenable
285
- Rake::Task['build:yum:sync'].invoke(target_data['flavor'],target_data['os_version'])
286
-
287
- # If you have previously downloaded packages from yum, you may need to run
288
- # $ rake build:yum:clean_cache
289
-
290
- # Optionally, you may drop in custom packages you wish to have available during an install into build/yum_data/SIMP<simp_version>_<CentOS or RHEL><os_version>_<architecture>/packages
291
- # TODO: ENV var for optional packages
292
-
293
- prepare_staging_dir( staging_dir, do_rm_staging, repo_root_dir, verbose )
294
- Dir.chdir staging_dir
295
-
296
- #
297
- # --------------------
298
- if do_unpack
299
- puts
300
- puts '='*80
301
- puts "#### unpack ISOs into staging directory"
302
- puts " staging area: '#{staging_dir}'"
303
- puts
304
- puts " (skip with `SIMP_BUILD_unpack=no`)"
305
- puts '='*80
306
- puts
307
-
308
- Dir.glob( File.join(staging_dir, "#{target_data['flavor']}*/") ).each do |f|
309
- FileUtils.rm_f( f , :verbose => verbose )
310
- end
311
-
312
- target_data['isos'].each do |iso|
313
- puts "---- rake unpack[#{iso},#{do_merge},#{Dir.pwd},isoinfo,#{target_data['os_version']}]"
314
- Rake::Task['unpack'].reenable
315
- Rake::Task['unpack'].invoke(iso,do_merge,Dir.pwd,'isoinfo',target_data['os_version'])
316
- end
317
- else
318
- puts
319
- puts '='*80
320
- puts "#### skipping ISOs unpack (because `SIMP_BUILD_unpack=no`)"
321
- puts
322
- end
191
+ if File.exist?(tar_file)
192
+ if prompt
193
+ valid_entry = false
194
+ while !valid_entry do
195
+ puts("Existing tar file found at #{tar_file}")
196
+ print("Do you want to overwrite it? (y|N): ")
323
197
 
324
- Dir.chdir staging_dir
325
-
326
- puts
327
- puts '='*80
328
- puts "#### iso:build[#{tarball}, #{staging_dir}, #{do_prune}]"
329
- puts '='*80
330
- puts
331
-
332
- ENV['SIMP_ISO_verbose'] = 'yes' if verbose
333
- ENV['SIMP_PKG_verbose'] = 'yes' if verbose
334
- Rake::Task['iso:build'].reenable
335
- Rake::Task['iso:build'].invoke(tarball,staging_dir,do_prune)
336
-
337
- _isos = Dir[ File.join(staging_dir, 'SIMP-*.iso') ]
338
- if _isos.size == 0
339
- fail "ERROR: No SIMP ISOs found in '#{staging_dir}'"
340
- elsif _isos.size > 1
341
- warn "WARNING: More than one SIMP ISO found in '#{staging_dir}'"
342
- _isos.each{ |i| warn i }
343
- end
198
+ resp = $stdin.gets.chomp
344
199
 
345
- # NOTE: It is possible at this point (given the right
346
- # `SIMP_BUILD_xxx=no` flags) that iso:build will not have set
347
- # `@simp_output_iso`. In that case, look at the ISOs in the staging
348
- # dir (there should only be one) and take our best guess.
349
- if @simp_output_iso.nil?
350
- @simp_output_iso = File.basename(_isos.first)
351
- end
200
+ if resp.empty? || (resp =~ /^(n|N)/)
201
+ tarball = tar_file
202
+ valid_entry = true
203
+ elsif resp =~ /^(y|Y)/
204
+ tarball = false
205
+ valid_entry = true
352
206
 
353
- output_file = full_iso_name ? full_iso_name : @simp_output_iso
354
- if iso_name_tag
355
- output_file = output_file.sub(/\.iso$/i, "__#{iso_name_tag}.iso")
207
+ if verbose
208
+ $stderr.puts("Notice: Overwriting existing tarball at #{tar_file}")
209
+ $stderr.puts("Notice: PRESS CTRL-C WITHIN 5 SECONDS TO CANCEL")
356
210
  end
357
211
 
358
- puts
359
- puts '='*80
360
- puts "#### Moving '#{@simp_output_iso}' into:"
361
- puts " '#{output_dir}/#{output_file}'"
362
- puts '='*80
363
- puts
364
-
365
- iso = File.join(output_dir,output_file)
366
- FileUtils.mkdir_p File.dirname(iso), :verbose => verbose
367
- FileUtils.mv(@simp_output_iso, iso, :verbose => verbose)
368
-
369
- # write vars.json for packer build
370
- # --------------------------------------
371
- vars_file = iso.sub(/.iso$/, '.json')
372
- puts
373
- puts '='*80
374
- puts "#### Checksumming #{iso}..."
375
- puts '='*80
376
- puts
377
-
378
- sum = `sha256sum "#{iso}"`.split(/ +/).first
379
-
380
- puts
381
- puts '='*80
382
- puts "#### Writing packer data to:"
383
- puts " '#{vars_file}'"
384
- puts '='*80
385
- puts
386
- box_distro_release = "SIMP-#{target_release}-#{File.basename(target_data['isos'].first).sub(/\.iso$/,'').sub(/-x86_64/,'')}"
387
- packer_vars = {
388
- 'box_simp_release' => target_release,
389
- 'box_distro_release' => box_distro_release,
390
- 'iso_url' => iso,
391
- 'iso_checksum' => sum,
392
- 'iso_checksum_type' => 'sha256',
393
- 'new_password' => 'suP3rP@ssw0r!suP3rP@ssw0r!suP3rP@ssw0r!',
394
- 'output_directory' => './OUTPUT',
395
- }
396
- File.open(vars_file, 'w'){|f| f.puts packer_vars.to_json }
397
-
398
- puts
399
- puts '='*80
400
- puts "#### FINIS!"
401
- puts '='*80
402
- puts
403
-
404
- iso_status[[distro, version, arch].join(' ')] = {
405
- 'success' => true
406
- }
407
-
408
- rescue => e
409
- iso_status[[distro, version, arch].join(' ')] = {
410
- 'success' => false,
411
- 'error' => e.to_s,
412
- 'backtrace' => e.backtrace
413
- }
212
+ sleep(5)
213
+ else
214
+ puts("Invalid input: '#{resp}', please try again")
414
215
  end
415
216
  end
416
217
  end
417
218
  end
418
219
 
419
- successful_isos = []
420
- failed_isos = []
421
-
422
- iso_status.keys.each do |iso|
423
- if iso_status[iso]['success']
424
- successful_isos << iso
425
- else
426
- failed_isos << iso
427
- end
428
- end
429
-
430
- unless successful_isos.empty?
431
- puts '='*80
432
- puts '='*80
433
- puts("Successful ISOs:")
434
- puts(%( * #{successful_isos.join("\n * ")}))
435
- end
436
-
437
- unless failed_isos.empty?
438
- puts '='*80
439
- puts("Failed ISOs:")
440
- failed_isos.each do |iso|
441
- puts(%( * #{iso}))
442
- puts(%( * Error: #{iso_status[iso]['error']}))
443
-
444
- if verbose
445
- puts(%( * Backtrace: #{iso_status[iso]['backtrace'].join("\n")}))
446
- else
447
- puts(%( * Context: #{iso_status[iso]['backtrace'].first}))
448
- end
449
- end
450
- end
451
- end
452
- else
453
- # Legacy
454
- desc <<-EOM
455
- Automatically detect and build a SIMP ISO for a target SIMP release.
456
-
457
- This task runs all other build tasks
458
-
459
- Arguments:
460
- * :release => SIMP release to build (e.g., '5.1.X')
461
- - :iso_paths => path to source ISO(s) and/or directories [Default: '.']
462
- NOTE: colon-delimited list
463
- - :tarball => SIMP build tarball file; if given, skips tar build. [Default: 'false']
464
- - :output_dir => path to write SIMP ISO. [Default: './SIMP_ISO']
465
- - :do_checksum => Use sha256sum checksum to compare each ISO. [Default: 'false']
466
- - :key_name => Key name to sign packages [Default: 'dev']
467
-
468
- ENV vars:
469
- - SIMP_BUILD_staging_dir => Path to stage big build assets
470
- [Default: './SIMP_ISO_STAGING']
471
- - SIMP_BUILD_rm_staging_dir => 'yes' forcibly removes the staging dir before starting
472
- - SIMP_BUILD_force_dirty => 'yes' tries to checks out subrepos even if dirty
473
- - SIMP_BUILD_docs => 'yes' builds & includes documentation
474
- - SIMP_BUILD_checkout => 'no' will skip the git repo checkouts
475
- - SIMP_BUILD_bundle => 'no' skips running bundle in each subrepo
476
- - SIMP_BUILD_unpack => 'no' skips the unpack section
477
- - SIMP_BUILD_unpack_merge => 'no' prevents auto-merging the unpacked DVD
478
- - SIMP_BUILD_prune => 'no' passes :prune=>false to iso:build
479
- - SIMP_BUILD_iso_name => Renames the output ISO filename [Default: false]
480
- - SIMP_BUILD_iso_tag => Appended to the output ISO's filename [Default: false]
481
- - SIMP_BUILD_verbose => 'yes' enables verbose reporting. [Default: 'no']
482
- - SIMP_BUILD_packer_vars => Write a packer vars.json to go with this ISO [Default: 'yes']
483
-
484
- Notes:
485
- - To skip `tar:build` (including `pkg:build`), use the `tarball` argument
486
- EOM
487
-
488
- task :auto, [:release,
489
- :iso_paths,
490
- :tarball,
491
- :output_dir,
492
- :do_checksum,
493
- :key_name,
494
- :packer_vars,
495
- ] do |t, args|
496
- # set up data
497
- # --------------------------------------------------------------------------
498
-
499
- args.with_defaults(
500
- :release => [@simp_version.split('.').first, 'X'].join('.'),
501
- :iso_paths => Dir.pwd,
502
- :tarball => 'false',
503
- :output_dir => '',
504
- :do_checksum => 'false',
505
- :key_name => 'dev',
506
- )
507
-
508
- # locals
509
- target_release = args[:release]
510
- iso_paths = File.expand_path(args[:iso_paths])
511
- tarball = (args.tarball =~ /^(false|)$/ ? false : args.tarball)
512
- output_dir = args[:output_dir].sub(/^$/, File.expand_path( 'SIMP_ISO', Dir.pwd ))
513
- do_checksum = (args.do_checksum =~ /^$/ ? 'false' : args.do_checksum)
514
- key_name = args[:key_name]
515
- staging_dir = ENV.fetch('SIMP_BUILD_staging_dir',
516
- File.expand_path( 'SIMP_ISO_STAGING', Dir.pwd ))
517
- do_packer_vars = ENV.fetch('SIMP_BUILD_packer_vars', 'yes') == 'yes'
518
- verbose = ENV.fetch('SIMP_BUILD_verbose', 'no') == 'yes'
519
-
520
- yaml_file = File.expand_path('build/release_mappings.yaml', @base_dir)
521
- pwd = Dir.pwd
522
- repo_root_dir = File.expand_path( @base_dir )
523
- method = ENV.fetch('SIMP_BUILD_puppetfile','tracking')
524
- do_rm_staging = ENV['SIMP_BUILD_rm_staging_dir'] == 'yes'
525
- do_docs = ENV['SIMP_BUILD_docs'] == 'yes' ? 'true' : 'false'
526
- do_merge = ENV['SIMP_BUILD_unpack_merge'] != 'no'
527
- do_prune = ENV['SIMP_BUILD_prune'] != 'no' ? 'true' : 'false'
528
- do_checkout = ENV['SIMP_BUILD_checkout'] != 'no'
529
- do_bundle = ENV['SIMP_BUILD_bundle'] == 'yes' ? true : false
530
- do_unpack = ENV['SIMP_BUILD_unpack'] != 'no'
531
- full_iso_name = ENV.fetch('SIMP_BUILD_iso_name', false)
532
- iso_name_tag = ENV.fetch('SIMP_BUILD_iso_tag', false)
533
-
534
- # Skip a bunch of unnecessary stuff if we're passed a tarball
535
220
  if tarball
536
- do_docs = false
221
+ do_docs = false
537
222
  do_checkout = false
538
- do_bundle = false
223
+ do_bundle = false
539
224
  end
540
225
 
541
226
  @dirty_repos = nil
542
227
  @simp_output_iso = nil
543
228
 
544
-
545
229
  # Build environment sanity checks
546
230
  # --------------------
547
231
  if do_rm_staging && !do_unpack
@@ -553,16 +237,14 @@ module Simp::Rake::Build
553
237
  " '#{output_dir}'\n\n"
554
238
  end
555
239
 
240
+ unless File.directory?(output_dir)
241
+ FileUtils.mkdir_p(output_dir)
242
+ end
556
243
 
557
244
  # Look up ISOs against known build assets
558
245
  # --------------------
559
246
  target_data = get_target_data(target_release, iso_paths, yaml_file, do_checksum, verbose )
560
247
 
561
- # Quick map to match the filenames in the build structures
562
- target_data['flavor'] = 'RHEL' if target_data['flavor'] == 'RedHat'
563
-
564
- # IDEA: check for prequisite build tools
565
-
566
248
  # check out subrepos
567
249
  # --------------------
568
250
  if do_checkout && !tarball
@@ -572,8 +254,11 @@ module Simp::Rake::Build
572
254
  puts
573
255
  puts " (skip with `SIMP_BUILD_checkout=no`)"
574
256
  puts '='*80
257
+
575
258
  Dir.chdir repo_root_dir
259
+ Rake::Task['deps:status'].reenable
576
260
  Rake::Task['deps:status'].invoke
261
+
577
262
  if @dirty_repos && !ENV['SIMP_BUILD_force_dirty'] == 'yes'
578
263
  raise SIMPBuildException, "ERROR: Dirty repos detected! I refuse to destroy uncommitted work."
579
264
  else
@@ -581,6 +266,7 @@ module Simp::Rake::Build
581
266
  puts '-'*80
582
267
  puts "#### Checking out subrepositories using method '#{method}'"
583
268
  puts '-'*80
269
+ Rake::Task['deps:checkout'].reenable
584
270
  Rake::Task['deps:checkout'].invoke(method)
585
271
  end
586
272
 
@@ -590,6 +276,7 @@ module Simp::Rake::Build
590
276
  puts "#### Running bundler in all repos"
591
277
  puts ' (Disable with `SIMP_BUILD_bundle=no`)'
592
278
  puts '-'*80
279
+ Rake::Task['build:bundle'].reenable
593
280
  Rake::Task['build:bundle'].invoke
594
281
  else
595
282
  puts
@@ -620,10 +307,12 @@ module Simp::Rake::Build
620
307
  puts '='*80
621
308
  puts "#### Running tar:build"
622
309
  puts '='*80
310
+
623
311
  # Horrible state passing magic vars
624
- $tarball_tgt = File.join(@base_dir, 'build', 'DVD_Overlay', "SIMP-#{@simp_version}-#{target_data['flavor']}-#{target_data['os_version']}.tar.gz")
312
+ $tarball_tgt = File.join(@distro_build_dir, 'DVD_Overlay', "SIMP-#{@simp_version}-#{distro}-#{version}-#{arch}.tar.gz")
625
313
 
626
- Rake::Task['tar:build'].invoke(target_data['mock'],key_name,do_docs)
314
+ Rake::Task['tar:build'].reenable
315
+ Rake::Task['tar:build'].invoke(key_name,do_docs)
627
316
 
628
317
  tarball = $tarball_tgt
629
318
  end
@@ -634,6 +323,7 @@ module Simp::Rake::Build
634
323
  puts '-'*80
635
324
  puts "#### rake build:yum:sync[#{target_data['flavor']},#{target_data['os_version']}]"
636
325
  puts '-'*80
326
+ Rake::Task['build:yum:sync'].reenable
637
327
  Rake::Task['build:yum:sync'].invoke(target_data['flavor'],target_data['os_version'])
638
328
 
639
329
  # If you have previously downloaded packages from yum, you may need to run
@@ -673,24 +363,24 @@ module Simp::Rake::Build
673
363
  puts
674
364
  end
675
365
 
676
- Dir.chdir repo_root_dir
366
+ Dir.chdir staging_dir
677
367
 
678
368
  puts
679
369
  puts '='*80
680
- puts "#### iso:build[#{tarball}]"
370
+ puts "#### iso:build[#{tarball}, #{staging_dir}, #{do_prune}]"
681
371
  puts '='*80
682
372
  puts
683
373
 
684
374
  ENV['SIMP_ISO_verbose'] = 'yes' if verbose
685
375
  ENV['SIMP_PKG_verbose'] = 'yes' if verbose
376
+ Rake::Task['iso:build'].reenable
686
377
  Rake::Task['iso:build'].invoke(tarball,staging_dir,do_prune)
687
378
 
688
-
689
- _isos = Dir[ File.join(Dir.pwd,'SIMP-*.iso') ]
379
+ _isos = Dir[ File.join(staging_dir, 'SIMP-*.iso') ]
690
380
  if _isos.size == 0
691
- fail "ERROR: No SIMP ISOs found in '#{Dir.pwd}'"
381
+ fail "ERROR: No SIMP ISOs found in '#{staging_dir}'"
692
382
  elsif _isos.size > 1
693
- warn "WARNING: More than one SIMP ISO found in '#{Dir.pwd}'"
383
+ warn "WARNING: More than one SIMP ISO found in '#{staging_dir}'"
694
384
  _isos.each{ |i| warn i }
695
385
  end
696
386
 
@@ -752,6 +442,52 @@ module Simp::Rake::Build
752
442
  puts "#### FINIS!"
753
443
  puts '='*80
754
444
  puts
445
+
446
+ iso_status[[distro, version, arch].join(' ')] = {
447
+ 'success' => true
448
+ }
449
+
450
+ rescue => e
451
+ iso_status[[distro, version, arch].join(' ')] = {
452
+ 'success' => false,
453
+ 'error' => e.to_s,
454
+ 'backtrace' => e.backtrace
455
+ }
456
+ end
457
+
458
+ successful_isos = []
459
+ failed_isos = []
460
+
461
+ iso_status.keys.each do |iso|
462
+ if iso_status[iso]['success']
463
+ successful_isos << iso
464
+ else
465
+ failed_isos << iso
466
+ end
467
+ end
468
+
469
+ unless successful_isos.empty?
470
+ puts '='*80
471
+ puts '='*80
472
+ puts("Successful ISOs:")
473
+ puts(%( * #{successful_isos.join("\n * ")}))
474
+ end
475
+
476
+ unless failed_isos.empty?
477
+ puts '='*80
478
+ puts("Failed ISOs:")
479
+ failed_isos.each do |iso|
480
+ puts(%( * #{iso}))
481
+ puts(%( * Error: #{iso_status[iso]['error']}))
482
+
483
+ if verbose
484
+ puts(%( * Backtrace: #{iso_status[iso]['backtrace'].join("\n")}))
485
+ else
486
+ puts(%( * Context: #{iso_status[iso]['backtrace'].first}))
487
+ end
488
+ end
489
+
490
+ exit(1)
755
491
  end
756
492
  end
757
493
  end
@@ -820,4 +556,3 @@ module Simp::Rake::Build
820
556
  end
821
557
  end
822
558
  end
823
-