3 // $Revision: 1.3 $, $Date: 2009/01/20 07:37:40 $
5 $database = 'sqlite:/home/services/httpd/html/pld-buildlogs/db/buildlogs2.db';
6 $root_directory = '/home/services/ftp/pub/pld-buildlogs';
7 // $database and $root_directory are taken from buildlogs.inc .
8 // parameter: argv[1] - full path to the log file.
11 $result = array("FAIL" => 0, "OK" => 1);
12 include('buildlogs.inc');
14 if (!isset($argv[1])) {
15 die("Usage: $argv[0] full_path_to_the_log\n");
17 if (!preg_match("|^$root_directory/(.*)/(.*)/(.*)/(.*)\.bz2$|", $argv[1], $matches))
20 if (preg_match("/^(.*),(.*)$/", $matches[4], $m2)) {
29 $ok = $result[$matches[3]];
30 $size = filesize($argv[1]);
31 $mtime = filemtime($argv[1]);
33 #print "name $name, id $id, dist $dist, arch $arch, ok $ok, size, $size, mtime $mtime\n";
36 $dbh = new PDO("$database");
37 } catch (PDOException $e) {
38 die ($e->getMessage());
40 $result = $dbh->query("SELECT log_id FROM logs WHERE dist = '$dist' AND arch = '$arch' AND name = '$name'"
41 ." AND id = '$id' LIMIT 1")->fetchAll();
42 if (count($result) == 1) {
43 foreach ($result as $row) {
44 $query = "UPDATE logs SET ok = $ok, size = $size, mtime = $mtime WHERE log_id = $row[log_id]";
48 $query = "INSERT INTO logs(dist, arch, ok, name, size, mtime, id) "
49 . "VALUES('$dist', '$arch', $ok, '$name', $size, $mtime, '$id')";
51 $ile = $dbh->exec("$query");
53 print_r($dbh->errorInfo());