summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Dibb <beandog@gentoo.org>2009-12-15 20:44:20 +0000
committerSteve Dibb <beandog@gentoo.org>2009-12-15 20:44:20 +0000
commit09088aa9aee870ff3e9dc490683976d224a68b4b (patch)
tree99637a9cd8193a2c937a3efd0e09d6726055916a /import.packages.php
downloadznurt-org-backend-09088aa9aee870ff3e9dc490683976d224a68b4b.tar.gz
znurt-org-backend-09088aa9aee870ff3e9dc490683976d224a68b4b.tar.bz2
znurt-org-backend-09088aa9aee870ff3e9dc490683976d224a68b4b.zip
initial commit
git-svn-id: file:///var/svn/portage@1 3218660a-b0cf-4799-a991-8ddcc5b9e0f3
Diffstat (limited to 'import.packages.php')
-rw-r--r--import.packages.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/import.packages.php b/import.packages.php
new file mode 100644
index 0000000..f3f08a9
--- /dev/null
+++ b/import.packages.php
@@ -0,0 +1,41 @@
+<?
+
+ require_once 'header.php';
+ require_once '../class.portage.tree.php';
+ require_once '../class.portage.category.php';
+ require_once '../class.portage.package.php';
+
+ $sql = "SELECT id, name FROM category ORDER BY name;";
+ $arr_categories = $db->getAssoc($sql);
+
+ $table = 'package';
+
+ foreach($arr_categories as $category_id => $category_name) {
+
+ $obj_category = new PortageCategory($category_name);
+
+ $arr_packages = $obj_category->getPackages();
+
+ $arr_diff = importDiff('package', $arr_packages, "category = $category_id");
+
+ 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) {
+
+ $obj_package = new PortagePackage($obj_category->name, $name);
+
+ $arr_insert = array('category' => $category_id, 'name' => $name, 'changelog' => $obj_package->changelog);
+ $db->autoExecute($table, $arr_insert, MDB2_AUTOQUERY_INSERT);
+ }
+ }
+
+ }
+
+?> \ No newline at end of file