cvs: pear-core /PEAR Installer.php /tests/PEAR_Command_Install/uninstall test_uninstallSOAP.phpt
| From: | Greg Beaver | Date: | Sun, 26 Mar 2006 22:39:22 +0000 |
| Subject: | cvs: pear-core /PEAR Installer.php /tests/PEAR_Command_Install/uninstall test_uninstallSOAP.phpt | ||
| Groups: | php.pear.cvs php.pear.core | ||
| Request: | Send a blank email to pear-cvs+get-39340@lists.php.net to get a copy of this message | ||
cellog Sun Mar 26 22:39:22 2006 UTC
Modified files:
/pear-core/PEAR Installer.php
/pear-core/tests/PEAR_Command_Install/uninstall
test_uninstallSOAP.phpt
Log:
remove as many @ as possible from PEAR_Installer, update tests
http://cvs.php.net/viewcvs.cgi/pear-core/PEAR/Installer.php?r1=1.230&r2=1.231&diff_format=u Index: pear-core/PEAR/Installer.php diff -u pear-core/PEAR/Installer.php:1.230 pear-core/PEAR/Installer.php:1.231 --- pear-core/PEAR/Installer.php:1.230 Sat Mar 25 21:09:08 2006 +++ pear-core/PEAR/Installer.php Sun Mar 26 22:39:22 2006 @@ -18,7 +18,7 @@ * @author Greg Beaver <cellog@php.net> * @copyright 1997-2006 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Installer.php,v 1.230 2006/03/25 21:09:08 cellog Exp $ + * @version CVS: $Id: Installer.php,v 1.231 2006/03/26 22:39:22 cellog Exp $ * @link http://pear.php.net/package/PEAR * @since File available since Release 0.1 */ @@ -295,7 +295,8 @@ $dest_file = $dest_dir . DIRECTORY_SEPARATOR . '.tmp' . basename($final_dest_file); // }}} - if (empty($this->_options['register-only']) && !@is_dir($dest_dir)) { + if (empty($this->_options['register-only']) && + (!file_exists($dest_dir) || !is_dir($dest_dir))) { if (!$this->mkDirHier($dest_dir)) { return $this->raiseError("failed to mkdir $dest_dir", PEAR_INSTALLER_FAILED); @@ -310,7 +311,7 @@ PEAR_INSTALLER_FAILED); } if (!@copy($orig_file, $dest_file)) { - return $this->raiseError("failed to write $dest_file", + return $this->raiseError("failed to write $dest_file: $php_errormsg", PEAR_INSTALLER_FAILED); } $this->log(3, "+ cp $orig_file $dest_file"); @@ -383,7 +384,7 @@ return $this->raiseError("failed to create $dest_file: $php_errormsg", PEAR_INSTALLER_FAILED); } - if (fwrite($wp, $contents) === false) { + if (@fwrite($wp, $contents) === false) { return $this->raiseError("failed writing to $dest_file: $php_errormsg", PEAR_INSTALLER_FAILED); } @@ -397,7 +398,9 @@ } else { if (empty($options['force'])) { // delete the file - @unlink($dest_file); + if (file_exists($dest_file)) { + unlink($dest_file); + } if (!isset($options['ignore-errors'])) { return $this->raiseError("bad md5sum for file $final_dest_file", PEAR_INSTALLER_FAILED); @@ -425,7 +428,7 @@ $this->addFileOperation("chmod", array($mode, $dest_file)); if (!@chmod($dest_file, $mode)) { if (!isset($options['soft'])) { - $this->log(0, "failed to change mode of $dest_file"); + $this->log(0, "failed to change mode of $dest_file: $php_errormsg"); } } } @@ -489,7 +492,7 @@ // }}} if (empty($this->_options['register-only'])) { - if (!@is_dir($dest_dir)) { + if (!file_exists($dest_dir) || !is_dir($dest_dir)) { if (!$this->mkDirHier($dest_dir)) { return $this->raiseError("failed to mkdir $dest_dir", PEAR_INSTALLER_FAILED); @@ -507,7 +510,7 @@ PEAR_INSTALLER_FAILED); } if (!@copy($orig_file, $dest_file)) { - return $this->raiseError("failed to write $dest_file", + return $this->raiseError("failed to write $dest_file: $php_errormsg", PEAR_INSTALLER_FAILED); } $this->log(3, "+ cp $orig_file $dest_file"); @@ -560,7 +563,9 @@ } else { if (empty($options['force'])) { // delete the file - @unlink($dest_file); + if (file_exists($dest_file)) { + unlink($dest_file); + } if (!isset($options['ignore-errors'])) { return $this->raiseError("bad md5sum for file $final_dest_file", PEAR_INSTALLER_FAILED); @@ -588,7 +593,7 @@ $this->addFileOperation("chmod", array($mode, $dest_file)); if (!@chmod($dest_file, $mode)) { if (!isset($options['soft'])) { - $this->log(0, "failed to change mode of $dest_file"); + $this->log(0, "failed to change mode of $dest_file: $php_errormsg"); } } } @@ -694,7 +699,8 @@ } else { // make sure the file to be deleted can be opened for writing $fp = false; - if (!is_dir($data[0]) && !($fp = @fopen($data[0], 'a'))) { + if (!is_dir($data[0]) && + (!is_writable($data[0]) || !($fp = @fopen($data[0], 'a')))) { $errors[] = "permission denied ($type): $data[0]"; } elseif ($fp) { fclose($fp); @@ -723,15 +729,25 @@ list($type, $data) = $tr; switch ($type) { case 'backup': - @copy($data[0], $data[0] . '.bak'); + if (!@copy($data[0], $data[0] . '.bak')) { + $this->log(1, 'Could not copy ' . $data[0] . ' to ' . $data[0] . + '.bak ' . $php_errormsg); + return false; + } $this->log(3, "+ backup $data[0] to $data[0].bak"); break; case 'removebackup': - @unlink($data[0] . '.bak'); - $this->log(3, "+ rm backup of $data[0] ($data[0].bak)"); + if (file_exists($data[0] . '.bak') && is_writable($data[0] . '.bak')) { + unlink($data[0] . '.bak'); + $this->log(3, "+ rm backup of $data[0] ($data[0].bak)"); + } break; case 'rename': - $test = @unlink($data[1]); + if (file_exists($data[1])) { + $test = @unlink($data[1]); + } else { + $test = null; + } if (!$test && file_exists($data[1])) { if ($data[2]) { $extra = ', this extension must be installed manually. Rename to "' . @@ -747,21 +763,51 @@ return false; } } - @rename($data[0], $data[1]); + if (!@rename($data[0], $data[1])) { + $this->log(1, 'Could not rename ' . $data[0] . ' to ' . $data[1] . + ' ' . $php_errormsg); + return false; + } $this->log(3, "+ mv $data[0] $data[1]"); break; case 'chmod': - @chmod($data[1], $data[0]); + if (!@chmod($data[1], $data[0])) { + $this->log(1, 'Could not chmod ' . $data[1] . ' to ' . + decoct($data[0]) . ' ' . $php_errormsg); + return false; + } $octmode = decoct($data[0]); $this->log(3, "+ chmod $octmode $data[1]"); break; case 'delete': - @unlink($data[0]); - $this->log(3, "+ rm $data[0]"); + if (file_exists($data[0])) { + if (!@unlink($data[0])) { + $this->log(1, 'Could not delete ' . $data[0] . ' ' . + $php_errormsg); + return false; + } + $this->log(3, "+ rm $data[0]"); + } break; case 'rmdir': - @rmdir($data[0]); - $this->log(3, "+ rmdir $data[0]"); + if (file_exists($data[0])) { + do { + $testme = opendir($data[0]); + while (false !== ($entry = readdir($testme))) { + if ($entry == '.' || $entry == '..') { + continue; + } + break 2; // this directory is not empty and can't be + // deleted + } + if (!@rmdir($data[0])) { + $this->log(1, 'Could not rmdir ' . $data[0] . ' ' . + $php_errormsg); + return false; + } + $this->log(3, "+ rmdir $data[0]"); + } while (false); + } break; case 'installed_as': $this->pkginfo->setInstalledAs($data[0], $data[1]); @@ -982,7 +1028,7 @@ if (realpath($descfile) != realpath($pkgfile)) { $tar = new Archive_Tar($pkgfile); - if (!@$tar->extract($tmpdir)) { + if (!$tar->extract($tmpdir)) { return $this->raiseError("unable to unpack $pkgfile"); } } @@ -1015,7 +1061,9 @@ } // {{{ checks to do when not in "force" mode - if (empty($options['force']) && @is_dir($this->config->get('php_dir'))) { + if (empty($options['force']) && + (file_exists($this->config->get('php_dir')) && + is_dir($this->config->get('php_dir')))) { $testp = $channel == 'pear.php.net' ? $pkgname : array($channel, $pkgname); $instfilelist = $pkg->getInstallationFileList(true); if (PEAR::isError($instfilelist)) { @@ -1329,7 +1377,7 @@ $copydir = dirname($copyto); // pretty much nothing happens if we are only registering the install if (empty($this->_options['register-only'])) { - if (!@is_dir($copydir)) { + if (!file_exists($copydir) || !is_dir($copydir)) { if (!$this->mkDirHier($copydir)) { return $this->raiseError("failed to mkdir $copydir", PEAR_INSTALLER_FAILED); @@ -1337,14 +1385,14 @@ $this->log(3, "+ mkdir $copydir"); } if (!@copy($ext['file'], $copyto)) { - return $this->raiseError("failed to write $copyto", PEAR_INSTALLER_FAILED); + return $this->raiseError("failed to write $copyto ($php_errormsg)", PEAR_INSTALLER_FAILED); } $this->log(3, "+ cp $ext[file] $copyto"); if (!OS_WINDOWS) { $mode = 0666 & ~(int)octdec($this->config->get('umask')); $this->addFileOperation('chmod', array($mode, $copyto)); if (!@chmod($copyto, $mode)) { - $this->log(0, "failed to change mode of $copyto"); + $this->log(0, "failed to change mode of $copyto ($php_errormsg)"); } } $this->addFileOperation('rename', array($ext['file'], $copyto)); http://cvs.php.net/viewcvs.cgi/pear-core/tests/PEAR_Command_Install/uninstall/test_uninstallSOAP.phpt?r1=1.5&r2=1.6&diff_format=u Index: pear-core/tests/PEAR_Command_Install/uninstall/test_uninstallSOAP.phpt diff -u pear-core/tests/PEAR_Command_Install/uninstall/test_uninstallSOAP.phpt:1.5 pear-core/tests/PEAR_Command_Install/uninstall/test_uninstallSOAP.phpt:1.6 --- pear-core/tests/PEAR_Command_Install/uninstall/test_uninstallSOAP.phpt:1.5 Fri Feb 3 05:01:48 2006 +++ pear-core/tests/PEAR_Command_Install/uninstall/test_uninstallSOAP.phpt Sun Mar 26 22:39:22 2006 @@ -1363,250 +1363,240 @@ ), 118 => array ( - 0 => 3, - 1 => '+ rmdir ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Net', - ), - 119 => - array ( 0 => 2, 1 => 'successfully committed 1 file operations', ), - 120 => + 119 => array ( 'info' => 'uninstall ok: channel://pear.php.net/Net_Socket-1.0.5', 'cmd' => 'uninstall', ), - 121 => + 120 => array ( 0 => 3, 1 => 'adding to transaction: delete ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Net' . DIRECTORY_SEPARATOR . 'URL.php', ), - 122 => + 121 => array ( 0 => 3, 1 => 'adding to transaction: delete ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'doc' . DIRECTORY_SEPARATOR . 'Net_URL' . DIRECTORY_SEPARATOR . 'docs' . DIRECTORY_SEPARATOR . 'example.php', ), - 123 => + 122 => array ( 0 => 2, 1 => 'about to commit 2 file operations', ), - 124 => + 123 => array ( 0 => 3, 1 => '+ rm ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Net' . DIRECTORY_SEPARATOR . 'URL.php', ), - 125 => + 124 => array ( 0 => 3, 1 => '+ rm ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'doc' . DIRECTORY_SEPARATOR . 'Net_URL' . DIRECTORY_SEPARATOR . 'docs' . DIRECTORY_SEPARATOR . 'example.php', ), - 126 => + 125 => array ( 0 => 2, 1 => 'successfully committed 2 file operations', ), - 127 => + 126 => array ( 0 => 3, 1 => 'adding to transaction: rmdir ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Net', ), - 128 => + 127 => array ( 0 => 3, 1 => 'adding to transaction: rmdir ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'doc' . DIRECTORY_SEPARATOR . 'Net_URL' . DIRECTORY_SEPARATOR . 'docs', ), - 129 => + 128 => array ( 0 => 2, 1 => 'about to commit 2 file operations', ), - 130 => - array ( - 0 => 3, - 1 => '+ rmdir ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Net', - ), - 131 => + 129 => array ( 0 => 3, 1 => '+ rmdir ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'doc' . DIRECTORY_SEPARATOR . 'Net_URL' . DIRECTORY_SEPARATOR . 'docs', ), - 132 => + 130 => array ( 0 => 2, 1 => 'successfully committed 2 file operations', ), - 133 => + 131 => array ( 'info' => 'uninstall ok: channel://pear.php.net/Net_URL-1.0.14', 'cmd' => 'uninstall', ), - 134 => + 132 => array ( 0 => 3, 1 => 'adding to transaction: delete ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Net' . DIRECTORY_SEPARATOR . 'DIME.php', ), - 135 => + 133 => array ( 0 => 3, 1 => 'adding to transaction: delete ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'Net_DIME' . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'dime_message_test.php', ), - 136 => + 134 => array ( 0 => 3, 1 => 'adding to transaction: delete ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'Net_DIME' . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'dime_record_test.php', ), - 137 => + 135 => array ( 0 => 2, 1 => 'about to commit 3 file operations', ), - 138 => + 136 => array ( 0 => 3, 1 => '+ rm ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Net' . DIRECTORY_SEPARATOR . 'DIME.php', ), - 139 => + 137 => array ( 0 => 3, 1 => '+ rm ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'Net_DIME' . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'dime_message_test.php', ), - 140 => + 138 => array ( 0 => 3, 1 => '+ rm ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'Net_DIME' . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'dime_record_test.php', ), - 141 => + 139 => array ( 0 => 2, 1 => 'successfully committed 3 file operations', ), - 142 => + 140 => array ( 0 => 3, 1 => 'adding to transaction: rmdir ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'Net_DIME' . DIRECTORY_SEPARATOR . 'test', ), - 143 => + 141 => array ( 0 => 3, 1 => 'adding to transaction: rmdir ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Net', ), - 144 => + 142 => array ( 0 => 2, 1 => 'about to commit 2 file operations', ), - 145 => + 143 => array ( 0 => 3, 1 => '+ rmdir ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'Net_DIME' . DIRECTORY_SEPARATOR . 'test', ), - 146 => + 144 => array ( 0 => 3, 1 => '+ rmdir ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Net', ), - 147 => + 145 => array ( 0 => 2, 1 => 'successfully committed 2 file operations', ), - 148 => + 146 => array ( 'info' => 'uninstall ok: channel://pear.php.net/Net_DIME-0.3', 'cmd' => 'uninstall', ), - 149 => + 147 => array ( 0 => 3, 1 => 'adding to transaction: delete ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Mail' . DIRECTORY_SEPARATOR . 'mime.php', ), - 150 => + 148 => array ( 0 => 3, 1 => 'adding to transaction: delete ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Mail' . DIRECTORY_SEPARATOR . 'mimeDecode.php', ), - 151 => + 149 => array ( 0 => 3, 1 => 'adding to transaction: delete ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Mail' . DIRECTORY_SEPARATOR . 'mimePart.php', ), - 152 => + 150 => array ( 0 => 3, 1 => 'adding to transaction: delete ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'Mail_Mime' . DIRECTORY_SEPARATOR . 'xmail.dtd', ), - 153 => + 151 => array ( 0 => 3, 1 => 'adding to transaction: delete ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'Mail_Mime' . DIRECTORY_SEPARATOR . 'xmail.xsl', ), - 154 => + 152 => array ( 0 => 2, 1 => 'about to commit 5 file operations', ), - 155 => + 153 => array ( 0 => 3, 1 => '+ rm ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Mail' . DIRECTORY_SEPARATOR . 'mime.php', ), - 156 => + 154 => array ( 0 => 3, 1 => '+ rm ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Mail' . DIRECTORY_SEPARATOR . 'mimeDecode.php', ), - 157 => + 155 => array ( 0 => 3, 1 => '+ rm ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Mail' . DIRECTORY_SEPARATOR . 'mimePart.php', ), - 158 => + 156 => array ( 0 => 3, 1 => '+ rm ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'Mail_Mime' . DIRECTORY_SEPARATOR . 'xmail.dtd', ), - 159 => + 157 => array ( 0 => 3, 1 => '+ rm ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'Mail_Mime' . DIRECTORY_SEPARATOR . 'xmail.xsl', ), - 160 => + 158 => array ( 0 => 2, 1 => 'successfully committed 5 file operations', ), - 161 => + 159 => array ( 0 => 3, 1 => 'adding to transaction: rmdir ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Mail', ), - 162 => + 160 => array ( 0 => 3, 1 => 'adding to transaction: rmdir ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'Mail_Mime', ), - 163 => + 161 => array ( 0 => 2, 1 => 'about to commit 2 file operations', ), - 164 => + 162 => array ( 0 => 3, 1 => '+ rmdir ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Mail', ), - 165 => + 163 => array ( 0 => 3, 1 => '+ rmdir ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'Mail_Mime', ), - 166 => + 164 => array ( 0 => 2, 1 => 'successfully committed 2 file operations', ), - 167 => + 165 => array ( 'info' => 'uninstall ok: channel://pear.php.net/Mail_Mime-1.2.1', 'cmd' => 'uninstall',
http://cvs.php.net/viewcvs.cgi/pear-core/PEAR/Installer.php?r1=1.230&r2=1.231&diff_format=u Index: pear-core/PEAR/Installer.php diff -u pear-core/PEAR/Installer.php:1.230 pear-core/PEAR/Installer.php:1.231 --- pear-core/PEAR/Installer.php:1.230 Sat Mar 25 21:09:08 2006 +++ pear-core/PEAR/Installer.php Sun Mar 26 22:39:22 2006 @@ -18,7 +18,7 @@ * @author Greg Beaver <cellog@php.net> * @copyright 1997-2006 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Installer.php,v 1.230 2006/03/25 21:09:08 cellog Exp $ + * @version CVS: $Id: Installer.php,v 1.231 2006/03/26 22:39:22 cellog Exp $ * @link http://pear.php.net/package/PEAR * @since File available since Release 0.1 */ @@ -295,7 +295,8 @@ $dest_file = $dest_dir . DIRECTORY_SEPARATOR . '.tmp' . basename($final_dest_file); // }}} - if (empty($this->_options['register-only']) && !@is_dir($dest_dir)) { + if (empty($this->_options['register-only']) && + (!file_exists($dest_dir) || !is_dir($dest_dir))) { if (!$this->mkDirHier($dest_dir)) { return $this->raiseError("failed to mkdir $dest_dir", PEAR_INSTALLER_FAILED); @@ -310,7 +311,7 @@ PEAR_INSTALLER_FAILED); } if (!@copy($orig_file, $dest_file)) { - return $this->raiseError("failed to write $dest_file", + return $this->raiseError("failed to write $dest_file: $php_errormsg", PEAR_INSTALLER_FAILED); } $this->log(3, "+ cp $orig_file $dest_file"); @@ -383,7 +384,7 @@ return $this->raiseError("failed to create $dest_file: $php_errormsg", PEAR_INSTALLER_FAILED); } - if (fwrite($wp, $contents) === false) { + if (@fwrite($wp, $contents) === false) { return $this->raiseError("failed writing to $dest_file: $php_errormsg", PEAR_INSTALLER_FAILED); } @@ -397,7 +398,9 @@ } else { if (empty($options['force'])) { // delete the file - @unlink($dest_file); + if (file_exists($dest_file)) { + unlink($dest_file); + } if (!isset($options['ignore-errors'])) { return $this->raiseError("bad md5sum for file $final_dest_file", PEAR_INSTALLER_FAILED); @@ -425,7 +428,7 @@ $this->addFileOperation("chmod", array($mode, $dest_file)); if (!@chmod($dest_file, $mode)) { if (!isset($options['soft'])) { - $this->log(0, "failed to change mode of $dest_file"); + $this->log(0, "failed to change mode of $dest_file: $php_errormsg"); } } } @@ -489,7 +492,7 @@ // }}} if (empty($this->_options['register-only'])) { - if (!@is_dir($dest_dir)) { + if (!file_exists($dest_dir) || !is_dir($dest_dir)) { if (!$this->mkDirHier($dest_dir)) { return $this->raiseError("failed to mkdir $dest_dir", PEAR_INSTALLER_FAILED); @@ -507,7 +510,7 @@ PEAR_INSTALLER_FAILED); } if (!@copy($orig_file, $dest_file)) { - return $this->raiseError("failed to write $dest_file", + return $this->raiseError("failed to write $dest_file: $php_errormsg", PEAR_INSTALLER_FAILED); } $this->log(3, "+ cp $orig_file $dest_file"); @@ -560,7 +563,9 @@ } else { if (empty($options['force'])) { // delete the file - @unlink($dest_file); + if (file_exists($dest_file)) { + unlink($dest_file); + } if (!isset($options['ignore-errors'])) { return $this->raiseError("bad md5sum for file $final_dest_file", PEAR_INSTALLER_FAILED); @@ -588,7 +593,7 @@ $this->addFileOperation("chmod", array($mode, $dest_file)); if (!@chmod($dest_file, $mode)) { if (!isset($options['soft'])) { - $this->log(0, "failed to change mode of $dest_file"); + $this->log(0, "failed to change mode of $dest_file: $php_errormsg"); } } } @@ -694,7 +699,8 @@ } else { // make sure the file to be deleted can be opened for writing $fp = false; - if (!is_dir($data[0]) && !($fp = @fopen($data[0], 'a'))) { + if (!is_dir($data[0]) && + (!is_writable($data[0]) || !($fp = @fopen($data[0], 'a')))) { $errors[] = "permission denied ($type): $data[0]"; } elseif ($fp) { fclose($fp); @@ -723,15 +729,25 @@ list($type, $data) = $tr; switch ($type) { case 'backup': - @copy($data[0], $data[0] . '.bak'); + if (!@copy($data[0], $data[0] . '.bak')) { + $this->log(1, 'Could not copy ' . $data[0] . ' to ' . $data[0] . + '.bak ' . $php_errormsg); + return false; + } $this->log(3, "+ backup $data[0] to $data[0].bak"); break; case 'removebackup': - @unlink($data[0] . '.bak'); - $this->log(3, "+ rm backup of $data[0] ($data[0].bak)"); + if (file_exists($data[0] . '.bak') && is_writable($data[0] . '.bak')) { + unlink($data[0] . '.bak'); + $this->log(3, "+ rm backup of $data[0] ($data[0].bak)"); + } break; case 'rename': - $test = @unlink($data[1]); + if (file_exists($data[1])) { + $test = @unlink($data[1]); + } else { + $test = null; + } if (!$test && file_exists($data[1])) { if ($data[2]) { $extra = ', this extension must be installed manually. Rename to "' . @@ -747,21 +763,51 @@ return false; } } - @rename($data[0], $data[1]); + if (!@rename($data[0], $data[1])) { + $this->log(1, 'Could not rename ' . $data[0] . ' to ' . $data[1] . + ' ' . $php_errormsg); + return false; + } $this->log(3, "+ mv $data[0] $data[1]"); break; case 'chmod': - @chmod($data[1], $data[0]); + if (!@chmod($data[1], $data[0])) { + $this->log(1, 'Could not chmod ' . $data[1] . ' to ' . + decoct($data[0]) . ' ' . $php_errormsg); + return false; + } $octmode = decoct($data[0]); $this->log(3, "+ chmod $octmode $data[1]"); break; case 'delete': - @unlink($data[0]); - $this->log(3, "+ rm $data[0]"); + if (file_exists($data[0])) { + if (!@unlink($data[0])) { + $this->log(1, 'Could not delete ' . $data[0] . ' ' . + $php_errormsg); + return false; + } + $this->log(3, "+ rm $data[0]"); + } break; case 'rmdir': - @rmdir($data[0]); - $this->log(3, "+ rmdir $data[0]"); + if (file_exists($data[0])) { + do { + $testme = opendir($data[0]); + while (false !== ($entry = readdir($testme))) { + if ($entry == '.' || $entry == '..') { + continue; + } + break 2; // this directory is not empty and can't be + // deleted + } + if (!@rmdir($data[0])) { + $this->log(1, 'Could not rmdir ' . $data[0] . ' ' . + $php_errormsg); + return false; + } + $this->log(3, "+ rmdir $data[0]"); + } while (false); + } break; case 'installed_as': $this->pkginfo->setInstalledAs($data[0], $data[1]); @@ -982,7 +1028,7 @@ if (realpath($descfile) != realpath($pkgfile)) { $tar = new Archive_Tar($pkgfile); - if (!@$tar->extract($tmpdir)) { + if (!$tar->extract($tmpdir)) { return $this->raiseError("unable to unpack $pkgfile"); } } @@ -1015,7 +1061,9 @@ } // {{{ checks to do when not in "force" mode - if (empty($options['force']) && @is_dir($this->config->get('php_dir'))) { + if (empty($options['force']) && + (file_exists($this->config->get('php_dir')) && + is_dir($this->config->get('php_dir')))) { $testp = $channel == 'pear.php.net' ? $pkgname : array($channel, $pkgname); $instfilelist = $pkg->getInstallationFileList(true); if (PEAR::isError($instfilelist)) { @@ -1329,7 +1377,7 @@ $copydir = dirname($copyto); // pretty much nothing happens if we are only registering the install if (empty($this->_options['register-only'])) { - if (!@is_dir($copydir)) { + if (!file_exists($copydir) || !is_dir($copydir)) { if (!$this->mkDirHier($copydir)) { return $this->raiseError("failed to mkdir $copydir", PEAR_INSTALLER_FAILED); @@ -1337,14 +1385,14 @@ $this->log(3, "+ mkdir $copydir"); } if (!@copy($ext['file'], $copyto)) { - return $this->raiseError("failed to write $copyto", PEAR_INSTALLER_FAILED); + return $this->raiseError("failed to write $copyto ($php_errormsg)", PEAR_INSTALLER_FAILED); } $this->log(3, "+ cp $ext[file] $copyto"); if (!OS_WINDOWS) { $mode = 0666 & ~(int)octdec($this->config->get('umask')); $this->addFileOperation('chmod', array($mode, $copyto)); if (!@chmod($copyto, $mode)) { - $this->log(0, "failed to change mode of $copyto"); + $this->log(0, "failed to change mode of $copyto ($php_errormsg)"); } } $this->addFileOperation('rename', array($ext['file'], $copyto)); http://cvs.php.net/viewcvs.cgi/pear-core/tests/PEAR_Command_Install/uninstall/test_uninstallSOAP.phpt?r1=1.5&r2=1.6&diff_format=u Index: pear-core/tests/PEAR_Command_Install/uninstall/test_uninstallSOAP.phpt diff -u pear-core/tests/PEAR_Command_Install/uninstall/test_uninstallSOAP.phpt:1.5 pear-core/tests/PEAR_Command_Install/uninstall/test_uninstallSOAP.phpt:1.6 --- pear-core/tests/PEAR_Command_Install/uninstall/test_uninstallSOAP.phpt:1.5 Fri Feb 3 05:01:48 2006 +++ pear-core/tests/PEAR_Command_Install/uninstall/test_uninstallSOAP.phpt Sun Mar 26 22:39:22 2006 @@ -1363,250 +1363,240 @@ ), 118 => array ( - 0 => 3, - 1 => '+ rmdir ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Net', - ), - 119 => - array ( 0 => 2, 1 => 'successfully committed 1 file operations', ), - 120 => + 119 => array ( 'info' => 'uninstall ok: channel://pear.php.net/Net_Socket-1.0.5', 'cmd' => 'uninstall', ), - 121 => + 120 => array ( 0 => 3, 1 => 'adding to transaction: delete ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Net' . DIRECTORY_SEPARATOR . 'URL.php', ), - 122 => + 121 => array ( 0 => 3, 1 => 'adding to transaction: delete ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'doc' . DIRECTORY_SEPARATOR . 'Net_URL' . DIRECTORY_SEPARATOR . 'docs' . DIRECTORY_SEPARATOR . 'example.php', ), - 123 => + 122 => array ( 0 => 2, 1 => 'about to commit 2 file operations', ), - 124 => + 123 => array ( 0 => 3, 1 => '+ rm ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Net' . DIRECTORY_SEPARATOR . 'URL.php', ), - 125 => + 124 => array ( 0 => 3, 1 => '+ rm ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'doc' . DIRECTORY_SEPARATOR . 'Net_URL' . DIRECTORY_SEPARATOR . 'docs' . DIRECTORY_SEPARATOR . 'example.php', ), - 126 => + 125 => array ( 0 => 2, 1 => 'successfully committed 2 file operations', ), - 127 => + 126 => array ( 0 => 3, 1 => 'adding to transaction: rmdir ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Net', ), - 128 => + 127 => array ( 0 => 3, 1 => 'adding to transaction: rmdir ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'doc' . DIRECTORY_SEPARATOR . 'Net_URL' . DIRECTORY_SEPARATOR . 'docs', ), - 129 => + 128 => array ( 0 => 2, 1 => 'about to commit 2 file operations', ), - 130 => - array ( - 0 => 3, - 1 => '+ rmdir ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Net', - ), - 131 => + 129 => array ( 0 => 3, 1 => '+ rmdir ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'doc' . DIRECTORY_SEPARATOR . 'Net_URL' . DIRECTORY_SEPARATOR . 'docs', ), - 132 => + 130 => array ( 0 => 2, 1 => 'successfully committed 2 file operations', ), - 133 => + 131 => array ( 'info' => 'uninstall ok: channel://pear.php.net/Net_URL-1.0.14', 'cmd' => 'uninstall', ), - 134 => + 132 => array ( 0 => 3, 1 => 'adding to transaction: delete ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Net' . DIRECTORY_SEPARATOR . 'DIME.php', ), - 135 => + 133 => array ( 0 => 3, 1 => 'adding to transaction: delete ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'Net_DIME' . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'dime_message_test.php', ), - 136 => + 134 => array ( 0 => 3, 1 => 'adding to transaction: delete ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'Net_DIME' . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'dime_record_test.php', ), - 137 => + 135 => array ( 0 => 2, 1 => 'about to commit 3 file operations', ), - 138 => + 136 => array ( 0 => 3, 1 => '+ rm ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Net' . DIRECTORY_SEPARATOR . 'DIME.php', ), - 139 => + 137 => array ( 0 => 3, 1 => '+ rm ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'Net_DIME' . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'dime_message_test.php', ), - 140 => + 138 => array ( 0 => 3, 1 => '+ rm ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'Net_DIME' . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'dime_record_test.php', ), - 141 => + 139 => array ( 0 => 2, 1 => 'successfully committed 3 file operations', ), - 142 => + 140 => array ( 0 => 3, 1 => 'adding to transaction: rmdir ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'Net_DIME' . DIRECTORY_SEPARATOR . 'test', ), - 143 => + 141 => array ( 0 => 3, 1 => 'adding to transaction: rmdir ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Net', ), - 144 => + 142 => array ( 0 => 2, 1 => 'about to commit 2 file operations', ), - 145 => + 143 => array ( 0 => 3, 1 => '+ rmdir ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'Net_DIME' . DIRECTORY_SEPARATOR . 'test', ), - 146 => + 144 => array ( 0 => 3, 1 => '+ rmdir ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Net', ), - 147 => + 145 => array ( 0 => 2, 1 => 'successfully committed 2 file operations', ), - 148 => + 146 => array ( 'info' => 'uninstall ok: channel://pear.php.net/Net_DIME-0.3', 'cmd' => 'uninstall', ), - 149 => + 147 => array ( 0 => 3, 1 => 'adding to transaction: delete ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Mail' . DIRECTORY_SEPARATOR . 'mime.php', ), - 150 => + 148 => array ( 0 => 3, 1 => 'adding to transaction: delete ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Mail' . DIRECTORY_SEPARATOR . 'mimeDecode.php', ), - 151 => + 149 => array ( 0 => 3, 1 => 'adding to transaction: delete ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Mail' . DIRECTORY_SEPARATOR . 'mimePart.php', ), - 152 => + 150 => array ( 0 => 3, 1 => 'adding to transaction: delete ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'Mail_Mime' . DIRECTORY_SEPARATOR . 'xmail.dtd', ), - 153 => + 151 => array ( 0 => 3, 1 => 'adding to transaction: delete ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'Mail_Mime' . DIRECTORY_SEPARATOR . 'xmail.xsl', ), - 154 => + 152 => array ( 0 => 2, 1 => 'about to commit 5 file operations', ), - 155 => + 153 => array ( 0 => 3, 1 => '+ rm ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Mail' . DIRECTORY_SEPARATOR . 'mime.php', ), - 156 => + 154 => array ( 0 => 3, 1 => '+ rm ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Mail' . DIRECTORY_SEPARATOR . 'mimeDecode.php', ), - 157 => + 155 => array ( 0 => 3, 1 => '+ rm ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Mail' . DIRECTORY_SEPARATOR . 'mimePart.php', ), - 158 => + 156 => array ( 0 => 3, 1 => '+ rm ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'Mail_Mime' . DIRECTORY_SEPARATOR . 'xmail.dtd', ), - 159 => + 157 => array ( 0 => 3, 1 => '+ rm ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'Mail_Mime' . DIRECTORY_SEPARATOR . 'xmail.xsl', ), - 160 => + 158 => array ( 0 => 2, 1 => 'successfully committed 5 file operations', ), - 161 => + 159 => array ( 0 => 3, 1 => 'adding to transaction: rmdir ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Mail', ), - 162 => + 160 => array ( 0 => 3, 1 => 'adding to transaction: rmdir ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'Mail_Mime', ), - 163 => + 161 => array ( 0 => 2, 1 => 'about to commit 2 file operations', ), - 164 => + 162 => array ( 0 => 3, 1 => '+ rmdir ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'Mail', ), - 165 => + 163 => array ( 0 => 3, 1 => '+ rmdir ' . $temp_path . '' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'Mail_Mime', ), - 166 => + 164 => array ( 0 => 2, 1 => 'successfully committed 2 file operations', ), - 167 => + 165 => array ( 'info' => 'uninstall ok: channel://pear.php.net/Mail_Mime-1.2.1', 'cmd' => 'uninstall',