install.php
来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· PHP 代码 · 共 1,172 行 · 第 1/4 页
PHP
1,172 行
} else { $newparams[] = &$info; // check for binary packages (this is an alias for those packages if so) if ($installedbinary = $info->getInstalledBinary()) { $this->ui->log('adding binary package ' . $reg->parsedPackageNameToString(array('channel' => $channel, 'package' => $installedbinary), true)); $newparams[] = &$reg->getPackage($installedbinary, $channel); } // add the contents of a dependency group to the list of installed packages if (isset($parsed['group'])) { $group = $info->getDependencyGroup($parsed['group']); if ($group) { $installed = &$reg->getInstalledGroup($group); if ($installed) { foreach ($installed as $i => $p) { $newparams[] = &$installed[$i]; } } } } } } $err = $this->installer->sortPackagesForUninstall($newparams); if (PEAR::isError($err)) { $this->ui->outputData($err->getMessage(), $command); return true; } $params = $newparams; // twist this to use it to check on whether dependent packages are also being uninstalled // for circular dependencies like subpackages $this->installer->setUninstallPackages($newparams); $params = array_merge($params, $badparams); foreach ($params as $pkg) { $this->installer->pushErrorHandling(PEAR_ERROR_RETURN); if ($err = $this->installer->uninstall($pkg, $options)) { $this->installer->popErrorHandling(); if (PEAR::isError($err)) { $this->ui->outputData($err->getMessage(), $command); continue; } if ($pkg->getPackageType() == 'extsrc' || $pkg->getPackageType() == 'extbin' || $pkg->getPackageType() == 'zendextsrc' || $pkg->getPackageType() == 'zendextbin') { if ($instbin = $pkg->getInstalledBinary()) { continue; // this will be uninstalled later } foreach ($pkg->getFilelist() as $name => $atts) { $pinfo = pathinfo($atts['installed_as']); if (!isset($pinfo['extension']) || in_array($pinfo['extension'], array('c', 'h'))) { continue; // make sure we don't match php_blah.h } if ((strpos($pinfo['basename'], 'php_') === 0 && $pinfo['extension'] == 'dll') || // most unices $pinfo['extension'] == 'so' || // hp-ux $pinfo['extension'] == 'sl') { $binaries[] = array($atts['installed_as'], $pinfo); break; } } foreach ($binaries as $pinfo) { PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); $ret = $this->disableExtension(array($pinfo[0]), $pkg->getPackageType()); PEAR::staticPopErrorHandling(); if (PEAR::isError($ret)) { $extrainfo[] = $ret->getMessage(); if ($pkg->getPackageType() == 'extsrc' || $pkg->getPackageType() == 'extbin') { $exttype = 'extension'; } else { ob_start(); phpinfo(INFO_GENERAL); $info = ob_get_contents(); ob_end_clean(); $debug = function_exists('leak') ? '_debug' : ''; $ts = preg_match('Thread Safety.+enabled', $info) ? '_ts' : ''; $exttype = 'zend_extension' . $debug . $ts; } $this->ui->outputData('Unable to remove "' . $exttype . '=' . $pinfo[1]['basename'] . '" from php.ini', $command); } else { $this->ui->outputData('Extension ' . $pkg->getProvidesExtension() . ' disabled in php.ini', $command); } } } $savepkg = $pkg; if ($this->config->get('verbose') > 0) { if (is_object($pkg)) { $pkg = $reg->parsedPackageNameToString($pkg); } $this->ui->outputData("uninstall ok: $pkg", $command); } if (!isset($options['offline']) && is_object($savepkg) && defined('PEAR_REMOTEINSTALL_OK')) { if ($this->config->isDefinedLayer('ftp')) { $this->installer->pushErrorHandling(PEAR_ERROR_RETURN); $info = $this->installer->ftpUninstall($savepkg); $this->installer->popErrorHandling(); if (PEAR::isError($info)) { $this->ui->outputData($info->getMessage()); $this->ui->outputData("remote uninstall failed: $pkg"); } else { $this->ui->outputData("remote uninstall ok: $pkg"); } } } } else { $this->installer->popErrorHandling(); if (is_object($pkg)) { $pkg = $reg->parsedPackageNameToString($pkg); } return $this->raiseError("uninstall failed: $pkg"); } } return true; } // }}} // }}} // {{{ doBundle() /* (cox) It just downloads and untars the package, does not do any check that the PEAR_Installer::_installFile() does. */ function doBundle($command, $options, $params) { $downloader = &$this->getDownloader($this->ui, array('force' => true, 'nodeps' => true, 'soft' => true, 'downloadonly' => true), $this->config); $reg = &$this->config->getRegistry(); if (sizeof($params) < 1) { return $this->raiseError("Please supply the package you want to bundle"); } if (isset($options['destination'])) { if (!is_dir($options['destination'])) { System::mkdir('-p ' . $options['destination']); } $dest = realpath($options['destination']); } else { $pwd = getcwd(); if (is_dir($pwd . DIRECTORY_SEPARATOR . 'ext')) { $dest = $pwd . DIRECTORY_SEPARATOR . 'ext'; } else { $dest = $pwd; } } PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); $err = $downloader->setDownloadDir($dest); PEAR::staticPopErrorHandling(); if (PEAR::isError($err)) { return PEAR::raiseError('download directory "' . $dest . '" is not writeable.'); } $result = &$downloader->download(array($params[0])); if (PEAR::isError($result)) { return $result; } $pkgfile = &$result[0]->getPackageFile(); $pkgname = $pkgfile->getName(); $pkgversion = $pkgfile->getVersion(); // Unpacking ------------------------------------------------- $dest .= DIRECTORY_SEPARATOR . $pkgname; $orig = $pkgname . '-' . $pkgversion; $tar = &new Archive_Tar($pkgfile->getArchiveFile()); if (!$tar->extractModify($dest, $orig)) { return $this->raiseError('unable to unpack ' . $pkgfile->getArchiveFile()); } $this->ui->outputData("Package ready at '$dest'"); // }}} } // }}} function doRunScripts($command, $options, $params) { if (!isset($params[0])) { return $this->raiseError('run-scripts expects 1 parameter: a package name'); } $reg = &$this->config->getRegistry(); PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); $parsed = $reg->parsePackageName($params[0], $this->config->get('default_channel')); PEAR::staticPopErrorHandling(); if (PEAR::isError($parsed)) { return $this->raiseError($parsed); } $package = &$reg->getPackage($parsed['package'], $parsed['channel']); if (is_object($package)) { $package->setConfig($this->config); $package->runPostinstallScripts(); } else { return $this->raiseError('Could not retrieve package "' . $params[0] . '" from registry'); } $this->ui->outputData('Install scripts complete', $command); return true; } /** * Given a list of packages, filter out those ones that are already up to date * * @param $packages: packages, in parsed array format ! * @return list of packages that can be upgraded */ function _filterUptodatePackages($packages, $command) { $reg = &$this->config->getRegistry(); $latestReleases = array(); $ret = array(); foreach($packages as $package) { if (isset($package['group'])) { $ret[] = $package; continue; } $channel = $package['channel']; $name = $package['package']; if (!$reg->packageExists($name, $channel)) { $ret[] = $package; continue; } if (!isset($latestReleases[$channel])) { // fill in cache for this channel $chan = &$reg->getChannel($channel); if (PEAR::isError($chan)) { return $this->raiseError($chan); } if ($chan->supportsREST($this->config->get('preferred_mirror', null, $channel)) && $base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror', null, $channel))) { $dorest = true; } else { $dorest = false; $remote = &$this->config->getRemote($this->config); } PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); if ($dorest) { $rest = &$this->config->getREST('1.0', array()); $installed = array_flip($reg->listPackages($channel)); $latest = $rest->listLatestUpgrades($base, $this->config->get('preferred_state', null, $channel), $installed, $channel, $reg); } else { $latest = $remote->call("package.listLatestReleases", $this->config->get('preferred_state', null, $channel)); unset($remote); } PEAR::staticPopErrorHandling(); if (PEAR::isError($latest)) { $this->ui->outputData('Error getting channel info from ' . $channel . ': ' . $latest->getMessage()); continue; } $latestReleases[$channel] = array_change_key_case($latest); } // check package for latest release if (isset($latestReleases[$channel][strtolower($name)])) { // if not set, up to date $inst_version = $reg->packageInfo($name, 'version', $channel); $channel_version = $latestReleases[$channel][strtolower($name)]['version']; if (version_compare($channel_version, $inst_version, "le")) { // installed version is up-to-date continue; } // maintain BC if ($command == 'upgrade-all') { $this->ui->outputData(array('data' => 'Will upgrade ' . $reg->parsedPackageNameToString($package)), $command); } $ret[] = $package; } } return $ret; }}?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?