File: history.php

package info (click to toggle)
emdebian-tools 1.4.3
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 1,112 kB
  • ctags: 274
  • sloc: perl: 6,297; xml: 4,828; sh: 1,902; php: 406; ansic: 189; makefile: 15
file content (282 lines) | stat: -rw-r--r-- 6,967 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
<?php

#  Copyright (C) 2008 Neil Williams <codehelp@debian.org>
#
#  This package is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.

# A few notes:
# 1. The CSS from buildd.debian.org is embedded so the colours match
# 2. There are ONLY two files / data sources available to this script -
#    the em_autobuild log and the emtarget file. (It is meant to be 
#    usable on the buildd as well as on www.emdebian.org.)
# 3. The script currently assumes /var/www


if (is_file ("/var/www/toolchains/emdebian.php"))
{
	include_once "/var/www/toolchains/emdebian.php";
	emheader();
}
?>
<style type="text/css">
a:visited {
	color: #3030ff;
	text-decoration: none;
}

a:link    {
	color: #3030ff;
	text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* data table */

.data {
    border-collapse: collapse;
    border: 1px solid #999999;
    font-size: 90%;
    margin: 1em 0em 1em 0em;
}

table.data th.title {
    background: #fffff1;
    border: 1px solid #999999;
    color: #333333;
    font-weight: bold;
    font-size: 120%;
    padding: 0.5em 1em 0.5em 1em;
    white-space: nowrap;
}

.data th {
    background: #ffffcc;
    border: 1px solid #999999;
    font-weight: bold;
    color: #545325;
    padding: 0em 0.2em 0em 0.2em;
}

.data td {
    border: 1px solid #999999;
    padding: 0.1em 0.5em;
    text-align: left;
    vertical-align: top;
}

.data tr.odd {
  background: #f9f9f1;
}

.data td.crit {
  background: #c15757;
}

.data td.warn {
  background: #cfcf00;
}

.data td.good {
  background: #00ff00;
}

.data tr.even {
  background: #ffffff;
}

.data tr:hover { background: #f4f4f4; }
</style>
<h1 style="position:absolute;top:10px;left:350px;font-family:sans-serif;">
Package History</h1>
<p>The package name in the table links to the repository data for the
package.
</p>
<?php
if ($_GET['pkg'] != '')
{
	# needs support for ARCH in the query string too.
	$pkg = htmlspecialchars ($_GET['pkg']);
	$pkg = preg_replace ('/\.+\/+/', "", $pkg);
	$pkg = preg_replace ('/\//', "", $pkg);
	$files = array ();
	print "<h2>Package: $pkg</h2>";
	print "<a href=\"index.php?log=#$pkg\">Back</a><br/>\n";
	$initchar = $pkg[0];
	$dirlist = array ();
	$pkglist = array ();
		if ($builddh = opendir ("/var/www/buildd/$initchar/$pkg/trunk/"))
	{
		while (($logfile = readdir ($builddh)) != false)
		{
			if (filetype ("$initchar/$pkg/trunk/". $logfile) != "dir")
			{
				preg_match ("/-([^-]*)-([0-9]+)\.log$/", $logfile, $matches);
				$arch = $matches[1];
				$time = $matches[2];
				array_push ($files, $logfile);
				$last_log++;
			}
		}
	}
	print "<h3>$last_log buildd logs</h3>";
	rsort ($files);
?>

<table class="data">
<tr><th>Package</th><th>Architecture</th><th>Version</th>
<th>Latest Build Time</th>
<th>Latest Build State</th>
<th>Possible reasons</th>
</tr>
<?php
	foreach ($files as $file)
	{
		$status=0;
		preg_match ("/(.*)-([^-]*)-([0-9]+)\.log$/", $file, $matches);
		$pkg = $matches[1];
		$arch = $matches[2];
		$time = $matches[3];
		$timestr = date ("D jS M, H:i:s T", $time);
		print "<tr id=\"$pkg\">\n";
		print "<td><a href=\"";
		print "http://www.emdebian.org/packages/search.php?package=$pkg\">";
		print "$pkg</a></td>";
		print "<td>".$arch."</td>";
#		print "<td>".$timestr."</td>";
	$contents = file_get_contents ("$initchar/$pkg/trunk/$file");
	if (preg_match ("#Changes file: /.*/$initchar/$pkg/trunk/${pkg}_(.*)_$arch.changes#", $contents))
	{
		preg_match ("#Changes file: /.*/$initchar/$pkg/trunk/${pkg}_(.*)_$arch.changes#", $contents, $matches);
		print "<td>".$matches[1]."</td>";
	}
	else
	{
		if (preg_match ("/dpkg-buildpackage: source version (.*)/", $contents, $matches))
		{
			print "<td>".$matches[1]."</td>";
		}
		# special tag line added by emsource >= 1.1.6 to assist in version detection.
		else if (preg_match ("/emsource: Attempted version: (.*)/", $contents, $matches))
		{
			print "<td>".$matches[1]."</td>";
		}
		else
		{
			print "<td>&nbsp;</td>";
		}
	}
	$safefile=urlencode($file);
	$safepkg=urlencode($pkg);
	print "<td>".$timestr."</td>";
	if (preg_match ("/dpkg-buildpackage: failure/", $contents)
		|| (! preg_match("/dpkg-genchanges/", $contents))
		|| (! preg_match("/Successful build/", $contents)))
	{
		print "<td class=\"warn\">";
		print "<a href=\"index.php?log=$safefile&amp;pkg=$safepkg\">maybe failed</a>";
		print "</td>\n";
		$status = -1;
		$numfail++;
	}
	else
	{
		print "<td class=\"good\">";
		print "<a href=\"index.php?log=$safefile&amp;pkg=$safepkg\">maybe successful</a>";
		print "</td>\n";
		$status = 1;
		$numok++;
	}
	# Look for the messages put into the build log by embug.
	$fail_pat = "Recording that the package failed to build.";
	$patch_pat = "Recording that the Emdebian SVN patches are out of date for";
	$lintian_pat = "Recording that '.*' has failed a lintian check";
	$fail_patch = "Package failed to build but patches are marked as out of date.";
	$wait_pat = "Recording that .* is waiting for another dependency.";
	# span support for each error.
	$ok="<td class=\"good\">";
	$bad="<td class=\"warn\">";
	if (preg_match("/$patch_pat/", $contents))
	{
		print $bad."Patches failed to apply.</td>\n";
	}
	else if (preg_match("/$fail_pat/", $contents))
	{
		print $bad."Failed to cross-build.</td>\n";
	}
	else if (preg_match("/$fail_patch/", $contents))
	{
		print $bad."Patches out of date.</td>\n";
	}
	else if (preg_match("/$lintian_pat/", $contents))
	{
		print $bad."Lintian errors.</td>\n";
	}
	else if ($status > 0)
	{
		# once uploads are automated, append .upload to log
		# and look for that data here.
		$dput_pat = "Successfully uploaded ?.* ?to ";
		if (preg_match("/$dput_pat/", $contents))
		{
			print $ok."Installed.</td>\n";
		}
		else if (preg_match("/$wait_pat/", $contents))
		{
			print $ok."Possible dependency problem.</td>\n";
		}
		else
		{
			print $ok."Manual upload.</td>\n";
		}
	}
	else
	{
		print "<td>&nbsp;</td>\n";
	}
	print "</tr>\n";
}

?>
</table>
</td>
    </tr>
</table>
<?php
if ($numok > 0)
{
	print "<p>$numok successful builds.</p>";
}
if ($numfail > 0)
{
	print "<p>$numfail failed cross builds.</p>";
}
?>
<p><a href="<?php echo "$SELF"; ?>?log=#top">Top</a>.</p>
<?php
	}
?>

<div style="clear: both;">&nbsp;</div>
<p>The autobuilder is part of <a 
href="http://packages.qa.debian.org/e/emdebian-tools.html">emdebian-tools</a>.
</p>
<?php
if (is_file ("/var/www/toolchains/emdebian.php"))
{
	footer();
}
?>