summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas V.V.Cox <cox@php.net>2001-11-15 01:24:35 +0000
committerTomas V.V.Cox <cox@php.net>2001-11-15 01:24:35 +0000
commit15f0f8ae23e9e13e4613eeb05e328dea2d67f2bd (patch)
tree33c81e0c7e15a973ad368225deac62aeeb984cb2
parentdf92e90d500864caa3cb3d08323f1ab5919ebc34 (diff)
downloadphp-git-15f0f8ae23e9e13e4613eeb05e328dea2d67f2bd.tar.gz
implemented "uninstall" command
-rw-r--r--pear/PEAR/Installer.php23
-rw-r--r--pear/scripts/pear.in16
2 files changed, 38 insertions, 1 deletions
diff --git a/pear/PEAR/Installer.php b/pear/PEAR/Installer.php
index dcfe5c8aff..194acce804 100644
--- a/pear/PEAR/Installer.php
+++ b/pear/PEAR/Installer.php
@@ -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;
+ }
}
?> \ No newline at end of file
diff --git a/pear/scripts/pear.in b/pear/scripts/pear.in
index 2784a4ed9a..d80e9aad20 100644
--- a/pear/scripts/pear.in
+++ b/pear/scripts/pear.in
@@ -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];
@@ -186,6 +186,19 @@ switch ($command) {
}
// }}}
+ // {{{ 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
case '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".