pkg-wizard 0.1.3 → 0.1.5

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.5
@@ -43,9 +43,9 @@ module PKGWizard
43
43
  "Missing pkg parameter.\n"
44
44
  else
45
45
  incoming_file = "incoming/#{pkg[:filename]}"
46
- $stdout.puts "Incoming file".ljust(40).bold.yellow + "#{pkg[:filename]}"
46
+ $stdout.puts "Incoming file".ljust(40) + "#{pkg[:filename]}"
47
47
  FileUtils.cp pkg[:tempfile].path, incoming_file
48
- $stdout.puts "File saved".ljust(40).green.bold + "#{pkg[:filename]}"
48
+ $stdout.puts "File saved".ljust(40) + "#{pkg[:filename]}"
49
49
  end
50
50
  end
51
51
 
@@ -67,39 +67,47 @@ module PKGWizard
67
67
  Dir.mkdir 'output' if not File.exist?('output')
68
68
  Dir.mkdir 'workspace' if not File.exist?('workspace')
69
69
  Dir.mkdir 'archive' if not File.exist?('archive')
70
+ Dir.mkdir 'failed' if not File.exist?('failed')
70
71
  scheduler = Rufus::Scheduler.start_new
71
72
  scheduler.every '2s', :blocking => true do
72
73
  meta[:start_time] = Time.now
73
74
  queue = Dir['incoming/*.src.rpm'].sort_by {|filename| File.mtime(filename) }
74
75
  if not queue.empty?
75
- job_time = Time.now.strftime '%Y%m%d_%H%M%S'
76
- $stdout.puts "Job accepted [#{queue.size} Queued]".ljust(40).blue.bold + job_time
77
76
  job_dir = "workspace/job_#{Time.now.strftime '%Y%m%d_%H%M%S'}"
77
+ qfile = File.join(job_dir, File.basename(queue.first))
78
+ job_time = Time.now.strftime '%Y%m%d_%H%M%S'
79
+ $stdout.puts "Job accepted [job_#{job_time}]".ljust(40) + File.basename(qfile)
78
80
  result_dir = job_dir + '/result'
79
81
  FileUtils.mkdir_p result_dir
80
82
  meta[:source] = File.basename(queue.first)
81
- qfile = File.join(job_dir, File.basename(queue.first))
82
83
  FileUtils.mv queue.first, qfile
83
- $stdout.puts "Building pkg [#{job_time}]".ljust(40).yellow.bold + "#{File.basename(qfile)}"
84
+ $stdout.puts "Building pkg [job_#{job_time}]".ljust(40).yellow.bold + "#{File.basename(qfile)}"
84
85
 
86
+ rdir = nil
85
87
  begin
86
88
  PKGWizard::Mock.srpm :srpm => qfile, :profile => mock_profile, :resultdir => result_dir
87
89
  meta[:status] = 'ok'
88
- $stdout.puts "Finished building [#{job_time}]".ljust(40).green.bold + "#{File.basename(qfile)}"
90
+ meta[:end_time] = Time.now
91
+ meta[:build_time] = meta[:end_time] - meta[:start_time]
92
+ $stdout.puts "Build OK [job_#{job_time}] #{meta[:build_time].to_i}s ".ljust(40).green.bold + "#{File.basename(qfile)}"
89
93
  rescue Exception => e
90
94
  meta[:status] = 'error'
91
- $stdout.puts "Job failed [#{job_time}]".ljust(40).red.bold
95
+ $stdout.puts "Build FAILED [job_#{job_time}]".ljust(40).red.bold + "#{File.basename(qfile)}"
92
96
  File.open(job_dir + '/buildbot.log', 'w') do |f|
93
97
  f.puts "#{e.backtrace.join("\n")}"
94
98
  f.puts "#{e.message}"
95
99
  end
96
100
  ensure
97
- meta[:end_time] = Time.now
98
- meta[:build_time] = meta[:end_time] - meta[:start_time]
99
101
  File.open(job_dir + '/meta.yml', 'w') do |f|
100
102
  f.puts meta.to_yaml
101
103
  end
