1 |
pterjan |
268 |
<?php |
2 |
|
|
|
3 |
|
|
/* Copyright (C) 2011 Oliver Blin *\ |
4 |
|
|
/**************************************************************************\ |
5 |
|
|
* This program is free software; you can redistribute it and/or modify it * |
6 |
|
|
* under the terms of the GNU General Public License aspublished by the * |
7 |
|
|
* Free Software Foundation; either version 2 of the License, or (at your * |
8 |
|
|
* option) any later version. * |
9 |
|
|
\**************************************************************************/ |
10 |
|
|
|
11 |
|
|
error_reporting(E_ALL); |
12 |
|
|
|
13 |
|
|
$upload_dir = "/home/schedbot/uploads"; |
14 |
|
|
$max_modified = 2; |
15 |
pterjan |
269 |
$title = "Mageia build system status"; |
16 |
|
|
$tz = new DateTimeZone("UTC"); |
17 |
pterjan |
268 |
|
18 |
pterjan |
269 |
# Temporary until initial mirror is ready |
19 |
|
|
$nb_rpm = shell_exec('rpm -qp --qf "%{SOURCERPM}\n" /distrib/bootstrap/distrib/cauldron/i586/media/core/release/*.rpm | sort -u | tee src.txt | wc -l'); |
20 |
|
|
$nb_rpm_mga = shell_exec('grep mga src.txt | tee src.mga.txt | wc -l'); |
21 |
|
|
shell_exec('grep -v mga src.txt > src.mdv.txt'); |
22 |
|
|
######################################### |
23 |
|
|
|
24 |
pterjan |
268 |
chdir($upload_dir); |
25 |
|
|
|
26 |
pterjan |
269 |
$all_files = shell_exec("find \( -name '*.rpm' -o -name '*.src.rpm.info' -o -name '*.youri' -o -name '*.lock' -o -name '*.done' \) ! -ctime $max_modified"); |
27 |
pterjan |
268 |
|
28 |
pterjan |
269 |
preg_match_all("!^\./(\w+)/((\w+)/(\w+)/(\w+)/(\d+)\.(\w+)\.(\w+)\.(\d+))_?(.+)(\.src\.rpm(?:\.info)?|\.youri|\.lock|\.done)$!m", $all_files, $matches, PREG_SET_ORDER); |
29 |
|
|
|
30 |
pterjan |
268 |
$pkgs = array(); |
31 |
|
|
foreach ($matches as $val) { |
32 |
pterjan |
269 |
if ($_GET["user"] && ($_GET["user"] != $val[7])) { |
33 |
|
|
continue; |
34 |
|
|
} |
35 |
|
|
$key = $val[6] . $val[7]; |
36 |
pterjan |
268 |
if (!is_array($pkgs[$key])) { |
37 |
|
|
$pkgs[$key] = array(); |
38 |
|
|
$pkgs[$key]["status"] = array(); |
39 |
|
|
$pkgs[$key]["path"] = $val[2]; |
40 |
|
|
$pkgs[$key]["version"] = $val[3]; |
41 |
|
|
$pkgs[$key]["media"] = $val[4]; |
42 |
|
|
$pkgs[$key]["section"] = $val[5]; |
43 |
|
|
$pkgs[$key]["user"] = $val[7]; |
44 |
|
|
$pkgs[$key]["host"] = $val[8]; |
45 |
|
|
$pkgs[$key]["job"] = $val[9]; |
46 |
|
|
} |
47 |
|
|
|
48 |
|
|
$status = $val[1]; |
49 |
|
|
$data = $val[10]; |
50 |
pterjan |
269 |
$pkgs[$key]["status"][$status] = $data; |
51 |
pterjan |
268 |
$ext = $val[11]; |
52 |
|
|
if ($ext == ".src.rpm.info") { |
53 |
|
|
preg_match("!^(?:@\d+:)?(.*)!", $data, $name); |
54 |
|
|
$pkgs[$key]["package"] = $name[1]; |
55 |
|
|
} else if ($ext == ".src") { |
56 |
|
|
$pkgs[$key]["status"]["src"] = 1; |
57 |
|
|
} else if ($ext == ".youri") { |
58 |
|
|
$pkgs[$key]["status"]["youri"] = 1; |
59 |
|
|
} else if ($ext == ".lock") { |
60 |
pterjan |
269 |
preg_match("/(.*)\..*\.(.*)\.\d+\.\d+/", "(\1@\2)", $data); |
61 |
pterjan |
268 |
// parse build bot from $data |
62 |
pterjan |
269 |
$pkgs[$key]["status"]["build"] = $data; |
63 |
pterjan |
268 |
} |
64 |
|
|
} |
65 |
|
|
// sort by key in reverse order to have more recent pkgs first |
66 |
|
|
krsort($pkgs); |
67 |
|
|
?> |
68 |
|
|
<html> |
69 |
|
|
|
70 |
|
|
<head> |
71 |
|
|
<title><? echo $title ?></title> |
72 |
|
|
<style type="text/css"> |
73 |
pterjan |
269 |
table { |
74 |
|
|
border-spacing: 0; |
75 |
|
|
font-family: Helvetica; font-size: 80%; |
76 |
|
|
border: 1px solid #ccc; |
77 |
pterjan |
268 |
} |
78 |
pterjan |
269 |
table tr { padding: 0; margin: 0; } |
79 |
|
|
table th { padding: 0.2em 0.5em; margin: 0; border-bottom: 2px solid #ccc; border-right: 1px solid #ccc; } |
80 |
|
|
table td { padding: 0; margin: 0; padding: 0.2em 0.5em; border-bottom: 1px solid #ccc; } |
81 |
|
|
|
82 |
|
|
tr { background: transparent; } |
83 |
|
|
tr.uploaded { background: #ddffdd; } |
84 |
|
|
tr.failure, tr.rejected { background: #ffdddd; } |
85 |
|
|
tr.todo { background: white; } |
86 |
|
|
tr.building { background: #ffffdd; } |
87 |
|
|
tr.partial { background: blue; } |
88 |
|
|
tr.built { background: #00CCFF; } |
89 |
|
|
tr.youri { background: olive; } |
90 |
|
|
|
91 |
|
|
td.status-box { width: 1em; height: 1em; } |
92 |
|
|
tr.uploaded td.status-box { background: green; } |
93 |
|
|
tr.failure td.status-box, tr.rejected td.status-box { background: red; } |
94 |
|
|
tr.todo td.status-box { background: white; } |
95 |
|
|
tr.building td.status-box { background: yellow; } |
96 |
|
|
tr.partial td.status-box { background: blue; } |
97 |
|
|
tr.built td.status-box { background: #00CCFF; } |
98 |
|
|
tr.youri td.status-box { background: olive; } |
99 |
|
|
|
100 |
pterjan |
268 |
</style> |
101 |
|
|
</head> |
102 |
|
|
|
103 |
|
|
<body> |
104 |
|
|
<h1><? echo $title ?></h1> |
105 |
|
|
|
106 |
|
|
<table> |
107 |
|
|
<? |
108 |
|
|
function pkg_gettype($pkg) { |
109 |
|
|
if (array_key_exists("rejected", $pkg["status"])) |
110 |
|
|
return "rejected"; |
111 |
|
|
if (array_key_exists("youri", $pkg["status"])) { |
112 |
|
|
if (array_key_exists("src", $pkg["status"])) |
113 |
|
|
return "youri"; |
114 |
|
|
else |
115 |
|
|
return "uploaded"; |
116 |
|
|
} |
117 |
|
|
if (array_key_exists("failure", $pkg["status"])) |
118 |
|
|
return "failure"; |
119 |
|
|
if (array_key_exists("done", $pkg["status"])) |
120 |
|
|
return "partial"; |
121 |
|
|
if (array_key_exists("build", $pkg["status"])) |
122 |
|
|
return "building"; |
123 |
|
|
if (array_key_exists("todo", $pkg["status"])) |
124 |
|
|
return "todo"; |
125 |
|
|
return "unknown"; |
126 |
|
|
} |
127 |
|
|
|
128 |
pterjan |
269 |
function plural($num) { |
129 |
|
|
if ($num > 1) |
130 |
|
|
return "s"; |
131 |
|
|
} |
132 |
|
|
|
133 |
|
|
function key2date($key) { |
134 |
|
|
global $tz; |
135 |
|
|
$date = DateTime::createFromFormat("YmdHis", $key+0, $tz); |
136 |
|
|
$diff = time() - $date->getTimestamp(); |
137 |
|
|
if ($diff<60) |
138 |
|
|
return $diff . " second" . plural($diff) . " ago"; |
139 |
|
|
$diff = round($diff/60); |
140 |
|
|
if ($diff<60) |
141 |
|
|
return $diff . " minute" . plural($diff) . " ago"; |
142 |
|
|
$diff = round($diff/60); |
143 |
|
|
if ($diff<24) |
144 |
|
|
return $diff . " hour" . plural($diff) . " ago"; |
145 |
|
|
$diff = round($diff/24); |
146 |
|
|
return $diff . " day" . plural($diff) . " ago"; |
147 |
|
|
} |
148 |
|
|
|
149 |
|
|
# Temporary until initial mirror is ready |
150 |
|
|
echo "<a href=\"src.mga.txt\">$nb_rpm_mga src.rpm</a> rebuilt for Mageia out of <a href=\"src.txt\">$nb_rpm</a>. <a href=\"src.mdv.txt\">List of Mandriva packages still present</a>.<br/>\n"; |
151 |
|
|
######################################### |
152 |
|
|
|
153 |
|
|
echo "<tr><th>Submitted</th><th>User</th><th>Package</th><th>Target</th><th>Media</th><th colspan=\"2\">Status</th></tr>\n"; |
154 |
pterjan |
268 |
foreach ($pkgs as $key => $p) { |
155 |
|
|
$p["type"] = pkg_gettype(&$p); |
156 |
pterjan |
269 |
echo "<tr class=" . $p["type"] . ">\n"; |
157 |
|
|
echo "<td>" . key2date($key) . "</td>\n"; |
158 |
|
|
echo "<td><a href='?user=" . $p["user"] . "'>" . $p["user"] . "</a></td>\n"; |
159 |
pterjan |
268 |
echo "<td>" . $p["package"] . "</td>\n"; |
160 |
|
|
echo "<td>" . $p["version"] . "</td>\n"; |
161 |
|
|
echo "<td>" . $p["media"] . "/" . $p["section"] . "</td>\n"; |
162 |
pterjan |
269 |
echo "<td class='status-box' />\n"; |
163 |
pterjan |
268 |
$typelink = ""; |
164 |
|
|
if ($p["type"] == "failure") { |
165 |
|
|
$typelink = "/uploads/" . $p["type"] . "/" . $p["path"]; |
166 |
|
|
} else if ($p["type"] == "rejected") { |
167 |
|
|
$typelink = "/uploads/" . $p["type"] . "/" . $p["path"] . ".youri"; |
168 |
|
|
} |
169 |
pterjan |
269 |
echo "<td>"; |
170 |
pterjan |
268 |
if ($typelink) |
171 |
|
|
echo "<a href='$typelink'>"; |
172 |
|
|
echo $p["type"]; |
173 |
|
|
if ($typelink) |
174 |
|
|
echo "</a>"; |
175 |
pterjan |
269 |
} |
176 |
|
|
echo "</td>\n"; |
177 |
pterjan |
268 |
echo "</tr>\n"; |
178 |
|
|
} |
179 |
|
|
?> |
180 |
|
|
</table> |
181 |
|
|
|
182 |
|
|
</body> |
183 |
|
|
|
184 |
|
|
</html> |