21require_once
'PEAR.php';
22require_once
'PEAR/DependencyDB.php';
24define(
'PEAR_REGISTRY_ERROR_LOCK', -2);
25define(
'PEAR_REGISTRY_ERROR_FORMAT', -3);
26define(
'PEAR_REGISTRY_ERROR_FILE', -4);
27define(
'PEAR_REGISTRY_ERROR_CONFLICT', -5);
28define(
'PEAR_REGISTRY_ERROR_CHANNEL_FILE', -6);
133 function __construct($pear_install_dir = PEAR_INSTALL_DIR, $pear_channel =
false,
134 $pecl_channel =
false, $pear_metadata_dir =
'')
136 parent::__construct();
138 $this->_pearChannel = $pear_channel;
139 $this->_peclChannel = $pecl_channel;
140 $this->_config =
false;
143 function setInstallDir($pear_install_dir = PEAR_INSTALL_DIR, $pear_metadata_dir =
'')
145 $ds = DIRECTORY_SEPARATOR;
146 $this->install_dir = $pear_install_dir;
147 if (!$pear_metadata_dir) {
148 $pear_metadata_dir = $pear_install_dir;
150 $this->channelsdir = $pear_metadata_dir.$ds.
'.channels';
151 $this->statedir = $pear_metadata_dir.$ds.
'.registry';
152 $this->filemap = $pear_metadata_dir.$ds.
'.filemap';
153 $this->lockfile = $pear_metadata_dir.$ds.
'.lock';
158 if (!file_exists($this->install_dir)) {
159 $dir = $this->install_dir;
160 while ($dir && $dir !=
'.') {
162 $dir = dirname($dir);
163 if ($dir !=
'.' && file_exists($dir)) {
164 if (is_writeable($dir)) {
171 if ($dir == $olddir) {
172 return @is_writable($dir);
179 return is_writeable($this->install_dir);
185 if ($resetInstallDir) {
192 static $running =
false;
195 $ds = DIRECTORY_SEPARATOR;
196 if (!is_dir($this->channelsdir) ||
197 !file_exists($this->channelsdir . $ds .
'pear.php.net.reg') ||
198 !file_exists($this->channelsdir . $ds .
'pecl.php.net.reg') ||
199 !file_exists($this->channelsdir . $ds .
'doc.php.net.reg') ||
200 !file_exists($this->channelsdir . $ds .
'__uri.reg')) {
201 if (!file_exists($this->channelsdir . $ds .
'pear.php.net.reg')) {
203 if (!is_a($pear_channel,
'PEAR_ChannelFile') || !$pear_channel->validate()) {
204 if (!class_exists(
'PEAR_ChannelFile')) {
205 require_once
'PEAR/ChannelFile.php';
210 $pear_channel->setServer(
'pear.php.net');
211 $pear_channel->setSummary(
'PHP Extension and Application Repository');
212 $pear_channel->setDefaultPEARProtocols();
213 $pear_channel->setBaseURL(
'REST1.0',
'https://pear.php.net/rest/');
214 $pear_channel->setBaseURL(
'REST1.1',
'https://pear.php.net/rest/');
215 $pear_channel->setBaseURL(
'REST1.3',
'https://pear.php.net/rest/');
218 $pear_channel->setServer(
'pear.php.net');
219 $pear_channel->setAlias(
'pear');
222 $pear_channel->validate();
226 if (!file_exists($this->channelsdir . $ds .
'pecl.php.net.reg')) {
228 if (!is_a($pecl_channel,
'PEAR_ChannelFile') || !$pecl_channel->validate()) {
229 if (!class_exists(
'PEAR_ChannelFile')) {
230 require_once
'PEAR/ChannelFile.php';
235 $pecl_channel->setServer(
'pecl.php.net');
236 $pecl_channel->setSummary(
'PHP Extension Community Library');
237 $pecl_channel->setDefaultPEARProtocols();
238 $pecl_channel->setBaseURL(
'REST1.0',
'https://pecl.php.net/rest/');
239 $pecl_channel->setBaseURL(
'REST1.1',
'https://pecl.php.net/rest/');
240 $pecl_channel->setValidationPackage(
'PEAR_Validator_PECL',
'1.0');
242 $pecl_channel->setServer(
'pecl.php.net');
243 $pecl_channel->setAlias(
'pecl');
246 $pecl_channel->validate();
250 if (!file_exists($this->channelsdir . $ds .
'doc.php.net.reg')) {
252 if (!is_a($doc_channel,
'PEAR_ChannelFile') || !$doc_channel->validate()) {
253 if (!class_exists(
'PEAR_ChannelFile')) {
254 require_once
'PEAR/ChannelFile.php';
259 $doc_channel->setServer(
'doc.php.net');
260 $doc_channel->setSummary(
'PHP Documentation Team');
261 $doc_channel->setDefaultPEARProtocols();
262 $doc_channel->setBaseURL(
'REST1.0',
'https://doc.php.net/rest/');
263 $doc_channel->setBaseURL(
'REST1.1',
'https://doc.php.net/rest/');
264 $doc_channel->setBaseURL(
'REST1.3',
'https://doc.php.net/rest/');
266 $doc_channel->setServer(
'doc.php.net');
267 $doc_channel->setAlias(
'doc');
270 $doc_channel->validate();
274 if (!file_exists($this->channelsdir . $ds .
'__uri.reg')) {
275 if (!class_exists(
'PEAR_ChannelFile')) {
276 require_once
'PEAR/ChannelFile.php';
281 $private->setDefaultPEARProtocols();
282 $private->setBaseURL(
'REST1.0',
'****');
283 $private->setSummary(
'Pseudo-channel for static packages');
295 $ds = DIRECTORY_SEPARATOR;
298 if (!OS_WINDOWS && file_exists($this->statedir) && is_dir($this->statedir) &&
299 $handle = opendir($this->statedir)) {
300 $dest = $this->statedir . $ds;
301 while (
false !== ($file = readdir($handle))) {
302 if (preg_match(
'/^.*[A-Z].*\.reg\\z/', $file)) {
303 rename($dest . $file, $dest . strtolower($file));
310 if (!file_exists($this->filemap)) {
318 if (!isset($this->_dependencyDB)) {
319 static $initializing =
false;
320 if (!$initializing) {
321 $initializing =
true;
322 if (!$this->_config) {
323 $file = OS_WINDOWS ?
'pear.ini' :
'.pearrc';
324 $this->_config =
new PEAR_Config($this->statedir . DIRECTORY_SEPARATOR .
326 $this->_config->setRegistry($this);
327 $this->_config->set(
'php_dir', $this->install_dir);
333 if (file_exists($this->_config->get(
'metadata_dir',
null,
'pear.php.net') .
334 DIRECTORY_SEPARATOR .
'.depdb')) {
335 @unlink($this->_config->get(
'metadata_dir',
null,
'pear.php.net') .
336 DIRECTORY_SEPARATOR .
'.depdb');
341 echo $this->_dependencyDB->getMessage();
342 echo
'Unrecoverable error';
347 $initializing =
false;
360 if (is_resource($this->lock_fp)) {
379 static $init =
false;
380 if (!file_exists($this->statedir)) {
385 require_once
'System.php';
386 if (!System::mkdir(array(
'-p', $this->statedir))) {
387 return $this->raiseError(
"could not create directory '{$this->statedir}'");
390 } elseif (!is_dir($this->statedir)) {
391 return $this->raiseError(
'Cannot create directory ' . $this->statedir .
', ' .
392 'it already exists and is not a directory');
395 $ds = DIRECTORY_SEPARATOR;
396 if (!file_exists($this->channelsdir)) {
397 if (!file_exists($this->channelsdir . $ds .
'pear.php.net.reg') ||
398 !file_exists($this->channelsdir . $ds .
'pecl.php.net.reg') ||
399 !file_exists($this->channelsdir . $ds .
'doc.php.net.reg') ||
400 !file_exists($this->channelsdir . $ds .
'__uri.reg')) {
403 } elseif (!is_dir($this->channelsdir)) {
404 return $this->raiseError(
'Cannot create directory ' . $this->channelsdir .
', ' .
405 'it already exists and is not a directory');
409 static $running =
false;
434 $ds = DIRECTORY_SEPARATOR;
436 if (!file_exists($this->channelsdir . $ds .
'pear.php.net.reg')) {
443 if (!is_dir($this->channelsdir) ||
444 !file_exists($this->channelsdir . $ds .
'pear.php.net.reg')) {
448 if (!file_exists($channelDir)) {
453 require_once
'System.php';
454 if (!System::mkdir(array(
'-p', $channelDir))) {
455 return $this->raiseError(
"could not create directory '" . $channelDir .
458 } elseif (!is_dir($channelDir)) {
459 return $this->raiseError(
"could not create directory '" . $channelDir .
460 "', already exists and is not a directory");
476 if (!file_exists($this->channelsdir)) {
481 require_once
'System.php';
482 if (!System::mkdir(array(
'-p', $this->channelsdir))) {
483 return $this->raiseError(
"could not create directory '{$this->channelsdir}'");
485 } elseif (!is_dir($this->channelsdir)) {
486 return $this->raiseError(
"could not create directory '{$this->channelsdir}" .
487 "', it already exists and is not a directory");
490 if (!file_exists($this->channelsdir . DIRECTORY_SEPARATOR .
'.alias')) {
495 require_once
'System.php';
496 if (!System::mkdir(array(
'-p', $this->channelsdir . DIRECTORY_SEPARATOR .
'.alias'))) {
497 return $this->raiseError(
"could not create directory '{$this->channelsdir}/.alias'");
499 } elseif (!is_dir($this->channelsdir . DIRECTORY_SEPARATOR .
'.alias')) {
500 return $this->raiseError(
"could not create directory '{$this->channelsdir}" .
501 "/.alias', it already exists and is not a directory");
521 strtolower($package) .
'.reg';
524 return $this->statedir . DIRECTORY_SEPARATOR . strtolower($package) .
'.reg';
539 return $this->channelsdir . DIRECTORY_SEPARATOR . str_replace(
'/',
'_',
540 strtolower($channel)) .
'.reg';
549 return $this->channelsdir . DIRECTORY_SEPARATOR .
'.alias' .
550 DIRECTORY_SEPARATOR . str_replace(
'/',
'_', strtolower($alias)) .
'.txt';
559 if ($channel ==
'pear.php.net') {
560 return 'pear.php.net';
563 if ($channel ==
'pecl.php.net') {
564 return 'pecl.php.net';
567 if ($channel ==
'doc.php.net') {
568 return 'doc.php.net';
571 if ($channel ==
'__uri') {
578 $channel = strtolower($channel);
593 if ($channel ==
'pear.php.net') {
597 if ($channel ==
'pecl.php.net') {
601 if ($channel ==
'doc.php.net') {
613 return $channel->getAlias();
637 return $this->statedir . DIRECTORY_SEPARATOR . strtolower(
'.channel.' .
638 str_replace(
'/',
'_', $ch));
647 if (!in_array($mode, array(
'r',
'rb')) && !$this->
hasWriteAccess()) {
652 if (!file_exists($file) && $mode ==
'r' || $mode ==
'rb') {
656 $fp = @fopen($file, $mode);
675 if (!in_array($mode, array(
'r',
'rb')) && !$this->
hasWriteAccess()) {
680 if (!file_exists($file) && $mode ==
'r' || $mode ==
'rb') {
684 $fp = @fopen($file, $mode);
699 if (!class_exists(
'PEAR_Installer_Role')) {
700 require_once
'PEAR/Installer/Role.php';
705 foreach (
$channels as $channel => $packages) {
706 foreach ($packages as $package) {
707 $version = $this->
_packageInfo($package,
'version', $channel);
708 $filelist = $this->
_packageInfo($package,
'filelist', $channel);
709 if (!is_array($filelist)) {
713 foreach ($filelist as $name => $attrs) {
714 if (isset($attrs[
'attribs'])) {
715 $attrs = $attrs[
'attribs'];
720 if ($name ==
'dirtree') {
724 if (isset($attrs[
'role']) && !in_array($attrs[
'role'],
730 if (isset($attrs[
'role']) && !in_array($attrs[
'role'],
732 $attrs[
'baseinstalldir'] = $package;
735 if (isset($attrs[
'baseinstalldir'])) {
736 $file = $attrs[
'baseinstalldir'].DIRECTORY_SEPARATOR.$name;
741 $file = preg_replace(
',^/+,',
'', $file);
742 if ($channel !=
'pear.php.net') {
743 if (!isset($files[$attrs[
'role']])) {
744 $files[$attrs[
'role']] = array();
746 $files[$attrs[
'role']][$file] = array(strtolower($channel),
747 strtolower($package));
749 if (!isset($files[$attrs[
'role']])) {
750 $files[$attrs[
'role']] = array();
752 $files[$attrs[
'role']][$file] = strtolower($package);
764 $fp = @fopen($this->filemap,
'wb');
769 $this->filemap_cache = $files;
770 fwrite($fp, serialize($files));
777 if (!file_exists($this->filemap)) {
781 $fp = @fopen($this->filemap,
'r');
784 $last_error = error_get_last();
785 if (!empty($last_error[
'message'])) {
786 $last_errormsg = $last_error[
'message'];
788 return $this->raiseError(
'PEAR_Registry: could not open filemap "' . $this->filemap .
'"',
PEAR_REGISTRY_ERROR_FILE,
null,
null, $last_errormsg);
792 $fsize = filesize($this->filemap);
794 $data = file_get_contents($this->filemap);
795 $tmp = unserialize($data);
796 if (!$tmp && $fsize > 7) {
800 $this->filemap_cache = $tmp;
818 if (stristr(php_uname(),
'Windows 9')) {
822 if ($mode != LOCK_UN && is_resource($this->lock_fp)) {
828 if ($mode == LOCK_EX) {
829 return $this->raiseError(
'Registry directory is not writeable by the current user');
837 if ($mode === LOCK_SH || $mode === LOCK_UN) {
838 if (!file_exists($this->lockfile)) {
839 touch($this->lockfile);
844 if (!is_resource($this->lock_fp)) {
845 $this->lock_fp = @fopen($this->lockfile, $open_mode);
848 if (!is_resource($this->lock_fp)) {
849 $this->lock_fp =
null;
850 return $this->raiseError(
"could not create lock file" .
851 (isset($php_errormsg) ?
": " . $php_errormsg :
""));
854 if (!(
int)flock($this->lock_fp, $mode)) {
856 case LOCK_SH: $str =
'shared';
break;
857 case LOCK_EX: $str =
'exclusive';
break;
858 case LOCK_UN: $str =
'unlock';
break;
859 default: $str =
'unknown';
break;
863 fclose($this->lock_fp);
864 $this->lock_fp =
null;
865 return $this->raiseError(
"could not acquire $str lock ($this->lockfile)",
874 $ret = $this->
_lock(LOCK_UN);
875 if (is_resource($this->lock_fp)) {
876 fclose($this->lock_fp);
879 $this->lock_fp =
null;
898 if (!$a && $channel ==
'pear.php.net') {
902 if (!$a && $channel ==
'pecl.php.net') {
906 if (!$a && $channel ==
'doc.php.net') {
924 if (!isset($data[
'servers'][
'mirror'])) {
928 foreach ($data[
'servers'][
'mirror'] as $m) {
929 if ($m[
'attribs'][
'host'] == $mirror) {
943 function _addChannel($channel, $update =
false, $lastmodified =
false)
945 if (!is_a($channel,
'PEAR_ChannelFile')) {
949 if (!$channel->validate()) {
958 $checker = $this->
_getChannel($channel->getName());
963 if ($channel->getAlias() != $checker->getAlias()) {
969 if ($update && !in_array($channel->getName(), array(
'pear.php.net',
'pecl.php.net',
'doc.php.net'))) {
984 if ($channel->getAlias() != $channel->getName()) {
986 $this->_getChannelFromAlias($channel->getAlias()) != $channel->getName()) {
987 $channel->setAlias($channel->getName());
999 fwrite($fp, $channel->getName());
1012 $info = $channel->toArray();
1013 if ($lastmodified) {
1014 $info[
'_lastmodified'] = $lastmodified;
1019 fwrite($fp, serialize($info));
1031 if (!is_string($channel)) {
1032 if (!is_a($channel,
'PEAR_ChannelFile')) {
1036 if (!$channel->validate()) {
1039 $channel = $channel->getName();
1063 if ($channel ==
'pear.php.net') {
1078 if (file_exists($file)) {
1079 $test = @unlink($file);
1087 if (file_exists($file)) {
1088 $ret = @unlink($file);
1111 function _packageInfo($package =
null, $key =
null, $channel =
'pear.php.net')
1113 if ($package ===
null) {
1114 if ($channel ===
null) {
1118 $channel = strtolower($channel);
1119 $ret[$channel] = array();
1121 foreach ($packages as $package) {
1122 $ret[$channel][] = $this->
_packageInfo($package,
null, $channel);
1133 return array_map(array(&$this,
'_packageInfo'),
1134 $ps, array_fill(0, count($ps),
null),
1135 array_fill(0, count($ps), $channel));
1146 $data = @unserialize($data);
1147 if ($key ===
null) {
1152 if (isset($data[
'old'][$key])) {
1153 return $data[
'old'][$key];
1156 if (isset($data[$key])) {
1182 $data = unserialize($data);
1188 $channellist = array();
1189 if (!file_exists($this->channelsdir) || !is_dir($this->channelsdir)) {
1190 return array(
'pear.php.net',
'pecl.php.net',
'doc.php.net',
'__uri');
1193 $dp = opendir($this->channelsdir);
1194 while ($ent = readdir($dp)) {
1195 if ($ent[0] ==
'.' || substr($ent, -4) !=
'.reg') {
1199 if ($ent ==
'__uri.reg') {
1200 $channellist[] =
'__uri';
1204 $channellist[] = str_replace(
'_',
'/', substr($ent, 0, -4));
1208 if (!in_array(
'pear.php.net', $channellist)) {
1209 $channellist[] =
'pear.php.net';
1212 if (!in_array(
'pecl.php.net', $channellist)) {
1213 $channellist[] =
'pecl.php.net';
1216 if (!in_array(
'doc.php.net', $channellist)) {
1217 $channellist[] =
'doc.php.net';
1221 if (!in_array(
'__uri', $channellist)) {
1222 $channellist[] =
'__uri';
1225 natsort($channellist);
1226 return $channellist;
1235 if (!file_exists($this->statedir) || !is_dir($this->statedir)) {
1240 $dp = opendir($this->statedir);
1245 while ($ent = readdir($dp)) {
1246 if ($ent[0] ==
'.' || substr($ent, -4) !=
'.reg') {
1250 $pkglist[] = substr($ent, 0, -4);
1270 while ($ent = readdir($dp)) {
1271 if ($ent[0] ==
'.' || substr($ent, -4) !=
'.reg') {
1274 $pkglist[] = substr($ent, 0, -4);
1310 fwrite($fp, serialize($info));
1312 if (isset($info[
'filelist'])) {
1326 if (!is_a($info,
'PEAR_PackageFile_v1') && !is_a($info,
'PEAR_PackageFile_v2')) {
1330 if (!$info->validate()) {
1331 if (class_exists(
'PEAR_Common')) {
1334 foreach ($info->getValidationWarnings() as $err) {
1335 $ui->log($err[
'message'],
true);
1342 $channel = $info->getChannel();
1343 $package = $info->getPackage();
1353 $info = $info->toArray(
true);
1364 fwrite($fp, serialize($info));
1379 if (empty($oldinfo)) {
1388 if (is_object($info)) {
1389 $info = $info->toArray();
1395 $info = array_merge($oldinfo, $info);
1400 fwrite($fp, serialize($info));
1402 if (isset($newinfo[
'filelist'])) {
1416 if (!$this->
_packageExists($info->getPackage(), $info->getChannel())) {
1420 $fp = $this->
_openPackageFile($info->getPackage(),
'w', $info->getChannel());
1426 $info = $save->getArray(
true);
1428 fwrite($fp, serialize($info));
1443 if ($info ===
null) {
1449 $this->_config =
new PEAR_Config;
1450 $this->_config->set(
'php_dir', $this->statedir);
1453 if (!class_exists(
'PEAR_PackageFile')) {
1454 require_once
'PEAR/PackageFile.php';
1458 $pf = &$pkg->fromArray($info);
1474 if (!class_exists(
'PEAR_ChannelFile')) {
1475 require_once
'PEAR/ChannelFile.php';
1483 if ($ch->validate()) {
1487 foreach ($ch->getErrors(
true) as $err) {
1488 $message = $err[
'message'] .
"\n";
1491 $ch = PEAR::raiseError($message);
1497 if (!class_exists(
'PEAR_ChannelFile')) {
1498 require_once
'PEAR/ChannelFile.php';
1502 $pear_channel->
setServer(
'pear.php.net');
1503 $pear_channel->setAlias(
'pear');
1504 $pear_channel->setSummary(
'PHP Extension and Application Repository');
1505 $pear_channel->setDefaultPEARProtocols();
1506 $pear_channel->setBaseURL(
'REST1.0',
'https://pear.php.net/rest/');
1507 $pear_channel->setBaseURL(
'REST1.1',
'https://pear.php.net/rest/');
1508 $pear_channel->setBaseURL(
'REST1.3',
'https://pear.php.net/rest/');
1509 return $pear_channel;
1514 if (!class_exists(
'PEAR_ChannelFile')) {
1515 require_once
'PEAR/ChannelFile.php';
1518 $pear_channel->
setServer(
'pecl.php.net');
1519 $pear_channel->setAlias(
'pecl');
1520 $pear_channel->setSummary(
'PHP Extension Community Library');
1521 $pear_channel->setDefaultPEARProtocols();
1522 $pear_channel->setBaseURL(
'REST1.0',
'https://pecl.php.net/rest/');
1523 $pear_channel->setBaseURL(
'REST1.1',
'https://pecl.php.net/rest/');
1524 $pear_channel->setValidationPackage(
'PEAR_Validator_PECL',
'1.0');
1525 return $pear_channel;
1530 if (!class_exists(
'PEAR_ChannelFile')) {
1531 require_once
'PEAR/ChannelFile.php';
1536 $doc_channel->setAlias(
'phpdocs');
1537 $doc_channel->setSummary(
'PHP Documentation Team');
1538 $doc_channel->setDefaultPEARProtocols();
1539 $doc_channel->setBaseURL(
'REST1.0',
'https://doc.php.net/rest/');
1540 $doc_channel->setBaseURL(
'REST1.1',
'https://doc.php.net/rest/');
1541 $doc_channel->setBaseURL(
'REST1.3',
'https://doc.php.net/rest/');
1542 return $doc_channel;
1548 if (!class_exists(
'PEAR_ChannelFile')) {
1549 require_once
'PEAR/ChannelFile.php';
1554 $private->setDefaultPEARProtocols();
1555 $private->setBaseURL(
'REST1.0',
'****');
1556 $private->setSummary(
'Pseudo-channel for static packages');
1642 function packageInfo($package =
null, $key =
null, $channel =
'pear.php.net')
1751 if (is_object($info)) {
1760 if (!class_exists(
'PEAR_PackageFile_v1')) {
1761 require_once
'PEAR/PackageFile/v1.php';
1765 $pf->fromArray($info);
1766 $this->_dependencyDB->uninstallPackage($pf);
1767 $this->_dependencyDB->installPackage($pf);
1777 if (!is_object($info)) {
1778 return $this->
addPackage($info[
'package'], $info);
1786 $this->_dependencyDB->uninstallPackage($info);
1787 $this->_dependencyDB->installPackage($info);
1801 if ($channel->getName() ==
'__uri') {
1804 return $this->
addChannel($channel, $lastmodified,
true);
1823 if ($ret && is_a($this->_config,
'PEAR_Config')) {
1838 function addChannel($channel, $lastmodified =
false, $update =
false)
1840 if (!is_a($channel,
'PEAR_ChannelFile') || !$channel->validate()) {
1848 $ret = $this->
_addChannel($channel, $update, $lastmodified);
1850 if (!$update && $ret && is_a($this->_config,
'PEAR_Config')) {
1867 $ret = file_exists($file) ? @unlink($file) :
false;
1870 $p = array(
'channel' => $channel,
'package' => $package);
1871 $this->_dependencyDB->uninstallPackage($p);
1880 if (is_object($info)) {
1889 if (!class_exists(
'PEAR_PackageFile_v1')) {
1890 require_once
'PEAR/PackageFile/v1.php';
1895 $this->_dependencyDB->uninstallPackage($pf);
1896 $this->_dependencyDB->installPackage($pf);
1907 if (!is_object($info)) {
1908 return $this->
updatePackage($info[
'package'], $info, $merge);
1922 $this->_dependencyDB->uninstallPackage($info);
1923 $this->_dependencyDB->installPackage($info);
1944 return PEAR::raiseError(
'Unknown channel: ' . $channel);
1979 if (isset($group[
'package'])) {
1980 if (!isset($group[
'package'][0])) {
1981 $group[
'package'] = array($group[
'package']);
1983 foreach ($group[
'package'] as $package) {
1984 $depchannel = isset($package[
'channel']) ? $package[
'channel'] :
'__uri';
1985 $p = &$this->
getPackage($package[
'name'], $depchannel);
1992 if (isset($group[
'subpackage'])) {
1993 if (!isset($group[
'subpackage'][0])) {
1994 $group[
'subpackage'] = array($group[
'subpackage']);
1996 foreach ($group[
'subpackage'] as $package) {
1997 $depchannel = isset($package[
'channel']) ? $package[
'channel'] :
'__uri';
1998 $p = &$this->
getPackage($package[
'name'], $depchannel);
2022 $val = $chan->getValidationObject();
2065 function checkFileMap($path, $package =
false, $api =
'1.0', $attrs =
false)
2067 if (is_array($path)) {
2069 if (empty($notempty)) {
2070 if (!class_exists(
'PEAR_Installer_Role')) {
2071 require_once
'PEAR/Installer/Role.php';
2073 $notempty =
function($a) {
return !empty($a); };
2075 $package = is_array($package) ? array(strtolower($package[0]), strtolower($package[1]))
2076 : strtolower($package);
2078 foreach ($path as $name => $attrs) {
2079 if (is_array($attrs)) {
2080 if (isset($attrs[
'install-as'])) {
2081 $name = $attrs[
'install-as'];
2088 $attrs[
'baseinstalldir'] = is_array($package) ? $package[1] : $package;
2090 if (isset($attrs[
'baseinstalldir'])) {
2091 $name = $attrs[
'baseinstalldir'] . DIRECTORY_SEPARATOR . $name;
2094 $pkgs[$name] = $this->
checkFileMap($name, $package, $api, $attrs);
2096 return $pkgs[$name];
2099 return array_filter($pkgs, $notempty);
2101 if (empty($this->filemap_cache)) {
2112 $attrs = array(
'role' =>
'php');
2114 if (isset($this->filemap_cache[$attrs[
'role']][$path])) {
2115 if ($api >=
'1.1' && $this->filemap_cache[$attrs[
'role']][$path] == $package) {
2118 return $this->filemap_cache[$attrs[
'role']][$path];
2120 $l = strlen($this->install_dir);
2121 if (substr($path, 0, $l) == $this->install_dir) {
2122 $path = preg_replace(
'!^'.DIRECTORY_SEPARATOR.
'+!',
'', substr($path, $l));
2124 if (isset($this->filemap_cache[$attrs[
'role']][$path])) {
2125 if ($api >=
'1.1' && $this->filemap_cache[$attrs[
'role']][$path] == $package) {
2128 return $this->filemap_cache[$attrs[
'role']][$path];
2141 $this->filemap_cache =
null;
2174 $saveparam = $param;
2175 if (is_array($param)) {
2179 if (!isset($param[
'package'])) {
2180 return PEAR::raiseError(
'parsePackageName(): array $param ' .
2181 'must contain a valid package name in index "param"',
2182 'package',
null,
null, $param);
2184 if (!isset($param[
'uri'])) {
2185 if (!isset($param[
'channel'])) {
2186 $param[
'channel'] = $defaultchannel;
2189 $param[
'channel'] =
'__uri';
2192 $components = @parse_url((
string) $param);
2193 if (isset($components[
'scheme'])) {
2194 if ($components[
'scheme'] ==
'http') {
2196 $param = array(
'uri' => $param,
'channel' =>
'__uri');
2197 } elseif($components[
'scheme'] !=
'channel') {
2198 return PEAR::raiseError(
'parsePackageName(): only channel:// uris may ' .
2199 'be downloaded, not "' . $param .
'"',
'invalid',
null,
null, $param);
2202 if (!isset($components[
'path'])) {
2203 return PEAR::raiseError(
'parsePackageName(): array $param ' .
2204 'must contain a valid package name in "' . $param .
'"',
2205 'package',
null,
null, $param);
2207 if (isset($components[
'host'])) {
2209 $components[
'path'] = substr($components[
'path'], 1);
2211 if (!isset($components[
'scheme'])) {
2212 if (strpos($components[
'path'],
'/') !==
false) {
2213 if ($components[
'path'][0] ==
'/') {
2214 return PEAR::raiseError(
'parsePackageName(): this is not ' .
2215 'a package name, it begins with "/" in "' . $param .
'"',
2216 'invalid',
null,
null, $param);
2218 $parts = explode(
'/', $components[
'path']);
2219 $components[
'host'] = array_shift($parts);
2220 if (count($parts) > 1) {
2221 $components[
'path'] = array_pop($parts);
2222 $components[
'host'] .=
'/' . implode(
'/', $parts);
2224 $components[
'path'] = implode(
'/', $parts);
2227 $components[
'host'] = $defaultchannel;
2230 if (strpos($components[
'path'],
'/')) {
2231 $parts = explode(
'/', $components[
'path']);
2232 $components[
'path'] = array_pop($parts);
2233 $components[
'host'] .=
'/' . implode(
'/', $parts);
2237 if (is_array($param)) {
2238 $param[
'package'] = $components[
'path'];
2241 'package' => $components[
'path']
2243 if (isset($components[
'host'])) {
2244 $param[
'channel'] = $components[
'host'];
2247 if (isset($components[
'fragment'])) {
2248 $param[
'group'] = $components[
'fragment'];
2250 if (isset($components[
'user'])) {
2251 $param[
'user'] = $components[
'user'];
2253 if (isset($components[
'pass'])) {
2254 $param[
'pass'] = $components[
'pass'];
2256 if (isset($components[
'query'])) {
2257 parse_str($components[
'query'], $param[
'opts']);
2260 $pathinfo = pathinfo($param[
'package']);
2261 if (isset($pathinfo[
'extension']) &&
2262 in_array(strtolower($pathinfo[
'extension']), array(
'tgz',
'tar'))) {
2263 $param[
'extension'] = $pathinfo[
'extension'];
2264 $param[
'package'] = substr($pathinfo[
'basename'], 0,
2265 strlen($pathinfo[
'basename']) - 4);
2268 if (strpos($param[
'package'],
'-')) {
2269 $test = explode(
'-', $param[
'package']);
2270 if (count($test) != 2) {
2271 return PEAR::raiseError(
'parsePackageName(): only one version/state ' .
2272 'delimiter "-" is allowed in "' . $saveparam .
'"',
2273 'version',
null,
null, $param);
2275 list($param[
'package'], $param[
'version']) = $test;
2284 return PEAR::raiseError(
'unknown channel "' . $param[
'channel'] .
2285 '" in "' . $saveparam .
'"',
'channel',
null,
null, $param);
2287 $chan = $this->
getChannel($param[
'channel']);
2292 return PEAR::raiseError(
"Exception: corrupt registry, could not " .
2293 "retrieve channel " . $param[
'channel'] .
" information",
2294 'registry',
null,
null, $param);
2296 $param[
'channel'] = $chan->getName();
2297 $validate = $chan->getValidationObject();
2298 $vpackage = $chan->getValidationPackage();
2300 if (!$validate->validPackageName($param[
'package'], $vpackage[
'_content'])) {
2301 return PEAR::raiseError(
'parsePackageName(): invalid package name "' .
2302 $param[
'package'] .
'" in "' . $saveparam .
'"',
2303 'package',
null,
null, $param);
2305 if (isset($param[
'group'])) {
2307 return PEAR::raiseError(
'parsePackageName(): dependency group "' . $param[
'group'] .
2308 '" is not a valid group name in "' . $saveparam .
'"',
'group',
null,
null,
2312 if (isset($param[
'state'])) {
2313 if (!in_array(strtolower($param[
'state']), $validate->getValidStates())) {
2314 return PEAR::raiseError(
'parsePackageName(): state "' . $param[
'state']
2315 .
'" is not a valid state in "' . $saveparam .
'"',
2316 'state',
null,
null, $param);
2319 if (isset($param[
'version'])) {
2320 if (isset($param[
'state'])) {
2321 return PEAR::raiseError(
'parsePackageName(): cannot contain both ' .
2322 'a version and a stability (state) in "' . $saveparam .
'"',
2323 'version/state',
null,
null, $param);
2326 if (in_array(strtolower($param[
'version']), $validate->getValidStates())) {
2327 $param[
'state'] = strtolower($param[
'version']);
2328 unset($param[
'version']);
2330 if (!$validate->validVersion($param[
'version'])) {
2331 return PEAR::raiseError(
'parsePackageName(): "' . $param[
'version'] .
2332 '" is neither a valid version nor a valid state in "' .
2333 $saveparam .
'"',
'version/state',
null,
null, $param);
2346 if (is_string($parsed)) {
2349 if (is_object($parsed)) {
2352 'package' => $p->getPackage(),
2353 'channel' => $p->getChannel(),
2354 'version' => $p->getVersion(),
2357 if (isset($parsed[
'uri'])) {
2358 return $parsed[
'uri'];
2361 if ($channel = $this->
channelAlias($parsed[
'channel'])) {
2362 return $channel .
'/' . $parsed[
'package'];
2366 if (isset($parsed[
'user'])) {
2367 $upass = $parsed[
'user'];
2368 if (isset($parsed[
'pass'])) {
2369 $upass .=
':' . $parsed[
'pass'];
2373 $ret =
'channel://' . $upass . $parsed[
'channel'] .
'/' . $parsed[
'package'];
2374 if (isset($parsed[
'version']) || isset($parsed[
'state'])) {
2375 $ver = isset($parsed[
'version']) ? $parsed[
'version'] :
'';
2376 $ver .= isset($parsed[
'state']) ? $parsed[
'state'] :
'';
2379 if (isset($parsed[
'extension'])) {
2380 $ret .=
'.' . $parsed[
'extension'];
2382 if (isset($parsed[
'opts'])) {
2384 foreach ($parsed[
'opts'] as $name => $value) {
2385 $parsed[
'opts'][$name] =
"$name=$value";
2387 $ret .= implode(
'&', $parsed[
'opts']);
2389 if (isset($parsed[
'group'])) {
2390 $ret .=
'#' . $parsed[
'group'];
const PEAR_REGISTRY_ERROR_FORMAT
const PEAR_REGISTRY_ERROR_FILE
const PEAR_REGISTRY_ERROR_LOCK
const PEAR_VALIDATE_DOWNLOADING
setServer($server, $mirror=false)
setAlias($alias, $local=false)
static & fromArrayWithErrors( $data, $compatibility=false, $stackClass='PEAR_ErrorStack')
static & singleton(&$config, $depdb=false)
static & singleton($type=null)
static getBaseinstallRoles($clear=false)
static getInstallableRoles($clear=false)
updateChannel($channel, $lastmodified=null)
& _getChannel($channel, $noaliases=false)
_openPackageFile($package, $mode, $channel=false)
& getChannelValidator($channel)
_listChannelPackages($channel)
setConfig(&$config, $resetInstallDir=true)
listPackages($channel=false)
deletePackage($package, $channel='pear.php.net')
_channelExists($channel, $noaliases=false)
_packageFileName($package, $channel=false)
_mirrorExists($channel, $mirror)
_channelDirectoryName($channel)
getChannel($channel, $noaliases=false)
& _getPackage($package, $channel='pear.php.net')
_channelFileName($channel, $noaliases=false)
getInstalledGroup($group)
_updatePackage($package, $info, $merge=true)
parsePackageName($param, $defaultchannel='pear.php.net')
checkFileMap($path, $package=false, $api='1.0', $attrs=false)
_packageInfo($package=null, $key=null, $channel='pear.php.net')
packageExists($package, $channel='pear.php.net')
_addPackage($package, $info)
addPackage($package, $info)
channelInfo($channel=null, $noaliases=false)
setInstallDir($pear_install_dir=PEAR_INSTALL_DIR, $pear_metadata_dir='')
_assertStateDir($channel=false)
__construct($pear_install_dir=PEAR_INSTALL_DIR, $pear_channel=false, $pecl_channel=false, $pear_metadata_dir='')
addChannel($channel, $lastmodified=false, $update=false)
_openChannelFile($channel, $mode)
mirrorExists($channel, $mirror)
& getPackage($package, $channel='pear.php.net')
_assertChannelStateDir($channel)
channelExists($channel, $noaliases=false)
_getChannelAliasFileName($alias)
parsedPackageNameToString($parsed, $brief=false)
_addChannel($channel, $update=false, $lastmodified=false)
packageInfo($package=null, $key=null, $channel='pear.php.net')
_channelInfo($channel, $noaliases=false)
_getChannelFromAlias($channel)
_packageExists($package, $channel=false)
updatePackage($package, $info, $merge=true)
_listPackages($channel=false)
static validGroupName($name)
static getSourceDateEpoch()
static isError($data, $code=null)