3 // $Revision: 1.3 $, $Date: 2007-11-24 11:10:33 $
4 $database = 'sqlite:/home/services/ftp/buildlogs.db';
5 $root_directory = '/home/services/ftp/pub/pld-buildlogs';
6 // $database and $root_directory are taken from buildlogs.inc .
7 include_once('buildlogs.inc');
8 // parameter: argv[1] - full path to the log file.
9 // Keep in sync with database
10 $result = array("FAIL" => 0, "OK" => 1);
33 if (!isset($argv[1])) {
34 die("Usage: $argv[0] full_path_to_the_log\n");
36 preg_match("|$root_directory/(.*/.*)/(.*)/(.*)\.bz2|", $argv[1], $matches);
38 $arch_name = $matches[1];
39 if (!array_key_exists($arch_name, $arch)) {
40 die("$argv[1]: Nieznana architektura \"$arch_name\"\n");
42 else $arch_id = $arch[$arch_name];
44 $result_name = $matches[2];
45 if (!array_key_exists($result_name, $result)) {
46 die("$argv[1]: Nieznany resultat \"$result_name\"\n");
48 else $result_id = $result[$result_name];
50 $spec_name = $matches[3];
51 if ($spec_name == '') {
52 die("$argv[1]: Brak nazwy speca.\n");
55 $spec_name = addslashes($spec_name);
56 $size = filesize($argv[1]);
57 $mtime = filemtime($argv[1]);
60 $dbh = new PDO("$database");
61 } catch (PDOException $e) {
62 die ($e->getMessage());
64 $result = $dbh->query("SELECT log_id FROM logs WHERE spec = '$spec_name' AND arch_id = $arch_id AND result = $result_id LIMIT 1")->fetchAll();
65 if (count($result) == 1) {
66 foreach ($result as $row) {
67 $query = "UPDATE logs SET result = $result_id, size = $size, mtime = $mtime WHERE log_id = $row[log_id]";
71 $query = "INSERT INTO logs(arch_id, result, size, mtime, spec) VALUES($arch_id, $result_id, $size, $mtime, '$spec_name')";
74 $dbh->beginTransaction();