cvs: php4 /pear/PEAR Installer.php
| From: | Thomas V.V.Cox | Date: | Mon, 17 Dec 2001 21:11:50 +0000 |
| Subject: | cvs: php4 /pear/PEAR Installer.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-1598@lists.php.net to get a copy of this message | ||
cox Mon Dec 17 16:11:50 2001 EDT
Modified files:
/php4/pear/PEAR Installer.php
Log:
Added dependencies check support for Installer
Index: php4/pear/PEAR/Installer.php
diff -u php4/pear/PEAR/Installer.php:1.31 php4/pear/PEAR/Installer.php:1.32
--- php4/pear/PEAR/Installer.php:1.31 Tue Dec 11 20:30:56 2001
+++ php4/pear/PEAR/Installer.php Mon Dec 17 16:11:50 2001
@@ -18,17 +18,18 @@
// | |
// +----------------------------------------------------------------------+
//
-// $Id: Installer.php,v 1.31 2001/12/12 01:30:56 ssb Exp $
+// $Id: Installer.php,v 1.32 2001/12/17 21:11:50 cox Exp $
require_once 'PEAR/Common.php';
require_once 'PEAR/Registry.php';
+require_once 'PEAR/Dependency.php';
/**
* Administration class used to install PEAR packages and maintain the
* installed package database.
*
* TODO:
- * - finish and test Windows support
+ * - Install the "role=doc" files in a central pear doc dir
* - kill FIXME's
*
* @since PHP 4.0.2
@@ -114,6 +115,7 @@
return true;
break;
case 'doc':
+ // XXX Fixme: install doc in a central doc dir. PEAR_DOC constant?
case 'php':
default:
$dest_file = $dest_dir . basename($file);
@@ -237,6 +239,15 @@
$pkgname = $pkginfo['package'];
+ // Check dependencies -------------------------------------------
+ if (isset($pkginfo['release_deps']) &&
!isset($options['nodeps'])) {
+ $error = $this->checkDeps($pkginfo);
+ if ($error) {
+ $this->log(0, $error);
+ return $this->raiseError('Dependencies failed');
+ }
+ }
+
if (empty($options['upgrade'])) {
// checks to do only when installing new packages
if (empty($options['force']) &&
$this->registry->packageExists($pkgname)) {
@@ -278,7 +289,7 @@
$fname = $tmp_path . DIRECTORY_SEPARATOR . $fname;
$this->_installFile($fname, $dest_dir, $atts);
}
- }
+ }
// Register that the package is installed -----------------------
if (empty($options['upgrade'])) {
@@ -307,6 +318,23 @@
}
// }}}
+
+ function checkDeps(&$pkginfo)
+ {
+ $deps = new PEAR_Dependency;
+ $errors = null;
+ if (is_array($pkginfo['release_deps'])) {
+ foreach($pkginfo['release_deps'] as $dep) {
+ if ($error = $deps->callCheckMethod($dep)) {
+ $errors .= "\n$error";
+ }
+ }
+ if ($errors) {
+ return $errors;
+ }
+ }
+ return false;
+ }
}
?>