simp-rake-helpers 3.0.2 → 3.1.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 +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
data/lib/simp/rake/build/tar.rb
CHANGED
@@ -11,17 +11,25 @@ module Simp::Rake::Build
|
|
11
11
|
|
12
12
|
def initialize( base_dir )
|
13
13
|
init_member_vars( base_dir )
|
14
|
+
|
14
15
|
define_tasks
|
15
16
|
end
|
16
17
|
|
17
18
|
# define rake tasks
|
18
19
|
def define_tasks
|
19
20
|
namespace :tar do
|
21
|
+
task :prep do
|
22
|
+
if $simp6
|
23
|
+
@build_dir = $simp6_build_dir
|
24
|
+
end
|
20
25
|
|
21
|
-
|
26
|
+
if $tarball_tgt
|
27
|
+
@dvd_dir = File.dirname($tarball_tgt)
|
28
|
+
end
|
29
|
+
end
|
22
30
|
|
23
31
|
def get_simp_version
|
24
|
-
simp_rpm = Dir.glob("#{@
|
32
|
+
simp_rpm = Dir.glob("#{@build_dir}/SIMP/RPMS/*/simp-[0-9]*.rpm").max_by {|f| File.mtime(f)}
|
25
33
|
fail("Could not find simp main RPM in output directory!") unless simp_rpm
|
26
34
|
simp_version = File.basename(simp_rpm).gsub(".noarch.rpm","").gsub("simp-","")
|
27
35
|
|
@@ -35,8 +43,9 @@ module Simp::Rake::Build
|
|
35
43
|
# Main tasks
|
36
44
|
##############################################################################
|
37
45
|
|
38
|
-
task :validate do |t,args|
|
39
|
-
rpm_dir = File.join(@
|
46
|
+
task :validate => [:prep] do |t,args|
|
47
|
+
rpm_dir = File.join(@build_dir,'SIMP','RPMS')
|
48
|
+
|
40
49
|
fail("Could not find output dir: '#{rpm_dir}'") unless File.directory?(rpm_dir)
|
41
50
|
|
42
51
|
required_rpms = {
|
@@ -88,43 +97,58 @@ module Simp::Rake::Build
|
|
88
97
|
|
89
98
|
validate_in_mock_group?
|
90
99
|
|
100
|
+
if $tarball_tgt
|
101
|
+
target_dists = ['simp6']
|
102
|
+
else
|
103
|
+
target_dists = @target_dists
|
104
|
+
end
|
105
|
+
|
91
106
|
Parallel.map(
|
92
|
-
|
107
|
+
target_dists,
|
93
108
|
:in_processes => get_cpu_limit,
|
94
109
|
:process => t.name
|
95
110
|
) do |dist|
|
96
|
-
|
111
|
+
if $tarball_tgt
|
112
|
+
base_dir = "#{@dvd_dir}/staging"
|
113
|
+
else
|
114
|
+
base_dir = "#{@dvd_dir}/#{dist}/staging"
|
115
|
+
end
|
116
|
+
|
97
117
|
destdir = "#{base_dir}/SIMP"
|
98
118
|
|
99
119
|
# Build the staging area
|
120
|
+
remove_entry_secure(destdir) if File.exist?(destdir)
|
121
|
+
|
100
122
|
mkdir_p(destdir)
|
123
|
+
|
101
124
|
Simp::RPM.copy_wo_vcs(@dvd_src,".",base_dir)
|
102
125
|
|
103
126
|
# Copy in the GPG Public Keys
|
104
127
|
mkdir_p("#{destdir}/GPGKEYS")
|
105
|
-
ln(Dir.glob("#{@build_dir}/GPGKEYS/RPM-GPG-KEY*"), "#{destdir}/GPGKEYS", :force => true)
|
128
|
+
ln(Dir.glob("#{@build_dir}/GPGKEYS/RPM-GPG-KEY*"), "#{destdir}/GPGKEYS", { :force => true })
|
106
129
|
|
107
130
|
# Copy in the auto-build RPMs
|
108
131
|
Dir.chdir("#{@build_dir}/SIMP/RPMS") do
|
109
132
|
Dir.glob('*').each do |type|
|
110
133
|
dest_type = type
|
111
|
-
if File.directory?(type)
|
112
|
-
if type =~ /i.*86/
|
134
|
+
if File.directory?(type)
|
135
|
+
if type =~ /i.*86/
|
113
136
|
dest_type = 'i386'
|
114
137
|
end
|
115
138
|
|
116
139
|
mkdir_p("#{destdir}/#{dest_type}")
|
140
|
+
|
117
141
|
Dir.chdir(type) do
|
118
|
-
ln(Dir.glob("*.#{type}.rpm"),"#{destdir}/#{dest_type}", :force => true)
|
142
|
+
ln(Dir.glob("*.#{type}.rpm"), "#{destdir}/#{dest_type}", { :force => true })
|
119
143
|
end
|
120
144
|
end
|
121
145
|
end
|
122
146
|
end
|
123
147
|
|
124
|
-
if args.docs.casecmp('true') == 0
|
148
|
+
if args.docs.casecmp('true') == 0
|
125
149
|
# Finally, the PDF docs if they exist.
|
126
150
|
pdfs = Dir.glob("#{@src_dir}/doc/pdf/*")
|
127
|
-
|
151
|
+
unless pdfs.empty?
|
128
152
|
pdfs.each do |pdf|
|
129
153
|
cp(pdf,base_dir)
|
130
154
|
end
|
@@ -132,8 +156,8 @@ module Simp::Rake::Build
|
|
132
156
|
# If we don't have PDFs in the directory, yank them out of the
|
133
157
|
# RPM itself!
|
134
158
|
simp_doc_rpm = Dir.glob("#{@build_dir}/SIMP/RPMS/*/simp-doc*.rpm").last
|
135
|
-
|
136
|
-
raise(
|
159
|
+
unless simp_doc_rpm
|
160
|
+
raise(StandardError,"Error: Could not find simp-doc*.rpm in the build, something went very wrong")
|
137
161
|
end
|
138
162
|
|
139
163
|
Dir.mktmpdir { |dir|
|
@@ -141,8 +165,8 @@ module Simp::Rake::Build
|
|
141
165
|
%x{rpm2cpio #{simp_doc_rpm} | cpio -u --quiet --warning none -ivd ./usr/share/doc/simp-*/pdf/SIMP*.pdf 2>&1 > /dev/null}
|
142
166
|
pdf_docs = Dir.glob("usr/share/doc/simp-*/pdf/*.pdf")
|
143
167
|
|
144
|
-
if pdf_docs.empty?
|
145
|
-
raise(
|
168
|
+
if pdf_docs.empty?
|
169
|
+
raise(StandardError,"Error: Could not find any PDFs in the simp-doc RPM, aborting.")
|
146
170
|
end
|
147
171
|
|
148
172
|
pdf_docs.each do |pdf|
|
@@ -156,13 +180,30 @@ module Simp::Rake::Build
|
|
156
180
|
|
157
181
|
# FIXME: this is a horribad way of sharing with `build:auto`
|
158
182
|
$simp_tarballs = {}
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
183
|
+
|
184
|
+
if $tarball_tgt
|
185
|
+
target_dists = ['simp6']
|
186
|
+
else
|
187
|
+
target_dists = @target_dists
|
188
|
+
end
|
189
|
+
|
190
|
+
target_dists.each do |dist|
|
191
|
+
if $tarball_tgt
|
192
|
+
dvd_tarball = File.basename($tarball_tgt)
|
193
|
+
base_dir = "#{@dvd_dir}/staging"
|
194
|
+
else
|
195
|
+
base_dir = "#{@dvd_dir}/#{dist}/staging"
|
196
|
+
dvd_name = [ 'SIMP', 'DVD', dist, get_simp_version ]
|
197
|
+
dvd_tarball = "#{dvd_name.join('-')}.tar.gz"
|
198
|
+
end
|
199
|
+
|
200
|
+
mkdir_p(base_dir)
|
201
|
+
|
163
202
|
Dir.chdir(base_dir) do
|
164
203
|
sh %{tar --owner 0 --group 0 --exclude-vcs --mode=u=rwX,g=rX,o=rX -cpzf "../#{dvd_tarball}" ./*}
|
165
|
-
|
204
|
+
unless $tarball_tgt
|
205
|
+
mv("../#{dvd_tarball}",@dvd_dir)
|
206
|
+
end
|
166
207
|
end
|
167
208
|
|
168
209
|
puts "Package DVD: #{@dvd_dir}/#{dvd_tarball}"
|
@@ -10,6 +10,7 @@ module Simp::Rake::Build
|
|
10
10
|
|
11
11
|
def initialize( base_dir )
|
12
12
|
init_member_vars( base_dir )
|
13
|
+
|
13
14
|
@mock = ENV['mock'] || '/usr/bin/mock'
|
14
15
|
define_tasks
|
15
16
|
end
|
@@ -78,9 +79,9 @@ module Simp::Rake::Build
|
|
78
79
|
out_dir = "#{File.expand_path(targetdir)}/#{map['baseos']}#{map['version']}-#{map['arch']}"
|
79
80
|
|
80
81
|
# Attempt a merge
|
81
|
-
if File.exist?(out_dir) and merge.to_s.strip == 'false'
|
82
|
+
if File.exist?(out_dir) and merge.to_s.strip == 'false'
|
82
83
|
puts "Directory '#{out_dir}' already exists! Would you like to merge? [Yn]?"
|
83
|
-
|
84
|
+
unless $stdin.gets.strip.match(/^(y.*|$)/i)
|
84
85
|
puts "Skipping #{iso_path}"
|
85
86
|
next
|
86
87
|
end
|
@@ -99,11 +100,11 @@ module Simp::Rake::Build
|
|
99
100
|
|
100
101
|
iso_toc.each do |iso_entry|
|
101
102
|
target = "#{out_dir}#{iso_entry}"
|
102
|
-
|
103
|
+
unless File.exist?(target)
|
103
104
|
FileUtils.mkdir_p(File.dirname(target))
|
104
105
|
system("#{iso_info} -R -x #{iso_entry} -i #{iso_path} > #{target}")
|
105
106
|
end
|
106
|
-
if progress
|
107
|
+
if progress
|
107
108
|
progress.increment
|
108
109
|
else
|
109
110
|
print "#"
|
@@ -12,6 +12,7 @@ module Simp::Rake::Build
|
|
12
12
|
|
13
13
|
def initialize( base_dir )
|
14
14
|
init_member_vars( base_dir )
|
15
|
+
|
15
16
|
@mock = ENV['mock'] || '/usr/bin/mock'
|
16
17
|
define_tasks
|
17
18
|
end
|
@@ -19,6 +20,11 @@ module Simp::Rake::Build
|
|
19
20
|
def define_tasks
|
20
21
|
|
21
22
|
namespace :upload do
|
23
|
+
task :prep do
|
24
|
+
if $simp6
|
25
|
+
@build_dir = $simp6_build_dir
|
26
|
+
end
|
27
|
+
end
|
22
28
|
|
23
29
|
##############################################################################
|
24
30
|
# Helper methods
|
@@ -56,7 +62,7 @@ module Simp::Rake::Build
|
|
56
62
|
stdin,stdout,stderr = Open3.popen3('git','rev-list',start)
|
57
63
|
stderr.read !~ /^fatal:/ and is_commit = true
|
58
64
|
|
59
|
-
if is_commit
|
65
|
+
if is_commit
|
60
66
|
# Snag the date.
|
61
67
|
start, humanstart = `git log #{start} --pretty=format:"%ct##%cd" --max-count=1`.chomp.split('##')
|
62
68
|
else
|
@@ -78,8 +84,8 @@ module Simp::Rake::Build
|
|
78
84
|
:is_new => false
|
79
85
|
}
|
80
86
|
pkg_info[file][:alias] = file
|
81
|
-
if file =~ /.spec$/
|
82
|
-
if script_format
|
87
|
+
if file =~ /.spec$/
|
88
|
+
if script_format
|
83
89
|
pkg_info[file][:alias] = "#{@build_dir}/RPMS/#{Simp::RPM.new(file).name}*.rpm"
|
84
90
|
else
|
85
91
|
pkg_info[file][:alias] = Simp::RPM.new(file).name
|
@@ -95,7 +101,7 @@ module Simp::Rake::Build
|
|
95
101
|
commit_head = `git log --before="#{start}" --pretty=format:%H --max-count=1 #{File.basename(file)}`.chomp
|
96
102
|
|
97
103
|
# Did we find something different?
|
98
|
-
if commit_head.empty?
|
104
|
+
if commit_head.empty?
|
99
105
|
pkg_info[file][:is_new] = true
|
100
106
|
else
|
101
107
|
pkg_info[file][:is_new] = !system('git','diff','--quiet',commit_head,File.basename(file))
|
@@ -111,7 +117,7 @@ module Simp::Rake::Build
|
|
111
117
|
|
112
118
|
The package list is created from the given date or git identifier (tag, branch, or hash)
|
113
119
|
EOM
|
114
|
-
task :get_modified,[:start,:script_format] do |t,args|
|
120
|
+
task :get_modified,[:start,:script_format] => [:prep] do |t,args|
|
115
121
|
args.with_defaults(:script_format => false)
|
116
122
|
|
117
123
|
args.start or raise "Error: You must specify a 'start'"
|
data/lib/simp/rake/pkg.rb
CHANGED
@@ -43,16 +43,20 @@ module Simp::Rake
|
|
43
43
|
@pkg_name = File.basename(@base_dir)
|
44
44
|
@pkg_dir = File.join(@base_dir, 'dist')
|
45
45
|
@pkg_tmp_dir = File.join(@pkg_dir, 'tmp')
|
46
|
+
@pkg_stash_dir = File.join(@pkg_tmp_dir, '.stash')
|
46
47
|
@exclude_list = [ File.basename(@pkg_dir) ]
|
47
48
|
@clean_list = []
|
48
|
-
@ignore_changes_list = [
|
49
|
+
@ignore_changes_list = [
|
50
|
+
'Gemfile.lock',
|
51
|
+
'spec/fixtures/modules'
|
52
|
+
]
|
49
53
|
@chroot_name = unique_name
|
50
54
|
|
51
55
|
local_spec = Dir.glob(File.join(@base_dir, 'build', '*.spec'))
|
52
56
|
unless local_spec.empty?
|
53
57
|
@spec_file = local_spec.first
|
54
58
|
else
|
55
|
-
FileUtils.mkdir_p(@
|
59
|
+
FileUtils.mkdir_p(@pkg_stash_dir) unless File.directory?(@pkg_stash_dir)
|
56
60
|
|
57
61
|
@spec_tempfile = File.open(File.join(@pkg_tmp_dir, "#{@pkg_name}.spec"), 'w')
|
58
62
|
@spec_tempfile.write(rpm_template(simp_version))
|
@@ -102,14 +106,32 @@ module Simp::Rake
|
|
102
106
|
define_pkg_rpm
|
103
107
|
define_pkg_scrub
|
104
108
|
task :default => 'pkg:tar'
|
109
|
+
|
110
|
+
Rake::Task['pkg:tar'].enhance(['pkg:restore_stash'])
|
111
|
+
Rake::Task['pkg:srpm'].enhance(['pkg:restore_stash'])
|
112
|
+
Rake::Task['pkg:rpm'].enhance(['pkg:restore_stash'])
|
113
|
+
|
105
114
|
self
|
106
115
|
end
|
107
116
|
|
117
|
+
# Add a file to the pkg stash
|
118
|
+
# These will be restored to the @pkg_dir at the end of the run
|
119
|
+
def stash(file)
|
120
|
+
FileUtils.mv(file, @pkg_stash_dir)
|
121
|
+
end
|
122
|
+
|
123
|
+
# Restore everything from the stash dir
|
124
|
+
def restore_stash
|
125
|
+
Dir.glob(File.join(@pkg_stash_dir, '*')).each do |file|
|
126
|
+
FileUtils.mv(file, @pkg_dir)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
108
130
|
# Initialize the mock space if passed and retrieve the spec info from that
|
109
131
|
# space directly.
|
110
132
|
#
|
111
133
|
# Ensures that the correct file names are used across the board.
|
112
|
-
def initialize_spec_info(chroot, unique)
|
134
|
+
def initialize_spec_info(chroot, unique='false')
|
113
135
|
unless @spec_info
|
114
136
|
# This gets the resting spec file and allows us to pull out the name
|
115
137
|
@spec_info = Simp::RPM.get_info(@spec_file)
|
@@ -122,38 +144,40 @@ module Simp::Rake
|
|
122
144
|
@chroot_name = @chroot_name + '__' + Time.now.strftime('%s%L')
|
123
145
|
end
|
124
146
|
|
125
|
-
|
147
|
+
if @spec_info[:has_dist_tag]
|
148
|
+
mock_cmd = mock_pre_check( chroot, @chroot_name, unique ) + " --root #{chroot}"
|
126
149
|
|
127
|
-
|
128
|
-
|
129
|
-
|
150
|
+
# Need to do this in case there is already a directory in /tmp
|
151
|
+
rand_dirname = (0...10).map { ('a'..'z').to_a[rand(26)] }.join
|
152
|
+
rand_tmpdir = %(/tmp/#{rand_dirname}_tmp)
|
130
153
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
154
|
+
# Hack to work around the fact that we have conflicting '-D' entries
|
155
|
+
# TODO: Refactor this
|
156
|
+
mock_cmd = mock_cmd.split(/-D '.*?'/).join
|
157
|
+
mock_cmd = "#{mock_cmd} -D 'pup_module_info_dir #{rand_tmpdir}'"
|
135
158
|
|
136
|
-
|
159
|
+
sh %Q(#{mock_cmd} --chroot 'mkdir -p #{rand_tmpdir}')
|
137
160
|
|
138
|
-
|
139
|
-
|
140
|
-
|
161
|
+
@puppet_module_info_files.each do |copy_in|
|
162
|
+
if File.exist?(copy_in)
|
163
|
+
sh %Q(#{mock_cmd} --copyin #{copy_in} #{rand_tmpdir})
|
164
|
+
end
|
141
165
|
end
|
142
|
-
end
|
143
166
|
|
144
|
-
|
167
|
+
sh %Q(#{mock_cmd} --chroot 'chmod -R ugo+rwX #{rand_tmpdir}')
|
145
168
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
169
|
+
info_hash = {
|
170
|
+
:command => %Q(#{mock_cmd} --chroot --cwd='#{rand_tmpdir}'),
|
171
|
+
:rpm_extras => %(--specfile #{rand_tmpdir}/#{File.basename(@spec_file)} )
|
172
|
+
}
|
150
173
|
|
151
|
-
|
174
|
+
@spec_info = Simp::RPM.get_info(@spec_file, info_hash)
|
175
|
+
end
|
152
176
|
end
|
153
177
|
|
154
178
|
@dir_name = "#{@spec_info[:name]}-#{@spec_info[:version]}"
|
155
|
-
|
156
|
-
@full_pkg_name =
|
179
|
+
_full_pkg_name = "#{@dir_name}-#{@spec_info[:release]}"
|
180
|
+
@full_pkg_name = _full_pkg_name.gsub("%{?snapshot_release}","")
|
157
181
|
@tar_dest = "#{@pkg_dir}/#{@full_pkg_name}.tar.gz"
|
158
182
|
|
159
183
|
if @tar_dest =~ /UNKNOWN/
|
@@ -179,11 +203,14 @@ module Simp::Rake
|
|
179
203
|
end
|
180
204
|
end
|
181
205
|
|
182
|
-
|
183
206
|
def define_pkg_tar
|
184
207
|
namespace :pkg do
|
185
208
|
directory @pkg_dir
|
186
209
|
|
210
|
+
task :restore_stash do |t,args|
|
211
|
+
at_exit { restore_stash }
|
212
|
+
end
|
213
|
+
|
187
214
|
task :initialize_spec_info,[:chroot,:unique] => [@pkg_dir] do |t,args|
|
188
215
|
args.with_defaults(:chroot => nil)
|
189
216
|
args.with_defaults(:unique => false)
|
@@ -210,6 +237,13 @@ module Simp::Rake
|
|
210
237
|
@tar_dest = "#{@pkg_dir}/#{@full_pkg_name}#{l_date}.tar.gz"
|
211
238
|
end
|
212
239
|
|
240
|
+
# Remove any tar files that are not from this version
|
241
|
+
tar_files = Dir.glob(%(#{@pkg_dir}/#{@spec_info[:name]}-#{@spec_info[:version]}*.tar.gz))
|
242
|
+
tar_files.delete(@tar_dest)
|
243
|
+
tar_files.each do |tf|
|
244
|
+
stash(tf)
|
245
|
+
end
|
246
|
+
|
213
247
|
target_dir = File.basename(@base_dir)
|
214
248
|
|
215
249
|
Dir.chdir(%(#{@base_dir}/..)) do
|
@@ -217,12 +251,15 @@ module Simp::Rake
|
|
217
251
|
if File.exist?(@tar_dest)
|
218
252
|
Find.find(target_dir) do |path|
|
219
253
|
filename = File.basename(path)
|
254
|
+
|
220
255
|
Find.prune if filename =~ /^\./
|
221
256
|
Find.prune if ((filename == File.basename(@pkg_dir)) && File.directory?(path))
|
222
|
-
|
223
|
-
|
257
|
+
|
258
|
+
to_ignore = @ignore_changes_list.map{|x| x = Dir.glob(File.join(@base_dir, x))}.flatten
|
259
|
+
Find.prune if to_ignore.include?(File.expand_path(path))
|
224
260
|
|
225
261
|
next if File.directory?(path)
|
262
|
+
|
226
263
|
unless uptodate?(@tar_dest,[path])
|
227
264
|
require_rebuild = true
|
228
265
|
break
|
@@ -265,12 +302,28 @@ module Simp::Rake
|
|
265
302
|
@tar_dest = "#{@pkg_dir}/#{@full_pkg_name}#{l_date}.tar.gz"
|
266
303
|
end
|
267
304
|
|
268
|
-
|
305
|
+
srpms = Dir.glob(%(#{@pkg_dir}/#{@spec_info[:name]}*-#{@spec_info[:version]}-*#{l_date}*.src.rpm))
|
306
|
+
|
307
|
+
# Get rid of any SRPMs that are not of this distribution build if we
|
308
|
+
# have found one
|
309
|
+
if @spec_info[:dist_tag]
|
310
|
+
srpms.delete_if do |srpm|
|
311
|
+
if srpm.split(@spec_info[:dist_tag]).last != '.src.rpm'
|
312
|
+
if File.exist?(srpm)
|
313
|
+
stash(srpm)
|
314
|
+
end
|
269
315
|
|
270
|
-
|
316
|
+
true
|
317
|
+
else
|
318
|
+
false
|
319
|
+
end
|
320
|
+
end
|
321
|
+
end
|
271
322
|
|
272
323
|
if require_rebuild?(srpms, @tar_dest)
|
273
324
|
|
325
|
+
mock_cmd = mock_pre_check( args[:chroot], @chroot_name, args[:unique] )
|
326
|
+
|
274
327
|
@puppet_module_info_files.each do |file|
|
275
328
|
next unless File.exist?(file)
|
276
329
|
|
@@ -278,7 +331,7 @@ module Simp::Rake
|
|
278
331
|
next if File.directory?(path)
|
279
332
|
|
280
333
|
tgt_file = File.join(@pkg_dir, File.basename(path))
|
281
|
-
FileUtils.
|
334
|
+
FileUtils.remove_entry_secure(tgt_file) if File.exist?(tgt_file)
|
282
335
|
FileUtils.cp(path, @pkg_dir) if File.exist?(path)
|
283
336
|
end
|
284
337
|
end
|
@@ -316,27 +369,46 @@ module Simp::Rake
|
|
316
369
|
@tar_dest = "#{@pkg_dir}/#{@full_pkg_name}#{l_date}.tar.gz"
|
317
370
|
end
|
318
371
|
|
319
|
-
|
372
|
+
rpms = Dir.glob(%(#{@pkg_dir}/#{@spec_info[:name]}-*#{@spec_info[:version]}-*#{l_date}*.rpm))
|
320
373
|
|
321
|
-
rpms = Dir.glob(%(#{@pkg_dir}/#{@spec_info[:name]}-#{@spec_info[:version]}-#{@spec_info[:release]}#{l_date}.*rpm))
|
322
374
|
srpms = rpms.select{|x| x =~ /src\.rpm$/}
|
323
375
|
rpms = (rpms - srpms)
|
324
376
|
|
377
|
+
# Get rid of any RPMs that are not of this distribution build if we
|
378
|
+
# have found one
|
379
|
+
if @spec_info[:dist_tag]
|
380
|
+
rpms.delete_if do |rpm|
|
381
|
+
if rpm.split(@spec_info[:dist_tag]).last != ".#{@spec_info[:arch]}.rpm"
|
382
|
+
if File.exist?(rpm)
|
383
|
+
stash(rpm)
|
384
|
+
end
|
385
|
+
|
386
|
+
true
|
387
|
+
else
|
388
|
+
false
|
389
|
+
end
|
390
|
+
end
|
391
|
+
end
|
392
|
+
|
325
393
|
srpms.each do |srpm|
|
326
394
|
dirname = File.dirname(srpm)
|
327
395
|
basename = File.basename(srpm,'.src.rpm')
|
328
|
-
|
396
|
+
srpm_info = Simp::RPM.get_info(srpm)
|
397
|
+
|
398
|
+
rpm = [File.join(dirname, basename), srpm_info[:arch], 'rpm'].join('.')
|
329
399
|
if require_rebuild?(rpm, srpm)
|
400
|
+
mock_cmd = mock_pre_check(args[:chroot], @chroot_name, args[:unique])
|
401
|
+
|
330
402
|
cmd = %Q(#{mock_cmd} --root #{args[:chroot]} #{mocksnap} #{srpm})
|
331
403
|
|
332
404
|
sh cmd
|
333
|
-
end
|
334
|
-
end
|
335
405
|
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
406
|
+
# remote chroot unless told not to (saves LOTS of space during ISO builds)
|
407
|
+
unless ENV['SIMP_RAKE_MOCK_cleanup'] == 'no'
|
408
|
+
cmd = %Q(#{mock_cmd} --root #{args[:chroot]} --clean)
|
409
|
+
sh cmd
|
410
|
+
end
|
411
|
+
end
|
340
412
|
end
|
341
413
|
end
|
342
414
|
end
|
@@ -350,7 +422,7 @@ module Simp::Rake
|
|
350
422
|
Scrub the #{@pkg_name} mock build directory.
|
351
423
|
EOM
|
352
424
|
task :scrub,[:chroot,:unique] do |t,args|
|
353
|
-
args.with_defaults(:unique => false)
|
425
|
+
args.with_defaults(:unique => 'false')
|
354
426
|
|
355
427
|
mock_cmd = mock_pre_check( args[:chroot], @chroot_name, args[:unique], false )
|
356
428
|
cmd = %Q(#{mock_cmd} --scrub=all)
|
@@ -371,23 +443,19 @@ module Simp::Rake
|
|
371
443
|
|
372
444
|
# Return True if any of the 'old' Array are newer than the 'new' Array
|
373
445
|
def require_rebuild?(new, old)
|
374
|
-
|
375
|
-
require_rebuild = true if ( Array(old).empty? || Array(new).empty?)
|
376
|
-
unless require_rebuild
|
377
|
-
Array(new).each do |new_file|
|
378
|
-
unless File.exist?(new_file)
|
379
|
-
require_rebuild = true
|
380
|
-
break
|
381
|
-
end
|
446
|
+
return true if ( Array(old).empty? || Array(new).empty?)
|
382
447
|
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
448
|
+
Array(new).each do |new_file|
|
449
|
+
unless File.exist?(new_file)
|
450
|
+
return true
|
451
|
+
end
|
452
|
+
|
453
|
+
unless uptodate?(new_file, Array(old))
|
454
|
+
return true
|
387
455
|
end
|
388
456
|
end
|
389
457
|
|
390
|
-
return
|
458
|
+
return false
|
391
459
|
end
|
392
460
|
|
393
461
|
# Run some pre-checks to make sure that mock will work properly.
|
@@ -397,23 +465,26 @@ module Simp::Rake
|
|
397
465
|
# Pass init=false if you do not want the function to initialize.
|
398
466
|
#
|
399
467
|
# Returns a String that contains the appropriate mock command.
|
400
|
-
def mock_pre_check( chroot, unique_ext, unique=false, init=true )
|
468
|
+
def mock_pre_check( chroot, unique_ext, unique='false', init=true )
|
401
469
|
|
402
470
|
mock = ENV['mock'] || '/usr/bin/mock'
|
403
471
|
|
404
|
-
raise(
|
472
|
+
raise(StandardError,"Could not find mock on your system, exiting") unless File.executable?(mock)
|
405
473
|
|
406
474
|
mock_configs = Pkg.get_mock_configs
|
407
475
|
unless chroot
|
408
|
-
raise(
|
476
|
+
raise(StandardError,
|
409
477
|
"Error: No mock chroot provided. Your choices are:\n #{mock_configs.join("\n ")}"
|
410
478
|
)
|
411
479
|
end
|
412
480
|
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
481
|
+
# If you pass a config file, just take it
|
482
|
+
unless chroot.split('.').last == 'cfg'
|
483
|
+
unless mock_configs.include?(chroot)
|
484
|
+
raise(StandardError,
|
485
|
+
"Error: Invalid mock chroot provided. Your choices are:\n #{mock_configs.join("\n ")}"
|
486
|
+
)
|
487
|
+
end
|
417
488
|
end
|
418
489
|
|
419
490
|
raise %Q(unique_ext must be a String ("#{unique_ext}" = #{unique_ext.class})) unless unique_ext.is_a?(String)
|
@@ -453,8 +524,12 @@ module Simp::Rake
|
|
453
524
|
end
|
454
525
|
|
455
526
|
def is_mock_initialized( mock_cmd, chroot )
|
527
|
+
@@initialized_mocks ||= []
|
528
|
+
return true if @@initialized_mocks.include?(chroot)
|
529
|
+
|
456
530
|
%x{#{mock_cmd} --root #{chroot} --chroot "test -d /tmp" &> /dev/null }
|
457
531
|
initialized = $?.success?
|
532
|
+
@@initialized_mocks << chroot
|
458
533
|
|
459
534
|
# A simple test to see if the chroot is initialized.
|
460
535
|
initialized
|
data/lib/simp/rpm.rb
CHANGED
@@ -88,8 +88,11 @@ module Simp
|
|
88
88
|
# reference to the spec file itself
|
89
89
|
# }
|
90
90
|
def self.get_info(rpm_source, mock_hash=nil)
|
91
|
-
info
|
92
|
-
|
91
|
+
info = {
|
92
|
+
:has_dist_tag => false
|
93
|
+
}
|
94
|
+
|
95
|
+
rpm_cmd = "rpm -q --queryformat '%{NAME} %{VERSION} %{RELEASE} %{ARCH}\n'"
|
93
96
|
|
94
97
|
if mock_hash
|
95
98
|
# Suppression of error messages is a hack for the following
|
@@ -105,10 +108,20 @@ module Simp
|
|
105
108
|
end
|
106
109
|
|
107
110
|
if File.readable?(rpm_source)
|
111
|
+
if File.read(rpm_source).include?('%{?dist}')
|
112
|
+
info[:has_dist_tag] = true
|
113
|
+
end
|
114
|
+
|
108
115
|
if rpm_source.split('.').last == 'rpm'
|
109
116
|
results = execute("#{rpm_cmd} -p #{rpm_source}")
|
110
117
|
elsif mock_hash
|
111
118
|
results = execute("#{rpm_cmd}")
|
119
|
+
|
120
|
+
if info[:has_dist_tag]
|
121
|
+
info[:dist_tag] = execute(%(#{mock_hash[:command]} --chroot 'rpm --eval "%{dist}"' 2>/dev/null))[:stdout].strip
|
122
|
+
|
123
|
+
info[:dist_tag] = nil if (info[:dist_tag][0].chr == '%')
|
124
|
+
end
|
112
125
|
else
|
113
126
|
results = execute("#{rpm_cmd} --specfile #{rpm_source}")
|
114
127
|
end
|
@@ -121,7 +134,7 @@ module Simp
|
|
121
134
|
EOE
|
122
135
|
end
|
123
136
|
|
124
|
-
info[:name],info[:version],info[:release] = results[:stdout].strip.split("\n").first.split(' ')
|
137
|
+
info[:name], info[:version], info[:release], info[:arch] = results[:stdout].strip.split("\n").first.split(' ')
|
125
138
|
else
|
126
139
|
raise "Error: unable to read '#{rpm_source}'"
|
127
140
|
end
|