blob: 6bef4c44c4f4fd6ca90f2cc5cf7984f16f502670 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
<?
class PortageUseFlag {
private $name;
private $description;
private $global;
private $local;
private $arr_use_flags;
function __construct($type = 'global', $name = "") {
global $hits;
$hits['use_flag']++;
$tree =& PortageTree::singleton();
$dir = $tree->getTree()."/profiles/";
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;
}
}
public function getUseFlags() {
return $this->arrUseFlags($this->filename);
}
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;
}
}
?>
|