/** * validate a downloaded package against installed packages * * @param $pkg downloaded package package.xml object * @param array $params full list of packages to install * @return bool */ function validateDownloadedPackage(\PEAR2\Pyrus\PackageFileInterface $pkg, $params = array()) { $me = $pkg->channel . '/' . $pkg->name; $reg = Config::current()->registry; $deppackages = $reg->getDependentPackages($pkg); $fail = false; if ($deppackages) { $actual = array(); // first, remove packages that will be installed foreach ($deppackages as $package) { foreach ($params as $packd) { if (strtolower($packd->name) == strtolower($package->name) && $packd->channel == $package->channel) { \PEAR2\Pyrus\Logger::log(3, 'skipping installed package check of "' . Config::parsedPackageNameToString(array('channel' => $package->channel, 'package' => $package->name), true) . '", version "' . $packd->version['release'] . '" will be ' . 'downloaded and installed'); continue 2; } } $actual[] = $package; } foreach ($actual as $package) { $checker = new \PEAR2\Pyrus\Dependency\Validator(array('channel' => $package->channel, 'package' => $package->name), $this->_state, $this->errs); foreach ($params as $packd) { $deps = $package->dependencies['required']->package; if (isset($deps[$me])) { $ret = $checker->_validatePackageDownload($deps[$me], array($pkg, $package)); } $deps = $package->dependencies['required']->subpackage; if (isset($deps[$me])) { $ret = $checker->_validatePackageDownload($deps[$me], array($pkg)); } $deps = $package->dependencies['optional']->package; if (isset($deps[$me])) { $ret = $checker->_validatePackageDownload($deps[$me], array($pkg, $package)); } $deps = $package->dependencies['optional']->subpackage; if (isset($deps[$me])) { $ret = $checker->_validatePackageDownload($deps[$me], array($pkg)); } } } } if (count($this->errs->E_ERROR)) { return $this->raiseError('%s cannot be installed, conflicts with installed packages'); } return true; }