cvs: php4 /pear/PEAR Installer.php

From: Date: Sun, 26 May 2002 11:46:12 +0000
Subject: cvs: php4 /pear/PEAR Installer.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-4086@lists.php.net to get a copy of this message
ssb Sun May 26 07:46:12 2002 EDT Modified files: /php4/pear/PEAR Installer.php Log: * cleaned up error handling in _installFile Index: php4/pear/PEAR/Installer.php diff -u php4/pear/PEAR/Installer.php:1.61 php4/pear/PEAR/Installer.php:1.62 --- php4/pear/PEAR/Installer.php:1.61 Thu May 23 16:42:33 2002 +++ php4/pear/PEAR/Installer.php Sun May 26 07:46:11 2002 @@ -17,12 +17,16 @@ // | Tomas V.V.Cox <cox@idecnet.com> | // +----------------------------------------------------------------------+ // -// $Id: Installer.php,v 1.61 2002/05/23 20:42:33 cox Exp $ +// $Id: Installer.php,v 1.62 2002/05/26 11:46:11 ssb Exp $ require_once 'PEAR/Common.php'; require_once 'PEAR/Registry.php'; require_once 'PEAR/Dependency.php'; +define('PEAR_INSTALLER_OK', 1); +define('PEAR_INSTALLER_FAILED', 0); +define('PEAR_INSTALLER_SKIPPED', -1); + /** * Administration class used to install PEAR packages and maintain the * installed package database. @@ -151,7 +155,7 @@ // return if this file is meant for another platform if (!$os->matchSignature($atts['platform'])) { $this->log(2, "skipped $file (meant for $atts[platform], we are ".$os->getSignature().")"); - return; + return PEAR_INSTALLER_SKIPPED; } } @@ -159,7 +163,7 @@ case 'test': case 'data': case 'ext': // don't install test files for now $this->log(2, "$file: $atts[role] file not installed yet"); - return true; + return PEAR_INSTALLER_OK; case 'doc': $dest_dir = $this->config->get('doc_dir') . DIRECTORY_SEPARATOR . $this->pkginfo['package']; @@ -167,7 +171,7 @@ case 'extsrc': // don't install test files for now $this->log(2, "$file: no support for building extensions yet"); - return true; + return PEAR_INSTALLER_OK; case 'php': $dest_dir = $this->config->get('php_dir'); break; @@ -197,16 +201,16 @@ $dest_file = preg_replace('!//+!', '/', $dest_file); if (!@is_dir($dest_dir)) { if (!$this->mkDirHier($dest_dir)) { - $this->log(0, "failed to mkdir $dest_dir"); - return false; + return $this->raiseError(PEAR_INSTALLER_FAILED, + "failed to mkdir $dest_dir"); } $this->log(3, "+ mkdir $dest_dir"); } $orig_file = $tmp_path . DIRECTORY_SEPARATOR . $file; if (empty($atts['replacements'])) { if (!@copy($orig_file, $dest_file)) { - $this->log(0, "failed to copy $orig_file to $dest_file"); - return false; + return $this->raiseError(PEAR_INSTALLER_FAILED, + "failed to copy $orig_file to $dest_file"); } $this->log(3, "+ cp $orig_file $dest_file"); } else { @@ -237,8 +241,8 @@ } $wp = @fopen($dest_file, "w"); if (!is_resource($wp)) { - $this->log(0, "failed to create $dest_file"); - return false; + return $this->raiseError(PEAR_INSTALLER_FAILED, + "failed to create $dest_file"); } fwrite($wp, $contents); fclose($wp); @@ -259,7 +263,7 @@ $this->pkginfo['filelist'][$file]['installed_as'] = $dest_file; $this->log(2, "installed file $dest_file"); - return true; + return PEAR_INSTALLER_OK; } // }}} @@ -448,13 +452,14 @@ // <== XXX This part should be removed later on foreach ($pkginfo['filelist'] as $file => $atts) { + $this->expectError(PEAR_INSTALLER_FAILED); $res = $this->_installFile($file, $atts, $tmp_path); - if (!$res) { - // If file can't be installed and 'force' is not set, abort - if (empty($options['force'])) { - return null; - } - // Do not register not installed files + $this->popExpect(); + if (PEAR::isError($res) && empty($options['force'])) { + return $this->raiseError($res); + } + if ($res != PEAR_INSTALLER_OK) { + // Do not register files that were not installed unset($pkginfo['filelist'][$file]); } }

« previous php.pear.cvs (#4086) next »