simp-rake-helpers 1.0.6 → 1.0.7

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: ade6e1ae8a744fa8b543ed966cb67ed411ab41c0
4
- data.tar.gz: ec51fff88f43b136d2932a655f8f39e2a2344510
3
+ metadata.gz: 2e0cc6b7460a766fa108056633ba7a765fd5962e
4
+ data.tar.gz: 052d02767af95ba15bca7b6f09f62cecef8ea5e8
5
5
  SHA512:
6
- metadata.gz: 34978e726b9a3378f5ecb2e5b943eb010c6b45722b48bb8ab388404786a7f538359af9ffd751b0aff84daa4f753f19c062ff8e0293a2659267358c402701d55b
7
- data.tar.gz: 0464603d53ab8e63fa4cc0d130fecafd5a68ce41343ea66e4a1c86448d98232d6762e2ac58901656d6af65797d564c687727d9119ce652d2c32a7be899f694a2
6
+ metadata.gz: b36f615ed3578ac0faad8ea57a3ea63bbffb4138a09425b66860a18cbf6393f2b7603ef53458bb3abd0ed4d9a10f157e959c3097ffe34e7b4015bb3c7745f1a2
7
+ data.tar.gz: 4e1afb4dc8fd6214ea1bf1fba6d80bcc958f3a0e8b412f9f469688714e42653afe0765bab0291f7f34a2c6cebc3df489e6f524d1a5bc74826c7dd78eec6fe86e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### 1.0.7 / 2015-06-27
2
+ * Ensure that the 'Release' variable doesn't pick up anything that's dynamic in
3
+ nature.
4
+ * Optimized the build check code. Sped up pretty much everything.
5
+
1
6
  ### 1.0.6 / 2015-06-24
2
7
  * Cleanup gemspec
3
8
  * Fixed bugs in the RPM signing code regarding fetching the username and
@@ -2,6 +2,6 @@ module Simp; end
2
2
  module Simp::Rake; end
3
3
 
4
4
  class Simp::Rake::Helpers
5
- VERSION = '1.0.6'
5
+ VERSION = '1.0.7'
6
6
  require 'simp/rake/pkg'
7
7
  end
data/lib/simp/rake/pkg.rb CHANGED
@@ -6,6 +6,7 @@ require 'rake/clean'
6
6
  require 'rake/tasklib'
7
7
  require 'fileutils'
8
8
  require 'find'
9
+ require 'simp/rpm'
9
10
 
10
11
  module Simp; end
11
12
  module Simp::Rake
@@ -61,7 +62,6 @@ module Simp::Rake
61
62
  define
62
63
  end
63
64
 
64
-
65
65
  def define
66
66
  # For the most part, we don't want to hear Rake's noise, unless it's an error
67
67
  # TODO: Make this configurable
@@ -106,23 +106,29 @@ module Simp::Rake
106
106
  # -----------------------------
107
107
  desc <<-EOM
108
108
  Build the #{@pkg_name} tar package
109
- * :snapshot_release - Add snapshot_release (date and time) to rpm version, rpm spec file must have macro for this to work.
109
+ * :snapshot_release - Add snapshot_release (date and time) to rpm
110
+ version, rpm spec file must have macro for
111
+ this to work.
110
112
  EOM
111
113
  task :tar,[:snapshot_release] => [@pkg_dir] do |t,args|
112
114
  args.with_defaults(:snapshot_release => false)
113
115
 
114
116
  l_date = ''
115
- if args.snapshot_release == 'true' then
117
+ if args.snapshot_release == 'true'
116
118
  l_date = '.' + "#{TIMESTAMP}"
117
119
  @tar_dest = "#{@pkg_dir}/#{@full_pkg_name}#{l_date}.tar.gz"
118
120
  end
