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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
<?
// $verbose = true;
// $debug = true;
// $qa = true;
// There's no real need for a status column here,
// since they won't show up unless the ebuild is completed importing
// anyway. Going to leave it in for now, though.
require_once 'header.php';
require_once 'import.functions.php';
if(!$tree) {
$tree =& PortageTree::singleton();
}
require_once 'class.portage.category.php';
require_once 'class.portage.package.php';
require_once 'class.portage.ebuild.php';
// Reset old entries that were new
$sql = "DELETE FROM ebuild_mask WHERE status = 1;";
$db->query($sql);
// Nothing to do if there are no new ebuilds
$import = false;
$sql = "SELECT COUNT(1) FROM ebuild WHERE status = 1;";
$count = $db->getOne($sql);
if($count)
$import = true;
// If there are *new* entries in package_mask, then we are going
// to check against those. Otherwise, check against the old ones.
$sql = "SELECT COUNT(1) FROM package_mask WHERE status = 1;";
$count = $db->getOne($sql);
if($count)
$pm_status = 1;
else
$pm_status = 0;
// If, for some reason, there are no ebuilds masked, check
// all the ebuilds, not just the new ones.
$sql = "SELECT COUNT(1) FROM ebuild_mask;";
$count = $db->getOne($sql);
if(!$count)
$e_status = "0,1";
else
$e_status = "1";
if($import) {
// Insert entries where the entire package is masked
$sql = "INSERT INTO ebuild_mask SELECT pm.id, e.id, 1 FROM ebuild e INNER JOIN package p ON e.package = p.id INNER JOIN package_mask pm ON pm.package = e.package WHERE e.status IN($e_status) AND pm.status = $pm_status AND pm.pvr = '' AND lt = FALSE AND gt = FALSE AND eq = FALSE AND ar = FALSE AND av = FALSE;";
$db->query($sql);
// Insert entries where it's an exact package and version
$sql = "INSERT INTO ebuild_mask SELECT pm.id, e.id, 1 FROM ebuild e INNER JOIN package p ON e.package = p.id INNER JOIN package_mask pm ON pm.package = e.package WHERE e.status IN($e_status) AND pm.status = $pm_status AND pm.pvr = e.pvr AND lt = FALSE AND gt = FALSE AND eq = TRUE AND ar = FALSE AND av = FALSE;";
$db->query($sql);
// Insert entries where atom is like:
// =media-video/mplayer-1.0*
// Specifically IGNORE gt and lt
$sql = "INSERT INTO ebuild_mask SELECT pm.id, e.id, 1 FROM ebuild e INNER JOIN package p ON e.package = p.id INNER JOIN package_mask pm ON pm.package = e.package WHERE e.status IN($e_status) AND pm.status = $pm_status AND e.pvr LIKE (pm.pvr || '%') AND eq = TRUE AND ar = FALSE AND av = TRUE;";
$db->query($sql);
// Insert entries where atom is like:
// ~media-video/mplayer-1.0
$sql = "INSERT INTO ebuild_mask SELECT pm.id, e.id, 1 FROM ebuild e INNER JOIN package p ON e.package = p.id INNER JOIN package_mask pm ON pm.package = e.package WHERE e.status IN($e_status) AND pm.status = $pm_status AND pm.pvr = e.version AND lt = FALSE AND gt = FALSE AND eq = FALSE AND ar = TRUE AND av = FALSE;";
$db->query($sql);
// All others
$sql = "SELECT pm.id AS pm_id, pm.package, pm.atom, pm.version AS pm_version, pm.gt, pm.lt, pm.eq, pl.level AS pm_level, e.version AS ebuild_version, el.level AS ebuild_level, e.id AS ebuild FROM package_mask pm INNER JOIN view_pmask_level pl ON pl.id = pm.id INNER JOIN ebuild e ON e.package = pm.package INNER JOIN view_ebuild_level el ON el.id = e.id WHERE e.status IN($e_status) AND pm.status = $pm_status AND (pm.gt = TRUE OR pm.lt = TRUE) ORDER BY pm.gt, pm.eq, pm.package;";
// shell::msg($sql);
$arr = $db->getAll($sql);
if(count($arr)) {
foreach($arr as $row) {
extract($row);
if(!$arr_pmask[$pm_id]) {
$arr_pmask[$pm_id] = array(
'atom' => $atom,
'package' => $package,
'version' => $pm_version,
'level' => $pm_level,
'gt' => $gt,
'lt' => $lt,
'eq' => $eq,
);
$arr_versions[$pm_id]['mask'] = $pm_version;
}
// print_r($arr_pmask);
$arr_ebuilds[$pm_id][$ebuild] = array(
'version' => $ebuild_version,
'level' => $ebuild_level,
);
$arr_versions[$pm_id][$ebuild] = $ebuild_version;
}
// print_r($arr_versions);
foreach($arr_versions as $pm_id => $arr) {
// Strip out any alpha chars, since we don't need them here
foreach($arr as $key => $value)
$arr[$key] = preg_replace("/[A-Za-z]/", "", $value);
$ext = extendVersions($arr);
$arr_extended[$pm_id] = $ext;
// print_r($arr);
// print_r($ext);
// die;
}
// print_r($arr_extended);
foreach($arr_pmask as $pm_id => $arr) {
extract($arr);
$mask_version = $arr_extended[$pm_id]['mask'];
foreach($arr_extended[$pm_id] as $key => $str) {
// Check against versions
if($key != 'mask' && ( ($gt == 't' && $str > $mask_version) || ($lt == 't' && $str < $mask_version) ) ) {
$arr_ebuild_masks[$pm_id][] = $key;
$arr_insert = array(
'package_mask' => $pm_id,
'ebuild' => $key,
'status' => 1
);
$db->autoExecute('ebuild_mask', $arr_insert, MDB2_AUTOQUERY_INSERT);
// If its the same version, look closer
} elseif($key != 'mask' && $str == $mask_version) {
$pm_level = $arr_pmask[$pm_id]['level'];
$ebuild_level = $arr_ebuilds[$pm_id][$key]['level'];
$pm_ext = $arr_extended[$pm_id][$key];
// Check against levels (alpha, beta, etc.)
if( ($gt == 't' && $ebuild_level > $pm_level) || ($lt == 't' && $ebuild_level < $pm_level) ) {
$arr_insert = array(
'package_mask' => $pm_id,
'ebuild' => $key,
'status' => 1,
);
$db->autoExecute('ebuild_mask', $arr_insert, MDB2_AUTOQUERY_INSERT);
// If the levels are the same too, then you need to look
// at which one is actually higher / lower
// Actually, I'm not sure if it ever really gets to this point anyway.... currently
// I don't have anything that gets this far.
// I think the queries above for checking level actually grab this already. Not sure.
} elseif($ebuild_level == $pm_level && $eq == 'f' && $pm_ext != $str) {
shell::msg("race condition! check import.ebuild_mask.php");
// var_dump($ebuild_level);
// var_dump($pm_level);
switch($ebuild_level) {
case "5":
// var_dump($arr_pmask[$pm_id]['atom']);
//
// var_dump($arr_extended[$pm_id][$key]);
// var_dump($str);
// echo "\n";
break;
}
}
}
}
}
}
}
?>
|