]>
Commit | Line | Data |
---|---|---|
638df245 | 1 | #!/usr/bin/php.cli |
2 | <?php | |
dec06e20 | 3 | // $Revision: 1.4 $, $Date: 2007-11-24 17:00:46 $ |
a9fbd433 | 4 | $database = 'sqlite:/home/services/ftp/buildlogs.db'; |
638df245 | 5 | $root_directory = '/home/services/ftp/pub/pld-buildlogs'; |
b27be918 | 6 | // $database and $root_directory are taken from buildlogs.inc . |
7 | include_once('buildlogs.inc'); | |
638df245 | 8 | // parameter: argv[1] - full path to the log file. |
9 | // Keep in sync with database | |
638df245 | 10 | $result = array("FAIL" => 0, "OK" => 1); |
11 | $arch = array( | |
a9fbd433 | 12 | "th/SRPMS" => 1, |
13 | "th/i486" => 2, | |
14 | "th/i686" => 3, | |
15 | "th/athlon" => 4, | |
16 | "th/x86_64" => 5, | |
17 | "th/ia64" => 6, | |
18 | "th/alpha" => 7, | |
19 | "th/ppc" => 8, | |
20 | "th/sparc" => 9, | |
21 | "ac/SRPMS" => 10, | |
22 | "ac/i386" => 11, | |
23 | "ac/i586" => 12, | |
24 | "ac/i686" => 13, | |
25 | "ac/athlon" => 14, | |
26 | "ac/amd64" => 15, | |
27 | "ac/alpha" => 16, | |
28 | "ac/ppc" => 17, | |
29 | "ac/sparc" => 18, | |
30 | "ac/sparc64" => 19 | |
638df245 | 31 | ); |
32 | ||
b27be918 | 33 | if (!isset($argv[1])) { |
34 | die("Usage: $argv[0] full_path_to_the_log\n"); | |
35 | } | |
638df245 | 36 | preg_match("|$root_directory/(.*/.*)/(.*)/(.*)\.bz2|", $argv[1], $matches); |
37 | ||
38 | $arch_name = $matches[1]; | |
b27be918 | 39 | if (!array_key_exists($arch_name, $arch)) { |
40 | die("$argv[1]: Nieznana architektura \"$arch_name\"\n"); | |
41 | } | |
638df245 | 42 | else $arch_id = $arch[$arch_name]; |
43 | ||
44 | $result_name = $matches[2]; | |
b27be918 | 45 | if (!array_key_exists($result_name, $result)) { |
46 | die("$argv[1]: Nieznany resultat \"$result_name\"\n"); | |
47 | } | |
638df245 | 48 | else $result_id = $result[$result_name]; |
49 | ||
50 | $spec_name = $matches[3]; | |
b27be918 | 51 | if ($spec_name == '') { |
52 | die("$argv[1]: Brak nazwy speca.\n"); | |
53 | } | |
638df245 | 54 | |
a9fbd433 | 55 | $spec_name = addslashes($spec_name); |
638df245 | 56 | $size = filesize($argv[1]); |
57 | $mtime = filemtime($argv[1]); | |
58 | ||
a9fbd433 | 59 | try { |
60 | $dbh = new PDO("$database"); | |
61 | } catch (PDOException $e) { | |
707f2f36 | 62 | die ($e->getMessage()); |
638df245 | 63 | } |
a9fbd433 | 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]"; | |
68 | break; | |
69 | } | |
638df245 | 70 | } else { |
a9fbd433 | 71 | $query = "INSERT INTO logs(arch_id, result, size, mtime, spec) VALUES($arch_id, $result_id, $size, $mtime, '$spec_name')"; |
638df245 | 72 | } |
dec06e20 | 73 | |
74 | $ile = $dbh->exec("$query"); | |
75 | if ($ile != 1) { | |
76 | print_r($dbh->errorInfo()); | |
77 | } | |
638df245 | 78 | ?> |