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

Contents of /build_system/web/index.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 277 - (show annotations) (download)
Thu Jan 13 11:12:27 2011 UTC (13 years, 3 months ago) by pterjan
File size: 6241 byte(s)
Lighter background for partial
1 <?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 $title = "Mageia build system status";
16 $tz = new DateTimeZone("UTC");
17
18 # Temporary until initial mirror is ready
19 chdir("data");
20 $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');
21 $nb_rpm_mga = shell_exec('grep mga src.txt | tee src.mga.txt | wc -l');
22 shell_exec('grep -v mga src.txt > src.mdv.txt');
23 #########################################
24
25 chdir($upload_dir);
26
27 $all_files = shell_exec("find \( -name '*.rpm' -o -name '*.src.rpm.info' -o -name '*.youri' -o -name '*.lock' -o -name '*.done' \) ! -ctime $max_modified");
28
29 preg_match_all("!^\./(\w+)/((\w+)/(\w+)/(\w+)/(\d+)\.(\w+)\.(\w+)\.(\d+))_?(.+)(\.src\.rpm(?:\.info)?|\.youri|\.lock|\.done)$!m", $all_files, $matches, PREG_SET_ORDER);
30
31 $pkgs = array();
32 foreach ($matches as $val) {
33 if ($_GET["user"] && ($_GET["user"] != $val[7])) {
34 continue;
35 }
36 $key = $val[6] . $val[7];
37 if (!is_array($pkgs[$key])) {
38 $pkgs[$key] = array();
39 $pkgs[$key]["status"] = array();
40 $pkgs[$key]["path"] = $val[2];
41 $pkgs[$key]["version"] = $val[3];
42 $pkgs[$key]["media"] = $val[4];
43 $pkgs[$key]["section"] = $val[5];
44 $pkgs[$key]["user"] = $val[7];
45 $pkgs[$key]["host"] = $val[8];
46 $pkgs[$key]["job"] = $val[9];
47 }
48
49 $status = $val[1];
50 $data = $val[10];
51 $pkgs[$key]["status"][$status] = 1;
52 $ext = $val[11];
53 if ($ext == ".src.rpm.info") {
54 preg_match("!^(?:@\d+:)?(.*)!", $data, $name);
55 $pkgs[$key]["package"] = $name[1];
56 } else if ($ext == ".src") {
57 $pkgs[$key]["status"]["src"] = 1;
58 } else if ($ext == ".youri") {
59 $pkgs[$key]["status"]["youri"] = 1;
60 } else if ($ext == ".lock") {
61 // parse build bot from $data
62 $pkgs[$key]["status"]["build"] = 1;
63 }
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 table {
74 border-spacing: 0;
75 font-family: Helvetica; font-size: 80%;
76 border: 1px solid #ccc;
77 }
78 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: #aaaaff; }
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 </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 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=\"data/src.mga.txt\">$nb_rpm_mga src.rpm</a> rebuilt for Mageia out of <a href=\"data/src.txt\">$nb_rpm</a>. <a href=\"data/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 foreach ($pkgs as $key => $p) {
155 $p["type"] = pkg_gettype(&$p);
156 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 echo "<td>" . $p["package"] . "</td>\n";
160 echo "<td>" . $p["version"] . "</td>\n";
161 echo "<td>" . $p["media"] . "/" . $p["section"] . "</td>\n";
162 echo "<td class='status-box' />\n";
163 $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 echo "<td>";
170 if ($typelink)
171 echo "<a href='$typelink'>";
172 echo $p["type"];
173 if ($typelink)
174 echo "</a>";
175 echo "</td>\n";
176 echo "</tr>\n";
177 }
178 ?>
179 </table>
180
181 </body>
182
183 </html>

  ViewVC Help
Powered by ViewVC 1.1.30