3 date_default_timezone_set ("GMT");
5 $script_path = '/var/www/bs/';
6 $bs_result_path = '/home/mandrake/uploads/';
8 /* Page creation start time */
9 $starttime = microtime(true);
11 /* BuildSystem paths */
12 $queuedir = "$bs_result_path/todo";
13 $faileddir = "$bs_result_path/failure";
14 $donedir = "$bs_result_path/done";
15 $rejecteddir = "$bs_result_path/rejected";
16 $builddir = "/home/mandrake/iurt";
18 /* Required archs for considering a package as 'built' */
19 $requiredarchs = array ("i586", "x86_64");
20 $sufficientarchs = array ("noarch");
23 $snmp_timeout = 1000000; /* miliseconds */
26 * format_time($timestamp)
27 * Formats a timestamp to a human-readable time
29 function format_time($timestamp)
31 return preg_replace("/(....)(..)(..)(..)(..)(..)/", '$1-$2-$3 $4:$5:$6', $timestamp);
35 * delta_time($timestamp)
36 * Provides a delta time from now to $timestamp.
38 function delta_time($timestamp, $reference = '')
40 $ftime = strptime ($timestamp, '%Y%m%d%H%M%S');
47 $ftime['tm_year'] +
1900
50 if (strlen ($reference)) {
51 $ftime = strptime ($reference, '%Y%m%d%H%M%S');
52 $reference = gmmktime (
58 $ftime['tm_year'] +
1900
62 $reference = gmmktime();
64 $delta = $reference - $stamp;
65 $days = date ("z", $delta);
66 $hours = date("G", $delta);
67 $mins = date("i", $delta);
68 $secs = date("s", $delta);
69 $strdays = $days > 1 ?
"days" : "day";
70 $strhours = $hours > 1 ?
"hours" : "hour";
71 $strmins = $mins > 1 ?
"minutes" : "minute";
72 $strsecs = $secs > 1 ?
"seconds" : "second";
74 return "$days $strdays";
77 return "$days $strdays $hours $strhours";
80 return "${hours}h ${mins}min";
83 return "${mins}min ${secs}s";
91 * Just like it sounds.
93 function page_header($title)
98 <link href
="http://www.mandriva.com/archives/extension/mdkdesign/design/mdk/stylesheets/screen.css" rel
="stylesheet" type
="text/css">
99 <link href
="http://www.mandriva.com/archives/design/mdk/stylesheets/target.css.php?t=none" rel
="stylesheet" type
="text/css">
100 <link href
="http://www.mandriva.com/extension/mdkdesign/design/mdk/stylesheets/screen.css" rel
="stylesheet" type
="text/css">
101 <link href
="http://www.mandriva.com/design/mdk/stylesheets/target.css.php?t=none" rel
="stylesheet" type
="text/css">
102 <link href
="http://www.mandriva.com/extension/mdkdesign/design/mdk/stylesheets/welcome.css" rel
="stylesheet" type
="text/css">
103 <link href
="style.css" rel
="stylesheet" type
="text/css">
104 <title
>Mandriva Build System
<?
php ($title) ?
print(" - ".$title) : "" ; ?
></title
>
108 <div id
="header-design">
110 <h3 id
="hide">Intersites Menu
</h3
>
112 <li id
="is_store"><a href
="http://store.mandriva.com/"><span
>Store
</span
></a
></li
>
113 <li id
="is_club"><a href
="http://club.mandriva.com/"><span
>Club
</span
></a
></li
>
114 <li id
="is_support"><a href
="http://www.mandriva.com/en/support"><span
>Support
</span
></a
></li
>
115 <li id
="is_downloads"><a href
="http://www.mandriva.com/en/download/free"><span
>Downloads
</span
></a
></li
>
116 <li id
="is_company"><a href
="http://www.mandriva.com/enterprise/en/company"><span
>Company
</span
></a
></li
>
118 <div
class="break"></div
>
120 <div id
="header-logo">
121 <h1
><a href
="http://www.mandriva.com/"><span
>Mandriva
</span
></a
></h1
>
122 <div
class="break"></div
>
124 <div id
="header-tools">
127 <td
><font size
=+
2>Mandriva Development Server
</font
></td
>
130 <div
class="break"></div
>
132 <div
class="break"></div
>
144 * Just like it sounds.
146 function page_footer()
149 Page generation time
:
152 printf ("%5.3fs", microtime(true)-$starttime);
162 * Prints the navigation bar
164 function navigation_bar()
167 <table width
="99%" cols
=6 cellspacing
=0 border
=0>
170 <nobr
><?php
echo gmdate ("D, Y-m-d G:i:s T");?
></nobr
>
175 <a href
="cluster.php">Cluster overview
</a
>
181 <a href
="http://kenobi.mandriva.com/ganglia/">System Status
</a
>
186 <a href
="queue.php">Queue
</a
>
191 <a href
="build.php">Building
</a
>
196 <a href
="output.php">Output
</a
>
203 Filter
: <input type
="text" name
="filter" value
="<?php echo $_GET['filter'];?>"><input type
="submit" value
="ok">
215 * parse_filterstring($filterstr)
216 * Parse the requested filterstr and properly sets up the globals
217 * $mustbe, $mustbenot and $oneof. Parsing this before avoids reparsing
218 * for all table cells.
220 function parse_filterstring($filterstr)
222 global $mustbe, $mustbenot, $oneof;
223 $filterstr = $_GET['filter'];
224 $words = explode(' ', $filterstr);
227 $mustbenot = array();
228 foreach ($words as $word) {
229 if ($word[0] == '-') {
230 $mustbenot[] = substr($word, 1);
232 elseif ($word[0] == '+') {
233 $mustbe[] = substr($word, 1);
244 * Match a table row against the globals $mustbe, $mustbenot and $oneof.
245 * Returns False to rows not filling the request, otherelse True.
247 function filter_item ($item)
249 global $mustbe, $mustbenot, $oneof;
252 foreach ($item as $element) {
253 foreach ($mustbenot as $badword) {
254 if (strstr($element, $badword)) {
258 foreach ($mustbe as $goodword) {
259 if (strstr($element, $goodword)) {
263 foreach ($oneof as $goodword) {
264 if (strstr($element, $goodword)) {
270 ($foundmustbe == count($mustbe)) and
271 (count($oneof) ?
$foundoneof > 0 : 1)
278 * Filter the given array according to the filter expression
279 * requested via GET method.
280 * Returns the filtered table.
282 function filter ($table)
284 $filterstr = $_GET['filter'];
288 parse_filterstring($filterstr);
289 return array_filter($table, "filter_item");
294 * parse_lock_item($item)
295 * Parses a given lock and returns a fields array
296 * $item must be like this:
297 * (base)_x86_64.iurt.frohike.20061101163646.4273.lock
299 function parse_lock_item($item)
301 preg_match('/_([A-Za-z0-9-_]+).iurt.(\w+)\.([0-9]{14})\.([0-9]+)/', $item, $file);
302 // i586 frohike 20061101163646 4273
304 if (strstr ($arch, "-noarch")) {
309 $file[2], // buildhost
310 $file[3], // build start time
318 * Parse the .info file, that contains .src.rpm informations
320 function parse_info($item)
323 $contents = @file
("$queuedir/$item");
324 $contents = array_map ("trim", $contents);
327 * Hide epoch information.
329 if ($contents[1] != "(none)") {
330 $version = "${contents[1]}:${contents[2]}";
333 $version = "${contents[2]}";
336 $version = "${contents[2]}";
338 preg_match('/^([^\/]+)\/([^\/]+)\/([^\/]+)\//', $item, $distrorepos);
339 // cooker contrib release
340 preg_match('/\/([0-9]{14})\.([a-zA-Z0-9]+)\.([a-zA-Z0-9]+)/', $item, $author);
341 // 20061026140631 neoclust kenobi
342 preg_match('/\.([0-9]+)_@([0-9]+):(.+)/', $item, $file);
343 // 29995 @-73078 crimson..\
345 preg_match('/\.([0-9]+)_(.+)/', $item, $file);
346 // 29995 @-73078 crimson..
355 "${distrorepos[2]}/${distrorepos[3]}",
366 * Search and return the list of info files
368 function list_info_files()
372 @exec
("find -L $queuedir -mindepth 4 -maxdepth 4 -type f -ctime -3 -name '*.src.rpm.info' |\
373 sed 's@$queuedir/*@@;".'s@.*/\([0-9]\{14\}\.\w\+\.\w\+\.[0-9]\{1,5\}\)_.*@\1 &@'."'", $rawlist);
375 foreach ($rawlist as $infoline) {
376 list ($id, $infofile) = split (" ", $infoline);
377 $infolist[$id] = $infofile;
380 $idlist = array_keys ($infolist);
382 return array (array_reverse ($idlist), $infolist);