1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
|
<?php
/**
* Mageia build-system quick status report script.
*
* @copyright Copyright (C) 2011 Mageia.Org
*
* @author Olivier Blin
* @author Pascal Terjan
* @author Romain d'Alverny
* @author Michael Scherer
*
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU GPL v2
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License aspublished by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
*
* Shows submitted packages in the past $max_modified 24 hours and their
* status (built & uploaded, failed build, rejected, etc.).
*
* This was written anew in Jan. 2011 because existing Mandriva build-system
* web report code was not clearly licensed at this very time.
*/
error_reporting(E_ALL);
require __DIR__ . '/conf.php';
require __DIR__ . '/lib.php';
// sanity checks
if (!is_dir($upload_dir)) {
$msg = "$upload_dir does not exist on this system. Please check your config.";
error_log($msg);
die($msg);
}
$g_user = isset($_GET['user']) ? htmlentities(strip_tags($_GET['user'])) : null;
if ($g_user) {
$title .= ' for ' . $g_user . "'s packages";
$robots = 'no' . $robots;
}
$tz = new DateTimeZone('UTC');
$date_gen = date('c');
$matches = get_submitted_packages($upload_dir, $max_modified);
echo 'debug:count:matches', count($matches), '<br>';
list($pkgs, $hosts, $build_dates, $buildtime_total) = get_refined_packages_list(
$matches,
isset($_GET['package']) ? $_GET['package'] : null,
isset($_GET['user']) ? $_GET['user'] : null
);
echo 'debug:count:pkgs', count($pkgs), '<br>';
list($stats, $users, $total, $pkgs) = build_stats($pkgs);
publish_stats_headers(
$stats,
$buildtime_total,
$build_count,
(isset($_GET['last']) && $total > 0) ? reset($pkgs) : null
);
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title><?php echo strip_tags($title); ?></title>
<meta name="robots" content="<?php echo $robots; ?>">
<link rel="home" href="<?php echo $g_root_url; ?>">
<link rel="icon" type="image/png" href="favicon.png">
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1><?php echo $title ?></h1>
<?php
$bannerfile = dirname(__FILE__) . '/banner.html';
if (file_exists($bannerfile)) {
echo file_get_contents($bannerfile);
}
if (!is_null($g_user) || isset($_GET['package'])) {
echo '<a href="/">« Back to full list</a>';
}
echo '<ul>';
$figures_list = array();
if (!isset($_GET['package'])) {
// TODO should be cached.
$missing_deps_count = preg_match_all("/<item>/m", file_get_contents("http://check.mageia.org/cauldron/dependencies.rss"), $matches);
$unmaintained_count = file_exists(__DIR__ . '/data/unmaintained.txt') ? count(file(__DIR__ . '/data/unmaintained.txt')) : 0;
if ($missing_deps_count > 0
|| $unmaintained_count > 0
) {
if ($missing_deps_count > 0) {
$figures_list[] = sprintf('<span class="figure">%d</span> <a href="%s">broken dependencies</a>',
$missing_deps_count,
'http://check.mageia.org/cauldron/dependencies.html'
);
}
if ($unmaintained_count > 0) {
$figures_list[] = sprintf('<span class="figure">%d</span> <a href="%s">unmaintained package%s</a>',
$unmaintained_count,
'data/unmaintained.txt',
plural($unmaintained_count)
);
}
if (count($figures_list) > 0)
$figures_list[count($figures_list)-1] .= sprintf(' » <a href="%s" class="action-btn">%s</a>',
'https://wiki.mageia.org/en/Importing_packages',
'you can help!');
}
preg_match_all('/<span class="bz_result_count">(\d+)/', file_get_contents("https://bugs.mageia.org/buglist.cgi?quicksearch=%40qa-bugs+-kw%3Avali"), $matches);
$qa_bugs = $matches[1][0];
if ($qa_bugs > 0) {
$figures_list[] = sprintf('<span class="figure">%d</span> <a href="%s">package update%s to validate</a> » <a href="%s" class="action-btn">%s</a>',
$qa_bugs,
'https://bugs.mageia.org/buglist.cgi?quicksearch=%40qa-bugs+-kw%3Avali',
plural($qa_bugs),
'https://wiki.mageia.org/en/QA_process_for_validating_updates',
'you can help!'
);
}
if (count($figures_list) > 0) {
echo array_reduce($figures_list, function ($res, $e) { return $res . '<li><p>' . $e . '</p></li>'; }, '');
}
$buildtime_stats = array();
// Builds in progress
if (count($hosts) > 0) {
echo '<li>',
sprintf('<p><span class="figure">%d</span> build%s in progress:</p>', count($hosts), plural(count($hosts)));
$s = '';
$tmpl = <<<TB
<tr>
<td>%s</td>
<td>%s</td>
<td><a href="?user=%s">%s</a></td>
<td>%s</td>
<td>%s</td>
<td>%s/%s</td>
</tr>
TB;
foreach ($hosts as $machine => $b) {
foreach ($b as $arch => $key) {
$s .= sprintf($tmpl,
$machine,
$arch,
$pkgs[$key]['user'], $pkgs[$key]['user'],
$pkgs[$key]['package'],
$pkgs[$key]['version'],
$pkgs[$key]['media'], $pkgs[$key]['section']);
}
}
echo '<div align="center"><table>',
'<tr><th>Machine</th><th>Arch</th><th>User</th><th>Package</th><th>Target</th><th>Media</th></tr>',
$s,
'</table></div>',
'<div class="clear"></div>',
'</li>';
} else {
echo '<li><p>No build in progress.</p></li>';
}
}
$upload_time = get_upload_time();
if (!is_null($upload_time)) {
echo sprintf('<li><p>Upload in progress for %s.</p></li>', timediff($upload_time));
}
// Build queue
$s = '';
$tmpl = <<<T
<tr class="%s">
<td class="timeinfo">%s</td>
<td><a href="?user=%s">%s</a></td>
<td><a href="http://svnweb.mageia.org/packages?view=revision&revision=%d" title="%s">%s</a></td>
<td>%s</td>
<td>%s/%s</td>
<td class="status-box"></td>
T;
if ($total > 0) {
foreach ($pkgs as $key => $p) {
if (trim($p['package']) == '') {
continue;
}
$s .= sprintf($tmpl,
$p['type'],
timediff(key2timestamp($key)) . ' ago',
$p['user'], $p['user'],
$p['revision'],
addslashes($p['summary']),
$p['package'],
$p['version'],
$p['media'], $p['section']
);
$typelink = '';
if ($p['type'] == 'failure') {
$typelink = '/uploads/' . $p['type'] . '/' . $p['path'];
} elseif ($p['type'] == 'rejected') {
$typelink = '/uploads/' . $p['type'] . '/' . $p['path'] . '.youri';
} else {
$typelink = '/uploads/done/' . $p['path'];
if (!is_dir("..$typelink")) {
$typelink = '';
}
}
$typestr = $p['type'];
if ($p['status']['build']) {
$typealt = 'Building on';
foreach ($p['status']['build'] as $h) {
$typealt .= " $h";
}
$typestr = "<span title='$typealt'>$typestr</a>";
}
$s .= '<td>';
$s .= ($typelink != '') ?
sprintf('<a href="%s">%s</a>', $typelink, $typestr) :
$typestr;
$s .= '</td><td class="timeinfo">';
if ($p['type'] == 'uploaded') {
$tdiff = timediff($p['buildtime']['start'], $p['buildtime']['end']); // use $p['buildtime']['diff']; instead?
$s .= $tdiff;
$tdiff = floor(($p['buildtime']['end'] - $p['buildtime']['start']) / 60)*60;
@$buildtime_stats[timediff(0, $tdiff)] += 1;
}
$s .= '</td>';
$s .= '</tr>';
}
echo sprintf('<li><p><span class="figure">%d</span> packages submitted in the past %d hours:</p>', $total, $max_modified * 24);
// Table
echo '<table>',
'<thead><tr><th>Submitted</th><th>User</th>
<th>Package</th><th>Target</th><th>Media</th>
<th colspan="2">Status</th><th>Build time</th></tr></thead>',
'<tbody>', $s, '</tbody>',
'</table>';
// Stats
$s = '<div id="stats">
<div id="status-chart"></div>
<div id="packagers-chart"></div>';
$s .= sprintf('<table style="width: 80%;"><tr><td>Total time</td><td>%s hours</td></tr>
<tr><td>Average</td><td>%s minutes</td></tr>
<tr><td>Builds count</td><td>%s</td></tr></table>',
round($buildtime_total / 60, 2),
$buildtime_avg,
$buildtime_cnt);
$s .= '</table><br /><br />';
$s .= '<div id="buildtime-chart"></div>
<div id="buildschedule-chart"></div>';
$s .= '</div>';
echo $s, '</li></ul>';
uksort($buildtime_stats, "timesort");
echo '<script>',
mga_bs_charts::js_draw_status_chart($stats, 'status-chart'),
mga_bs_charts::js_draw_buildtime_chart($buildtime_stats, 'buildtime-chart'),
mga_bs_charts::js_draw_buildschedule_chart($build_dates, 'buildschedule-chart'),
mga_bs_charts::js_draw_packagers_chart($users, 'packagers-chart'),
mga_bs_charts::js_draw_charts(),
'</script>';
echo mga_bs_charts::js_init();
}
else
{
echo sprintf('<li><p>No package has been submitted in the past %d hours.</p></li></ul>',
$max_modified * 24);
}
?>
</ul>
<div class="clear"></div>
<hr />
<p>Generated at <?php echo $date_gen; ?>.
Code for this page is in <a href="http://svnweb.mageia.org/soft/build_system/web/">http://svnweb.mageia.org/soft/build_system/web/</a>.</p>
</body>
</html>
|