18require_once
'PEAR/ErrorStack.php';
133 $this->_stack =
new PEAR_ErrorStack(
'PEAR_PackageFile_v2',
false,
null);
134 $this->_isValid =
false;
171 if (!class_exists(
'PEAR_Dependency2')) {
172 require_once
'PEAR/Dependency2.php';
180 return isset($this->_packageInfo[
'#binarypackage']) ? $this->_packageInfo[
'#binarypackage'] :
198 if (!is_array($installer->getInstallPackages())) {
202 foreach ($installer->getInstallPackages() as $p) {
203 if ($p->isExtension($this->_packageInfo[
'providesextension'])) {
204 if ($p->getPackageType() !=
'extsrc' && $p->getPackageType() !=
'zendextsrc') {
210 if (isset($this->_packageInfo[$releasetype][
'binarypackage'])) {
211 $installer->log(0,
'Attempting to download binary version of extension "' .
212 $this->_packageInfo[
'providesextension'] .
'"');
213 $params = $this->_packageInfo[$releasetype][
'binarypackage'];
214 if (!is_array($params) || !isset($params[0])) {
215 $params = array($params);
217 if (isset($this->_packageInfo[
'channel'])) {
218 foreach ($params as $i => $param) {
219 $params[$i] = array(
'channel' => $this->_packageInfo[
'channel'],
220 'package' => $param,
'version' => $this->
getVersion());
225 $verbose = $dl->config->get(
'verbose');
226 $dl->config->set(
'verbose', -1);
227 foreach ($params as $param) {
229 $ret = $dl->download(array($param));
230 PEAR::popErrorHandling();
231 if (is_array($ret) && count($ret)) {
235 $dl->config->set(
'verbose',
$verbose);
236 if (is_array($ret)) {
237 if (count($ret) == 1) {
238 $pf = $ret[0]->getPackageFile();
240 $err = $installer->install($ret[0]);
241 PEAR::popErrorHandling();
242 if (is_array($err)) {
243 $this->_packageInfo[
'#binarypackage'] = $ret[0]->getPackage();
245 $this->_registry->addPackage2($this);
246 $installer->log(0,
'Download and install of binary extension "' .
247 $this->_registry->parsedPackageNameToString(
248 array(
'channel' => $pf->getChannel(),
249 'package' => $pf->getPackage()),
true) .
'" successful');
250 $a = array($ret[0], $err);
253 $installer->log(0,
'Download and install of binary extension "' .
254 $this->_registry->parsedPackageNameToString(
255 array(
'channel' => $pf->getChannel(),
256 'package' => $pf->getPackage()),
true) .
'" failed');
271 array(
'extsrc',
'extbin',
'zendextsrc',
'zendextbin'))) {
272 if (isset($this->_packageInfo[
'providesextension'])) {
273 return $this->_packageInfo[
'providesextension'];
286 array(
'extsrc',
'extbin',
'zendextsrc',
'zendextbin'))) {
287 return $this->_packageInfo[
'providesextension'] == $extension;
306 $this->_stack->getErrors(
true);
311 if ($pf1->getPackage() != $this->getPackage()) {
315 if ($pf1->getVersion() != $this->getVersion()) {
319 if (trim($pf1->getSummary()) != $this->getSummary()) {
323 if (preg_replace(
'/\s+/',
'', $pf1->getDescription()) !=
328 if ($pf1->getState() != $this->getState()) {
332 if (!strstr(preg_replace(
'/\s+/',
'', $this->
getNotes()),
333 preg_replace(
'/\s+/',
'', $pf1->getNotes()))) {
338 $yourmaintainers = $pf1->getMaintainers();
339 for ($i1 = 0; $i1 < count($yourmaintainers); $i1++) {
341 for ($i2 = 0; $i2 < count($mymaintainers); $i2++) {
342 if ($mymaintainers[$i2][
'handle'] == $yourmaintainers[$i1][
'handle']) {
343 if ($mymaintainers[$i2][
'role'] != $yourmaintainers[$i1][
'role']) {
345 $yourmaintainers[$i1][
'role'], $mymaintainers[$i2][
'role']);
348 if ($mymaintainers[$i2][
'email'] != $yourmaintainers[$i1][
'email']) {
350 $yourmaintainers[$i1][
'email'], $mymaintainers[$i2][
'email']);
353 if ($mymaintainers[$i2][
'name'] != $yourmaintainers[$i1][
'name']) {
355 $yourmaintainers[$i1][
'name'], $mymaintainers[$i2][
'name']);
358 unset($mymaintainers[$i2]);
359 $mymaintainers = array_values($mymaintainers);
360 unset($yourmaintainers[$i1]);
361 $yourmaintainers = array_values($yourmaintainers);
372 foreach ($pf1->getFilelist() as $file => $atts) {
373 if (!isset($filelist[$file])) {
383 $this->_stack->push(__FUNCTION__,
'error', array(
'package' => $package,
385 'package.xml 1.0 package "%package%" does not match "%self%"');
390 $this->_stack->push(__FUNCTION__,
'error', array(
'version' => $version,
392 'package.xml 1.0 version "%version%" does not match "%self%"');
397 $this->_stack->push(__FUNCTION__,
'error', array(
'state' => $state,
399 'package.xml 1.0 state "%state%" does not match "%self%"');
404 $this->_stack->push(__FUNCTION__,
'error', array(
'handle' => $handle,
405 'role' => $role,
'self' => $selfrole),
406 'package.xml 1.0 maintainer "%handle%" role "%role%" does not match "%self%"');
411 $this->_stack->push(__FUNCTION__,
'error', array(
'handle' => $handle,
412 'email' => $email,
'self' => $selfemail),
413 'package.xml 1.0 maintainer "%handle%" email "%email%" does not match "%self%"');
418 $this->_stack->push(__FUNCTION__,
'error', array(
'handle' => $handle,
419 'name' => $name,
'self' => $selfname),
420 'package.xml 1.0 maintainer "%handle%" name "%name%" does not match "%self%"');
426 array_walk($my,
function(&$i, $k) { $i = $i[
"handle"]; });
427 $this->_stack->push(__FUNCTION__,
'error', array(
'handles' => $my),
428 'package.xml 2.0 has unmatched extra maintainers "%handles%"');
431 array_walk($yours,
function(&$i, $k) { $i = $i[
"handle"]; });
432 $this->_stack->push(__FUNCTION__,
'error', array(
'handles' => $yours),
433 'package.xml 1.0 has unmatched extra maintainers "%handles%"');
439 $truncnotes = strlen($notes) < 25 ? $notes : substr($notes, 0, 24) .
'...';
441 substr($this->
getNotes(), 0, 24) .
'...';
442 $this->_stack->push(__FUNCTION__,
'error', array(
'notes' => $truncnotes,
443 'self' => $truncmynotes),
444 'package.xml 1.0 release notes "%notes%" do not match "%self%"');
449 $truncsummary = strlen($summary) < 25 ? $summary : substr($summary, 0, 24) .
'...';
450 $truncmysummary = strlen($this->getsummary()) < 25 ? $this->
getSummary() :
451 substr($this->getsummary(), 0, 24) .
'...';
452 $this->_stack->push(__FUNCTION__,
'error', array(
'summary' => $truncsummary,
453 'self' => $truncmysummary),
454 'package.xml 1.0 summary "%summary%" does not match "%self%"');
459 $truncdescription = trim(strlen($description) < 25 ? $description : substr($description, 0, 24) .
'...');
461 substr($this->getdescription(), 0, 24) .
'...');
462 $this->_stack->push(__FUNCTION__,
'error', array(
'description' => $truncdescription,
463 'self' => $truncmydescription),
464 'package.xml 1.0 description "%description%" does not match "%self%"');
469 $this->_stack->push(__FUNCTION__,
'error', array(
'file' => $file),
470 'package.xml 1.0 file "%file%" is not present in <contents>');
478 if (!isset($this->_packageInfo[
'stability'])) {
479 $this->_packageInfo[
'stability'] = array();
481 $this->_packageInfo[
'stability'][
'release'] = $state;
489 $this->_packageInfo[
'compatible'] = $compatible;
497 $this->_packageInfo[
'name'] = $package;
505 $this->_packageInfo[
'channel'] = $channel;
510 $this->_requestedGroup = $group;
515 if (isset($this->_requestedGroup)) {
529 $this->_packageInfo[
'_lastversion'] = $version;
537 if (isset($this->_packageInfo[
'_lastversion'])) {
538 return $this->_packageInfo[
'_lastversion'];
551 $contents = $contents[
'dir'][
'file'];
552 if (!is_array($contents) || !isset($contents[0])) {
553 $contents = array($contents);
555 $taskfiles = array();
556 foreach ($contents as $file) {
557 $atts = $file[
'attribs'];
558 unset($file[
'attribs']);
560 $taskfiles[$atts[
'name']] = $file;
564 $common->debug = $this->_config->get(
'verbose');
565 $this->_scripts = array();
567 foreach ($taskfiles as $name => $tasks) {
568 if (!isset($filelist[$name])) {
572 $atts = $filelist[$name];
573 foreach ($tasks as $tag =>
$raw) {
576 if ($task->isScript()) {
577 $ret[] = $filelist[$name][
'installed_as'];
598 $contents = $contents[
'dir'][
'file'];
599 if (!is_array($contents) || !isset($contents[0])) {
600 $contents = array($contents);
602 $taskfiles = array();
603 foreach ($contents as $file) {
604 $atts = $file[
'attribs'];
605 unset($file[
'attribs']);
607 $taskfiles[$atts[
'name']] = $file;
611 $common->debug = $this->_config->get(
'verbose');
612 $this->_scripts = array();
613 foreach ($taskfiles as $name => $tasks) {
614 if (!isset($filelist[$name])) {
618 $atts = $filelist[$name];
619 foreach ($tasks as $tag =>
$raw) {
620 $taskname = $this->
getTask($tag);
622 if (!$task->isScript()) {
625 $lastversion = isset($this->_packageInfo[
'_lastversion']) ?
626 $this->_packageInfo[
'_lastversion'] :
null;
627 $task->init(
$raw, $atts, $lastversion);
628 $res = $task->startSession($this, $atts[
'installed_as'],
null);
632 if (PEAR::isError($res)) {
635 $this->_scripts[] = $task;
638 if (count($this->_scripts)) {
649 $ui->runPostinstallScripts($this->_scripts, $this);
661 if (isset($this->_packageInfo[
'bundle'])) {
665 if (isset($this->_packageInfo[
'contents'][
'dir'][
'dir'])) {
667 if (!isset($filelist[1])) {
668 $filelist = $filelist[0];
670 $this->_packageInfo[
'contents'][
'dir'][
'file'] = $filelist;
671 unset($this->_packageInfo[
'contents'][
'dir'][
'dir']);
674 if (isset($this->_packageInfo[
'contents'][
'dir'][
'attribs'][
'baseinstalldir'])) {
675 if (isset($this->_packageInfo[
'contents'][
'dir'][
'file'][0])) {
676 foreach ($this->_packageInfo[
'contents'][
'dir'][
'file'] as $i => $file) {
677 if (isset($file[
'attribs'][
'baseinstalldir'])) {
680 $this->_packageInfo[
'contents'][
'dir'][
'file'][$i][
'attribs'][
'baseinstalldir']
681 = $this->_packageInfo[
'contents'][
'dir'][
'attribs'][
'baseinstalldir'];
684 if (!isset($this->_packageInfo[
'contents'][
'dir'][
'file'][
'attribs'][
'baseinstalldir'])) {
685 $this->_packageInfo[
'contents'][
'dir'][
'file'][
'attribs'][
'baseinstalldir']
686 = $this->_packageInfo[
'contents'][
'dir'][
'attribs'][
'baseinstalldir'];
703 if (isset($dir[
'attribs']) && isset($dir[
'attribs'][
'baseinstalldir'])) {
704 $baseinstall = $dir[
'attribs'][
'baseinstalldir'];
706 if (isset($dir[
'dir'])) {
707 if (!isset($dir[
'dir'][0])) {
708 $dir[
'dir'] = array($dir[
'dir']);
710 foreach ($dir[
'dir'] as $subdir) {
711 if (!isset($subdir[
'attribs']) || !isset($subdir[
'attribs'][
'name'])) {
714 $name = $subdir[
'attribs'][
'name'];
716 $newpath = empty($path) ? $name :
719 $baseinstall, $newpath);
722 if (isset($dir[
'file'])) {
723 if (!isset($dir[
'file'][0])) {
724 $dir[
'file'] = array($dir[
'file']);
726 foreach ($dir[
'file'] as $file) {
727 $attrs = $file[
'attribs'];
728 $name = $attrs[
'name'];
729 if ($baseinstall && !isset($attrs[
'baseinstalldir'])) {
730 $attrs[
'baseinstalldir'] = $baseinstall;
732 $attrs[
'name'] = empty($path) ? $name : $path .
'/' . $name;
733 $attrs[
'name'] = preg_replace(array(
'!\\\\+!',
'!/+!'), array(
'/',
'/'),
735 $file[
'attribs'] = $attrs;
744 $this->_registry = &
$config->getRegistry();
749 if (!is_object($logger) || !method_exists($logger,
'log')) {
750 return PEAR::raiseError(
'Logger must be compatible with PEAR_Common::log');
752 $this->_logger = &$logger;
760 $this->_packageInfo[
'dependencies'] = $deps;
768 $this->_packageInfo[
'compatible'] = $compat;
773 $this->_packageFile = $file;
774 $this->_archiveFile = $archive ? $archive : $file;
784 return $this->_stack->getErrors($purge);
807 unset($pinfo[
'old']);
808 unset($pinfo[
'xsdversion']);
810 if (isset($pinfo[
'changelog']) && !is_array($pinfo[
'changelog'])) {
811 unset($pinfo[
'changelog']);
813 $this->_incomplete =
false;
814 $this->_packageInfo = $pinfo;
837 $arr[
'old'] = array();
839 $arr[
'old'][
'release_date'] = $this->
getDate();
840 $arr[
'old'][
'release_state'] = $this->
getState();
841 $arr[
'old'][
'release_license'] = $this->
getLicense();
842 $arr[
'old'][
'release_notes'] = $this->
getNotes();
843 $arr[
'old'][
'release_deps'] = $this->
getDeps();
845 $arr[
'xsdversion'] =
'2.0';
849 unset($info[
'dirtree']);
850 if (isset($info[
'_lastversion'])) {
851 unset($info[
'_lastversion']);
853 if (isset($info[
'#binarypackage'])) {
854 unset($info[
'#binarypackage']);
863 if ($field ==
'state') {
864 return $arr[
'stability'][
'release'];
866 if ($field ==
'api-version') {
867 return $arr[
'version'][
'api'];
869 if ($field ==
'api-state') {
870 return $arr[
'stability'][
'api'];
872 if (isset($arr[
'old'][$field])) {
873 if (!is_string($arr[
'old'][$field])) {
876 return $arr[
'old'][$field];
878 if (isset($arr[$field])) {
879 if (!is_string($arr[$field])) {
894 if (isset($this->_packageInfo[
'name'])) {
895 return $this->_packageInfo[
'name'];
902 if (isset($this->_packageInfo[
'uri'])) {
905 if (isset($this->_packageInfo[
'channel'])) {
906 return strtolower($this->_packageInfo[
'channel']);
913 if (isset($this->_packageInfo[
'uri'])) {
914 return $this->_packageInfo[
'uri'];
921 if (isset($this->_packageInfo[
'extends'])) {
922 return $this->_packageInfo[
'extends'];
929 if (isset($this->_packageInfo[
'summary'])) {
930 return $this->_packageInfo[
'summary'];
937 if (isset($this->_packageInfo[
'description'])) {
938 return $this->_packageInfo[
'description'];
945 if (!isset($this->_packageInfo[
'lead'])) {
949 $ret = array(
'lead' => $this->_packageInfo[
'lead']);
950 (isset($this->_packageInfo[
'developer'])) ?
951 $ret[
'developer'] = $this->_packageInfo[
'developer'] :
null;
952 (isset($this->_packageInfo[
'contributor'])) ?
953 $ret[
'contributor'] = $this->_packageInfo[
'contributor'] :
null;
954 (isset($this->_packageInfo[
'helper'])) ?
955 $ret[
'helper'] = $this->_packageInfo[
'helper'] :
null;
959 $leads = isset($this->_packageInfo[
'lead'][0]) ? $this->_packageInfo[
'lead'] :
960 array($this->_packageInfo[
'lead']);
961 foreach ($leads as $lead) {
963 $s[
'handle'] = $s[
'user'];
968 if (isset($this->_packageInfo[
'developer'])) {
969 $leads = isset($this->_packageInfo[
'developer'][0]) ?
970 $this->_packageInfo[
'developer'] :
971 array($this->_packageInfo[
'developer']);
972 foreach ($leads as $maintainer) {
974 $s[
'handle'] = $s[
'user'];
976 $s[
'role'] =
'developer';
980 if (isset($this->_packageInfo[
'contributor'])) {
981 $leads = isset($this->_packageInfo[
'contributor'][0]) ?
982 $this->_packageInfo[
'contributor'] :
983 array($this->_packageInfo[
'contributor']);
984 foreach ($leads as $maintainer) {
986 $s[
'handle'] = $s[
'user'];
988 $s[
'role'] =
'contributor';
992 if (isset($this->_packageInfo[
'helper'])) {
993 $leads = isset($this->_packageInfo[
'helper'][0]) ?
994 $this->_packageInfo[
'helper'] :
995 array($this->_packageInfo[
'helper']);
996 foreach ($leads as $maintainer) {
998 $s[
'handle'] = $s[
'user'];
1000 $s[
'role'] =
'helper';
1011 if (isset($this->_packageInfo[
'lead'])) {
1012 return $this->_packageInfo[
'lead'];
1019 if (isset($this->_packageInfo[
'developer'])) {
1020 return $this->_packageInfo[
'developer'];
1027 if (isset($this->_packageInfo[
'contributor'])) {
1028 return $this->_packageInfo[
'contributor'];
1035 if (isset($this->_packageInfo[
'helper'])) {
1036 return $this->_packageInfo[
'helper'];
1043 if (!isset($this->_packageInfo[
'date'])) {
1045 $this->_packageInfo = $this->
_insertBefore($this->_packageInfo,
1046 array(
'time',
'version',
1047 'stability',
'license',
'notes',
'contents',
'compatible',
1048 'dependencies',
'providesextension',
'srcpackage',
'srcuri',
1049 'phprelease',
'extsrcrelease',
'extbinrelease',
'zendextsrcrelease',
1050 'zendextbinrelease',
'bundle',
'changelog'), array(),
'date');
1052 $this->_packageInfo[
'date'] = $date;
1053 $this->_isValid = 0;
1058 $this->_isValid = 0;
1059 if (!isset($this->_packageInfo[
'time'])) {
1061 $this->_packageInfo = $this->
_insertBefore($this->_packageInfo,
1063 'stability',
'license',
'notes',
'contents',
'compatible',
1064 'dependencies',
'providesextension',
'srcpackage',
'srcuri',
1065 'phprelease',
'extsrcrelease',
'extbinrelease',
'zendextsrcrelease',
1066 'zendextbinrelease',
'bundle',
'changelog'), $time,
'time');
1068 $this->_packageInfo[
'time'] = $time;
1073 if (isset($this->_packageInfo[
'date'])) {
1074 return $this->_packageInfo[
'date'];
1081 if (isset($this->_packageInfo[
'time'])) {
1082 return $this->_packageInfo[
'time'];
1092 if (isset($this->_packageInfo[
'version'][$key])) {
1093 return $this->_packageInfo[
'version'][$key];
1100 if (isset($this->_packageInfo[
'stability'])) {
1101 return $this->_packageInfo[
'stability'];
1108 if (isset($this->_packageInfo[
'stability'][$key])) {
1109 return $this->_packageInfo[
'stability'][$key];
1116 if (isset($this->_packageInfo[
'license'])) {
1118 return $this->_packageInfo[
'license'];
1120 if (is_array($this->_packageInfo[
'license'])) {
1121 return $this->_packageInfo[
'license'][
'_content'];
1123 return $this->_packageInfo[
'license'];
1131 if (!isset($this->_packageInfo[
'license']) || !is_array($this->_packageInfo[
'license'])) {
1134 return $this->_packageInfo[
'license'][
'attribs'];
1139 if (isset($this->_packageInfo[
'notes'])) {
1140 return $this->_packageInfo[
'notes'];
1151 if (isset($this->_packageInfo[
'usesrole'])) {
1152 return $this->_packageInfo[
'usesrole'];
1163 if (isset($this->_packageInfo[
'usestask'])) {
1164 return $this->_packageInfo[
'usestask'];
1174 if (isset($this->_packageInfo[
'filelist']) && !$preserve) {
1175 return $this->_packageInfo[
'filelist'];
1180 if (!isset($contents[
'dir'])) {
1183 if (!isset($contents[
'dir'][
'file'][0])) {
1184 $contents[
'dir'][
'file'] = array($contents[
'dir'][
'file']);
1186 foreach ($contents[
'dir'][
'file'] as $file) {
1187 if (!isset($file[
'attribs'][
'name'])) {
1190 $name = $file[
'attribs'][
'name'];
1192 $file = $file[
'attribs'];
1194 $ret[$name] = $file;
1197 $this->_packageInfo[
'filelist'] = $ret;
1216 if (isset($releases[0])) {
1217 $releases = $releases[0];
1220 if (isset($releases[
'configureoption'])) {
1221 if (!isset($releases[
'configureoption'][0])) {
1222 $releases[
'configureoption'] = array($releases[
'configureoption']);
1225 for ($i = 0; $i < count($releases[
'configureoption']); $i++) {
1226 $releases[
'configureoption'][$i] = $releases[
'configureoption'][$i][
'attribs'];
1229 return $releases[
'configureoption'];
1241 $this->_packageInfo[
'filelist'] = array();
1251 if (isset($contents[
'dir'][
'attribs'][
'baseinstalldir'])) {
1252 $base = $contents[
'dir'][
'attribs'][
'baseinstalldir'];
1254 if (isset($this->_packageInfo[
'bundle'])) {
1255 return PEAR::raiseError(
1256 'Exception: bundles should be handled in download code only');
1260 if (!isset($release[0])) {
1261 if (!isset($release[
'installconditions']) && !isset($release[
'filelist'])) {
1262 if ($forfilecheck) {
1267 $release = array($release);
1272 foreach ($release as $instance) {
1273 if (isset($instance[
'installconditions'])) {
1274 $installconditions = $instance[
'installconditions'];
1275 if (is_array($installconditions)) {
1277 foreach ($installconditions as $type => $conditions) {
1278 if (!isset($conditions[0])) {
1279 $conditions = array($conditions);
1281 foreach ($conditions as $condition) {
1282 $ret = $depchecker->{
"validate{$type}Dependency"}($condition);
1283 if (PEAR::isError($ret)) {
1284 PEAR::popErrorHandling();
1289 PEAR::popErrorHandling();
1293 if (isset($instance[
'filelist'])) {
1295 if (isset($instance[
'filelist'][
'ignore'])) {
1296 $ignore = isset($instance[
'filelist'][
'ignore'][0]) ?
1297 $instance[
'filelist'][
'ignore'] :
1298 array($instance[
'filelist'][
'ignore']);
1299 foreach ($ignore as $ig) {
1300 unset ($contents[$ig[
'attribs'][
'name']]);
1304 if (isset($instance[
'filelist'][
'install'])) {
1305 $installas = isset($instance[
'filelist'][
'install'][0]) ?
1306 $instance[
'filelist'][
'install'] :
1307 array($instance[
'filelist'][
'install']);
1308 foreach ($installas as $as) {
1309 $contents[$as[
'attribs'][
'name']][
'attribs'][
'install-as'] =
1310 $as[
'attribs'][
'as'];
1314 if ($forfilecheck) {
1315 foreach ($contents as $file => $attrs) {
1316 $contents[$file] = $attrs[
'attribs'];
1322 if ($forfilecheck) {
1328 return PEAR::raiseError(
'No releases in package.xml matched the existing operating ' .
1329 'system, extensions installed, or architecture, cannot install');
1341 return $this->_packageInfo[
'filelist'][$file][
'installed_as'] = $path;
1343 unset($this->_packageInfo[
'filelist'][$file][
'installed_as']);
1348 if (isset($this->_packageInfo[
'filelist'][$file][
'installed_as'])) {
1349 return $this->_packageInfo[
'filelist'][$file][
'installed_as'];
1360 if (isset($this->_packageInfo[
'filelist'][$file])) {
1361 $this->_packageInfo[
'filelist'][$file] =
1362 array_merge($this->_packageInfo[
'filelist'][$file], $atts[
'attribs']);
1364 $this->_packageInfo[
'filelist'][$file] = $atts[
'attribs'];
1373 if (isset($this->_packageInfo[
'contents'])) {
1374 return $this->_packageInfo[
'contents'];
1389 $this->_isValid = 0;
1390 if (in_array($attr, array(
'role',
'name',
'baseinstalldir'))) {
1391 $this->_filesValid =
false;
1393 if ($index !==
false &&
1394 isset($this->_packageInfo[
'contents'][
'dir'][
'file'][$index][
'attribs'])) {
1395 $this->_packageInfo[
'contents'][
'dir'][
'file'][$index][
'attribs'][$attr] = $value;
1398 if (!isset($this->_packageInfo[
'contents'][
'dir'][
'file'])) {
1401 $files = $this->_packageInfo[
'contents'][
'dir'][
'file'];
1402 if (!isset($files[0])) {
1403 $files = array($files);
1408 foreach ($files as $i => $file) {
1409 if (isset($file[
'attribs'])) {
1410 if ($file[
'attribs'][
'name'] == $filename) {
1412 $this->_packageInfo[
'contents'][
'dir'][
'file'][$i][
'attribs'][$attr] = $value;
1414 $this->_packageInfo[
'contents'][
'dir'][
'file'][
'attribs'][$attr] = $value;
1425 if (!isset($this->_packageInfo[
'dirtree'])) {
1426 $this->_packageInfo[
'dirtree'] = array();
1428 $this->_packageInfo[
'dirtree'][$path] =
true;
1433 if (isset($this->_packageInfo[
'dirtree']) && count($this->_packageInfo[
'dirtree'])) {
1434 return $this->_packageInfo[
'dirtree'];
1441 unset($this->_packageInfo[
'dirtree']);
1452 if (!isset($this->_packageInfo[
'compatible'])) {
1455 if (!isset($this->_packageInfo[
'channel'])) {
1458 $me = $pf->getVersion();
1459 $compatible = $this->_packageInfo[
'compatible'];
1460 if (!isset($compatible[0])) {
1461 $compatible = array($compatible);
1464 foreach ($compatible as $info) {
1465 if (strtolower($info[
'name']) == strtolower($pf->getPackage())) {
1466 if (strtolower($info[
'channel']) == strtolower($pf->getChannel())) {
1475 if (isset($info[
'exclude'])) {
1476 if (!isset($info[
'exclude'][0])) {
1477 $info[
'exclude'] = array($info[
'exclude']);
1479 foreach ($info[
'exclude'] as $exclude) {
1480 if (version_compare($me, $exclude,
'==')) {
1485 if (version_compare($me, $info[
'min'],
'>=') && version_compare($me, $info[
'max'],
'<=')) {
1496 if (isset($this->_packageInfo[
'compatible'])) {
1497 return $this->_packageInfo[
'compatible'];
1504 if (isset($this->_packageInfo[
'dependencies'])) {
1505 return $this->_packageInfo[
'dependencies'];
1512 return $p->isSubpackage($this);
1525 if (isset($this->_packageInfo[
'dependencies'][
'required'][
'subpackage'])) {
1526 $sub = $this->_packageInfo[
'dependencies'][
'required'][
'subpackage'];
1527 if (!isset($sub[0])) {
1531 if (isset($this->_packageInfo[
'dependencies'][
'optional'][
'subpackage'])) {
1532 $sub1 = $this->_packageInfo[
'dependencies'][
'optional'][
'subpackage'];
1533 if (!isset($sub1[0])) {
1534 $sub1 = array($sub1);
1536 $sub = array_merge($sub, $sub1);
1538 if (isset($this->_packageInfo[
'dependencies'][
'group'])) {
1539 $group = $this->_packageInfo[
'dependencies'][
'group'];
1540 if (!isset($group[0])) {
1541 $group = array($group);
1543 foreach ($group as $deps) {
1544 if (isset($deps[
'subpackage'])) {
1545 $sub2 = $deps[
'subpackage'];
1546 if (!isset($sub2[0])) {
1547 $sub2 = array($sub2);
1549 $sub = array_merge($sub, $sub2);
1553 foreach ($sub as $dep) {
1554 if (strtolower($dep[
'name']) == strtolower($p->getPackage())) {
1555 if (isset($dep[
'channel'])) {
1556 if (strtolower($dep[
'channel']) == strtolower($p->getChannel())) {
1560 if ($dep[
'uri'] == $p->getURI()) {
1574 foreach (array(
'package',
'subpackage') as $type) {
1575 foreach (array(
'required',
'optional') as $needed) {
1576 if (isset($deps[$needed][$type])) {
1577 if (!isset($deps[$needed][$type][0])) {
1578 $deps[$needed][$type] = array($deps[$needed][$type]);
1580 foreach ($deps[$needed][$type] as $dep) {
1581 $depchannel = isset($dep[
'channel']) ? $dep[
'channel'] :
'__uri';
1582 if (strtolower($dep[
'name']) == strtolower($package) &&
1583 $depchannel == $channel) {
1589 if (isset($deps[
'group'])) {
1590 if (!isset($deps[
'group'][0])) {
1591 $dep[
'group'] = array($deps[
'group']);
1593 foreach ($deps[
'group'] as $group) {
1594 if (isset($group[$type])) {
1595 if (!is_array($group[$type])) {
1596 $group[$type] = array($group[$type]);
1598 foreach ($group[$type] as $dep) {
1599 $depchannel = isset($dep[
'channel']) ? $dep[
'channel'] :
'__uri';
1600 if (strtolower($dep[
'name']) == strtolower($package) &&
1601 $depchannel == $channel) {
1619 $name = strtolower($name);
1620 if (!isset($this->_packageInfo[
'dependencies'][
'group'])) {
1623 $groups = $this->_packageInfo[
'dependencies'][
'group'];
1624 if (!isset($groups[0])) {
1625 $groups = array($groups);
1627 foreach ($groups as $group) {
1628 if (strtolower($group[
'attribs'][
'name']) == $name) {
1648 if (isset($this->_packageInfo[
'dependencies'])) {
1650 return $this->_packageInfo[
'dependencies'];
1656 'subpackage' =>
'pkg',
1657 'extension' =>
'ext',
1659 'pearinstaller' =>
'pkg',
1661 foreach (array(
'required',
'optional') as $type) {
1662 $optional = ($type ==
'optional') ?
'yes' :
'no';
1663 if (!isset($this->_packageInfo[
'dependencies'][$type])
1664 || empty($this->_packageInfo[
'dependencies'][$type])) {
1667 foreach ($this->_packageInfo[
'dependencies'][$type] as $dtype => $deps) {
1668 if ($dtype ==
'pearinstaller' && $nopearinstaller) {
1671 if ((is_array($deps) && !isset($deps[0])) || !is_array($deps)) {
1672 $deps = array($deps);
1674 foreach ($deps as $dep) {
1675 if (!isset($map[$dtype])) {
1679 if ($dtype ==
'pearinstaller') {
1680 $dep[
'name'] =
'PEAR';
1681 $dep[
'channel'] =
'pear.php.net';
1683 $s = array(
'type' => $map[$dtype]);
1684 if (isset($dep[
'channel'])) {
1685 $s[
'channel'] = $dep[
'channel'];
1687 if (isset($dep[
'uri'])) {
1688 $s[
'uri'] = $dep[
'uri'];
1690 if (isset($dep[
'name'])) {
1691 $s[
'name'] = $dep[
'name'];
1693 if (isset($dep[
'conflicts'])) {
1696 if (!isset($dep[
'min']) &&
1697 !isset($dep[
'max'])) {
1699 $s[
'optional'] = $optional;
1700 } elseif (isset($dep[
'min']) &&
1701 isset($dep[
'max'])) {
1705 $s[
'version'] = $dep[
'min'];
1706 $s1[
'version'] = $dep[
'max'];
1707 if (isset($dep[
'channel'])) {
1708 $s1[
'channel'] = $dep[
'channel'];
1710 if ($dtype !=
'php') {
1711 $s[
'name'] = $dep[
'name'];
1712 $s1[
'name'] = $dep[
'name'];
1714 $s[
'optional'] = $optional;
1715 $s1[
'optional'] = $optional;
1717 } elseif (isset($dep[
'min'])) {
1718 if (isset($dep[
'exclude']) &&
1719 $dep[
'exclude'] == $dep[
'min']) {
1724 $s[
'version'] = $dep[
'min'];
1725 $s[
'optional'] = $optional;
1726 if ($dtype !=
'php') {
1727 $s[
'name'] = $dep[
'name'];
1729 } elseif (isset($dep[
'max'])) {
1730 if (isset($dep[
'exclude']) &&
1731 $dep[
'exclude'] == $dep[
'max']) {
1736 $s[
'version'] = $dep[
'max'];
1737 $s[
'optional'] = $optional;
1738 if ($dtype !=
'php') {
1739 $s[
'name'] = $dep[
'name'];
1759 if (isset($this->_packageInfo[
'phprelease'])) {
1762 if (isset($this->_packageInfo[
'extsrcrelease'])) {
1765 if (isset($this->_packageInfo[
'extbinrelease'])) {
1768 if (isset($this->_packageInfo[
'zendextsrcrelease'])) {
1769 return 'zendextsrc';
1771 if (isset($this->_packageInfo[
'zendextbinrelease'])) {
1772 return 'zendextbin';
1774 if (isset($this->_packageInfo[
'bundle'])) {
1786 if ($type !=
'bundle') {
1789 if ($this->
getPackageType() && isset($this->_packageInfo[$type])) {
1790 return $this->_packageInfo[$type];
1800 if (isset($this->_packageInfo[
'changelog'])) {
1801 return $this->_packageInfo[
'changelog'];
1808 return isset($this->_packageInfo[
'dependencies']);
1813 if (isset($this->_packageInfo[
'zendextsrcrelease'])) {
1816 if (isset($this->_packageInfo[
'zendextbinrelease'])) {
1827 if (isset($this->_packageInfo[
'extbinrelease']) ||
1828 isset($this->_packageInfo[
'zendextbinrelease'])) {
1829 return array(
'channel' => $this->_packageInfo[
'srcchannel'],
1830 'package' => $this->_packageInfo[
'srcpackage']);
1837 if (isset($this->_packageInfo[
'bundle'])) {
1838 return $this->_packageInfo[
'contents'][
'bundledpackage'];
1845 if (isset($this->_packageInfo[
'_lastmodified'])) {
1846 return $this->_packageInfo[
'_lastmodified'];
1858 if ($this->_archiveFile == $this->_packageFile) {
1859 $dir = dirname($this->_packageFile);
1860 $file = $dir . DIRECTORY_SEPARATOR . $file;
1861 $file = str_replace(array(
'/',
'\\'),
1862 array(DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR), $file);
1863 if (file_exists($file) && is_readable($file)) {
1864 return implode(
'', file($file));
1869 if ($file !=
'package.xml' && $file !=
'package2.xml') {
1872 $file = $tar->extractInString($file);
1873 $tar->popErrorHandling();
1874 if (PEAR::isError($file)) {
1875 return PEAR::raiseError(
"Cannot locate file '$file' in archive");
1883 if (!class_exists(
'PEAR_PackageFile_v2_rw')) {
1884 require_once
'PEAR/PackageFile/v2/rw.php';
1887 foreach (get_object_vars($this) as $name => $unused) {
1888 if (!isset($this->$name)) {
1891 if ($name ==
'_config' || $name ==
'_logger'|| $name ==
'_registry' ||
1892 $name ==
'_stack') {
1893 $a->$name = &$this->$name;
1895 $a->$name = $this->$name;
1903 if (!class_exists(
'PEAR_PackageFile_Generator_v2')) {
1904 require_once
'PEAR/PackageFile/Generator/v2.php';
1912 if (!isset($this->_v2Validator) ||
1913 !is_a($this->_v2Validator,
'PEAR_PackageFile_v2_Validator')) {
1914 if (!class_exists(
'PEAR_PackageFile_v2_Validator')) {
1915 require_once
'PEAR/PackageFile/v2/Validator.php';
1919 return $this->_v2Validator->analyzeSourceCode($file, $string);
1924 if (!isset($this->_packageInfo) || !is_array($this->_packageInfo)) {
1927 if (!isset($this->_v2Validator) ||
1928 !is_a($this->_v2Validator,
'PEAR_PackageFile_v2_Validator')) {
1929 if (!class_exists(
'PEAR_PackageFile_v2_Validator')) {
1930 require_once
'PEAR/PackageFile/v2/Validator.php';
1934 if (isset($this->_packageInfo[
'xsdversion'])) {
1935 unset($this->_packageInfo[
'xsdversion']);
1937 return $this->_v2Validator->validate($this, $state);
1942 if (!isset($this->_tasksNs)) {
1943 if (isset($this->_packageInfo[
'attribs'])) {
1944 foreach ($this->_packageInfo[
'attribs'] as $name => $value) {
1945 if ($value ==
'http://pear.php.net/dtd/tasks-1.0') {
1946 $this->_tasksNs = str_replace(
'xmlns:',
'', $name);
1952 return $this->_tasksNs;
1969 $task = str_replace(array($this->_tasksNs .
':',
'-'), array(
'',
' '), $task);
1970 $taskfile = str_replace(
' ',
'/', ucwords($task));
1971 $task = str_replace(array(
' ',
'/'),
'_', ucwords($task));
1972 if (class_exists(
"PEAR_Task_$task")) {
1973 return "PEAR_Task_$task";
1975 $fp = @fopen(
"PEAR/Task/$taskfile.php",
'r',
true);
1978 require_once
"PEAR/Task/$taskfile.php";
1979 return "PEAR_Task_$task";
1992 $offset = array_search($key, array_keys($array));
1993 $after = array_slice($array, $offset);
1994 $before = array_slice($array, 0, $offset);
1995 $before[$newkey] = $value;
1996 return array_merge($before, $after);
2007 foreach ($keys as $key) {
2008 if (isset($array[$key])) {
2009 return $array = $this->
_ksplice($array, $key, $contents, $newkey);
2012 $array[$newkey] = $contents;
2032 if (count($order)) {
2033 foreach ($order as $tag => $curorder) {
2034 if (!isset($manip[$tag])) {
2036 $manip = $this->
_insertBefore($manip, $curorder, array(), $tag);
2038 if (count($order) > 1) {
2039 $manip[$tag] = $this->
_mergeTag($manip[$tag], $contents, array_slice($order, 1));
2046 if (is_array($manip[$tag]) && !empty($manip[$tag]) && isset($manip[$tag][0])) {
2047 $manip[$tag][] = $contents;
2049 if (is_array($manip[$tag]) && !count($manip[$tag])) {
2050 $manip[$tag] = $contents;
2052 $manip[$tag] = array($manip[$tag]);
2053 $manip[$tag][] = $contents;
const PEAR_VALIDATE_NORMAL
const PEAR_VALIDATE_INSTALLING
static & singleton($type=null)
_unmatchedMaintainers($my, $yours)
setPackagefile($file, $archive=false)
& getPEARDownloader(&$i, $o, &$c)
_differentSummary($summary)
analyzeSourceCode($file, $string=false)
_differentRole($handle, $role, $selfrole)
_getFlattenedFilelist(&$files, $dir, $baseinstall=false, $path='')
validate($state=PEAR_VALIDATE_NORMAL)
getInstalledLocation($file)
setRequestedGroup($group)
_differentEmail($handle, $email, $selfemail)
setFileAttribute($filename, $attr, $value, $index=false)
getVersion($key='release')
setRawCompatible($compatible)
_mergeTag($manip, $contents, $order)
_differentVersion($version)
getDeps($raw=false, $nopearinstaller=false)
getFilelist($preserve=false)
_differentDescription($description)
getMaintainers($raw=false)
getValidationWarnings($purge=true)
getInstallationFilelist($forfilecheck=false)
_ksplice($array, $key, $value, $newkey)
installBinary(&$installer)
_differentName($handle, $name, $selfname)
& getPEARDependency2(&$c, $o, $p, $s=PEAR_VALIDATE_INSTALLING)
_differentPackage($package)
setInstalledAs($file, $path)
setLastInstalledVersion($version)
dependsOn($package, $channel)
installedFile($file, $atts)
getLastInstalledVersion()
getDependencyGroup($name)
_insertBefore($array, $keys, $contents, $newkey)