simp-rake-helpers 3.0.2 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/simp/rake/build/auto.rb +673 -253
- data/lib/simp/rake/build/build.rb +63 -27
- data/lib/simp/rake/build/clean.rb +5 -1
- data/lib/simp/rake/build/code.rb +24 -24
- data/lib/simp/rake/build/constants.rb +94 -15
- data/lib/simp/rake/build/deps.rb +2 -0
- data/lib/simp/rake/build/helpers.rb +1 -1
- data/lib/simp/rake/build/iso.rb +34 -13
- data/lib/simp/rake/build/pkg.rb +162 -141
- data/lib/simp/rake/build/spec.rb +13 -6
- data/lib/simp/rake/build/tar.rb +62 -21
- data/lib/simp/rake/build/unpack.rb +5 -4
- data/lib/simp/rake/build/upload.rb +11 -5
- data/lib/simp/rake/helpers/version.rb +1 -1
- data/lib/simp/rake/pkg.rb +135 -60
- data/lib/simp/rpm.rb +16 -3
- metadata +65 -65
@@ -5,7 +5,7 @@ require 'simp/rake/build/constants'
|
|
5
5
|
module Simp; end
|
6
6
|
module Simp::Rake; end
|
7
7
|
module Simp::Rake::Build
|
8
|
-
class SIMPBuildException <
|
8
|
+
class SIMPBuildException < StandardError
|
9
9
|
end
|
10
10
|
|
11
11
|
include Simp::Rake
|
@@ -15,12 +15,19 @@ module Simp::Rake::Build
|
|
15
15
|
|
16
16
|
def initialize( base_dir )
|
17
17
|
init_member_vars( base_dir )
|
18
|
+
|
18
19
|
define_tasks
|
19
20
|
end
|
20
21
|
|
21
22
|
# define rake tasks
|
22
23
|
def define_tasks
|
23
24
|
namespace :build do
|
25
|
+
task :prep do
|
26
|
+
if $simp6
|
27
|
+
@build_dir = $simp6_build_dir
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
24
31
|
desc <<-EOM
|
25
32
|
Run bundle at every level of the project.
|
26
33
|
|
@@ -33,7 +40,7 @@ module Simp::Rake::Build
|
|
33
40
|
* :verbose => Enable verbose reporting. Default => 'false'
|
34
41
|
EOM
|
35
42
|
|
36
|
-
task :bundle, [:action, :verbose, :method] do |t, args|
|
43
|
+
task :bundle, [:action, :verbose, :method] => [:prep] do |t, args|
|
37
44
|
args.with_defaults(:action => 'install')
|
38
45
|
args.with_defaults(:verbose => 'false')
|
39
46
|
args.with_defaults(:method => 'tracking')
|
@@ -84,8 +91,22 @@ module Simp::Rake::Build
|
|
84
91
|
end
|
85
92
|
|
86
93
|
namespace :yum do
|
87
|
-
|
88
|
-
|
94
|
+
task :prep do
|
95
|
+
if $simp6
|
96
|
+
@build_dir = $simp6_build_dir
|
97
|
+
|
98
|
+
unless @build_dir
|
99
|
+
if ENV['SIMP_BUILD_yum_dir'] && File.exist?(File.join(ENV['SIMP_BUILD_yum_dir'], 'yum_data'))
|
100
|
+
@build_dir = ENV['SIMP_BUILD_yum_dir']
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
raise('Error: For SIMP 6+ builds, you need to set SIMP_BUILD_yum_dir to the directory holding the "yum_data" directory that you wish to sync') unless @build_dir
|
105
|
+
end
|
106
|
+
|
107
|
+
@build_base_dir = File.join(@build_dir,'yum_data')
|
108
|
+
@build_arch = 'x86_64'
|
109
|
+
end
|
89
110
|
|
90
111
|
##############################################################################
|
91
112
|
# Helpers
|
@@ -114,20 +135,24 @@ module Simp::Rake::Build
|
|
114
135
|
# Return the target directory
|
115
136
|
# Expects one argument wich is the 'arguments' hash to one of the tasks.
|
116
137
|
def get_target_dir(args)
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
@
|
129
|
-
|
130
|
-
|
138
|
+
if $simp6
|
139
|
+
return @build_base_dir
|
140
|
+
else
|
141
|
+
fail("Error: You must specify 'os'") unless args[:os]
|
142
|
+
fail("Error: You must specify 'os_version'") unless args[:os_version]
|
143
|
+
fail("Error: You must specify both major and minor version for the OS") unless args[:os_version] =~ /^.+\..+$/
|
144
|
+
fail("Error: You must specify 'simp_version'") unless args[:simp_version]
|
145
|
+
fail("Error: You must specify 'arch'") unless args[:arch]
|
146
|
+
|
147
|
+
# Yes, this is a kluge but the amount of variable passing that would need
|
148
|
+
# to be done to support this is silly.
|
149
|
+
@build_arch = args[:arch]
|
150
|
+
|
151
|
+
return File.join(
|
152
|
+
@build_base_dir,
|
153
|
+
"SIMP#{args[:simp_version]}_#{args[:os]}#{args[:os_version]}_#{args[:arch]}"
|
154
|
+
)
|
155
|
+
end
|
131
156
|
end
|
132
157
|
|
133
158
|
# Return where YUM finds the passed RPM
|
@@ -192,7 +217,7 @@ module Simp::Rake::Build
|
|
192
217
|
puts("Downloading: #{full_pkg}")
|
193
218
|
unless @use_yumdownloader
|
194
219
|
%x(curl -L --max-redirs 10 -s -o "#{full_pkg}" -k "#{source}")
|
195
|
-
|
220
|
+
if File.exist?(full_pkg) && !%x(file #{full_pkg}).include?('RPM')
|
196
221
|
@use_yumdownloader = true
|
197
222
|
FileUtils.rm(full_pkg)
|
198
223
|
end
|
@@ -200,6 +225,11 @@ module Simp::Rake::Build
|
|
200
225
|
|
201
226
|
if @use_yumdownloader
|
202
227
|
%x(yumdownloader -c #{yum_conf} #{File.basename(full_pkg,'.rpm')} 2>/dev/null )
|
228
|
+
|
229
|
+
if File.exist?(full_pkg) && !%x(file #{full_pkg}).include?('RPM')
|
230
|
+
@use_yumdownloader = true
|
231
|
+
FileUtils.rm(full_pkg)
|
232
|
+
end
|
203
233
|
end
|
204
234
|
|
205
235
|
unless $?.success?
|
@@ -231,7 +261,7 @@ module Simp::Rake::Build
|
|
231
261
|
|
232
262
|
if clean
|
233
263
|
errmsg += ', removing'
|
234
|
-
FileUtils.rm(rpm)
|
264
|
+
FileUtils.rm(rpm) if File.exist?(rpm)
|
235
265
|
end
|
236
266
|
|
237
267
|
raise(SIMPBuildException,errmsg)
|
@@ -334,7 +364,7 @@ module Simp::Rake::Build
|
|
334
364
|
# Update the packages.yaml and packages/ directories
|
335
365
|
# * target_dir => The actual distribution directory where packages.yaml and
|
336
366
|
# packages/ reside.
|
337
|
-
def update_packages(target_dir,bootstrap=false)
|
367
|
+
def update_packages(target_dir, bootstrap=false)
|
338
368
|
# This really should never happen....
|
339
369
|
unless File.directory?(target_dir)
|
340
370
|
fail <<-EOM
|
@@ -483,6 +513,8 @@ module Simp::Rake::Build
|
|
483
513
|
failed_updates.keys.sort.each do |k|
|
484
514
|
$stderr.puts(" * #{k} => #{failed_updates[k]}")
|
485
515
|
end
|
516
|
+
|
517
|
+
raise('Could not update all packages')
|
486
518
|
end
|
487
519
|
end
|
488
520
|
end
|
@@ -559,7 +591,7 @@ module Simp::Rake::Build
|
|
559
591
|
|
560
592
|
* :arch - The architecture that you support. Default: x86_64
|
561
593
|
EOM
|
562
|
-
task :scaffold,[:os,:os_version,:simp_version,:arch] do |t,args|
|
594
|
+
task :scaffold,[:os,:os_version,:simp_version,:arch] => [:prep] do |t,args|
|
563
595
|
# @simp_version is set in the main Rakefile
|
564
596
|
args.with_defaults(:simp_version => @simp_version.split('-').first)
|
565
597
|
args.with_defaults(:arch => @build_arch)
|
@@ -572,8 +604,12 @@ module Simp::Rake::Build
|
|
572
604
|
end
|
573
605
|
|
574
606
|
# Put together the rest of the scaffold directories
|
575
|
-
Dir.chdir(@
|
576
|
-
|
607
|
+
Dir.chdir(@build_base_dir) do
|
608
|
+
if $simp6
|
609
|
+
mkdir('../my_repos') unless File.exist?('../my_repos')
|
610
|
+
else
|
611
|
+
mkdir('my_repos') unless File.exist?('my_repos')
|
612
|
+
end
|
577
613
|
end
|
578
614
|
|
579
615
|
Dir.chdir(target_dir) do
|
@@ -597,7 +633,7 @@ module Simp::Rake::Build
|
|
597
633
|
|
598
634
|
* :arch - The architecture that you support. Default: x86_64
|
599
635
|
EOM
|
600
|
-
task :sync,[:os,:os_version,:simp_version,:arch] => [:scaffold] do |t,args|
|
636
|
+
task :sync,[:os,:os_version,:simp_version,:arch] => [:prep, :scaffold] do |t,args|
|
601
637
|
# @simp_version is set in the main Rakefile
|
602
638
|
args.with_defaults(:simp_version => @simp_version.split('-').first)
|
603
639
|
args.with_defaults(:arch => @build_arch)
|
@@ -622,7 +658,7 @@ module Simp::Rake::Build
|
|
622
658
|
|
623
659
|
* :arch - The architecture that you support. Default: x86_64
|
624
660
|
EOM
|
625
|
-
task :diff,[:os,:os_version,:simp_version,:arch] => [:scaffold] do |t,args|
|
661
|
+
task :diff,[:os,:os_version,:simp_version,:arch] => [:prep, :scaffold] do |t,args|
|
626
662
|
args.with_defaults(:simp_version => @simp_version.split('-').first)
|
627
663
|
args.with_defaults(:arch => @build_arch)
|
628
664
|
|
@@ -688,7 +724,7 @@ module Simp::Rake::Build
|
|
688
724
|
|
689
725
|
* :arch - The architecture that you support. Default: x86_64
|
690
726
|
EOM
|
691
|
-
task :fetch,[:pkg,:os,:os_version,:simp_version,:arch] => [:scaffold] do |t,args|
|
727
|
+
task :fetch,[:pkg,:os,:os_version,:simp_version,:arch] => [:prep, :clean_cache, :scaffold] do |t,args|
|
692
728
|
args.with_defaults(:simp_version => @simp_version.split('-').first)
|
693
729
|
args.with_defaults(:arch => @build_arch)
|
694
730
|
|
@@ -21,6 +21,10 @@ module Simp::Rake::Build
|
|
21
21
|
"#{@base_dir}/SIMP_ISO*"
|
22
22
|
)
|
23
23
|
|
24
|
+
if $simp6_build_dirs
|
25
|
+
::CLEAN.include($simp6_clean_dirs)
|
26
|
+
end
|
27
|
+
|
24
28
|
::CLOBBER.include(
|
25
29
|
@dist_dir,
|
26
30
|
"#{@build_dir}/build_keys/dev",
|
@@ -35,7 +39,7 @@ module Simp::Rake::Build
|
|
35
39
|
|
36
40
|
mock_dirs = Dir.glob("/var/lib/mock/*").map{|x| x = File.basename(x) }
|
37
41
|
|
38
|
-
|
42
|
+
unless ( mock_dirs.empty? or args.chroot )
|
39
43
|
$stderr.puts "Notice: You must pass a Mock chroot to erase a specified build root."
|
40
44
|
end
|
41
45
|
|
data/lib/simp/rake/build/code.rb
CHANGED
@@ -16,14 +16,13 @@ module Simp::Rake::Build
|
|
16
16
|
|
17
17
|
def define_tasks
|
18
18
|
namespace :code do
|
19
|
-
|
20
19
|
desc "Show some basic stats. Uses git to figure out what has changed.
|
21
20
|
* :since - Do not include any stats before this date.
|
22
21
|
* :until - Do not include any stats after this date."
|
23
22
|
task :stats,[:since,:until] do |t,args|
|
24
23
|
cur_branch = %x{git rev-parse --abbrev-ref HEAD}.chomp
|
25
24
|
|
26
|
-
if cur_branch.empty?
|
25
|
+
if cur_branch.empty?
|
27
26
|
fail "Error: Could not find branch ID!"
|
28
27
|
end
|
29
28
|
|
@@ -33,15 +32,15 @@ module Simp::Rake::Build
|
|
33
32
|
|
34
33
|
cmd = "git log --shortstat --reverse --pretty=oneline"
|
35
34
|
|
36
|
-
if args.since
|
35
|
+
if args.since
|
37
36
|
cmd = cmd + " --since=#{args.since}"
|
38
37
|
end
|
39
|
-
if args.until
|
38
|
+
if args.until
|
40
39
|
cmd = cmd + " --until=#{args.until}"
|
41
40
|
end
|
42
41
|
|
43
42
|
%x{#{cmd}}.each_line do |line|
|
44
|
-
if encode_line(line) =~ /(\d+) files changed, (\d+) insertions\(\+\), (\d+) del.*/
|
43
|
+
if encode_line(line) =~ /(\d+) files changed, (\d+) insertions\(\+\), (\d+) del.*/
|
45
44
|
changed = changed + $1.to_i
|
46
45
|
new = new + $2.to_i
|
47
46
|
removed = removed + $3.to_i
|
@@ -50,15 +49,15 @@ module Simp::Rake::Build
|
|
50
49
|
|
51
50
|
cmd = "git submodule foreach git log --shortstat --reverse --pretty=oneline"
|
52
51
|
|
53
|
-
if args.since
|
52
|
+
if args.since
|
54
53
|
cmd = cmd + " --since=#{args.since}"
|
55
54
|
end
|
56
|
-
if args.until
|
55
|
+
if args.until
|
57
56
|
cmd = cmd + " --until=#{args.until}"
|
58
57
|
end
|
59
58
|
|
60
59
|
%x{#{cmd}}.each_line do |line|
|
61
|
-
if encode_line(line) =~ /(\d+) files changed, (\d+) insertions\(\+\), (\d+) del.*/
|
60
|
+
if encode_line(line) =~ /(\d+) files changed, (\d+) insertions\(\+\), (\d+) del.*/
|
62
61
|
changed = changed + $1.to_i
|
63
62
|
new = new + $2.to_i
|
64
63
|
removed = removed + $3.to_i
|
@@ -88,7 +87,7 @@ module Simp::Rake::Build
|
|
88
87
|
loc["other"] = 0
|
89
88
|
|
90
89
|
File.open("#{SRC_DIR}/../Rakefile","r").each do |line|
|
91
|
-
if encode_line(line) !~ /^\s*$/
|
90
|
+
if encode_line(line) !~ /^\s*$/
|
92
91
|
loc["rake"] = loc["rake"] + 1
|
93
92
|
end
|
94
93
|
end.close
|
@@ -96,26 +95,27 @@ module Simp::Rake::Build
|
|
96
95
|
other_ext = Array.new
|
97
96
|
|
98
97
|
Find.find(SRC_DIR) do |path|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
98
|
+
if (
|
99
|
+
( File.basename(path)[0] == ?. ) or
|
100
|
+
( path =~ /src\/rsync/ ) or
|
101
|
+
( path[-3..-1] =~ /\.gz|pem|pub/ ) or
|
102
|
+
( path =~ /developers_guide\/rdoc/ )
|
103
|
+
)
|
104
|
+
Find.prune
|
105
|
+
else
|
106
|
+
next if FileTest.symlink?(path) or FileTest.directory?(path)
|
107
|
+
end
|
109
108
|
|
110
109
|
ext = File.extname(path)[1..-1]
|
111
|
-
|
112
|
-
|
113
|
-
|
110
|
+
ext ||= 'none'
|
111
|
+
|
112
|
+
unless loc[ext]
|
113
|
+
other_ext.push(ext) unless other_ext.include?(ext)
|
114
114
|
ext = 'other'
|
115
115
|
end
|
116
116
|
|
117
117
|
File.open(path,'r').each do |line|
|
118
|
-
if encode_line(line) !~ /^\s*$/
|
118
|
+
if encode_line(line) !~ /^\s*$/
|
119
119
|
loc[ext] = loc[ext] + 1
|
120
120
|
end
|
121
121
|
end
|
@@ -136,7 +136,7 @@ module Simp::Rake::Build
|
|
136
136
|
puts
|
137
137
|
puts "Unknown Extension Count: #{other_ext.length}"
|
138
138
|
|
139
|
-
if args.show_unknown
|
139
|
+
if args.show_unknown
|
140
140
|
puts "Unknown Extensions:"
|
141
141
|
other_ext.sort.each do |ext|
|
142
142
|
puts " #{ext}"
|
@@ -3,21 +3,100 @@ require 'rake/tasklib'
|
|
3
3
|
module Simp::Rake; end
|
4
4
|
module Simp::Rake::Build; end
|
5
5
|
module Simp::Rake::Build::Constants
|
6
|
+
def os_build_metadata(distro=nil, version=nil, arch=nil)
|
7
|
+
unless @member_vars_initialized
|
8
|
+
init_member_vars(Dir.pwd)
|
9
|
+
end
|
10
|
+
|
11
|
+
metadata = nil
|
12
|
+
|
13
|
+
build_metadata_file = File.join(@distro_build_dir, 'build_metadata.yaml')
|
14
|
+
|
15
|
+
if File.exist?(build_metadata_file)
|
16
|
+
build_metadata = YAML.load_file(build_metadata_file)
|
17
|
+
|
18
|
+
if distro
|
19
|
+
begin
|
20
|
+
metadata_init = { 'distributions' => {} }
|
21
|
+
metadata = metadata_init.dup
|
22
|
+
|
23
|
+
if build_metadata['distributions'][distro]
|
24
|
+
if version && build_metadata['distributions'][distro][version]
|
25
|
+
metadata['distributions'][distro] = {}
|
26
|
+
metadata['distributions'][distro][version] = build_metadata['distributions'][distro][version].dup
|
27
|
+
|
28
|
+
if arch && build_metadata['distributions'][distro][version]['arch'].include?(arch)
|
29
|
+
metadata['distributions'][distro][version]['arch'] = Array(arch)
|
30
|
+
else
|
31
|
+
raise(NoMethodError)
|
32
|
+
end
|
33
|
+
else
|
34
|
+
metadata['distributions'][distro] = build_metadata['distributions'][distro].dup
|
35
|
+
end
|
36
|
+
|
37
|
+
# Build everything that we've selected
|
38
|
+
metadata['distributions'][distro].keys.each do |d|
|
39
|
+
metadata['distributions'][distro][d]['build'] = true
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
if metadata['distributions'].empty?
|
44
|
+
raise(NoMethodError)
|
45
|
+
end
|
46
|
+
rescue NoMethodError
|
47
|
+
$stderr.puts(%(Error: Could not find distribution for '#{ENV['SIMP_BUILD_distro']}'))
|
48
|
+
$stderr.puts(%( Check #{File.expand_path(build_metadata_file)}))
|
49
|
+
exit(1)
|
50
|
+
end
|
51
|
+
else
|
52
|
+
metadata = build_metadata
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
return metadata
|
57
|
+
end
|
58
|
+
|
6
59
|
def init_member_vars( base_dir )
|
7
|
-
@
|
8
|
-
|
9
|
-
@
|
10
|
-
@
|
11
|
-
@
|
12
|
-
@
|
13
|
-
@
|
14
|
-
@
|
15
|
-
@
|
16
|
-
@
|
17
|
-
@
|
18
|
-
@
|
19
|
-
@
|
20
|
-
@
|
60
|
+
return if @member_vars_initialized
|
61
|
+
|
62
|
+
@run_dir = Dir.pwd
|
63
|
+
@base_dir = base_dir
|
64
|
+
@build_arch = ENV['buld_arch'] || %x{#{:facter} hardwaremodel 2>/dev/null}.chomp
|
65
|
+
@build_dir = File.join(@base_dir, 'build')
|
66
|
+
@dvd_dir = File.join(@build_dir, 'DVD_Overlay')
|
67
|
+
@target_dists = ['CentOS', 'RedHat']
|
68
|
+
@dist_dir = File.join(@build_dir, 'dist')
|
69
|
+
@src_dir = File.join(@base_dir, 'src')
|
70
|
+
@dvd_src = File.join(@src_dir, 'DVD')
|
71
|
+
@spec_dir = File.join(@src_dir, 'build')
|
72
|
+
@spec_file = FileList[File.join(@spec_dir, '*.spec')]
|
73
|
+
@simp_version = Simp::RPM.get_info(File.join(@spec_dir, 'simp.spec'))[:full_version]
|
74
|
+
@simp_dvd_dirs = ["SIMP","ks","Config"]
|
75
|
+
@distro_build_dir = File.join(@build_dir,'distributions')
|
76
|
+
@os_build_metadata = nil
|
77
|
+
@member_vars_initialized = true
|
78
|
+
|
79
|
+
if ENV['SIMP_BUILD_distro']
|
80
|
+
distro, version, arch = ENV['SIMP_BUILD_distro'].split(/,|\//)
|
81
|
+
|
82
|
+
@os_build_metadata = os_build_metadata(distro, version, arch)
|
83
|
+
else
|
84
|
+
@os_build_metadata = os_build_metadata()
|
85
|
+
end
|
86
|
+
|
87
|
+
if @os_build_metadata && !@os_build_metadata.empty?
|
88
|
+
$simp6 = true
|
89
|
+
$simp6_clean_dirs = []
|
90
|
+
|
91
|
+
@os_build_metadata['distributions'].keys.sort.each do |d|
|
92
|
+
@os_build_metadata['distributions'][d].keys.sort.each do |v|
|
93
|
+
next unless @os_build_metadata['distributions'][d][v]['build']
|
94
|
+
@os_build_metadata['distributions'][d][v]['arch'].sort.each do |a|
|
95
|
+
$simp6_clean_dirs << File.join(@distro_build_dir, d, v, a, 'SIMP')
|
96
|
+
$simp6_clean_dirs << File.join(@distro_build_dir, d, v, a, 'SIMP_ISO*')
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
21
101
|
end
|
22
102
|
end
|
23
|
-
|
data/lib/simp/rake/build/deps.rb
CHANGED
@@ -128,6 +128,8 @@ class R10KHelper
|
|
128
128
|
@modules.each do |mod|
|
129
129
|
module_dir = mod[:path].split(@basedir.to_s).last.split('/')[1..-2].join('/')
|
130
130
|
|
131
|
+
next unless mod[:r10k_module]
|
132
|
+
|
131
133
|
if last_module_dir != module_dir
|
132
134
|
pupfile << "moduledir '#{module_dir}'\n"
|
133
135
|
last_module_dir = module_dir
|
@@ -13,7 +13,6 @@ class Simp::Rake::Build::Helpers
|
|
13
13
|
end
|
14
14
|
Simp::Rake::Build::Auto.new( dir )
|
15
15
|
Simp::Rake::Build::Build.new( dir )
|
16
|
-
Simp::Rake::Build::Clean.new( dir )
|
17
16
|
Simp::Rake::Build::Code.new( dir )
|
18
17
|
Simp::Rake::Build::Deps.new( dir )
|
19
18
|
Simp::Rake::Build::Iso.new( dir )
|
@@ -22,5 +21,6 @@ class Simp::Rake::Build::Helpers
|
|
22
21
|
Simp::Rake::Build::Tar.new( dir )
|
23
22
|
Simp::Rake::Build::Upload.new( dir )
|
24
23
|
Simp::Rake::Build::Unpack.new( dir )
|
24
|
+
Simp::Rake::Build::Clean.new( dir )
|
25
25
|
end
|
26
26
|
end
|
data/lib/simp/rake/build/iso.rb
CHANGED
@@ -11,6 +11,7 @@ module Simp::Rake::Build
|
|
11
11
|
|
12
12
|
def initialize( base_dir )
|
13
13
|
init_member_vars( base_dir )
|
14
|
+
|
14
15
|
@mock = ENV['mock'] || '/usr/bin/mock'
|
15
16
|
define_tasks
|
16
17
|
end
|
@@ -20,6 +21,11 @@ module Simp::Rake::Build
|
|
20
21
|
File.umask(0007)
|
21
22
|
|
22
23
|
namespace :iso do
|
24
|
+
task :prep do
|
25
|
+
if $simp6
|
26
|
+
@build_dir = $simp6_build_dir
|
27
|
+
end
|
28
|
+
end
|
23
29
|
|
24
30
|
# Remove packages from the given directory. The goal of this method is to help
|
25
31
|
# get the distro to be as small as possible.
|
@@ -98,13 +104,14 @@ module Simp::Rake::Build
|
|
98
104
|
ENV vars:
|
99
105
|
- Set `SIMP_ISO_verbose=yes` to report file operations as they happen.
|
100
106
|
EOM
|
101
|
-
task :build,[:tarball,:unpacked_dvds,:prune] do |t,args|
|
107
|
+
task :build,[:tarball,:unpacked_dvds,:prune] => [:prep] do |t,args|
|
102
108
|
args.with_defaults(:unpacked_dvds => "#{@run_dir}", :prune => 'true')
|
103
109
|
|
104
110
|
if args.tarball.nil?
|
105
111
|
fail("Error: You must specify a source tarball or tarball directory!")
|
106
112
|
else
|
107
113
|
tarball = File.expand_path(args.tarball)
|
114
|
+
|
108
115
|
unless File.exist?(tarball)
|
109
116
|
fail("Error: Could not find tarball at '#{tarball}'!")
|
110
117
|
end
|
@@ -116,10 +123,17 @@ module Simp::Rake::Build
|
|
116
123
|
Dir.glob("#{tarball}/*.tar.gz") : [tarball]
|
117
124
|
vermap = YAML::load_file( File.join( File.dirname(__FILE__), 'vermap.yaml'))
|
118
125
|
|
119
|
-
tarfiles.each do |
|
126
|
+
tarfiles.each do |tball|
|
120
127
|
namepieces = File.basename(tarball,".tar.gz").split('-')
|
121
|
-
|
122
|
-
|
128
|
+
|
129
|
+
# SIMP 6
|
130
|
+
if namepieces[1] =~ /^\d/
|
131
|
+
simpver = namepieces[1..2].join('-')
|
132
|
+
baseos = namepieces[3]
|
133
|
+
else
|
134
|
+
simpver = namepieces[3..-1].join('-')
|
135
|
+
baseos = namepieces[2]
|
136
|
+
end
|
123
137
|
|
124
138
|
iso_dirs = Dir.glob("#{File.expand_path(args.unpacked_dvds)}/#{baseos}*")
|
125
139
|
if iso_dirs.empty?
|
@@ -173,14 +187,16 @@ module Simp::Rake::Build
|
|
173
187
|
|
174
188
|
# Prune unwanted packages
|
175
189
|
begin
|
176
|
-
system("tar --no-same-permissions -C #{dir} -xzf #{
|
190
|
+
system("tar --no-same-permissions -C #{dir} -xzf #{tball} *simp_pkglist.txt")
|
177
191
|
rescue
|
178
192
|
# Does not matter if the command fails
|
179
193
|
end
|
194
|
+
|
180
195
|
pkglist_file = ENV.fetch(
|
181
|
-
|
182
|
-
|
183
|
-
|
196
|
+
'SIMP_PKGLIST_FILE',
|
197
|
+
File.join(dir,"#{baseosver.split('.').first}-simp_pkglist.txt")
|
198
|
+
)
|
199
|
+
|
184
200
|
puts
|
185
201
|
puts '-'*80
|
186
202
|
puts "### Pruning packages not in file '#{pkglist_file}'"
|
@@ -200,13 +216,18 @@ module Simp::Rake::Build
|
|
200
216
|
end
|
201
217
|
|
202
218
|
# Add the SIMP code
|
203
|
-
system("tar --no-same-permissions -C #{dir} -xzf #{
|
219
|
+
system("tar --no-same-permissions -C #{dir} -xzf #{tball}")
|
204
220
|
|
205
221
|
Dir.chdir("#{dir}/SIMP") do
|
206
222
|
# Add the SIMP Dependencies
|
207
223
|
simp_base_ver = simpver.split('-').first
|
208
|
-
|
209
|
-
|
224
|
+
|
225
|
+
if $simp6
|
226
|
+
yum_dep_location = File.join(@build_dir,'yum_data','packages')
|
227
|
+
else
|
228
|
+
simp_dep_src = %(SIMP#{simp_base_ver}_#{baseos}#{baseosver}_#{arch})
|
229
|
+
yum_dep_location = File.join(@build_dir,'yum_data',simp_dep_src,'packages')
|
230
|
+
end
|
210
231
|
|
211
232
|
unless File.directory?(yum_dep_location)
|
212
233
|
fail("Could not find dependency directory at #{yum_dep_location}")
|
@@ -220,7 +241,7 @@ module Simp::Rake::Build
|
|
220
241
|
# Add any one-off RPMs that you might want to add to your own build
|
221
242
|
# These are *not* checked to make sure that they actually match your
|
222
243
|
# environment
|
223
|
-
aux_packages = File.join(
|
244
|
+
aux_packages = File.join(File.dirname(yum_dep_location),'aux_packages')
|
224
245
|
if File.directory?(aux_packages)
|
225
246
|
yum_dep_rpms += Dir.glob(File.join(aux_packages,'*.rpm'))
|
226
247
|
end
|
@@ -307,7 +328,7 @@ module Simp::Rake::Build
|
|
307
328
|
* :key - The GPG key to sign the RPMs with. Defaults to 'prod'.
|
308
329
|
* :chroot - An optional Mock Chroot. If this is passed, the tar:build task will be called.
|
309
330
|
EOM
|
310
|
-
task :src,[:key,:chroot] do |t,args|
|
331
|
+
task :src,[:prep, :key,:chroot] do |t,args|
|
311
332
|
args.with_defaults(:key => 'prod')
|
312
333
|
|
313
334
|
if Dir.glob("#{@dvd_dir}/*.gz").empty? && !args.chroot
|