cvs: php4 /pear/PEAR Installer.php /pear/scripts pear.in
| From: | Thomas V.V.Cox | Date: | Thu, 15 Nov 2001 01:24:35 +0000 |
| Subject: | cvs: php4 /pear/PEAR Installer.php /pear/scripts pear.in | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-1323@lists.php.net to get a copy of this message | ||
cox Wed Nov 14 20:24:35 2001 EDT
Modified files:
/php4/pear/scripts pear.in
/php4/pear/PEAR Installer.php
Log:
implemented "uninstall" command
Index: php4/pear/scripts/pear.in
diff -u php4/pear/scripts/pear.in:1.17 php4/pear/scripts/pear.in:1.18
--- php4/pear/scripts/pear.in:1.17 Mon Nov 12 20:07:36 2001
+++ php4/pear/scripts/pear.in Wed Nov 14 20:24:35 2001
@@ -84,7 +84,7 @@
$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 @@
}
// }}}
+ // {{{ 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 @@
" -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".
Index: php4/pear/PEAR/Installer.php
diff -u php4/pear/PEAR/Installer.php:1.26 php4/pear/PEAR/Installer.php:1.27
--- php4/pear/PEAR/Installer.php:1.26 Mon Nov 12 20:05:46 2001
+++ php4/pear/PEAR/Installer.php Wed Nov 14 20:24:35 2001
@@ -18,7 +18,7 @@
// | |
// +----------------------------------------------------------------------+
//
-// $Id: Installer.php,v 1.26 2001/11/13 01:05:46 ssb Exp $
+// $Id: Installer.php,v 1.27 2001/11/15 01:24:35 cox Exp $
require_once 'PEAR/Common.php';
require_once 'PEAR/Registry.php';
@@ -240,6 +240,29 @@
}
// }}}
+
+ 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;
+ }
}
?>