diff options
author | Eudyptula <eitan@mosenkis.net> | 2009-07-16 16:39:03 -0400 |
---|---|---|
committer | Eudyptula <eitan@mosenkis.net> | 2009-07-16 16:39:03 -0400 |
commit | b04ca72439752a5c964c75b18994311d0aef5618 (patch) | |
tree | 13a190764f26bffea538ea77aaa7a15108c454cd /shared | |
parent | Add dev-manager support to gentoo/portage modules (diff) | |
download | ingenue-b04ca72439752a5c964c75b18994311d0aef5618.tar.gz ingenue-b04ca72439752a5c964c75b18994311d0aef5618.tar.bz2 ingenue-b04ca72439752a5c964c75b18994311d0aef5618.zip |
Added predefined package sets; separated gentoo-specific setup into gentoo_setup.php
Diffstat (limited to 'shared')
-rw-r--r-- | shared/classes/build.php | 3 | ||||
-rw-r--r-- | shared/classes/gentoo_package.php | 20 | ||||
-rw-r--r-- | shared/classes/gentoo_pkgset.php | 32 | ||||
-rw-r--r-- | shared/classes/gentoo_profile.php | 30 |
4 files changed, 84 insertions, 1 deletions
diff --git a/shared/classes/build.php b/shared/classes/build.php index 3f76b7d..8b19b41 100644 --- a/shared/classes/build.php +++ b/shared/classes/build.php @@ -22,7 +22,8 @@ class sql_build extends conf_build_common { 'module' => array ( 'type' => 'VARCHAR', 'length' => 255, - 'not_null' => true + 'not_null' => true, + 'default' => '' ), 'status' => array ( 'type' => 'VARCHAR', diff --git a/shared/classes/gentoo_package.php b/shared/classes/gentoo_package.php index f16a3e1..4426565 100644 --- a/shared/classes/gentoo_package.php +++ b/shared/classes/gentoo_package.php @@ -66,5 +66,25 @@ class sql_gentoo_package extends sql_row_obj { $heads=$this->get_profile()->get_headers(); return !count(array_intersect(explode(' ', $array['keywords']), explode(' ', $heads['accept_keywords']))); } + public static function from_atom($atom, &$profile=null) { + global $S; + if (strpos($atom, '/')) { + list($bcat, $name)=explode('/', $atom); + if ($i=strpos($bcat, '-')) { + $lcat=substr($bcat, $i); + $bcat=substr($bcat, 0, strlen($bcat)-strlen($lcat)); + } + } else { + $name=$atom; + } + $c=array(); + if ($profile) $c[]='`profile`='.$profile->id; + if ($bcat) $c[]='`bcat`="'.$bcat.'"'; + if ($lcat) $c[]='`lcat`="'.$lcat.'"'; + if ($name) $c[]='`name`="'.$name.'"'; + $c=implode(' AND ', $c); + $r=$S['pdo']->query('SELECT * FROM `gentoo_packages` WHERE '.$c.' LIMIT 1'); + return $r->rowCount()?new sql_gentoo_package($r->fetch(PDO::FETCH_ASSOC)):null; + } } ?> diff --git a/shared/classes/gentoo_pkgset.php b/shared/classes/gentoo_pkgset.php new file mode 100644 index 0000000..3829bbb --- /dev/null +++ b/shared/classes/gentoo_pkgset.php @@ -0,0 +1,32 @@ +<?php +class sql_gentoo_pkgset extends sql_row_obj { + protected $table='gentoo_pkgsets', $primary_key=array('id'), $columns=array( + 'id' => array ( + 'type' => 'TINYINT', + 'length' => 3, + 'unsigned' => true, + 'not_null' => true, + 'auto_increment' => true + ), + 'profile' => array ( + 'type' => 'TINYINT', + 'length' => 3, + 'unsigned' => true, + 'not_null' => true, + 'default' => 0, + 'refers_to' => 'gentoo_profiles.id' + ), + 'name' => array ( + 'type' => 'VARCHAR', + 'length' => 255, + 'not_null' => true, + 'default' => '' + ), + 'packages' => array ( + 'type' => 'TEXT', + 'not_null' => true + ) + + ); +} +?> diff --git a/shared/classes/gentoo_profile.php b/shared/classes/gentoo_profile.php index b2b970f..5657ed1 100644 --- a/shared/classes/gentoo_profile.php +++ b/shared/classes/gentoo_profile.php @@ -133,6 +133,36 @@ class sql_gentoo_profile extends sql_row_obj { } return array($n, $u, $d, $t); } + public function read_pkgsets($update=false) { + global $S; + $file=realpath(BACKEND.'/../gentoo_pkgsets.csv'); + if (!is_readable($file)) return false; + $file=fopen($file, 'r'); + while (!feof($file)) { + $add=array(); + $pkgs=explode("\t", rtrim(fgets($file))); + $name=array_shift($pkgs); + $obj=new sql_gentoo_pkgset(); + if ($update) { + $r=$S['pdo']->query('SELECT * FROM `gentoo_pkgsets` WHERE `profile`='.$this->id.' AND `name`="'.$name.'" LIMIT 1'); + if ($r->rowCount()) { + $obj->from_array($r->fetch(PDO::FETCH_ASSOC), true); + } + } + foreach ($pkgs as $pkg) { + if ($pkg=sql_gentoo_package::from_atom($pkg, $this)) + $add[]="$pkg->bcat$pkg->lcat/$pkg->name"; + } + if (count($add)) { + $obj->profile=$this->id; + $obj->name=$name; + $obj->packages=implode("\n", $add); + $obj->write(); + } elseif (isset($obj->id)) { + $obj->delete(); + } + } + } public function &get_packages() { global $S; $r=$S['pdo']->query('SELECT * FROM `gentoo_packages` WHERE `profile`='.$this->id); |