]> git.pld-linux.org Git - projects/buildlogs.git/blob - pld-buildlogs/scripts/addlog.php
i486 replaced with x32 (baggins?)
[projects/buildlogs.git] / pld-buildlogs / scripts / addlog.php
1 #!/usr/bin/php.cli
2 <?php
3 // $Revision: 1.3 $, $Date: 2009/01/20 07:37:40 $
4 /*
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.
9 */
10
11 $result = array("FAIL" => 0, "OK" => 1);
12 include('buildlogs.inc');
13
14 if (!isset($argv[1])) {
15         die("Usage: $argv[0] full_path_to_the_log\n");
16 }
17 if (!preg_match("|^$root_directory/(.*)/(.*)/(.*)/(.*)\.bz2$|", $argv[1], $matches))
18         exit(0);
19
20 if (preg_match("/^(.*),(.*)$/", $matches[4], $m2)) {
21     $name = $m2[1];
22     $id = $m2[2];
23 } else {
24     $name = $matches[4];
25     $id = "";
26 }
27 $dist = $matches[1];
28 $arch = $matches[2];
29 $ok = $result[$matches[3]];
30 $size = filesize($argv[1]);
31 $mtime = filemtime($argv[1]);
32
33 #print "name $name, id $id, dist $dist, arch $arch, ok $ok, size, $size, mtime $mtime\n";
34
35 try {
36         $dbh = new PDO("$database");
37 } catch (PDOException $e) {
38         die ($e->getMessage());
39 }
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]";
45                 break;
46         }
47 } else {
48         $query = "INSERT INTO logs(dist, arch, ok, name, size, mtime, id) "
49         . "VALUES('$dist', '$arch', $ok, '$name', $size, $mtime, '$id')";
50 }
51 $ile = $dbh->exec("$query");
52 if ($ile != 1) {
53         print_r($dbh->errorInfo());
54 }
55 ?>
This page took 0.076121 seconds and 3 git commands to generate.