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

Contents of /build_system/web/index.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 268 - (show annotations) (download)
Wed Jan 12 11:42:10 2011 UTC (13 years, 3 months ago) by pterjan
File size: 3816 byte(s)
Import blino's web interface
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";
16
17 chdir($upload_dir);
18 $all_files = shell_exec("find \( -name '*.rpm' -o -name '*.src.rpm.info' -o -name '*.youri' -o -name '*.lock' \) ! -ctime $max_modified");
19
20 preg_match_all("!^\./(\w+)/((\w+)/(\w+)/(\w+)/(\d+)\.(\w+)\.(\w+)\.(\d+))_?(.+)(\.src\.rpm(?:\.info)?|\.youri|\.lock)$!m", $all_files, $matches, PREG_SET_ORDER);
21
22 $pkgs = array();
23 foreach ($matches as $val) {
24 $key = $val[6];
25 if (!is_array($pkgs[$key])) {
26 $pkgs[$key] = array();
27 $pkgs[$key]["status"] = array();
28 $pkgs[$key]["path"] = $val[2];
29 $pkgs[$key]["version"] = $val[3];
30 $pkgs[$key]["media"] = $val[4];
31 $pkgs[$key]["section"] = $val[5];
32 $pkgs[$key]["user"] = $val[7];
33 $pkgs[$key]["host"] = $val[8];
34 $pkgs[$key]["job"] = $val[9];
35 }
36
37 $status = $val[1];
38 $pkgs[$key]["status"][$status] = 1;
39 $data = $val[10];
40 $ext = $val[11];
41 if ($ext == ".src.rpm.info") {
42 preg_match("!^(?:@\d+:)?(.*)!", $data, $name);
43 $pkgs[$key]["package"] = $name[1];
44 } else if ($ext == ".src") {
45 $pkgs[$key]["status"]["src"] = 1;
46 } else if ($ext == ".youri") {
47 $pkgs[$key]["status"]["youri"] = 1;
48 } else if ($ext == ".lock") {
49 // parse build bot from $data
50 $pkgs[$key]["status"]["build"] = 1;
51 }
52 }
53 // sort by key in reverse order to have more recent pkgs first
54 krsort($pkgs);
55 ?>
56 <html>
57
58 <head>
59 <title><? echo $title ?></title>
60 <style type="text/css">
61 td.todo {
62 color: black;
63 }
64 td.building {
65 color: fuchsia;
66 }
67 td.partial {
68 color: purple;
69 }
70 td.built {
71 color: blue;
72 }
73 td.youri {
74 color: olive
75 }
76 td.uploaded {
77 color: green;
78 }
79 td.failure, td.failure a, td.rejected, td.rejected a {
80 color: red;
81 }
82 </style>
83 </head>
84
85 <body>
86 <h1><? echo $title ?></h1>
87
88 <table>
89 <?
90 function pkg_gettype($pkg) {
91 if (array_key_exists("rejected", $pkg["status"]))
92 return "rejected";
93 if (array_key_exists("youri", $pkg["status"])) {
94 if (array_key_exists("src", $pkg["status"]))
95 return "youri";
96 else
97 return "uploaded";
98 }
99 if (array_key_exists("failure", $pkg["status"]))
100 return "failure";
101 if (array_key_exists("done", $pkg["status"]))
102 return "partial";
103 if (array_key_exists("build", $pkg["status"]))
104 return "building";
105 if (array_key_exists("todo", $pkg["status"]))
106 return "todo";
107 return "unknown";
108 }
109
110 foreach ($pkgs as $key => $p) {
111 $p["type"] = pkg_gettype(&$p);
112 echo "<tr>\n";
113 echo "<td>" . $p["user"] . "</td>\n";
114 echo "<td>" . $p["package"] . "</td>\n";
115 echo "<td>" . $p["version"] . "</td>\n";
116 echo "<td>" . $p["media"] . "/" . $p["section"] . "</td>\n";
117 $typelink = "";
118 if ($p["type"] == "failure") {
119 $typelink = "/uploads/" . $p["type"] . "/" . $p["path"];
120 } else if ($p["type"] == "rejected") {
121 $typelink = "/uploads/" . $p["type"] . "/" . $p["path"] . ".youri";
122 }
123 echo "<td class='" . $p["type"] . "'>";
124 if ($typelink)
125 echo "<a href='$typelink'>";
126 echo $p["type"];
127 if ($typelink)
128 echo "</a>";
129 echo "</td>\n";;
130 echo "</tr>\n";
131 }
132 ?>
133 </table>
134
135 </body>
136
137 </html>

  ViewVC Help
Powered by ViewVC 1.1.30