* Check package dependencies on uninstall
*
* @param string $error The resultant error string
+ * @param string $warning The resultant warning string
* @param string $name Name of the package to test
*
* @return bool true if there were errors
*/
- function checkPackageUninstall(&$error, $package)
+ function checkPackageUninstall(&$error, &$warning, $package)
{
$error = null;
$packages = $this->registry->listPackages();
}
foreach ($deps as $dep) {
if ($dep['type'] == 'pkg' && strcasecmp($dep['name'], $package) == 0) {
- $error .= "Package '$pkg' depends on '$package'\n";
+ if (isset($dep['optional']) && $dep['optional'] == 'yes') {
+ $warning .= "\nWarning: Package '$pkg' optionally depends on '$package'";
+ } else {
+ $error .= "Package '$pkg' depends on '$package'\n";
+ }
}
}
}
$this->installroot = '';
}
$this->registry = &new PEAR_Registry($php_dir);
+ $filelist = $this->registry->packageInfo($package, 'filelist');
+ if ($filelist == null) {
+ return $this->raiseError("$package not installed");
+ }
if (empty($options['nodeps'])) {
$depchecker = &new PEAR_Dependency($this->registry);
- $error = $depchecker->checkPackageUninstall($errors, $package);
+ $error = $depchecker->checkPackageUninstall($errors, $warning, $package);
if ($error) {
return $this->raiseError($errors . 'uninstall failed');
}
+ if ($warning) {
+ $this->log(0, $warning);
+ }
}
// Delete the files
if (PEAR::isError($err = $this->_deletePackageFiles($package))) {