mirror of
https://github.com/php/php-src.git
synced 2024-09-22 02:17:32 +00:00
implemented "uninstall" command
This commit is contained in:
parent
df92e90d50
commit
15f0f8ae23
@ -240,6 +240,29 @@ class PEAR_Installer extends PEAR_Common
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
function uninstall($package)
|
||||
{
|
||||
if (empty($this->registry)) {
|
||||
$this->registry = new PEAR_Registry;
|
||||
}
|
||||
if (!$this->registry->packageExists($package)) {
|
||||
return $this->raiseError("is not installed");
|
||||
}
|
||||
$info = $this->registry->packageInfo($package);
|
||||
foreach ($info['filelist'] as $file => $props) {
|
||||
$base = (isset($props['baseinstalldir'])) ? $props['baseinstalldir'] : '';
|
||||
$path = PEAR_INSTALL_DIR . DIRECTORY_SEPARATOR . $base .
|
||||
DIRECTORY_SEPARATOR . $file;
|
||||
if (!@unlink($path)) {
|
||||
$this->log(2, "unable to delete: $path");
|
||||
} else {
|
||||
$this->log(2, "+ deleted file: $path");
|
||||
}
|
||||
}
|
||||
$this->registry->deletePackage($package);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -84,7 +84,7 @@ foreach ($opts as $opt) {
|
||||
$config = new PEAR_Config($pear_user_config, $pear_default_config);
|
||||
$store_user_config = false;
|
||||
$store_default_config = false;
|
||||
$verbose = 0;
|
||||
$verbose = 1;
|
||||
|
||||
foreach ($opts as $opt) {
|
||||
$param = $opt[1];
|
||||
@ -185,6 +185,19 @@ switch ($command) {
|
||||
break;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ uninstall
|
||||
case 'uninstall': {
|
||||
include_once 'PEAR/Installer.php';
|
||||
$pkgfile = $options[1][2];
|
||||
$installer =& new PEAR_Installer($script_dir, $ext_dir, $doc_dir);
|
||||
$installer->setErrorHandling(PEAR_ERROR_DIE,
|
||||
basename($pkgfile) . ": %s\n");
|
||||
$installer->debug = $verbose;
|
||||
$installer->uninstall($pkgfile);
|
||||
print "uninstall ok\n";
|
||||
break;
|
||||
}
|
||||
// }}}
|
||||
// {{{ package
|
||||
|
||||
@ -315,6 +328,7 @@ function usage($error = null)
|
||||
" -h, -? display help/usage (this message)\n".
|
||||
"Commands:\n".
|
||||
" install <package file>\n".
|
||||
" uninstall <package name>\n".
|
||||
" package [package info file]\n".
|
||||
" list-installed\n".
|
||||
" list-available\n".
|
||||
|
Loading…
Reference in New Issue
Block a user