function _validatePackageUninstall($dep, $required, $dl) { $depname = $this->_registry->parsedPackageNameToString($dep, true); $version = $this->_registry->packageinfo($dep['package'], 'version', $dep['channel']); if (!$version) { return true; } $extra = $this->_getExtraString($dep); if (isset($dep['exclude'])) { if (!is_array($dep['exclude'])) { $dep['exclude'] = array($dep['exclude']); } } if (isset($dep['conflicts'])) { return true; // uninstall OK - these packages conflict (probably installed with --force) } if (!isset($dep['min']) && !isset($dep['max'])) { if ($required) { if (!isset($this->_options['nodeps']) && !isset($this->_options['force'])) { return $this->raiseError('"' . $depname . '" is required by ' . 'installed package %s' . $extra); } else { return $this->warning('warning: "' . $depname . '" is required by ' . 'installed package %s' . $extra); } } else { return $this->warning('"' . $depname . '" can be optionally used by ' . 'installed package %s' . $extra); } } $fail = false; if (isset($dep['min'])) { if (version_compare($version, $dep['min'], '>=')) { $fail = true; } } if (isset($dep['max'])) { if (version_compare($version, $dep['max'], '<=')) { $fail = true; } } // we re-use this variable, preserve the original value $saverequired = $required; if ($required) { if (!isset($this->_options['nodeps']) && !isset($this->_options['force'])) { return $this->raiseError($depname . $extra . ' is required by installed package' . ' "%s"'); } else { return $this->raiseError('warning: ' . $depname . $extra . ' is required by installed package "%s"'); } } else { return $this->warning($depname . $extra . ' can be optionally used by installed package' . ' "%s"'); } return true; }
function _validatePackageUninstall($dep, $required, $params, &$dl) { $dep['package'] = $dep['name']; $depname = $this->_registry->parsedPackageNameToString($dep, true); $found = false; foreach ($params as $param) { if ($param->isEqual($this->_currentPackage)) { $found = true; break; } } $version = $this->_registry->packageinfo($dep['name'], 'version', $dep['channel']); if (!$version) { return true; } $extra = $this->_getExtraString($dep); if (isset($dep['exclude'])) { if (!is_array($dep['exclude'])) { $dep['exclude'] = array($dep['exclude']); } } if (isset($dep['conflicts'])) { return true; // uninstall OK - these packages conflict (probably installed with --force) } if (!isset($dep['min']) && !isset($dep['max'])) { if ($required) { if (!isset($this->_options['nodeps']) && !isset($this->_options['force'])) { return $this->raiseError('%s' . $extra . ' is required by installed package "' . $depname . '"'); } else { return $this->warning('warning: %s' . $extra . ' is required by installed package "' . $depname . '"'); } } else { return $this->warning('%s' . $extra . ' can be optionally used by installed package "' . $depname . '"'); } } $fail = false; if (isset($dep['min'])) { if (version_compare($version, $dep['min'], '>=')) { $fail = true; } } if (isset($dep['max'])) { if (version_compare($version, $dep['max'], '<=')) { $fail = true; } } if ($fail) { if ($found) { if (!isset($dl->___checked[$this->_currentPackage['channel']][$this->_currentPackage['package']])) { $dl->___checked[$this->_currentPackage['channel']][$this->_currentPackage['package']] = true; $deps = $this->_dependencydb->getDependentPackageDependencies($this->_currentPackage); if ($deps) { foreach ($deps as $channel => $info) { foreach ($info as $package => $ds) { foreach ($ds as $d) { $d['dep']['package'] = $d['dep']['name']; $checker =& new PEAR_Dependency2($this->_config, $this->_options, array('channel' => $channel, 'package' => $package), $this->_state); $dep = $d['dep']; $required = $d['type'] == 'required'; $ret = $checker->_validatePackageUninstall($dep, $required, $params, $dl); if (PEAR::isError($ret)) { $fail = true; break 3; } } } $fail = false; } } } else { return true; } } if (!$fail) { return true; } if ($required) { if (!isset($this->_options['nodeps']) && !isset($this->_options['force'])) { return $this->raiseError($depname . $extra . ' is required by installed package' . ' "%s"'); } else { return $this->warning('warning: ' . $depname . $extra . ' is required by installed package "%s"'); } } else { return $this->warning($depname . $extra . ' can be optionally used by installed package' . ' "%s"'); } } return true; }