diff options
-rw-r--r-- | import.ebuilds.php | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/import.ebuilds.php b/import.ebuilds.php index f6c08f1..83f389e 100644 --- a/import.ebuilds.php +++ b/import.ebuilds.php @@ -108,7 +108,7 @@ extract($row); $arr_db[$category_name][$package_name] = $package_id; if($ebuild_name) { - $arr_ids[$category_name][$package_name][$ebuild_name] = $ebuild; + $arr_ebuild_ids[$category_name][$package_name][$ebuild_name] = $ebuild; } } } @@ -129,28 +129,32 @@ $arr_insert = array(); $arr_delete = array(); - if(count($arr_ids[$category_name][$package_name])) - $arr_old = array_keys($arr_ids[$category_name][$package_name]); + if(count($arr_ebuild_ids[$category_name][$package_name])) + $arr_db_ebuilds = array_keys($arr_ebuild_ids[$category_name][$package_name]); else - $arr_old = array(); + $arr_db_ebuilds = array(); $obj_package = new PortagePackage($category_name, $package_name); $package_id =& $arr_db[$category_name][$package_name]; // If there are any old ebuilds (in the DB), then compare the new (in portage) - if(count($arr_old)) { + if(count($arr_db_ebuilds)) { - $arr_new = $obj_package->getEbuilds(); + $arr_fs_ebuilds = $obj_package->getEbuilds(); + + // Check old against new + $arr_delete = array_diff($arr_db_ebuilds, $arr_fs_ebuilds); + $arr_insert = array_diff($arr_fs_ebuilds, $arr_db_ebuilds); // Next, look at the mtimes and see if any need to be updated - if(count($arr_new)) { + if(count($arr_fs_ebuilds)) { - foreach($arr_new as $ebuild_name) { + foreach($arr_fs_ebuilds as $ebuild_name) { $obj_ebuild = new PortageEbuild("$category_name/$ebuild_name"); - $ebuild = $arr_ids[$category_name][$package_name][$ebuild_name]; + $ebuild = $arr_ebuild_ids[$category_name][$package_name][$ebuild_name]; if($ebuild) { $db_ebuild = new DBEbuild($ebuild); @@ -180,7 +184,7 @@ if($verbose) shell::msg("[delete] $category_name/$ebuild_name"); - $ebuild = $arr_ids[$category_name][$package_name][$ebuild_name]; + $ebuild = $arr_ebuild_ids[$category_name][$package_name][$ebuild_name]; if($ebuild) { $db_ebuild = new DBEbuild($ebuild); |