cvs: php-src /pear package-PEAR.xml /pear/PEAR Installer.php
| From: | Greg Beaver | Date: | Mon, 15 Sep 2003 05:10:51 +0000 |
| Subject: | cvs: php-src /pear package-PEAR.xml /pear/PEAR Installer.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-12741@lists.php.net to get a copy of this message | ||
cellog Mon Sep 15 01:10:51 2003 EDT
Modified files:
/php-src/pear/PEAR Installer.php
/php-src/pear package-PEAR.xml
Log:
Now empty directories are removed on uninstall, so uninstallation is complete and correct
Index: php-src/pear/PEAR/Installer.php
diff -u php-src/pear/PEAR/Installer.php:1.117 php-src/pear/PEAR/Installer.php:1.118
--- php-src/pear/PEAR/Installer.php:1.117 Sun Sep 14 23:36:02 2003
+++ php-src/pear/PEAR/Installer.php Mon Sep 15 01:10:50 2003
@@ -18,7 +18,7 @@
// | Martin Jansen <mj@php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: Installer.php,v 1.117 2003/09/15 03:36:02 cellog Exp $
+// $Id: Installer.php,v 1.118 2003/09/15 05:10:50 cellog Exp $
require_once 'PEAR/Common.php';
require_once 'PEAR/Registry.php';
@@ -199,6 +199,7 @@
default:
return $this->raiseError("Invalid role `$atts[role]' for file
$file");
}
+ $save_destdir = $dest_dir;
if (!empty($atts['baseinstalldir'])) {
$dest_dir .= DIRECTORY_SEPARATOR . $atts['baseinstalldir'];
}
@@ -315,7 +316,8 @@
}
$this->addFileOperation("rename", array($dest_file, $final_dest_file));
// Store the full path where the file was installed for easy unistall
- $this->addFileOperation("installed_as", array($file, $installed_as));
+ $this->addFileOperation("installed_as", array($file, $installed_as,
+ $save_destdir, dirname(substr($dest_file,
strlen($save_destdir)))));
//$this->log(2, "installed: $dest_file");
return PEAR_INSTALLER_OK;
@@ -410,6 +412,14 @@
break;
case 'installed_as':
$this->pkginfo['filelist'][$data[0]]['installed_as'] =
$data[1];
+ if
(!isset($this->pkginfo['filelist']['dirtree'][dirname($data[1])])) {
+
$this->pkginfo['filelist']['dirtree'][dirname($data[1])] = true;
+ while(!empty($data[3]) && $data[3] != '/' &&
$data[3] != '\\') {
+ $this->pkginfo['filelist']['dirtree']
+ [$this->_prependPath($data[3], $data[2])] = true;
+ $data[3] = dirname($data[3]);
+ }
+ }
break;
}
}
@@ -1052,6 +1062,16 @@
// }}}
// {{{ uninstall()
+ /**
+ * Uninstall a package
+ *
+ * This method removes all files installed by the application, and then
+ * removes any empty directories.
+ * @param string package name
+ * @param array Command-line options. Possibilities include:
+ *
+ * - installroot: base installation dir, if not the default
+ */
function uninstall($package, $options = array())
{
$php_dir = $this->config->get('php_dir');
@@ -1087,10 +1107,29 @@
if (!$this->commitFileTransaction()) {
$this->rollbackFileTransaction();
return $this->raiseError("uninstall failed");
+ } else {
+ $this->startFileTransaction();
+ // attempt to delete empty directories
+ uksort($filelist['dirtree'], array($this, '_sortDirs'));
+ foreach($filelist['dirtree'] as $dir => $notused) {
+ $this->addFileOperation('rmdir', array($dir));
+ }
+ if (!$this->commitFileTransaction()) {
+ $this->rollbackFileTransaction();
+ }
}
// Register that the package is no longer installed
return $this->registry->deletePackage($package);
+ }
+
+ // }}}
+ // {{{ _sortDirs()
+ function _sortDirs($a, $b)
+ {
+ if (strnatcmp($a, $b) == -1) return 1;
+ if (strnatcmp($a, $b) == 1) return -1;
+ return 0;
}
// }}}
Index: php-src/pear/package-PEAR.xml
diff -u php-src/pear/package-PEAR.xml:1.68 php-src/pear/package-PEAR.xml:1.69
--- php-src/pear/package-PEAR.xml:1.68 Sun Aug 31 02:08:41 2003
+++ php-src/pear/package-PEAR.xml Mon Sep 15 01:10:51 2003
@@ -66,6 +66,7 @@
* Fix #25008 - unhelpful error message
* Fixed optional dependencies in Dependency.php
* Fix #25322 - bad md5sum should be fatal error
+* Package uninstall now also removes empty directories
</notes>
<provides type="class" name="OS_Guess" />
<provides type="class" name="System" />