102
- FileUtils.mv job_dir, 'output/'
104
+ if meta[:status] == 'error'
105
+ FileUtils.mv job_dir, 'failed/'
106
+ FileUtils.ln_sf "#{File.basename(job_dir)}", "failed/last"
107
+ else
108
+ FileUtils.mv job_dir, 'output/'
109
+ FileUtils.ln_sf "#{File.basename(job_dir)}", "output/last"
110
+ end
103
111
  end
104
112
  end
105
113
  end
@@ -30,6 +30,12 @@ module PKGWizard
30
30
  :short => '-b URL',
31
31
  :description => 'rpmwiz build-bot URL',
32
32
  :long => '--buildbot URL'
33
+
34
+ option :buildbot_port,
35
+ :short => '-p PORT',
36
+ :description => 'rpmwiz build-bot PORT (default 4567)',
37
+ :long => '--buildbot-port PORT',
38
+ :default => 4567
33
39
 
34
40
  option :tmpdir,
35
41
  :short => '-t TEMP',
@@ -41,7 +47,9 @@ module PKGWizard
41
47
  cli = RemoteBuild.new
42
48
  cli.banner = "\nUsage: rpmwiz remote-build (options)\n\n"
43
49
  pkgs = cli.parse_options
44
- bbot_url = cli.config[:buildbot]
50
+ bbot_host = cli.config[:buildbot]
51
+ bbot_port = cli.config[:buildbot_port]
52
+ bbot_url = "http://#{bbot_host}:#{bbot_port}"
45
53
  if bbot_url.nil?
46
54
  $stderr.puts "\n--buildbot is required.\n"
47
55
  puts cli.opt_parser.help
@@ -51,7 +59,7 @@ module PKGWizard
51
59
  pkgs.reject! do |p|
52
60
  if p =~ /http:\/\//
53
61
  pkg = URI.parse(p).path.split("/").last
54
- $stdout.puts "Downloading #{pkg}..."
62
+ $stdout.puts "Downloading: #{pkg}"
55
63
  downloaded_pkgs << download_from_url(p,cli.config[:tmpdir])
56
64
  true
57
65
  else
@@ -83,6 +91,7 @@ module PKGWizard
83
91
  fo = File.new(pkg)
84
92
  fsize = File.size(pkg)
85
93
  count = 0
94
+ pcount = 0
86
95
  $stdout.sync = true
87
96
  line_reset = "\r\e[0K"
88
97
  res = StreamingUploader.post(
@@ -92,11 +101,11 @@ module PKGWizard
92
101
  count += size
93
102
  per = (100*count)/fsize
94
103
  if per %10 == 0
95
- print "#{line_reset}Uploading:".ljust(40) + "#{(100*count)/fsize}% "
104
+ pcount += 10
105
+ print "#{line_reset}Uploading:".ljust(40) + "#{pcount}%"
96
106
  end
97
107
  end
98
- #puts "#{line_reset}Uploading: #{File.basename(pkg).gsub(/-((\d|\.)*)-(.*)\.src\.rpm/,'')} ".ljust(40) + "#{(100*count)/fsize}% [COMPLETE]"
99
- puts "#{line_reset}Uploading: #{File.basename(pkg)} ".ljust(40) + "#{(100*count)/fsize}% [COMPLETE]"
108
+ puts "#{line_reset}Uploading: #{File.basename(pkg)} ".ljust(40) + "[#{fsize}] [COMPLETE]"
100
109
  end
101
110
  end
102
111
 
@@ -105,7 +114,9 @@ module PKGWizard
105
114
  remote_pkg = uri.path.split('/').last
106
115
  d = StreamingDownloader.new
107
116
  f = "#{tmpdir}/#{remote_pkg}"
108
- d.download!(url, File.new(f, 'w'))
117
+ tmpfile = File.new(f, 'w')
118
+ d.download!(url, tmpfile)
119
+ tmpfile.close
109
120
  f
110
121
  end
111
122
 
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.3'
7
+ VERSION = '0.1.5'
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: 29
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 5
10
+ version: 0.1.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sergio Rubio
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-14 00:00:00 +01:00
18
+ date: 2011-02-15 00:00:00 +01:00
19
19
  default_executable: pkgwiz
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency