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
|
<?
// $verbose = true;
// $debug = true;
// $qa = true;
require_once 'header.php';
require_once 'class.portage.tree.php';
require_once 'class.portage.category.php';
require_once 'class.portage.package.php';
require_once 'class.portage.ebuild.php';
require_once 'class.portage.atom.php';
require_once 'class.portage.package.mask.php';
require_once 'class.db.mtime.php';
$pmask = new PackageMask();
$dbmtime = new DBMtime($pmask->filename);
$import = false;
if($debug)
$import = true;
if(is_null($dbmtime->mtime) || ($pmask->mtime > $dbmtime->mtime) ) {
$dbmtime->mtime = $pmask->mtime;
$import = true;
}
if($import) {
// Delete any previous import attempts
$sql = "DELETE FROM package_mask WHERE status = 1;";
$arr = $pmask->getMaskedPackages();
$arr_pg_bool = array('false', 'true');
function null2str($var) {
global $db;
if(is_null($var))
return 'NULL';
else
return $db->quote($var);
}
foreach($arr as $str) {
$a = new PortageAtom($str);
$pvr = $a->pvr;
if(!$pvr)
$pvr = '';
$sql = "INSERT INTO package_mask (package, atom, lt, gt, eq, ar, av, pf, pv, pr, pvr, alpha, beta, pre, rc, p, version, status) SELECT p.id, ".$db->quote($str).", ".$arr_pg_bool[intval($a->lt)].", ".$arr_pg_bool[intval($a->gt)].", ".$arr_pg_bool[intval($a->eq)].", ".$arr_pg_bool[intval($a->ar)].", ".$arr_pg_bool[intval($a->av)].", ".null2str($a->pf).", ".null2str($a->pv).", ".null2str($a->pr).", ".null2str($a->pvr).", ".null2str($a->_alpha).", ".null2str($a->_beta).", ".null2str($a->_pre).", ".null2str($a->_rc).", ".null2str($a->_p).", ".null2str($a->version).", 1 FROM category c INNER JOIN package p ON p.category = c.id WHERE c.name = ".$db->quote($a->category)." AND p.name = ".$db->quote($a->pn).";";
$db->query($sql);
}
}
?>
|