diff options
author | Steve Dibb <beandog@gentoo.org> | 2009-12-18 05:56:38 +0000 |
---|---|---|
committer | Steve Dibb <beandog@gentoo.org> | 2009-12-18 05:56:38 +0000 |
commit | 80a889bb3bc5c614de2c6e9591eba271a4f431e9 (patch) | |
tree | 40e19f98d6b69c6265d5d7456f40e6977cde108c /class.portage.use_flag.php | |
parent | git-svn-id: file:///var/svn/portage@2 3218660a-b0cf-4799-a991-8ddcc5b9e0f3 (diff) | |
download | znurt-org-backend-80a889bb3bc5c614de2c6e9591eba271a4f431e9.tar.gz znurt-org-backend-80a889bb3bc5c614de2c6e9591eba271a4f431e9.tar.bz2 znurt-org-backend-80a889bb3bc5c614de2c6e9591eba271a4f431e9.zip |
updates
git-svn-id: file:///var/svn/portage@3 3218660a-b0cf-4799-a991-8ddcc5b9e0f3
Diffstat (limited to 'class.portage.use_flag.php')
-rw-r--r-- | class.portage.use_flag.php | 82 |
1 files changed, 69 insertions, 13 deletions
diff --git a/class.portage.use_flag.php b/class.portage.use_flag.php index 9be0497..3572660 100644 --- a/class.portage.use_flag.php +++ b/class.portage.use_flag.php @@ -9,28 +9,84 @@ private $arr_use_flags; - function __construct($str = null) { + function __construct($type = 'global', $name = "") { parent::__construct(); - $this->arr_use_flags = $this->arrUseFlags($this->getTree()."/profiles/use.desc"); + $dir = $this->getTree()."/profiles/"; - if($str) - $this->setFlag($str); + switch($type) { + + case 'global': + $this->type = $type; + $this->filename = $dir."use.desc"; + break; + + case 'local': + $this->type = $type; + $this->filename = $dir."use.local.desc"; + break; + + case 'expand': + $this->type = $type; + $name = basename($name); + $this->filename = $dir."desc/$name.desc"; + + if(file_exists($this->filename)) { + $this->prefix = $name; + } + + break; + + } - } - private function setFlag($str) { - if($this->arr_use_flags[$str]) - $this->name = $str; } - - public function getName() { - return $this->name; + + public function getUseFlags() { + + return $this->arrUseFlags($this->filename); + } - public function getDescription() { - return $this->arr_use_flags[$this->getName()]; + public function arrUseFlags($filename) { + + $arr_file = file($filename, FILE_IGNORE_NEW_LINES); + + $arr_file = preg_grep('/^.+\s+\-\s+/', $arr_file); + + sort($arr_file); + + foreach($arr_file as $str) { + + if($this->type == 'local') { + + $tmp = explode(":", $str); + $package = array_shift($tmp); + $str = implode(":", $tmp); + + } + +// $arr = explode(" - ", $str); + $arr = preg_split("/\s+-\s+/", $str); + + $name = array_shift($arr); + $description = implode(" - ", $arr); + + if($this->prefix) { + $name = $this->prefix."_$name"; + $arr_use_flags[$name]['prefix'] = $this->prefix; + } + + if($package) { + $arr_use_flags[$package][$name]['description'] = $description; + } else { + $arr_use_flags[$name]['description'] = $description; + } + + } + + return $arr_use_flags; } |