Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 147 lines (125 sloc) 5.683 kb
f1bc6546 » Flameeyes
2012-06-15 Use ruby19 for the script, so that we can use advanced sockets.
1 #!/usr/bin/ruby19
4cfd669f » Flameeyes
2012-06-15 Import initial script that receives a tar in input and produces an ou…
2 # -*- coding: utf-8 -*-
3 # Copyright © 2012 Diego Elio Pettenò <flameeyes@flameeyes.eu>
4 #
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
8 #
9 # THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
10 # ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
11 # OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
12 # CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 # DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 # PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
15 # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
16 # SOFTWARE.
17
6c6f25a8 » Flameeyes
2012-10-21 Make it all use inifile 2.
18 gem 'inifile', '>= 2'
450af901 » Flameeyes
2012-06-15 Add support for sending the logs to S3.
19 require 'inifile'
20 require 'aws'
9ef25a37 » Flameeyes
2012-06-15 Transform the script from a pipe to a multi-service daemon.
21 require 'socket'
4cfd669f » Flameeyes
2012-06-15 Import initial script that receives a tar in input and produces an ou…
22 require 'archive/tar/minitar'
450af901 » Flameeyes
2012-06-15 Add support for sending the logs to S3.
23 require 'builder'
4cfd669f » Flameeyes
2012-06-15 Import initial script that receives a tar in input and produces an ou…
24
270f9295 » Flameeyes
2013-02-05 Add one more warning about udev rules to the list of the highlighted …
25 warnings = Regexp.new("(Tinderbox QA Warning!|QA Notice: (Pre-stripped|file does not exist|command not found|USE flag|Files built without respecting|The following files)|linux_config_exists|will always overflow|called with bigger|maintainer mode detected|econf called in src_compile|udev rules should be installed)")
4cfd669f » Flameeyes
2012-06-15 Import initial script that receives a tar in input and produces an ou…
26
6c6f25a8 » Flameeyes
2012-10-21 Make it all use inifile 2.
27 config = IniFile.new(File.read("./tboxanalysis.ini"))
450af901 » Flameeyes
2012-06-15 Add support for sending the logs to S3.
28
29 s3 = AWS::S3.new(:access_key_id => config['aws']['access_key'],
30 :secret_access_key => config['aws']['secret_key'])
31
98815c1a » Flameeyes
2012-06-15 Store basic data about the analysis on Amazon's SimpleDB.
32 bucket_name = config['aws']['bucket']
33 bucket = s3.buckets[bucket_name]
34 s3.buckets.create(bucket_name) unless bucket.exists?
450af901 » Flameeyes
2012-06-15 Add support for sending the logs to S3.
35
36 unless bucket.objects['htmlgrep.css']
37 bucket.objects.create('htmlgrep.css',
38 :file => 'htmlgrep.css',
39 :acl => :public_read,
40 :content_type => "text/css",
41 :storage_class => :reduced_redundancy)
42 end
43
98815c1a » Flameeyes
2012-06-15 Store basic data about the analysis on Amazon's SimpleDB.
44 sdb = AWS::SimpleDB.new(:access_key_id => config['aws']['access_key'],
45 :secret_access_key => config['aws']['secret_key'])
46
47 domain_name = config['aws']['domain']
48 domain = sdb.domains[domain_name]
49 sdb.domains.create(domain_name) unless domain.exists?
50
9ef25a37 » Flameeyes
2012-06-15 Transform the script from a pipe to a multi-service daemon.
51 Socket.tcp_server_loop("::", 28011) do |sock, client_host|
5593764e » Flameeyes
2012-06-25 Create a new thread for each connection inbound.
52 Thread.new {
53 begin
54 hostname = client_host.getnameinfo()[0] rescue client_host.ip_address
55 puts "Received connection from #{hostname}"
56
57 Archive::Tar::Minitar::Reader.open(sock) do |input|
58 input.each do |log|
59 matches = 0
60 pkg_failed = false
61 test_failed = false
56ae55b5 » Flameeyes
2012-07-16 Fix handling of file collisions.
62 collision = false
5593764e » Flameeyes
2012-06-25 Create a new thread for each connection inbound.
63 bug_assignee = 'bug-wranglers@gentoo.org'
64 bug_cc = ''
65
66 next unless log.file?
67
2045198f » Flameeyes
2012-06-25 Add some more output diagnostics.
68 puts " got file #{log.name}"
69
5593764e » Flameeyes
2012-06-25 Create a new thread for each connection inbound.
70 log_name = File.basename(log.name, ".log")
71
72 xml_builder = Builder::XmlMarkup.new(:indent => 2)
73 xml_builder.instruct!
74
75 html_output = xml_builder.html {
76 xml_builder.head {
77 xml_builder.link(:href => "../htmlgrep.css",
78 :rel => "stylesheet",
79 :type => "text/css")
80 }
12b1e26a » Flameeyes
2012-06-17 Do a smarter match on the lines to split warnings and errors.
81
5593764e » Flameeyes
2012-06-25 Create a new thread for each connection inbound.
82 xml_builder.body {
83 xml_builder.ol {
84 log.read.split("\n").each do |line|
85 match = false
86
87 # remove escape sequences
8767bc7a » Flameeyes
2012-07-05 Make sure to strip out escape reset as well.
88 line.gsub!(/\x1b\[[^\x40-\x7e]*[\x40-\x7e]/, '')
5593764e » Flameeyes
2012-06-25 Create a new thread for each connection inbound.
89
90 if line =~ warnings
91 match = true
92 elsif line =~ /^ \* ERROR: .* failed \(test phase\):/
93 test_failed = true
94 match = true
5d0e23d6 » Flameeyes
2012-07-16 List detected file collisions as build failure _and_ separately.
95 elsif line =~ /^ \* ERROR: .* failed/
5593764e » Flameeyes
2012-06-25 Create a new thread for each connection inbound.
96 pkg_failed = true
97 match = true
5d0e23d6 » Flameeyes
2012-07-16 List detected file collisions as build failure _and_ separately.
98 elsif line =~ /Detected file collision/
99 pkg_failed = true
100 collision = true
101 match = true
6c5b9efd » Flameeyes
2012-06-27 Match hkBst as well.
102 elsif line =~ /^ \* Maintainer: ([a-zA-Z0-9.@_+-]+)(?: ([a-zA-Z0-9.@_+,-]+))?$/
5593764e » Flameeyes
2012-06-25 Create a new thread for each connection inbound.
103 bug_assignee = $1
104 bug_cc = $2
105 end
106
107 if match
108 matches += 1
109 xml_builder.li(line, :class => "match")
110 else
111 xml_builder.li(line)
112 end
9ef25a37 » Flameeyes
2012-06-15 Transform the script from a pipe to a multi-service daemon.
113 end
5593764e » Flameeyes
2012-06-25 Create a new thread for each connection inbound.
114 }
9ef25a37 » Flameeyes
2012-06-15 Transform the script from a pipe to a multi-service daemon.
115 }
116 }
5593764e » Flameeyes
2012-06-25 Create a new thread for each connection inbound.
117
118 html_log = bucket.objects.create("#{hostname}/#{log_name}.html",
119 :data => html_output,
120 :acl => :public_read,
121 # if we don't use text/html Chromium is
122 # unable to render it with the CSS.
123 :content_type => 'text/html',
124 :storage_class => :reduced_redundancy)
125
126 log_parts = log_name.split(':')
127 pkg_name = log_parts[0..1].join("/")
128 date_time = log_parts[2]
129
130 domain.items.create("#{hostname}/#{log_name}",
131 :host => hostname,
132 :pkg => pkg_name,
133 :date => date_time,
134 :matches => matches,
135 :pkg_failed => pkg_failed,
136 :test_failed => test_failed,
5d0e23d6 » Flameeyes
2012-07-16 List detected file collisions as build failure _and_ separately.
137 :collision => collision,
5593764e » Flameeyes
2012-06-25 Create a new thread for each connection inbound.
138 :public_url => html_log.public_url,
139 :bug_assignee => bug_assignee,
140 :bug_cc => bug_cc);
141 end
9ef25a37 » Flameeyes
2012-06-15 Transform the script from a pipe to a multi-service daemon.
142 end
5593764e » Flameeyes
2012-06-25 Create a new thread for each connection inbound.
143 ensure
144 sock.close
9ef25a37 » Flameeyes
2012-06-15 Transform the script from a pipe to a multi-service daemon.
145 end
5593764e » Flameeyes
2012-06-25 Create a new thread for each connection inbound.
146 }
4cfd669f » Flameeyes
2012-06-15 Import initial script that receives a tar in input and produces an ou…
147 end
Something went wrong with that request. Please try again.