/**
* Install the dependencies of a component.
*
* @param Components_Pear_Environment $environment The environment we
* install into.
* @param Components_Component $component The component that
* should be installed.
* @param array $options Install options.
* @param string $reason Optional reason for
* adding the package.
*
* @return NULL
*/
private function _installDependencies(Components_Pear_Environment $environment, Components_Component $component, $options = array(), $reason = '')
{
foreach ($component->getDependencyList() as $dependency) {
if (!$dependency->isPhp() && $dependency->isPackage()) {
$c_options = $this->_getPerComponentOptions($dependency, $options);
if ($dependency->isRequired() || !empty($c_options['include'])) {
$dep = $dependency->getComponent($c_options);
if (!$dep instanceof Components_Component_Archive && !empty($options['build_distribution'])) {
if (empty($options['allow_remote']) && !$component instanceof Components_Component_Source) {
throw new Components_Exception(sprintf('Cannot add component "%s". Remote access has been disabled (activate with --allow-remote)!', $channel));
}
if (!empty($options['sourcepath'])) {
$source = $options['sourcepath'] . '/' . $component->getChannel();
if (!file_exists($source)) {
@mkdir(dirname($source), 0777, true);
}
if ($dep instanceof Components_Component_Source) {
$environment->provideChannel($dep->getChannel(), $options, sprintf(' [required by %s]', $dep->getName()));
}
$dep->placeArchive($source);
if ($dep instanceof Components_Component_Remote) {
$this->_output->warn(sprintf('Downloaded component %s via network to %s.', $dep->getName(), $source));
} else {
$this->_output->ok(sprintf('Generated archive for component %s in %s.', $dep->getName(), $source));
}
$dep = $dependency->getComponent($c_options);
}
}
if ($dep === false) {
throw new Components_Exception(sprintf('Failed resolving component %s/%s!', $dependency->getChannel(), $dependency->getName()));
} else {
$this->installTree($environment, $dep, $options, sprintf(' [required by %s]', $component->getName()));
}
}
}
}
}