- Add module for generating component documentation.
- - Allow handling various Horde package locations (horde/, horde/framework/, Horde_SQL -> horde/framework/SQL)
-
- Allow linking files during the installation.
- Allow filtering (see http://github.com/horde/horde/commit/404e8d1ea7c0bf99373aec2ce7f2534a442149b3)
--- /dev/null
+<?php
+/**
+ * Components_Helper_Root:: handles the root position for a tree of dependencies
+ * and takes the Horde component layout into account.
+ *
+ * PHP version 5
+ *
+ * @category Horde
+ * @package Components
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Components
+ */
+
+/**
+ * Components_Helper_Root:: handles the root position for a tree of dependencies
+ * and takes the Horde component layout into account.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Horde
+ * @package Components
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Components
+ */
+class Components_Helper_Root
+{
+ /**
+ * Root path of the Horde repository.
+ *
+ * @var string
+ */
+ private $_root_path;
+
+ /**
+ * Constructor.
+ *
+ * @param string $path The helper will try to determine the root of the
+ * Horde repository based on this path.
+ */
+ public function __construct($path)
+ {
+ $i = 0;
+ $root = 0;
+ $current = $path;
+ while ($current != '/' || $i < 10) {
+ if (is_dir($current)) {
+ $objects = scandir($current);
+ if (in_array('framework', $objects) && in_array('horde', $objects)) {
+ $this->_root_path = $current;
+ break;
+ }
+ }
+ $current = dirname($current);
+ $i++;
+ }
+ if ($i >= 10) {
+ throw new Components_Exception(sprintf('Unable to determine Horde root from path %s!', $path));
+ }
+ }
+
+ /**
+ * Return the path to the package.xml for the package with the provided
+ * name.
+ *
+ * @param string $name The name of the package.
+ *
+ * @return string The path to the package.xml of the requested package.
+ */
+ public function getPackageXml($name)
+ {
+ $package_file = $this->_root_path . DIRECTORY_SEPARATOR
+ . $name . DIRECTORY_SEPARATOR . 'package.xml';
+ if (!file_exists($package_file)) {
+ $package_file = $this->_root_path . DIRECTORY_SEPARATOR
+ . 'framework' . DIRECTORY_SEPARATOR . $name
+ . DIRECTORY_SEPARATOR . 'package.xml';
+ }
+ if (!file_exists($package_file) && substr($name, 0, 6) == 'Horde_') {
+ $package_file = $this->_root_path . DIRECTORY_SEPARATOR
+ . 'framework' . DIRECTORY_SEPARATOR . substr($name, 6)
+ . DIRECTORY_SEPARATOR . 'package.xml';
+ }
+ if (!file_exists($package_file)) {
+ throw new Components_Exception(sprintf('Unknown package %s.', $name));
+ }
+ return $package_file;
+ }
+}
\ No newline at end of file
<?php
/**
- * Components_Helper_Tree:: handles a tree of dependencies and takes the Horde
- * component layout into account.
+ * Components_Helper_Tree:: handles a tree of dependencies.
*
* PHP version 5
*
*/
/**
- * Components_Helper_Tree:: handles a tree of dependencies and takes the Horde
- * component layout into account.
+ * Components_Helper_Tree:: handles a tree of dependencies.
*
* Copyright 2010 The Horde Project (http://www.horde.org/)
*
private $_environment;
/**
- * The root path for the Horde package hierarchy.
+ * The root handler for the Horde package hierarchy.
*
- * @var string
+ * @var Components_Helper_Root
*/
- private $_root_path;
+ private $_root;
/**
* Constructor.
* @param Components_Pear_Factory $factory The factory for PEAR
* dependencies.
* @param Components_Pear_InstallLocation $environment The PEAR environment.
- * @param string $root_path The basic root path for
+ * @param Components_Helper_Root $root The root handler for
* Horde packages.
*
*/
public function __construct(
Components_Pear_Factory $factory,
Components_Pear_InstallLocation $environment,
- $root_path
+ Components_Helper_Root $root
) {
$this->_factory = $factory;
$this->_environment = $environment;
- $this->_root_path = $root_path;
+ $this->_root = $root;
}
/**
public function installTreeInEnvironment(
$package_file,
Components_Output $output,
- array $options)
- {
+ array $options
+ ) {
$run = new Components_Helper_InstallationRun($this->_environment, $this, $output, $options);
$run->install($this->_getHordeChildElement($package_file));
}
{
$children = array();
foreach ($dependencies as $dependency) {
- $package_file = $this->_root_path . DIRECTORY_SEPARATOR
- . $dependency->name() . DIRECTORY_SEPARATOR . 'package.xml';
- if (!file_exists($package_file)) {
- $package_file = $this->_root_path . DIRECTORY_SEPARATOR
- . 'framework' . DIRECTORY_SEPARATOR . $dependency->name()
- . DIRECTORY_SEPARATOR . 'package.xml';
- }
$children[$dependency->key()] = $this->_getHordeChildElement(
- $package_file
+ $this->_root->getPackageXml($dependency->name())
);
}
return $children;
basename($config_file)
);
$environment->setResourceDirectories($options);
- return new Components_Helper_Tree($this, $environment, $root_path);
+ return new Components_Helper_Tree(
+ $this, $environment, new Components_Helper_Root($root_path)
+ );
}
/**
*
* @return Components_Helper_Tree The tree helper.
*/
- public function createSimpleTreeHelper( $root_path)
+ public function createSimpleTreeHelper($root_path)
{
return new Components_Helper_Tree(
$this,
$this->_dependencies->createInstance('Components_Pear_InstallLocation'),
- $root_path
+ new Components_Helper_Root($root_path)
);
}
$options = $this->_config->getOptions();
$arguments = $this->_config->getArguments();
$this->_factory
- ->createSimpleTreeHelper(dirname(realpath($arguments[0])))
+ ->createSimpleTreeHelper(realpath($arguments[0]))
->listDependencyTree(
realpath($arguments[0]) . DIRECTORY_SEPARATOR . 'package.xml',
$this->_output
$arguments = $this->_config->getArguments();
$tree = $this->_factory
->createTreeHelper(
- $environment, dirname(realpath($arguments[0])), $options
+ $environment, realpath($arguments[0]), $options
);
$tree->getEnvironment()->provideChannel('pear.horde.org');
$tree->installTreeInEnvironment(
->then('the dummy PEAR package will be listed')
->and('the non-Horde dependencies of the component would be installed')
->and('the Horde dependencies of the component would be installed')
+ ->and('the old-style Horde dependencies of the component would be installed')
->and('the component will be listed');
}
$trimmed
);
break;
+ case 'the old-style Horde dependencies of the component would be installed':
+ $trimmed = strtr($world['output'], array(' ' => '', "\n" => ''));
+ $this->assertRegExp(
+ '#Wouldinstallpackage.*Old/package.xml#',
+ $trimmed
+ );
+ break;
case 'the Optional package will be listed':
$trimmed = strtr($world['output'], array(' ' => '', "\n" => ''));
$this->assertRegExp(
<channel>pear.horde.org</channel>
</package>
<package>
+ <name>Horde_Old</name>
+ <channel>pear.horde.org</channel>
+ </package>
+ <package>
<name>Console_Getopt</name>
<channel>pear.php.net</channel>
</package>
--- /dev/null
+<?php
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<package packagerversion="1.9.0" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
+ <name>Horde_Old</name>
+ <channel>pear.horde.org</channel>
+ <summary>Test fixture.</summary>
+ <description>A dummy package.xml used for testing the Components package.</description>
+ <lead>
+ <name>Gunnar Wrobel</name>
+ <user>wrobel</user>
+ <email>p@rdus.de</email>
+ <active>yes</active>
+ </lead>
+ <date>2010-08-22</date>
+ <time>21:12:03</time>
+ <version>
+ <release>0.0.1</release>
+ <api>0.0.1</api>
+ </version>
+ <stability>
+ <release>alpha</release>
+ <api>alpha</api>
+ </stability>
+ <license uri="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html">LGPL</license>
+ <notes>
+* Initial release
+ </notes>
+ <contents>
+ <dir baseinstalldir="/" name="/">
+ <dir name="lib">
+ <file name="Old.php" role="php" />
+ </dir> <!-- /lib -->
+ </dir> <!-- / -->
+ </contents>
+ <dependencies>
+ <required>
+ <php>
+ <min>5.0.0</min>
+ </php>
+ <pearinstaller>
+ <min>1.7.0</min>
+ </pearinstaller>
+ <package>
+ <name>Console_Getopt</name>
+ <channel>pear.php.net</channel>
+ </package>
+ </required>
+ <optional>
+ <package>
+ <name>PECL</name>
+ <channel>pecl.php.net</channel>
+ </package>
+ </optional>
+ </dependencies>
+ <phprelease>
+ <filelist>
+ <install as="Old.php" name="lib/Old.php" />
+ </filelist>
+ </phprelease>
+ <changelog>
+ <release>
+ <version>
+ <release>0.0.1</release>
+ <api>0.0.1</api>
+ </version>
+ <stability>
+ <release>alpha</release>
+ <api>alpha</api>
+ </stability>
+ <date>2010-08-22</date>
+ <license uri="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html">LGPL</license>
+ <notes>
+* Initial release
+ </notes>
+ </release>
+ </changelog>
+</package>