summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'import.packages.php')
-rw-r--r--import.packages.php37
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;";