From 1a451a98ba9d2bf66816df24b1f4daaac3bef5ce Mon Sep 17 00:00:00 2001 From: "Tomas V.V.Cox" Date: Mon, 17 Dec 2001 21:11:50 +0000 Subject: [PATCH] Added dependencies check support for Installer --- pear/PEAR/Installer.php | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/pear/PEAR/Installer.php b/pear/PEAR/Installer.php index 054fcb52f0..11b59965ca 100644 --- a/pear/PEAR/Installer.php +++ b/pear/PEAR/Installer.php @@ -22,13 +22,14 @@ 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 @@ class PEAR_Installer extends PEAR_Common 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 @@ class PEAR_Installer extends PEAR_Common $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 @@ class PEAR_Installer extends PEAR_Common $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 @@ class PEAR_Installer extends PEAR_Common } // }}} + + 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; + } } ?> \ No newline at end of file -- 2.50.1