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.ebuild_arch.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.ebuild_arch.php')
-rw-r--r--import.ebuild_arch.php99
1 files changed, 99 insertions, 0 deletions
diff --git a/import.ebuild_arch.php b/import.ebuild_arch.php
new file mode 100644
index 0000000..4380d80
--- /dev/null
+++ b/import.ebuild_arch.php
@@ -0,0 +1,99 @@
+<?
+
+ $verbose = true;
+ $qa = true;
+
+
+ require_once 'header.php';
+ require_once '../class.portage.tree.php';
+ require_once '../class.portage.category.php';
+ require_once '../class.portage.package.php';
+ require_once '../class.portage.ebuild.php';
+
+ // Get the arches
+ $tree = new PortageTree();
+ $arr_arches = $tree->getArches();
+
+ // Find all the ebuilds that are missing ebuild arch
+ $sql = "SELECT id, metadata FROM missing_arch;";
+ $arr = $db->getAssoc($sql);
+
+ if($verbose)
+ shell::msg(count($arr)." ebuilds to check");
+
+ // Get the arches from the database
+ $db_arches = $db->getAssoc("SELECT name, id FROM arch;");
+
+ foreach($arr as $ebuild_id => $keywords) {
+
+ if(!empty($keywords))
+ $arr = arrKeywords($keywords, $arr_arches);
+ else {
+ $arr = array();
+ }
+
+ if(count($arr)) {
+ foreach($arr as $arch => $status) {
+
+ if($db_arches[$arch]) {
+ $arr_insert = array(
+ 'ebuild' => $ebuild_id,
+ 'arch' => $db_arches[$arch],
+ 'status' => $status,
+ );
+
+ $db->autoExecute('ebuild_arch', $arr_insert, MDB2_AUTOQUERY_INSERT);
+ }
+ }
+ }
+
+
+ }
+
+ /**
+ * Create an array of the arch keywords
+ *
+ * @param string keywords
+ * @return array
+ */
+ function arrKeywords($str, $arches) {
+
+ $arr = explode(' ', $str);
+
+ $arr_keywords = array();
+
+ if(count($arr)) {
+
+ // If it has -* at all, set them all to -arch by default
+ if(in_array('-*', $arr)) {
+ foreach($arches as $name) {
+ $arr_keywords[$name] = 2;
+ }
+ }
+
+ foreach($arr as $name) {
+ if($name[0] == '~' || $name[0] == '-')
+ $arch = substr($name, 1);
+ else
+ $arch = $name;
+
+ if($name[0] == '~') {
+ $arr_keywords[$arch] = 1;
+ }
+ elseif($name[0] == '-') {
+ $arr_keywords[$arch] = 2;
+ }
+ else {
+ $arr_keywords[$arch] = 0;
+ }
+ }
+ }
+
+ ksort($arr_keywords);
+
+ return $arr_keywords;
+ }
+
+
+
+?> \ No newline at end of file