119
- Dir.chdir("#{@base_dir}/..") do
120
- Find.find(@pkg_name) do |path|
121
+
122
+ target_dir = File.basename(@base_dir)
123
+
124
+ Dir.chdir(%(#{@base_dir}/..)) do
125
+ Find.find(target_dir) do |path|
121
126
  Find.prune if path =~ /^\.git/
122
127
  Find.prune if path == "#{@pkg_name}/#{File.basename(@pkg_dir)}"
123
128
  Find.prune if @ignore_changes_list.include?(path)
124
- if path == @pkg_name and not uptodate?(@tar_dest,[path]) then
125
- sh %Q{tar --owner 0 --group 0 --exclude-vcs --exclude=#{@exclude_list.join(' --exclude=')} --transform='s/^#{@pkg_name}/#{@dir_name}/' -cpzf "#{@tar_dest}" #{@pkg_name}}
129
+ next if File.directory?(path)
130
+ unless uptodate?(@tar_dest,[path])
131
+ sh %Q(tar --owner 0 --group 0 --exclude-vcs --exclude=#{@exclude_list.join(' --exclude=')} --transform='s/^#{@pkg_name}/#{@dir_name}/' -cpzf "#{@tar_dest}" #{@pkg_name})
126
132
  break
127
133
  end
128
134
  end
@@ -131,7 +137,6 @@ module Simp::Rake
131
137
  end
132
138
  end
133
139
 
134
-
135
140
  def define_pkg_srpm
136
141
  namespace :pkg do
137
142
  desc <<-EOM
@@ -148,24 +153,24 @@ module Simp::Rake
148
153
  args.with_defaults(:snapshot_release => false)
149
154
 
150
155
  l_date = ''
151
- if args.snapshot_release == 'true' then
156
+ if args.snapshot_release == 'true'
152
157
  l_date = '.' + "#{TIMESTAMP}"
153
158
  mocksnap = "-D 'snapshot_release #{l_date}'"
154
159
  @tar_dest = "#{@pkg_dir}/#{@full_pkg_name}#{l_date}.tar.gz"
155
160
  end
156
161
 
157
162
  mock_cmd = mock_pre_check( args.chroot, @chroot_name, args.unique )
158
- output = "#{@full_pkg_name}#{l_date}.src.rpm"
159
- if not uptodate?("#{@pkg_dir}/#{output}",[@tar_dest]) then
160
- cmd = %Q{#{mock_cmd} --no-clean --root #{args.chroot} #{mocksnap} --buildsrpm --spec #{@spec_file} --source #{@pkg_dir}}
163
+
164
+ srpms = Dir.glob(%(#{@pkg_dir}/#{@full_pkg_name}#{l_date}.*src.rpm))
165
+
166
+ if require_rebuild?(@tar_dest,srpms)
167
+ cmd = %Q(#{mock_cmd} --no-clean --root #{args.chroot} #{mocksnap} --buildsrpm --spec #{@spec_file} --source #{@pkg_dir})
161
168
  sh cmd
162
169
  end
163
170
  end
164
171
  end
165
172
  end
166
173
 
167
-
168
-
169
174
  def define_pkg_rpm
170
175
  namespace :pkg do
171
176
  desc <<-EOM
@@ -182,19 +187,25 @@ module Simp::Rake
182
187
  args.with_defaults(:snapshot_release => false)
183
188
 
184
189
  l_date = ''
185
- if args.snapshot_release == 'true' then
190
+ if args.snapshot_release == 'true'
186
191
  l_date = '.' + "#{TIMESTAMP}"
187
192
  mocksnap = "-D 'snapshot_release #{l_date}'"
188
193
  @tar_dest = "#{@pkg_dir}/#{@full_pkg_name}#{l_date}.tar.gz"
189
194
  end
190
195
 
191
- mock_cmd = mock_pre_check( args.chroot, @chroot_name, args.unique )
192
196
  Rake::Task['pkg:srpm'].invoke(args.chroot,args.unique,args.snapshot_release)
193
197
 
194
- output = "#{@full_pkg_name}#{l_date}.#{@spec_info[:arch]}.rpm"
195
- if not uptodate?("#{@pkg_dir}/#{output}",[@tar_dest]) then
196
- cmd = %Q{#{mock_cmd} --root #{args.chroot} #{mocksnap} #{@pkg_dir}/#{@full_pkg_name}#{l_date}.src.rpm}
197
- sh cmd
198
+ mock_cmd = mock_pre_check(args.chroot, @chroot_name, args.unique)
199
+
200
+ rpms = Dir.glob(%(#{@pkg_dir}/#{@full_pkg_name}#{l_date}*.rpm))
201
+ srpms = rpms.select{|x| x =~ /src\.rpm$/}
202
+ rpms = (rpms - srpms)
203
+
204
+ srpms.each do |srpm|
205
+ if require_rebuild?(srpm,rpms)
206
+ cmd = %Q(#{mock_cmd} --root #{args.chroot} #{mocksnap} #{srpm})
207
+ sh cmd
208
+ end
198
209
  end
199
210
  end
200
211
  end
@@ -211,7 +222,7 @@ module Simp::Rake
211
222
  args.with_defaults(:unique => false)
212
223
 
213
224
  mock_cmd = mock_pre_check( args.chroot, @chroot_name, args.unique, false )
214
- cmd = %Q{#{mock_cmd} --scrub=all}
225
+ cmd = %Q(#{mock_cmd} --scrub=all)
215
226
  sh cmd
216
227
  end
217
228
 
@@ -224,37 +235,29 @@ module Simp::Rake
224
235
  # ------------------------------------------------------------------------------
225
236
  # Pull the main RPM information out of the package spec file.
226
237
  def Pkg.get_info(specfile)
227
- info = Hash.new
228
- info[:arch] = %x{uname -i}
229
-
230
- if File.readable?(specfile) then
231
- File.open(specfile).each do |line|
232
- if line =~ /^\s*Version:\s+(.*)\s*/ then
233
- info[:version] = $1
234
- next
235
- elsif line =~ /^\s*Release:\s+(.*)\s*/ then
236
- info[:release] = $1
237
- next
238
- elsif line =~ /^\s*Name:\s+(.*)\s*/ then
239
- info[:name] = $1
240
- next
241
- elsif line =~ /^\s*Buildarch:\s+(.*)\s*/ then
242
- info[:arch] = $1
243
- next
244
- end
245
- end
246
- else
247
- raise "Error: unable to read the spec file '#{specfile}'"
248
- end
249
- return info
238
+ return Simp::RPM.get_info(specfile)
250
239
  end
251
240
 
252
-
253
241
  # Get a list of all of the mock configs available on the system.
254
242
  def Pkg.get_mock_configs
255
243
  Dir.glob('/etc/mock/*.cfg').sort.map{ |x| x = File.basename(x,'.cfg')}
256
244
  end
257
245
 
246
+ # Return True if any of the 'output_files' are older than the 'src_file'
247
+ def require_rebuild?(src_file,output_files)
248
+ require_rebuild = false
249
+ require_rebuild = true if output_files.empty?
250
+ unless require_rebuild
251
+ output_files.each do |outfile|
252
+ unless uptodate?(outfile,Array(src_file))
253
+ require_rebuild = true
254
+ break
255
+ end
256
+ end
257
+ end
258
+
259
+ require_rebuild
260
+ end
258
261
 
259
262
  # Run some pre-checks to make sure that mock will work properly.
260
263
  #
@@ -265,18 +268,18 @@ module Simp::Rake
265
268
  # Returns a String that contains the appropriate mock command.
266
269
  def mock_pre_check( chroot, unique_ext, unique=false, init=true )
267
270
 
268
- raise %Q{unique_ext must be a String ("#{unique_ext}" = #{unique_ext.class})} if not unique_ext.is_a? String
271
+ raise %Q(unique_ext must be a String ("#{unique_ext}" = #{unique_ext.class})) unless unique_ext.is_a? String
269
272
 
270
273
  mock = ENV['mock'] || '/usr/bin/mock'
271
274
  raise(Exception,"Could not find mock on your system, exiting") unless File.executable?('/usr/bin/mock')
272
275
 
273
276
  mock_configs = Pkg.get_mock_configs
274
- if not chroot then
277
+ unless chroot
275
278
  raise(Exception,
276
279
  "Error: No mock chroot provided. Your choices are:\n #{mock_configs.join("\n ")}"
277
280
  )
278
281
  end
279
- if not mock_configs.include?(chroot) then
282
+ unless mock_configs.include?(chroot)
280
283
  raise(Exception,
281
284
  "Error: Invalid mock chroot provided. Your choices are:\n #{mock_configs.join("\n ")}"
282
285
  )
@@ -287,16 +290,16 @@ module Simp::Rake
287
290
 
288
291
  mock_cmd = "#{mock} --quiet"
289
292
  mock_cmd += " --uniqueext=#{unique_ext}" if unique
290
- mock_cmd += " --offline" if mock_offline
293
+ mock_cmd += ' --offline' if mock_offline
291
294
 
292
295
  initialized = is_mock_initialized( mock_cmd, chroot)
293
296
 
294
- if init and not initialized then
295
- sh %Q{#{mock_cmd} --root #{chroot} --init ##{unique_ext} }
297
+ unless initialized && init
298
+ sh %Q(#{mock_cmd} --root #{chroot} --init ##{unique_ext} )
296
299
  else
297
300
  # Remove any old build cruft from the mock directory.
298
301
  # This is kludgy but WAY faster than rebuilding them all, even with a cache.
299
- sh %Q{#{mock_cmd} --root #{chroot} --chroot "/bin/rm -rf /builddir/build/BUILDROOT /builddir/build/*/*"}
302
+ sh %Q(#{mock_cmd} --root #{chroot} --chroot "/bin/rm -rf /builddir/build/BUILDROOT /builddir/build/*/*")
300
303
  end
301
304
 
302
305
  mock_cmd + " --no-clean --no-cleanup-after --resultdir=#{@pkg_dir} --disable-plugin=package_state"
data/lib/simp/rpm.rb CHANGED
@@ -20,6 +20,8 @@ module Simp
20
20
  # [basename] The name of the package (as it would be queried in yum)
21
21
  # [version] The version of the package
22
22
  # [release] The release version of the package
23
+ # * NOTE: If this is a 'spec' file, it will stop on the first '%'
24
+ # encountered!
23
25
  # [full_version] The full version of the package: [version]-[release]
24
26
  # [name] The full name of the package: [basename]-[full_version]
25
27
  def initialize(rpm_source)
@@ -62,7 +64,8 @@ module Simp
62
64
  info[:version] = $1
63
65
  next
64
66
  elsif line =~ /^\s*Release:\s+(.*)\s*/
65
- info[:release] = $1
67
+ # We don't want anything after the first '%'
68
+ info[:release] = $1.split('%').first
66
69
  next
67
70
  elsif line =~ /^\s*Name:\s+(.*)\s*/
68
71
  info[:name] = $1
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: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Tessmer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-06-24 00:00:00.000000000 Z
12
+ date: 2015-06-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler