diff options
author | 2009-12-28 15:25:42 +0000 | |
---|---|---|
committer | 2009-12-28 15:25:42 +0000 | |
commit | 905e0d151df076249d923117372cb8b1cfcda91a (patch) | |
tree | b531412fc1c947748c0c4f31a1c584e5d01e106a | |
parent | mtime, ctime (diff) | |
download | znurt-org-backend-905e0d151df076249d923117372cb8b1cfcda91a.tar.gz znurt-org-backend-905e0d151df076249d923117372cb8b1cfcda91a.tar.bz2 znurt-org-backend-905e0d151df076249d923117372cb8b1cfcda91a.zip |
update changelog, mtime, ctime
git-svn-id: file:///var/svn/portage@11 3218660a-b0cf-4799-a991-8ddcc5b9e0f3
-rw-r--r-- | import.packages.php | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/import.packages.php b/import.packages.php index 6d74703..c407900 100644 --- a/import.packages.php +++ b/import.packages.php @@ -4,10 +4,17 @@ require_once 'class.portage.tree.php'; require_once 'class.portage.category.php'; require_once 'class.portage.package.php'; + require_once '/home/steve/svn/znurt/class.db.package.php'; $sql = "SELECT id, name FROM category ORDER BY name;"; $arr_categories = $db->getAssoc($sql); + $sql = "SELECT category, package, category_name, package_name FROM view_package;"; + $arr = $db->getAll($sql); + foreach($arr as $row) { + $arr_package_ids[$row['category_name']][$row['package_name']] = $row['package']; + } + $table = 'package'; foreach($arr_categories as $category_id => $category_name) { @@ -21,21 +28,46 @@ if(count($arr_diff['delete'])) { foreach($arr_diff['delete'] as $name) { $sql = "DELETE FROM $table WHERE name = ".$db->quote($name)." AND category = $category_id;"; - shell::msg($sql); $db->query($sql); } } if(count($arr_diff['insert'])) { - foreach($arr_diff['insert'] as $name) { + + foreach($arr_diff['insert'] as $package_name) { - $obj_package = new PortagePackage($obj_category->name, $name); + $obj_package = new PortagePackage($obj_category->name, $package_name); - $arr_insert = array('category' => $category_id, 'name' => $name, 'changelog' => $obj_package->changelog); + $arr_insert = array('category' => $category_id, 'name' => $package_name, 'changelog' => $obj_package->changelog); $db->autoExecute($table, $arr_insert, MDB2_AUTOQUERY_INSERT); } } + foreach($arr_packages as $package_name) { + + if(!in_array($package_name, $arr_diff['insert'])) { + $package_id = $arr_package_ids[$category_name][$package_name]; + + if($package_id) { + + if($verbose) { + shell::msg("Updating $category_name/$package_name id: $package_id"); + } + + $db_package = new DBPackage($package_id); + $p = new PortagePackage($obj_category->name, $package_name); + + if($p->mtime != $db_package->mtime) + $db_package->mtime = $p->mtime; + if($p->ctime != $db_package->ctime) + $db_package->ctime = $p->ctime; + if($p->changelog != $db_package->changelog) + $db_package->changelog = $p->changelog; + + } + } + } + } ?>
\ No newline at end of file |