189 if ($dep[
'name'] ==
'*') {
193 $not = isset($dep[
'conflicts']) ? true :
false;
194 switch (strtolower($dep[
'name'])) {
197 if (strtolower(substr($this->
getPHP_OS(), 0, 3)) ==
'win') {
198 if (!isset($this->_options[
'nodeps']) && !isset($this->_options[
'force'])) {
199 return $this->
raiseError(
"Cannot install %s on Windows");
202 return $this->
warning(
"warning: Cannot install %s on Windows");
205 if (strtolower(substr($this->
getPHP_OS(), 0, 3)) !=
'win') {
206 if (!isset($this->_options[
'nodeps']) && !isset($this->_options[
'force'])) {
207 return $this->
raiseError(
"Can only install %s on Windows");
210 return $this->
warning(
"warning: Can only install %s on Windows");
215 $unices = array(
'linux',
'freebsd',
'darwin',
'sunos',
'irix',
'hpux',
'aix');
217 if (in_array($this->getSysname(), $unices)) {
218 if (!isset($this->_options[
'nodeps']) && !isset($this->_options[
'force'])) {
219 return $this->
raiseError(
"Cannot install %s on any Unix system");
222 return $this->
warning(
"warning: Cannot install %s on any Unix system");
225 if (!in_array($this->getSysname(), $unices)) {
226 if (!isset($this->_options[
'nodeps']) && !isset($this->_options[
'force'])) {
227 return $this->
raiseError(
"Can only install %s on a Unix system");
230 return $this->
warning(
"warning: Can only install %s on a Unix system");
236 if (strtolower($dep[
'name']) == strtolower($this->getSysname())) {
237 if (!isset($this->_options[
'nodeps']) &&
238 !isset($this->_options[
'force'])) {
239 return $this->
raiseError(
'Cannot install %s on ' . $dep[
'name'] .
240 ' operating system');
243 return $this->
warning(
'warning: Cannot install %s on ' .
244 $dep[
'name'] .
' operating system');
247 if (strtolower($dep[
'name']) != strtolower($this->getSysname())) {
248 if (!isset($this->_options[
'nodeps']) && !isset($this->_options[
'force'])) {
249 return $this->
raiseError(
'Cannot install %s on ' .
250 $this->getSysname() .
251 ' operating system, can only install on ' . $dep[
'name']);
254 return $this->
warning(
'warning: Cannot install %s on ' .
255 $this->getSysname() .
256 ' operating system, can only install on ' . $dep[
'name']);
341 if (isset($dep[
'exclude'])) {
342 if (!is_array($dep[
'exclude'])) {
343 $dep[
'exclude'] = array($dep[
'exclude']);
347 if (!isset($dep[
'min']) && !isset($dep[
'max']) &&
348 !isset($dep[
'recommended']) && !isset($dep[
'exclude'])
351 if (isset($dep[
'conflicts'])) {
352 if (!isset($this->_options[
'nodeps']) && !isset($this->_options[
'force'])) {
353 return $this->
raiseError(
'%s conflicts with PHP extension "' .
354 $dep[
'name'] .
'"' . $extra);
357 return $this->
warning(
'warning: %s conflicts with PHP extension "' .
358 $dep[
'name'] .
'"' . $extra);
364 if (isset($dep[
'conflicts'])) {
369 if (!isset($this->_options[
'nodeps']) && !isset($this->_options[
'force'])) {
370 return $this->
raiseError(
'%s requires PHP extension "' .
371 $dep[
'name'] .
'"' . $extra);
374 return $this->
warning(
'warning: %s requires PHP extension "' .
375 $dep[
'name'] .
'"' . $extra);
378 return $this->
warning(
'%s can optionally use PHP extension "' .
379 $dep[
'name'] .
'"' . $extra);
383 if (isset($dep[
'conflicts'])) {
388 return $this->
warning(
'%s can optionally use PHP extension "' .
389 $dep[
'name'] .
'"' . $extra);
392 if (!isset($this->_options[
'nodeps']) && !isset($this->_options[
'force'])) {
393 return $this->
raiseError(
'%s requires PHP extension "' . $dep[
'name'] .
397 return $this->
warning(
'warning: %s requires PHP extension "' . $dep[
'name'] .
401 $version = (string) $this->
phpversion($dep[
'name']);
402 if (empty($version)) {
407 if (isset($dep[
'min']) && !version_compare($version, $dep[
'min'],
'>=')) {
411 if (isset($dep[
'max']) && !version_compare($version, $dep[
'max'],
'<=')) {
415 if ($fail && !isset($dep[
'conflicts'])) {
416 if (!isset($this->_options[
'nodeps']) && !isset($this->_options[
'force'])) {
417 return $this->
raiseError(
'%s requires PHP extension "' . $dep[
'name'] .
418 '"' . $extra .
', installed version is ' . $version);
421 return $this->
warning(
'warning: %s requires PHP extension "' . $dep[
'name'] .
422 '"' . $extra .
', installed version is ' . $version);
423 } elseif ((isset($dep[
'min']) || isset($dep[
'max'])) && !$fail && isset($dep[
'conflicts'])) {
424 if (!isset($this->_options[
'nodeps']) && !isset($this->_options[
'force'])) {
425 return $this->
raiseError(
'%s conflicts with PHP extension "' .
426 $dep[
'name'] .
'"' . $extra .
', installed version is ' . $version);
429 return $this->
warning(
'warning: %s conflicts with PHP extension "' .
430 $dep[
'name'] .
'"' . $extra .
', installed version is ' . $version);
433 if (isset($dep[
'exclude'])) {
434 foreach ($dep[
'exclude'] as $exclude) {
435 if (version_compare($version, $exclude,
'==')) {
436 if (isset($dep[
'conflicts'])) {
440 if (!isset($this->_options[
'nodeps']) && !isset($this->_options[
'force'])) {
441 return $this->
raiseError(
'%s is not compatible with PHP extension "' .
442 $dep[
'name'] .
'" version ' .
446 return $this->
warning(
'warning: %s is not compatible with PHP extension "' .
447 $dep[
'name'] .
'" version ' .
449 } elseif (version_compare($version, $exclude,
'!=') && isset($dep[
'conflicts'])) {
450 if (!isset($this->_options[
'nodeps']) && !isset($this->_options[
'force'])) {
451 return $this->
raiseError(
'%s conflicts with PHP extension "' .
452 $dep[
'name'] .
'"' . $extra .
', installed version is ' . $version);
455 return $this->
warning(
'warning: %s conflicts with PHP extension "' .
456 $dep[
'name'] .
'"' . $extra .
', installed version is ' . $version);
461 if (isset($dep[
'recommended'])) {
462 if (version_compare($version, $dep[
'recommended'],
'==')) {
466 if (!isset($this->_options[
'nodeps']) && !isset($this->_options[
'force'])) {
467 return $this->
raiseError(
'%s dependency: PHP extension ' . $dep[
'name'] .
468 ' version "' . $version .
'"' .
469 ' is not the recommended version "' . $dep[
'recommended'] .
470 '", but may be compatible, use --force to install');
473 return $this->
warning(
'warning: %s dependency: PHP extension ' .
474 $dep[
'name'] .
' version "' . $version .
'"' .
475 ' is not the recommended version "' . $dep[
'recommended'].
'"');
550 if (isset($dep[
'exclude'])) {
551 if (!is_array($dep[
'exclude'])) {
552 $dep[
'exclude'] = array($dep[
'exclude']);
556 if (version_compare($pearversion, $dep[
'min'],
'<')) {
557 if (!isset($this->_options[
'nodeps']) && !isset($this->_options[
'force'])) {
558 return $this->
raiseError(
'%s requires PEAR Installer' . $extra .
559 ', installed version is ' . $pearversion);
562 return $this->
warning(
'warning: %s requires PEAR Installer' . $extra .
563 ', installed version is ' . $pearversion);
566 if (isset($dep[
'max'])) {
567 if (version_compare($pearversion, $dep[
'max'],
'>')) {
568 if (!isset($this->_options[
'nodeps']) && !isset($this->_options[
'force'])) {
569 return $this->
raiseError(
'%s requires PEAR Installer' . $extra .
570 ', installed version is ' . $pearversion);
573 return $this->
warning(
'warning: %s requires PEAR Installer' . $extra .
574 ', installed version is ' . $pearversion);
578 if (isset($dep[
'exclude'])) {
579 if (!isset($dep[
'exclude'][0])) {
580 $dep[
'exclude'] = array($dep[
'exclude']);
583 foreach ($dep[
'exclude'] as $exclude) {
584 if (version_compare($exclude, $pearversion,
'==')) {
585 if (!isset($this->_options[
'nodeps']) && !isset($this->_options[
'force'])) {
586 return $this->
raiseError(
'%s is not compatible with PEAR Installer ' .
587 'version ' . $exclude);
590 return $this->
warning(
'warning: %s is not compatible with PEAR ' .
591 'Installer version ' . $exclude);
644 $dep[
'package'] = $dep[
'name'];
645 if (isset($dep[
'uri'])) {
646 $dep[
'channel'] =
'__uri';
649 $depname = $this->_registry->parsedPackageNameToString($dep,
true);
651 foreach ($params as $param) {
653 array(
'package' => $dep[
'name'],
654 'channel' => $dep[
'channel']))) {
659 if ($depv1 && $dep[
'channel'] ==
'pear.php.net') {
661 array(
'package' => $dep[
'name'],
662 'channel' =>
'pecl.php.net'))) {
669 if (!$found && isset($dep[
'providesextension'])) {
670 foreach ($params as $param) {
671 if ($param->isExtension($dep[
'providesextension'])) {
679 $version = $param->getVersion();
683 if ($this->_registry->packageExists($dep[
'name'], $dep[
'channel'])) {
686 $version = $this->_registry->packageinfo($dep[
'name'],
'version',
689 if ($dep[
'channel'] ==
'pecl.php.net' && $this->_registry->packageExists($dep[
'name'],
693 $version = $this->_registry->packageinfo($dep[
'name'],
'version',
696 $version =
'not installed or downloaded';
704 if (isset($dep[
'exclude']) && !is_array($dep[
'exclude'])) {
705 $dep[
'exclude'] = array($dep[
'exclude']);
708 if (!isset($dep[
'min']) && !isset($dep[
'max']) &&
709 !isset($dep[
'recommended']) && !isset($dep[
'exclude'])
711 if ($installed || $downloaded) {
712 $installed = $installed ?
'installed' :
'downloaded';
713 if (isset($dep[
'conflicts'])) {
716 $rest =
", $installed version is " . $version;
719 if (!isset($this->_options[
'nodeps']) && !isset($this->_options[
'force'])) {
720 return $this->
raiseError(
'%s conflicts with package "' . $depname .
'"' . $extra . $rest);
723 return $this->
warning(
'warning: %s conflicts with package "' . $depname .
'"' . $extra . $rest);
729 if (isset($dep[
'conflicts'])) {
734 if (!isset($this->_options[
'nodeps']) && !isset($this->_options[
'force'])) {
735 return $this->
raiseError(
'%s requires package "' . $depname .
'"' . $extra);
738 return $this->
warning(
'warning: %s requires package "' . $depname .
'"' . $extra);
741 return $this->
warning(
'%s can optionally use package "' . $depname .
'"' . $extra);
744 if (!$installed && !$downloaded) {
745 if (isset($dep[
'conflicts'])) {
750 if (!isset($this->_options[
'nodeps']) && !isset($this->_options[
'force'])) {
751 return $this->
raiseError(
'%s requires package "' . $depname .
'"' . $extra);
754 return $this->
warning(
'warning: %s requires package "' . $depname .
'"' . $extra);
757 return $this->
warning(
'%s can optionally use package "' . $depname .
'"' . $extra);
761 if (isset($dep[
'min']) && version_compare($version, $dep[
'min'],
'<')) {
765 if (isset($dep[
'max']) && version_compare($version, $dep[
'max'],
'>')) {
769 if ($fail && !isset($dep[
'conflicts'])) {
770 $installed = $installed ?
'installed' :
'downloaded';
771 $dep[
'package'] = $dep[
'name'];
772 $dep = $this->_registry->parsedPackageNameToString($dep,
true);
773 if (!isset($this->_options[
'nodeps']) && !isset($this->_options[
'force'])) {
774 return $this->
raiseError(
'%s requires package "' . $depname .
'"' .
775 $extra .
", $installed version is " . $version);
778 return $this->
warning(
'warning: %s requires package "' . $depname .
'"' .
779 $extra .
", $installed version is " . $version);
780 } elseif ((isset($dep[
'min']) || isset($dep[
'max'])) && !$fail &&
781 isset($dep[
'conflicts']) && !isset($dep[
'exclude'])) {
782 $installed = $installed ?
'installed' :
'downloaded';
783 if (!isset($this->_options[
'nodeps']) && !isset($this->_options[
'force'])) {
784 return $this->
raiseError(
'%s conflicts with package "' . $depname .
'"' . $extra .
785 ", $installed version is " . $version);
788 return $this->
warning(
'warning: %s conflicts with package "' . $depname .
'"' .
789 $extra .
", $installed version is " . $version);
792 if (isset($dep[
'exclude'])) {
793 $installed = $installed ?
'installed' :
'downloaded';
794 foreach ($dep[
'exclude'] as $exclude) {
795 if (version_compare($version, $exclude,
'==') && !isset($dep[
'conflicts'])) {
796 if (!isset($this->_options[
'nodeps']) &&
797 !isset($this->_options[
'force'])
799 return $this->
raiseError(
'%s is not compatible with ' .
800 $installed .
' package "' .
801 $depname .
'" version ' .
805 return $this->
warning(
'warning: %s is not compatible with ' .
806 $installed .
' package "' .
807 $depname .
'" version ' .
809 } elseif (version_compare($version, $exclude,
'!=') && isset($dep[
'conflicts'])) {
810 $installed = $installed ?
'installed' :
'downloaded';
811 if (!isset($this->_options[
'nodeps']) && !isset($this->_options[
'force'])) {
812 return $this->
raiseError(
'%s conflicts with package "' . $depname .
'"' .
813 $extra .
", $installed version is " . $version);
816 return $this->
warning(
'warning: %s conflicts with package "' . $depname .
'"' .
817 $extra .
", $installed version is " . $version);
822 if (isset($dep[
'recommended'])) {
823 $installed = $installed ?
'installed' :
'downloaded';
824 if (version_compare($version, $dep[
'recommended'],
'==')) {
828 if (!$found && $installed) {
829 $param = $this->_registry->getPackage($dep[
'name'], $dep[
'channel']);
834 foreach ($params as $parent) {
835 if ($parent->isEqual($this->_currentPackage)) {
842 if ($param->isCompatible($parent)) {
846 $parent = $this->_registry->getPackage($this->_currentPackage[
'package'],
847 $this->_currentPackage[
'channel']);
848 if ($parent !==
null && $param->isCompatible($parent)) {
854 if (!isset($this->_options[
'nodeps']) && !isset($this->_options[
'force']) &&
855 !isset($this->_options[
'loose'])
857 return $this->
raiseError(
'%s dependency package "' . $depname .
858 '" ' . $installed .
' version ' . $version .
859 ' is not the recommended version ' . $dep[
'recommended'] .
860 ', but may be compatible, use --force to install');
863 return $this->
warning(
'warning: %s dependency package "' . $depname .
864 '" ' . $installed .
' version ' . $version .
865 ' is not the recommended version ' . $dep[
'recommended']);
884 if (PEAR::isError($this->_dependencydb)) {
891 $downloaded = &$dl->getUninstallPackages();
892 foreach ($downloaded as $i => $pf) {
893 if (!class_exists(
'PEAR_Downloader_Package')) {
894 require_once
'PEAR/Downloader/Package.php';
897 $dp->setPackageFile($downloaded[$i]);
902 $memyselfandI = strtolower($this->_currentPackage[
'channel']) .
'/' .
903 strtolower($this->_currentPackage[
'package']);
904 if (isset($dl->___uninstall_package_cache)) {
905 $badpackages = $dl->___uninstall_package_cache;
906 if (isset($badpackages[$memyselfandI][
'warnings'])) {
907 foreach ($badpackages[$memyselfandI][
'warnings'] as $warning) {
908 $dl->log(0, $warning[0]);
912 if (isset($badpackages[$memyselfandI][
'errors'])) {
913 foreach ($badpackages[$memyselfandI][
'errors'] as $error) {
914 if (is_array($error)) {
915 $dl->log(0, $error[0]);
917 $dl->log(0, $error->getMessage());
921 if (isset($this->_options[
'nodeps']) || isset($this->_options[
'force'])) {
923 'warning: %s should not be uninstalled, other installed packages depend ' .
928 '%s cannot be uninstalled, other installed packages depend on this package');
935 $perpackagelist = array();
936 $allparents = array();
937 foreach ($params as $i => $param) {
939 'channel' => strtolower($param->getChannel()),
940 'package' => strtolower($param->getPackage())
943 $deps = $this->_dependencydb->getDependentPackages($a);
945 foreach ($deps as $d) {
946 $pardeps = $this->_dependencydb->getDependencies($d);
947 foreach ($pardeps as $dep) {
948 if (strtolower($dep[
'dep'][
'channel']) == $a[
'channel'] &&
949 strtolower($dep[
'dep'][
'name']) == $a[
'package']) {
950 if (!isset($perpackagelist[$a[
'channel'] .
'/' . $a[
'package']])) {
951 $perpackagelist[$a[
'channel'] .
'/' . $a[
'package']] = array();
953 $perpackagelist[$a[
'channel'] .
'/' . $a[
'package']][]
954 = array($d[
'channel'] .
'/' . $d[
'package'], $dep);
955 if (!isset($allparents[$d[
'channel'] .
'/' . $d[
'package']])) {
956 $allparents[$d[
'channel'] .
'/' . $d[
'package']] = array();
958 if (!isset($allparents[$d[
'channel'] .
'/' . $d[
'package']][$a[
'channel'] .
'/' . $a[
'package']])) {
959 $allparents[$d[
'channel'] .
'/' . $d[
'package']][$a[
'channel'] .
'/' . $a[
'package']] = array();
961 $allparents[$d[
'channel'] .
'/' . $d[
'package']]
962 [$a[
'channel'] .
'/' . $a[
'package']][]
972 foreach ($allparents as $parent => $d1) {
973 foreach ($d1 as $d) {
974 if ($this->_registry->packageExists($d[0][0][
'package'], $d[0][0][
'channel'])) {
977 $remove[$parent] =
true;
983 foreach ($allparents as $parent => $d1) {
984 foreach ($d1 as $d) {
985 foreach ($params as $param) {
986 if (strtolower($param->getChannel()) == $d[0][0][
'channel'] &&
987 strtolower($param->getPackage()) == $d[0][0][
'package']) {
992 $remove[$parent] =
true;
998 $badchildren = array();
1001 foreach ($remove as $package => $unused) {
1002 if (!isset($allparents[$package])) {
1006 foreach ($allparents[$package] as $kid => $d1) {
1007 foreach ($d1 as $depinfo) {
1008 if ($depinfo[1][
'type'] !=
'optional') {
1009 if (isset($badchildren[$kid])) {
1012 $badchildren[$kid] =
true;
1013 $remove[$kid] =
true;
1027 $badpackages = array();
1029 foreach ($perpackagelist as $package => $packagedeps) {
1030 foreach ($packagedeps as $parent) {
1031 if (!isset($remove[$parent[0]])) {
1035 $packagename = $this->_registry->parsePackageName($parent[0]);
1036 $packagename[
'channel'] = $this->_registry->channelAlias($packagename[
'channel']);
1037 $pa = $this->_registry->getPackage($packagename[
'package'], $packagename[
'channel']);
1038 $packagename[
'package'] = $pa->getPackage();
1039 $this->_currentPackage = $packagename;
1042 $parentname[
'channel'] = $this->_registry->channelAlias($parent[1][
'dep'][
'channel']);
1043 $pa = $this->_registry->getPackage($parent[1][
'dep'][
'name'], $parent[1][
'dep'][
'channel']);
1044 $parentname[
'package'] = $pa->getPackage();
1045 $parent[1][
'dep'][
'package'] = $parentname[
'package'];
1046 $parent[1][
'dep'][
'channel'] = $parentname[
'channel'];
1047 if ($parent[1][
'type'] ==
'optional') {
1049 if ($test !==
true) {
1050 $badpackages[$package][
'warnings'][] = $test;
1054 if ($test !==
true) {
1055 $badpackages[$package][
'errors'][] = $test;
1061 $this->_currentPackage = $save;
1062 $dl->___uninstall_package_cache = $badpackages;
1063 if (isset($badpackages[$memyselfandI])) {
1064 if (isset($badpackages[$memyselfandI][
'warnings'])) {
1065 foreach ($badpackages[$memyselfandI][
'warnings'] as $warning) {
1066 $dl->log(0, $warning[0]);
1070 if (isset($badpackages[$memyselfandI][
'errors'])) {
1071 foreach ($badpackages[$memyselfandI][
'errors'] as $error) {
1072 if (is_array($error)) {
1073 $dl->log(0, $error[0]);
1075 $dl->log(0, $error->getMessage());
1079 if (isset($this->_options[
'nodeps']) || isset($this->_options[
'force'])) {
1081 'warning: %s should not be uninstalled, other installed packages depend ' .
1086 '%s cannot be uninstalled, other installed packages depend on this package');
1095 $depname = $this->_registry->parsedPackageNameToString($dep,
true);
1096 $version = $this->_registry->packageinfo($dep[
'package'],
'version', $dep[
'channel']);
1102 if (isset($dep[
'exclude']) && !is_array($dep[
'exclude'])) {
1103 $dep[
'exclude'] = array($dep[
'exclude']);
1106 if (isset($dep[
'conflicts'])) {
1110 if (!isset($dep[
'min']) && !isset($dep[
'max'])) {
1112 return $this->
warning(
'"' . $depname .
'" can be optionally used by ' .
1113 'installed package %s' . $extra);
1116 if (!isset($this->_options[
'nodeps']) && !isset($this->_options[
'force'])) {
1117 return $this->
raiseError(
'"' . $depname .
'" is required by ' .
1118 'installed package %s' . $extra);
1121 return $this->
warning(
'warning: "' . $depname .
'" is required by ' .
1122 'installed package %s' . $extra);
1126 if (isset($dep[
'min']) && version_compare($version, $dep[
'min'],
'>=')) {
1130 if (isset($dep[
'max']) && version_compare($version, $dep[
'max'],
'<=')) {
1135 $saverequired = $required;
1137 return $this->
warning($depname . $extra .
' can be optionally used by installed package' .
1141 if (!isset($this->_options[
'nodeps']) && !isset($this->_options[
'force'])) {
1142 return $this->
raiseError($depname . $extra .
' is required by installed package' .
1146 return $this->
raiseError(
'warning: ' . $depname . $extra .
1147 ' is required by installed package "%s"');
1165 if (is_array($pkg) && isset($pkg[
'info'])) {
1166 $deps = $this->_dependencydb->getDependentPackageDependencies($pkg[
'info']);
1168 $deps = $this->_dependencydb->getDependentPackageDependencies($pkg);
1173 if (!class_exists(
'PEAR_Downloader_Package')) {
1174 require_once
'PEAR/Downloader/Package.php';
1178 if (is_object($pkg)) {
1179 $dp->setPackageFile($pkg);
1181 $dp->setDownloadURL($pkg);
1185 foreach ($deps as $channel => $info) {
1186 foreach ($info as $package => $ds) {
1187 foreach ($params as $packd) {
1188 if (strtolower($packd->getPackage()) == strtolower($package) &&
1189 $packd->getChannel() == $channel) {
1190 $dl->log(3,
'skipping installed package check of "' .
1191 $this->_registry->parsedPackageNameToString(
1192 array(
'channel' => $channel,
'package' => $package),
1194 '", version "' . $packd->getVersion() .
'" will be ' .
1195 'downloaded and installed');
1200 foreach ($ds as $d) {
1202 array(
'channel' => $channel,
'package' => $package), $this->_state);
1204 $required = $d[
'type'] ==
'required';
1205 $ret = $checker->_validatePackageDownload($dep, $required, array(&$dp));
1206 if (is_array($ret)) {
1207 $dl->log(0, $ret[0]);
1208 } elseif (PEAR::isError($ret)) {
1209 $dl->log(0, $ret->getMessage());
1215 PEAR::popErrorHandling();
1220 '%s cannot be installed, conflicts with installed packages');