pkg-wizard 0.1.12 → 0.1.14

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.
@@ -39,6 +39,14 @@ module PKGWizard
39
39
  (Dir["failed/job_*"] + Dir["success/job_*"]).find { |j| File.basename(j) == name }
40
40
  end
41
41
 
42
+ post '/createrepo' do
43
+ FileUtils.touch 'repo/.createrepo'
44
+ end
45
+
46
+ post '/createsnapshot' do
47
+ FileUtils.touch 'snapshot/.createsnapshot'
48
+ end
49
+
42
50
  post '/build/' do
43
51
  pkg = params[:pkg]
44
52
  if pkg.nil?
@@ -68,10 +76,12 @@ module PKGWizard
68
76
  get '/job/stats' do
69
77
  fjobs = Dir["failed/job*"].size
70
78
  sjobs = Dir["output/job*"].size
79
+ qjobs = Dir["incoming/*.src.rpm"].size
71
80
  total_jobs = fjobs + sjobs
72
81
  {
73
82
  :failed_jobs => fjobs,
74
83
  :successful_jobs => sjobs,
84
+ :enqueued => qjobs,
75
85
  :total_jobs => total_jobs
76
86
  }.to_yaml
77
87
  end
@@ -158,6 +168,50 @@ module PKGWizard
158
168
  Dir.mkdir 'workspace' if not File.exist?('workspace')
159
169
  Dir.mkdir 'archive' if not File.exist?('archive')
160
170
  Dir.mkdir 'failed' if not File.exist?('failed')
171
+ Dir.mkdir 'snapshot' if not File.exist?('snapshot')
172
+ FileUtils.ln_sf 'output', 'repo' if not File.exist?('repo')
173
+
174
+ # createrepo snapshot
175
+ snapshot_sched = Rufus::Scheduler.start_new
176
+ snapshot_sched.every '2s', :blocking => true do
177
+ if File.exist?('snapshot/.createsnapshot')
178
+ $stdout.puts '* snapshot START'
179
+ stamp = Time.now.strftime '%Y%m%d_%H%M%S'
180
+ snapshot_dir = "snapshot/snapshot_#{stamp}"
181
+ Dir.mkdir snapshot_dir
182
+ begin
183
+ Dir["output/*/result/*.rpm"].each do |rpm|
184
+ FileUtils.cp rpm, snapshot_dir
185
+ end
186
+ $stdout.puts '* snapshot DONE'
187
+ rescue Exception => e
188
+ $stdout.puts "snapshot operation failed".red.bold
189
+ ensure
190
+ FileUtils.rm 'snapshot/.createsnapshot'
191
+ end
192
+ end
193
+ end
194
+
195
+ # createrepo scheduler
196
+ createrepo_sched = Rufus::Scheduler.start_new
197
+ createrepo_sched.every '2s', :blocking => true do
198
+ if File.exist?('repo/.createrepo')
199
+ $stdout.puts '* createrepo START'
200
+ begin
201
+ output = `createrepo -q -o repo/ --update -d output/ 2>&1`
202
+ if $? != 0
203
+ raise Exception.new(output)
204
+ end
205
+ $stdout.puts '* createrepo DONE'
206
+ rescue Exception => e
207
+ $stdout.puts "createrepo operation failed".red.bold
208
+ File.open('repo/createrepo.log', 'a') { |f| f.puts e.message }
209
+ ensure
210
+ FileUtils.rm 'repo/.createrepo'
211
+ end
212
+ end
213
+ end
214
+
161
215
  scheduler = Rufus::Scheduler.start_new
162
216
  scheduler.every '2s', :blocking => true do
163
217
  meta[:start_time] = Time.now
data/lib/pkg-wizard.rb CHANGED
@@ -4,7 +4,7 @@ require 'mixlib/cli'
4
4
 
5
5
  module PKGWizard
6
6
 
7
- VERSION = '0.1.12'
7
+ VERSION = '0.1.14'
8
8
 
9
9
  class Distribution
10
10
  def self.detect
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pkg-wizard
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 12
10
- version: 0.1.12
9
+ - 14
10
+ version: 0.1.14
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sergio Rubio