diff options
author | 2010-02-14 18:12:32 +0000 | |
---|---|---|
committer | 2010-02-14 18:12:32 +0000 | |
commit | 9fb4324258e83f74cb5bad210abb2b170feb680c (patch) | |
tree | d79358dc1208a3b6a3f7a8897cfccca50c679c34 | |
parent | Cleanup; init using category, package instead of string (diff) | |
download | znurt-org-backend-9fb4324258e83f74cb5bad210abb2b170feb680c.tar.gz znurt-org-backend-9fb4324258e83f74cb5bad210abb2b170feb680c.tar.bz2 znurt-org-backend-9fb4324258e83f74cb5bad210abb2b170feb680c.zip |
split changelog, manifest
git-svn-id: file:///var/svn/portage@86 3218660a-b0cf-4799-a991-8ddcc5b9e0f3
-rw-r--r-- | import.packages.php | 59 |
1 files changed, 45 insertions, 14 deletions
diff --git a/import.packages.php b/import.packages.php index 0692f7c..2b46c8a 100644 --- a/import.packages.php +++ b/import.packages.php @@ -61,6 +61,11 @@ } + if($count === "0") { + $sql = "ALTER SEQUENCE package_id_seq RESTART WITH 1;"; + $db->query($sql); + } + if(!$all) { $categories = $tree->getCategories(); @@ -81,11 +86,15 @@ } unlink($tmp); + $count = 0; + foreach($arr as $name) { $name = str_replace($dir."/", "", $name); $tmp = explode("/", $name); $arr_update[$tmp[0]][] = $tmp[1]; + + $count++; } @@ -100,6 +109,8 @@ $arr_package_ids[$row['category_name']][$row['package_name']] = $row['package']; } + + $table = 'package'; foreach($arr_categories as $category_id => $category_name) { @@ -143,6 +154,7 @@ 'mtime' => $ch->mtime, 'hash' => $ch->hash, 'filesize' => $ch->filesize, + 'recent_changes' => $ch->recent_changes, ); $db->autoExecute('package_changelog', $arr_insert, MDB2_AUTOQUERY_INSERT); @@ -196,7 +208,9 @@ } } - unset($c, $p, $ch, $ma); + unset($c, $p, $ch, $ma, $arr_insert, $arr_diff, $arr_packages, $arr_categories, $categories, $package_id, $arr, $filename); + + $count = 0; foreach($arr_update as $category_name => $arr_packages) { @@ -207,34 +221,51 @@ if($package_id) { $p = new PortagePackage($category_name, $package_name); + $db_package = new DBPackage($package_id); + + $manifest = new PackageManifest($category_name, $package_name, $tree->getTree()); + $db_manifest = new DBPackageManifest($package_id); - if($p->portage_mtime > $max_portage_mtime || $debug) { + if($manifest->hash != $db_manifest->hash || $debug) { if($debug) { shell::msg("Updating $category_name/$package_name id: $package_id"); } - $db_package = new DBPackage($package_id); + $changelog = new PackageChangelog($category_name, $package_name, $tree->getTree()); + $db_changelog = new DBPackageChangelog($package_id); - // If the mtime of this directory changed, then a file - // somewhere has been added or deleted. Flag the status + // If the hash of this Manifest file changed, then a file + // somewhere has been added, deleted or modified. Flag the status // to make sure we examine that directory later. + $db_package->status = 1; + + // Update the manifest in the DB + $db_manifest->hash = $manifest->hash; + $db_manifest->manifest = $manifest->manifest; + $db_manifest->mtime= $manifest->mtime; + $db_manifest->filesize = $manifest->filesize; + + // Same for the changelog entry if it's changed on the filesystem. + // FIXME Add metadata.xml as well + if($changelog->hash != $db_changelog->hash) { + $db_changelog->hash = $changelog->hash; + $db_changelog->manifest = $changelog->manifest; + $db_changelog->mtime= $changelog->mtime; + $db_changelog->filesize = $changelog->filesize; + $db_changelog->changelog = $changelog->changelog; + } + + // FIXME hopefully can phase out mtime soon. if($p->portage_mtime != $db_package->portage_mtime) { $db_package->portage_mtime = $p->portage_mtime; - $db_package->status = 1; } -// if($p->changelog_mtime != $db_package->changelog_mtime) { -// $db_package->changelog_mtime = $p->changelog_mtime; -// $db_package->changelog = $p->changelog; -// } -// -// if($p->metadata_mtime != $db_package->metadata_mtime) -// $db_package->metadata_mtime = $p->metadata_mtime; - } } } } + unset($arr_update, $category_name, $arr_packages, $package_id, $arr_package_ids, $db_package); + ?>
\ No newline at end of file |