diff options
author | Steve Dibb <beandog@gentoo.org> | 2009-12-28 15:26:23 +0000 |
---|---|---|
committer | Steve Dibb <beandog@gentoo.org> | 2009-12-28 15:26:23 +0000 |
commit | f8f37406d710a50de37931500807e849e6c1e0f3 (patch) | |
tree | e2b3367f185207987e0f2c5790e489acbbfea1ba | |
parent | update changelog, mtime, ctime (diff) | |
download | znurt-org-backend-f8f37406d710a50de37931500807e849e6c1e0f3.tar.gz znurt-org-backend-f8f37406d710a50de37931500807e849e6c1e0f3.tar.bz2 znurt-org-backend-f8f37406d710a50de37931500807e849e6c1e0f3.zip |
ctime, mtime, new statuses
git-svn-id: file:///var/svn/portage@12 3218660a-b0cf-4799-a991-8ddcc5b9e0f3
-rw-r--r-- | import.ebuilds.php | 72 |
1 files changed, 40 insertions, 32 deletions
diff --git a/import.ebuilds.php b/import.ebuilds.php index 5975516..f6c08f1 100644 --- a/import.ebuilds.php +++ b/import.ebuilds.php @@ -8,7 +8,7 @@ * like that. It's too much of a pain to have it check for it (at this point). */ - $verbose = false; + $verbose = true; $debug = false; $all = false; @@ -21,9 +21,13 @@ require_once 'class.portage.category.php'; require_once 'class.portage.package.php'; require_once 'class.portage.ebuild.php'; + require_once '/home/steve/svn/znurt/class.db.ebuild.php'; - // Delete any that were previously getting inserted or deleted - $sql = "DELETE FROM ebuild WHERE status > 0;"; + // Reset the status on ones that were going to be removed or updated + $sql = "UPDATE ebuild SET status = 0 WHERE status IN (1,3);"; + + // Delete any ebuilds that were new ones + $sql = "DELETE FROM ebuild WHERE status = 1;"; $db->query($sql); // Check to see if there are any ebuilds @@ -97,31 +101,36 @@ // Get the package IDs for reference // and the mtimes of the ebuilds for verification - $sql = "SELECT p.id AS package_id, c.name AS category_name, p.name AS package_name, e.pf AS ebuild_name, e.mtime FROM ebuild e RIGHT OUTER JOIN package p ON e.package = p.id INNER JOIN category c ON p.category = c.id ORDER BY c.name, p.name;"; + $sql = "SELECT p.id AS package_id, c.name AS category_name, p.name AS package_name, e.pf AS ebuild_name, e.mtime, e.id AS ebuild FROM ebuild e RIGHT OUTER JOIN package p ON e.package = p.id INNER JOIN category c ON p.category = c.id ORDER BY c.name, p.name;"; $arr = $db->getAll($sql); if(count($arr)) { foreach($arr as $row) { extract($row); $arr_db[$category_name][$package_name] = $package_id; - if($ebuild_name) - $arr_mtime[$category_name][$package_name][$ebuild_name] = $mtime; + if($ebuild_name) { + $arr_ids[$category_name][$package_name][$ebuild_name] = $ebuild; + } } } if(count($arr_import)) { + foreach($arr_import as $category_name => $arr_category) { foreach($arr_category as $package_name) { + // FIXME always snags the last few, so says they are + // being updated even if they're not (to duplicate, delete + // all ebuilds, and run this twice in a row). if($verbose) shell::msg("[$category_name/$package_name]"); $arr_insert = array(); $arr_delete = array(); - if(count($arr_mtime[$category_name][$package_name])) - $arr_old = array_keys($arr_mtime[$category_name][$package_name]); + if(count($arr_ids[$category_name][$package_name])) + $arr_old = array_keys($arr_ids[$category_name][$package_name]); else $arr_old = array(); @@ -134,11 +143,6 @@ $arr_new = $obj_package->getEbuilds(); - if(count($arr_new)) { - $arr_delete = array_diff($arr_old, $arr_new); - $arr_insert = array_diff($arr_new, $arr_old); - } - // Next, look at the mtimes and see if any need to be updated if(count($arr_new)) { @@ -146,13 +150,25 @@ $obj_ebuild = new PortageEbuild("$category_name/$ebuild_name"); - if($obj_ebuild->mtime != $arr_mtime[$category_name][$package_name][$ebuild_name]) { + $ebuild = $arr_ids[$category_name][$package_name][$ebuild_name]; - if($verbose) - shell::msg("[update] $category_name/$ebuild_name"); + if($ebuild) { + $db_ebuild = new DBEbuild($ebuild); - $arr_delete[] = $ebuild_name; - $arr_insert[] = $ebuild_name; + if($obj_ebuild->mtime != $db_ebuild->mtime || $obj_ebuild->ctime != $db_ebuild->ctime) { + + if($verbose) { + shell::msg("[update] $category_name/$ebuild_name"); + } + + // Flag as being updated + $db_ebuild->status = 2; + if($obj_ebuild->mtime != $db_ebuild->mtime) + $db_ebuild->mtime = $obj_ebuild->mtime; + if($obj_ebuild->ctime != $db_ebuild->ctime) + $db_ebuild->ctime = $obj_ebuild->ctime; + + } } } } @@ -164,11 +180,12 @@ if($verbose) shell::msg("[delete] $category_name/$ebuild_name"); - $arr_update = array( - 'status' => 2, - ); + $ebuild = $arr_ids[$category_name][$package_name][$ebuild_name]; - $db->autoExecute('ebuild', $arr_update, MDB2_AUTOQUERY_UPDATE, "package = $package_id AND pf = ".$db->quote($ebuild_name)); + if($ebuild) { + $db_ebuild = new DBEbuild($ebuild); + $db_ebuild->status = 3; + } } @@ -191,16 +208,6 @@ $obj_ebuild = new PortageEbuild("$category_name/$ebuild_name"); - // print_r($obj_ebuild); - // var_dump($obj_ebuild->_beta); - // var_dump($obj_ebuild->_pre); - // var_dump($obj_ebuild->_rc); - // var_dump($obj_ebuild->_p); - // var_dump($obj_ebuild->_r); - // var_dump($obj_ebuild->slot); - - - $arr = array( 'package' => $package_id, 'pf' => $obj_ebuild->pf, @@ -215,6 +222,7 @@ 'version' => $obj_ebuild->version, 'slot' => $obj_ebuild->slot, 'mtime' => $obj_ebuild->mtime, + 'ctime' => $obj_ebuild->ctime, 'status' => 1, ); |