diff options
author | Steve Dibb <beandog@gentoo.org> | 2010-01-05 06:06:49 +0000 |
---|---|---|
committer | Steve Dibb <beandog@gentoo.org> | 2010-01-05 06:06:49 +0000 |
commit | 94035ee59f70fa3f97dd7635546a25a9f159fff8 (patch) | |
tree | 9ee16f15b2c47dc67a75194fcf3c5f4e224381a9 /import.packages.php | |
parent | Much more flexibliity on importing package masks, should be self-healing now (diff) | |
download | znurt-org-backend-94035ee59f70fa3f97dd7635546a25a9f159fff8.tar.gz znurt-org-backend-94035ee59f70fa3f97dd7635546a25a9f159fff8.tar.bz2 znurt-org-backend-94035ee59f70fa3f97dd7635546a25a9f159fff8.zip |
add comments; cleanup; cosmetics
git-svn-id: file:///var/svn/portage@65 3218660a-b0cf-4799-a991-8ddcc5b9e0f3
Diffstat (limited to 'import.packages.php')
-rw-r--r-- | import.packages.php | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/import.packages.php b/import.packages.php index de8db86..8bc0ce2 100644 --- a/import.packages.php +++ b/import.packages.php @@ -3,8 +3,40 @@ // $verbose = true; // $debug = false; + /** + * This script creates a temporary file in /tmp named znurt[foo] that sets itself + * to the mtime of the latest package mtime in the database. This way, I can simply + * use find to do all the heavy lifting to quickly locate any package directories + * that were modified since last import. + * + * Directory names in portage tend to get their mtimes updated on a regular basis; + * generally speaking, I'd say that about 50% of them change each sync, though + * I can't pin down why. Packages that haven't been touched in ages get their + * directory modified for no reason I can see. + * + * As a result, the mtime of a package is notoriously unreliable as a reference + * for anything. However, if it does change, it *can* indicate that an ebuild or + * file was removed, so, with all due diligence, we will check those later to see + * if something was actually taken away, and update the database. + */ + + /** + * This is the first file where tables start to have a status column. There is + * only three status levels: 0 - completely imported, and "live", 1 - being updated, + * or newly inserted and 2 - flagged to be removed. + * + * The package table only uses 0 and 1. The website should ignore the status, since + * the changes are only to notify the other scripts that something has changed, and to + * look more closely at the files related to the package. + */ + require_once 'header.php'; - require_once 'class.portage.tree.php'; + + if(!$tree) { + require_once 'class.portage.tree.php'; + $tree = new PortageTree(); + } + require_once 'class.portage.category.php'; require_once 'class.portage.package.php'; require_once 'class.db.package.php'; @@ -28,7 +60,6 @@ if(!$all) { - $tree = new PortageTree(); $categories = $tree->getCategories(); $tmp = tempnam('/tmp', 'znurt'); @@ -76,6 +107,8 @@ $arr_diff = importDiff('package', $arr_packages, "category = $category_id"); // FIXME Flag to be deleted, execute later + // This is dangerous to delete right now because 1) it will take a *long* time, and + // 2) you're breaking the whole "snapshot" approach. if(count($arr_diff['delete'])) { foreach($arr_diff['delete'] as $package_name) { $sql = "DELETE FROM $table WHERE name = ".$db->quote($package_name)." AND category = $category_id;"; |