-
Notifications
You must be signed in to change notification settings - Fork 8
/
insert.php
executable file
·85 lines (75 loc) · 2.84 KB
/
insert.php
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
#!/usr/bin/php5
<?php
//$_SERVER['HTTP_HOST']="localhost";
$_SERVER['HTTP_HOST']="clang.debian.net";
include "config.inc.php";
include "listErrors.php";
if (isset($argv[1])) {
$CLANG_VERSION=$argv[1];
} else {
$CLANG_VERSION="11";
}
if (isset($argv[2])) {
$DATE_REBUILD=$argv[2];
} else {
$DATE_REBUILD="2020-10-30";
}
$QUERY="DELETE FROM errors WHERE clang_version='$CLANG_VERSION' AND date_build='$DATE_REBUILD 00:00:00'";
mysql_query($QUERY);
$handle = fopen("scanlog-".$CLANG_VERSION."-".$DATE_REBUILD, "r");
if ($handle==FALSE) {
die("Could not find source datafile");
}
$i=1;
$previous_pkg_name="";
if ($handle) {
while (($buffer = fgets($handle, 40096)) !== false) {
$line = explode(" ", $buffer);
if ($line[2] != "OK") {
if ($line[0] == "UNKNOWN") {
echo "Fix line $i";
} else {
if ($line[2] != "Failed" && $line[2] != "Unknown") {
echo "error on line $buffer";
echo "found {$line[2]}";
die();
}
$msg="";
for ($j=4; $j < count($line); $j++) {
$msg .= $line[$j]. " ";
}
$key_code=get_key_clang($known_errors, $msg);
if ($key_code != "BUILD_DEP") {
$pkg_name=mysqli_real_escape_string($conn_db, $line[0]);
if (trim($msg)=="XXX") {
$msg="Undetected error";
}
if ($previous_pkg_name == $pkg_name) {
// Duplicate. Delete the former one
$sql="DELETE FROM errors WHERE package='{$pkg_name}' AND clang_version='{$CLANG_VERSION}'";
mysql_query($sql);
$i--;
}
$SQL="INSERT INTO errors (package, version, detected_error, error_code, date_build, clang_version, key_code) VALUES (";
$SQL.="'".$pkg_name."', '". mysqli_real_escape_string($conn_db, $line[1])."', '". mysqli_real_escape_string($conn_db, $msg)."', '". mysqli_real_escape_string($conn_db, $line[3])."','$DATE_REBUILD','$CLANG_VERSION','$key_code')";
$result=mysql_query($SQL);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
$previous_pkg_name = $pkg_name;
}
}
}
$i++;
}
if (!feof($handle)) {
echo "Error: unexpected fgets() fail\n";
}
fclose($handle);
}
$query="delete from errors where clang_version=3.2 and trim(detected_error)='\n'";
mysql_query($query);
$query="delete from errors where clang_version=3.2 and trim(detected_error) like '%Dependencies installation failed%'";
mysql_query($query);
echo "$i lines processed\n";
?>