/[soft]/build_system/web/index.php
ViewVC logotype

Contents of /build_system/web/index.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6684 - (show annotations) (download)
Mon Dec 10 17:08:01 2012 UTC (11 years, 4 months ago) by boklm
File size: 8473 byte(s)
conf.php: add $themes_dir variable
1 <?php
2 /**
3 * Mageia build-system quick status report script.
4 *
5 * @copyright Copyright (C) 2011 Mageia.Org
6 *
7 * @author Olivier Blin
8 * @author Pascal Terjan
9 * @author Romain d'Alverny
10 * @author Michael Scherer
11 *
12 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU GPL v2
13 *
14 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License aspublished by the
16 * Free Software Foundation; either version 2 of the License, or (at your
17 * option) any later version.
18 *
19 *
20 * Shows submitted packages in the past $max_modified 24 hours and their
21 * status (built & uploaded, failed build, rejected, etc.).
22 *
23 * This was written anew in Jan. 2011 because existing Mandriva build-system
24 * web report code was not clearly licensed at this very time.
25 */
26
27 error_reporting(E_ALL);
28
29 require __DIR__ . '/conf.php';
30 require __DIR__ . '/lib.php';
31
32 // sanity checks
33 if (!is_dir($upload_dir)) {
34 $msg = "$upload_dir does not exist on this system. Please check your config.";
35 error_log($msg);
36 die($msg);
37 }
38
39 $g_user = isset($_GET['user']) ? htmlentities(strip_tags($_GET['user'])) : null;
40
41 if ($g_user) {
42 $title .= ' for ' . $g_user . "'s packages";
43 $robots = 'no' . $robots;
44 }
45 $tz = new DateTimeZone('UTC');
46 $date_gen = date('c');
47
48 $matches = get_submitted_packages($upload_dir, $max_modified);
49
50 list($pkgs, $hosts, $build_count, $build_dates, $buildtime_total) = get_refined_packages_list(
51 $matches,
52 isset($_GET['package']) ? $_GET['package'] : null,
53 isset($_GET['user']) ? $_GET['user'] : null
54 );
55
56 list($stats, $users, $total, $pkgs) = build_stats($pkgs);
57
58 $buildtime_total = $buildtime_total / 60;
59 $buildtime_avg = ($build_count == 0) ?
60 0 :
61 round($buildtime_total / $build_count, 2);
62
63 publish_stats_headers(
64 $stats,
65 $buildtime_total,
66 $buildtime_avg,
67 $build_count,
68 (isset($_GET['last']) && $total > 0) ? reset($pkgs) : null
69 );
70
71 require "$themes_dir/$theme_name/page_header.php";
72
73 if (!isset($_GET['package'])) {
74 $bannerfile = dirname(__FILE__) . '/banner.html';
75 if (file_exists($bannerfile)) {
76 echo file_get_contents($bannerfile);
77 }
78
79 if (!is_null($g_user) || isset($_GET['package'])) {
80 echo '<a href="/">&laquo;&nbsp;Back to full list</a>';
81 }
82
83 echo '<ul class="builds">';
84 $buildtime_stats = array();
85
86 // Builds in progress
87 if (count($hosts) > 0) {
88 echo '<li>',
89 sprintf('<p><span class="figure">%d</span> build%s in progress:</p>', count($hosts), plural(count($hosts)));
90
91 $s = '';
92 $tmpl = <<<TB
93 <tr>
94 <td><span class="package">%s</span></td>
95 <td><a rel="nofollow" href="?user=%s">%s</a></td>
96 <td>%s <span class="media">%s/%s</span></td>
97 <td>%s <span class="media">%s</span></td>
98 </tr>
99 TB;
100 foreach ($hosts as $machine => $b) {
101 foreach ($b as $arch => $key) {
102 $s .= sprintf($tmpl,
103 $pkgs[$key]['package'],
104 $pkgs[$key]['user'], $pkgs[$key]['user'],
105 $pkgs[$key]['version'], $pkgs[$key]['media'], $pkgs[$key]['section'],
106 $machine, $arch);
107 }
108 }
109 echo '<div align="center"><table><thead><tr>',
110 '<th>Package</th>
111 <th>User</th>
112 <th>Target <span class="media">media</span></th>
113 <th>Machine <span class="media">arch</span></th></tr></thead><tbody>',
114 $s,
115 '</tbody></table></div>',
116 '<div class="clear"></div>',
117 '</li>';
118 } else {
119 //echo '<li><p>No build in progress.</p></li>';
120 }
121 }
122
123 $upload_time = get_upload_time();
124 if (!is_null($upload_time)) {
125 echo sprintf('<li><p>Upload in progress for %s.</p></li>', timediff($upload_time));
126 }
127
128 // Build queue
129 $s = '';
130 $tmpl = <<<T
131 <tr class="%s">
132 <td><span class="status-box"></span> <a rel="nofollow" href="%s" title="%s" class="package">%s</a></td>
133 <td class="user"><a rel="nofollow" href="?user=%s" class="committer">%s</a>
134 <span class="timeinfo">%s</span></td>
135 <td>%s
136 <span class="media">%s/%s</span></td>
137 T;
138
139 if ($total > 0) {
140 foreach ($pkgs as $key => $p) {
141 if (trim($p['package']) == '') {
142 continue;
143 }
144 $revision_link = sprintf($package_commit_url, $p['revision']);
145
146 $s .= sprintf($tmpl,
147 $p['type'],
148 $revision_link,
149 addslashes($p['summary']),
150 $p['package'],
151 $p['user'], $p['user'],
152 timediff(key2timestamp($key)) . ' ago',
153 $p['version'],
154 $p['media'], $p['section']
155 );
156
157 $typelink = '';
158 if ($p['type'] == 'failure') {
159 $typelink = '/uploads/' . $p['type'] . '/' . $p['path'];
160 } elseif ($p['type'] == 'rejected') {
161 $typelink = '/uploads/' . $p['type'] . '/' . $p['path'] . '.youri';
162 } else {
163 $typelink = '/uploads/done/' . $p['path'];
164 if (!is_dir(realpath($upload_dir . '/..' . $typelink))) {
165 $typelink = '';
166 }
167 }
168 $typestr = $p['type'];
169 if (isset($p['status']['build'])) {
170 $typealt = 'Building on';
171 foreach ($p['status']['build'] as $h) {
172 $typealt .= " $h";
173 }
174 $typestr = "<span title='$typealt'>$typestr</a>";
175 }
176
177 $s .= '<td class="status">';
178
179 $show_time = '';
180 if ($p['type'] == 'uploaded') {
181 $tdiff = timediff($p['buildtime']['start'], $p['buildtime']['end']); // use $p['buildtime']['diff']; instead?
182 $show_time = '<span class="timeinfo">' . $tdiff . '</span>';
183
184 $tdiff = floor(($p['buildtime']['end'] - $p['buildtime']['start']) / 60)*60;
185 @$buildtime_stats[timediff(0, $tdiff)] += 1;
186 }
187 $s .= ($typelink != '')
188 ? sprintf('<a rel="nofollow" href="%s" class="status-link"><span class="status-box"></span> %s %s</a>',
189 $typelink, $typestr, $show_time)
190 : sprintf('<span class="status-box"></span> %s %s',
191 $typestr, $show_time);
192
193 $s .= '</td></tr>';
194 }
195 echo sprintf('<li><p><span class="figure">%d</span> packages submitted in the past %d&nbsp;hours:</p>', $total, $max_modified * 24);
196
197 // Last submitted packages
198 echo '<table id="submitted-packages">',
199 '<thead><tr>
200 <th>Package</th>
201 <th>Who <span class="timeinfo">when</span></th>
202 <th>Target <span class="media">media</span></th>
203 <th>Status <span class="timeinfo">process&nbsp;time</span></th>
204 </tr></thead>',
205 '<tbody>', $s, '</tbody>',
206 '</table>';
207
208 echo '</li></ul>';
209
210 // Stats
211 $s = '<ul id="stats">
212 <li><p><span class="figure">Stats</span></p></li>
213 <li id="status-chart"></li>
214 <li id="packagers-chart"></li>';
215
216 $total_buildtime = round($buildtime_total / 60, 1);
217 $avail_capacity = 24 * $max_modified * $g_nodes_count;
218 $capacity_used = round($total_buildtime / $avail_capacity * 100, 1);
219 $s .= sprintf(
220 '<table style="width: 70%%; margin: 2em 0 2em 80px;">
221 <tr><td>Total time</td><td>%s hours (%s%% of capacity with %d nodes)</td></tr>
222 <tr><td>Average</td><td>%s minutes</td></tr>
223 <tr><td>Builds count</td><td>%s</td></tr>
224 </table>',
225 $total_buildtime,
226 $capacity_used,
227 $g_nodes_count,
228 $buildtime_avg,
229 $build_count
230 );
231
232 $s .= '<li id="buildtime-chart"></li>
233 <li id="buildschedule-chart"></li>
234 </ul>';
235
236 echo $s;
237
238 uksort($buildtime_stats, "timesort");
239 echo '<script>',
240 mga_bs_charts::js_draw_status_chart($stats, 'status-chart'),
241 mga_bs_charts::js_draw_buildtime_chart($buildtime_stats, 'buildtime-chart'),
242 mga_bs_charts::js_draw_buildschedule_chart($build_dates, 'buildschedule-chart'),
243 mga_bs_charts::js_draw_packagers_chart($users, 'packagers-chart'),
244 mga_bs_charts::js_draw_charts(),
245 '</script>';
246 echo mga_bs_charts::js_init();
247 }
248 else
249 {
250 echo sprintf('<li><p>No package has been submitted in the past %d&nbsp;hours.</p></li></ul>',
251 $max_modified * 24);
252 }
253
254 ?>
255 </ul>
256 <script src="js/jquery.js"></script>
257 <script src="js/pkgsubmit.js"></script>
258 <?php
259 require "$themes_dir/$theme_name/page_footer.php";
260 ?>

  ViewVC Help
Powered by ViewVC 1.1.30