summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'import.package_mask.php')
-rw-r--r--import.package_mask.php75
1 files changed, 40 insertions, 35 deletions
diff --git a/import.package_mask.php b/import.package_mask.php
index b439b4e..efc4ea9 100644
--- a/import.package_mask.php
+++ b/import.package_mask.php
@@ -1,7 +1,8 @@
<?
- $verbose = true;
- $qa = true;
+// $verbose = true;
+// $debug = true;
+// $qa = true;
require_once 'header.php';
require_once 'class.portage.tree.php';
@@ -10,54 +11,58 @@
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();
- $arr = $pmask->getMaskedPackages();
-
- $arr_pg_bool = array('false', 'true');
- // FIXME do an importDiff
- $db->query("DELETE FROM package_mask;");
+ $dbmtime = new DBMtime($pmask->filename);
- function null2str($var) {
+ $import = false;
- global $db;
+ if($debug)
+ $import = true;
- if(is_null($var))
- return 'NULL';
- else
- return $db->quote($var);
+ if(is_null($dbmtime->mtime)) {
+ $dbmtime->mtime = $pmask->mtime;
+ $import = true;
+ } elseif($pmask->mtime > $dbmtime->mtime) {
+ $dbmtime->mtime = $pmask->mtime;
+ $import = true;
}
- foreach($arr as $str) {
+ if($import) {
+
+ // Delete any previous import attempts
+ $sql = "DELETE FROM package_mask WHERE status = 1;";
- $a = new PortageAtom($str);
+ $arr = $pmask->getMaskedPackages();
-// shell::msg("atom: ".$a->atom);
-// shell::msg("pn: ".$a->pn);
-// shell::msg("pf: ".$a->pf);
-// shell::msg("_alpha: ".$a->_alpha);
-// shell::msg("_beta: ".$a->_beta);
-// shell::msg("_pre: ".$a->_pre);
-// shell::msg("_rc: ".$a->_rc);
-// shell::msg("_p: ".$a->_p);
-// shell::msg("pr: ".$a->pr);
-// shell::msg("version: ".$a->version);
-// echo "\n";
+ $arr_pg_bool = array('false', 'true');
- $pvr = $a->pvr;
+ function null2str($var) {
- if(!$pvr)
- $pvr = '';
+ global $db;
- $sql = "INSERT INTO package_mask (package, atom, lt, gt, eq, ar, av, pf, pv, pr, pvr, alpha, beta, pre, rc, p, version) 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)." 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).";";
-// shell::msg($sql);
- $db->query($sql);
-
-// die;
+ 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);
+ }
+
}