- Document usage
- - Do the distribution runner.
-
- Add module for generating component documentation.
- Add module for an initial empty PEAR template
- Allow absolute/relative paths as arguments
- - Fail on missing dependencies in a decent way
-
- WWW frontend
--- /dev/null
+<?php
+echo 'DONE';
*/
public function getOptionGroupDescription()
{
- return 'This module prepares a distribution package (e.g. RPM, APT, Ebuild, ...) from a component.';
+ return 'This module prepares a distribution package (e.g. RPM, APT, Ebuild, ...) for a component.';
}
/**
'--distribute',
array(
'action' => 'store',
- 'help' => 'Prepare the component package in the specified DISTRIBUTE location'
+ 'help' => 'Prepare the package definition for the component in the specified DISTRIBUTE location'
)
),
);
private $_config;
/**
- * The package handler.
+ * The application configuration.
*
- * @var Components_Pear_Package
+ * @var Components_Config_Application
*/
- private $_package;
+ private $_config_application;
+
+ /**
+ * The factory for PEAR dependencies.
+ *
+ * @var Components_Pear_Factory
+ */
+ private $_factory;
/**
* Constructor.
*
- * @param Components_Config $config The configuration for the current job.
- * @param Components_Pear_Package $package Package handler.
+ * @param Components_Config $config The configuration for the current job.
+ * @param Components_Config_Application $cfgapp The application
+ * configuration.
+ * @param Components_Pear_Factory $factory The factory for PEAR
+ * dependencies.
*/
public function __construct(
Components_Config $config,
- Components_Pear_Package $package
+ Components_Config_Application $cfgapp,
+ Components_Pear_Factory $factory
) {
$this->_config = $config;
- $this->_package = $package;
+ $this->_config_application = $cfgapp;
+ $this->_factory = $factory;
}
public function run()
$arguments = $this->_config->getArguments();
$location = realpath($options['distribute']);
+ $template = null;
+ foreach (
+ new RecursiveIteratorIterator(
+ new RecursiveDirectoryIterator(
+ $this->_config_application->getTemplateDirectory()
+ ),
+ RecursiveIteratorIterator::CHILD_FIRST
+ )
+ as $file
+ ) {
+ if (strpos($file->getBasename(), 'distribute_') === 0) {
+ $template = $file;
+ break;
+ }
+ }
+ if (empty($template)) {
+ throw new Components_Exception(
+ sprintf(
+ 'No packaging template starting with "distribute_" was found in the template directoy %s!',
+ $this->_config_application->getTemplateDirectory()
+ )
+ );
+ }
+
+ ob_start();
+ include $template->getPathname();
+ $packaging = ob_get_clean();
+
+ file_put_contents(
+ realpath($options['distribute']) . DIRECTORY_SEPARATOR
+ . substr($template->getBasename(), 11),
+ $packaging
+ );
}
}
<email>jan@horde.org</email>
<active>yes</active>
</lead>
- <date>2010-10-12</date>
- <time>22:18:04</time>
+ <date>2010-10-13</date>
+ <time>23:49:33</time>
<version>
<release>0.0.1</release>
<api>0.0.1</api>
<contents>
<dir baseinstalldir="/" name="/">
<dir name="data">
+ <file name="distribute_package.spec" role="data" />
<file name="hudson-component-build.xml.template" role="data" />
<file name="hudson-component-config.xml.template" role="data" />
<file name="hudson-component-phpunit.xml.template" role="data" />
<dir name="Dependencies">
<file name="Injector.php" role="php" />
</dir> <!-- /lib/Components/Dependencies -->
+ <dir name="Helper">
+ <dir name="Tree">
+ <file name="Element.php" role="php" />
+ </dir> <!-- /lib/Components/Helper/Tree -->
+ <file name="InstallationRun.php" role="php" />
+ <file name="ListRun.php" role="php" />
+ <file name="Tree.php" role="php" />
+ </dir> <!-- /lib/Components/Helper -->
<dir name="Module">
<file name="Base.php" role="php" />
<file name="CiSetup.php" role="php" />
+ <file name="Dependencies.php" role="php" />
<file name="DevPackage.php" role="php" />
<file name="Distribute.php" role="php" />
<file name="Installer.php" role="php" />
<dir name="Runner">
<file name="CiPrebuild.php" role="php" />
<file name="CiSetup.php" role="php" />
+ <file name="Dependencies.php" role="php" />
<file name="Distribute.php" role="php" />
<file name="Installer.php" role="php" />
<file name="PearPackageXml.php" role="php" />
<dir name="Components">
<dir name="Module">
<file name="CiSetupTest.php" role="test" />
+ <file name="DependenciesTest.php" role="test" />
+ <file name="DistributeTest.php" role="test" />
<file name="InstallerTest.php" role="test" />
<file name="PearPackageXmlTest.php" role="test" />
</dir> <!-- /test/Components/Integration/Components/Module -->
</dependencies>
<phprelease>
<filelist>
+ <install as="distribute_package.spec" name="data/distribute_package.spec" />
<install as="hudson-component-build.xml.template" name="data/hudson-component-build.xml.template" />
<install as="hudson-component-config.xml.template" name="data/hudson-component-config.xml.template" />
<install as="hudson-component-phpunit.xml.template" name="data/hudson-component-phpunit.xml.template" />
<install as="Components/Config/Application.php" name="lib/Components/Config/Application.php" />
<install as="Components/Config/Cli.php" name="lib/Components/Config/Cli.php" />
<install as="Components/Dependencies/Injector.php" name="lib/Components/Dependencies/Injector.php" />
+ <install as="Components/Helper/InstallationRun.php" name="lib/Components/Helper/InstallationRun.php" />
+ <install as="Components/Helper/ListRun.php" name="lib/Components/Helper/ListRun.php" />
+ <install as="Components/Helper/Tree.php" name="lib/Components/Helper/Tree.php" />
+ <install as="Components/Helper/Tree/Element.php" name="lib/Components/Helper/Tree/Element.php" />
<install as="Components/Module/Base.php" name="lib/Components/Module/Base.php" />
<install as="Components/Module/CiSetup.php" name="lib/Components/Module/CiSetup.php" />
+ <install as="Components/Module/Dependencies.php" name="lib/Components/Module/Dependencies.php" />
<install as="Components/Module/DevPackage.php" name="lib/Components/Module/DevPackage.php" />
<install as="Components/Module/Distribute.php" name="lib/Components/Module/Distribute.php" />
<install as="Components/Module/Installer.php" name="lib/Components/Module/Installer.php" />
<install as="Components/Pear/Package.php" name="lib/Components/Pear/Package.php" />
<install as="Components/Runner/CiPrebuild.php" name="lib/Components/Runner/CiPrebuild.php" />
<install as="Components/Runner/CiSetup.php" name="lib/Components/Runner/CiSetup.php" />
+ <install as="Components/Runner/Dependencies.php" name="lib/Components/Runner/Dependencies.php" />
<install as="Components/Runner/Distribute.php" name="lib/Components/Runner/Distribute.php" />
<install as="Components/Runner/Installer.php" name="lib/Components/Runner/Installer.php" />
<install as="Components/Runner/PearPackageXml.php" name="lib/Components/Runner/PearPackageXml.php" />
<install as="Components/fixture/templates/hudson-component-phpunit.xml.template" name="test/Components/fixture/templates/hudson-component-phpunit.xml.template" />
<install as="Components/Integration/ComponentsTest.php" name="test/Components/Integration/ComponentsTest.php" />
<install as="Components/Integration/Components/Module/CiSetupTest.php" name="test/Components/Integration/Components/Module/CiSetupTest.php" />
+ <install as="Components/Integration/Components/Module/DependenciesTest.php" name="test/Components/Integration/Components/Module/DependenciesTest.php" />
+ <install as="Components/Integration/Components/Module/DistributeTest.php" name="test/Components/Integration/Components/Module/DistributeTest.php" />
<install as="Components/Integration/Components/Module/InstallerTest.php" name="test/Components/Integration/Components/Module/InstallerTest.php" />
<install as="Components/Integration/Components/Module/PearPackageXmlTest.php" name="test/Components/Integration/Components/Module/PearPackageXmlTest.php" />
<install as="Components/Stub/Cli.php" name="test/Components/Stub/Cli.php" />
<release>alpha</release>
<api>alpha</api>
</stability>
- <date>2010-10-12</date>
+ <date>2010-10-13</date>
<license uri="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html">LGPL</license>
<notes>
* Initial release
--- /dev/null
+<?php
+/**
+ * Test the Distribute module.
+ *
+ * PHP version 5
+ *
+ * @category Horde
+ * @package Components
+ * @subpackage UnitTests
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Components
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../../../Autoload.php';
+
+/**
+ * Test the Distribute module.
+ *
+ * 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
+ * @subpackage UnitTests
+ * @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_Integration_Components_Module_DistributeTest
+extends Components_StoryTestCase
+{
+ /**
+ * @scenario
+ */
+ public function theDistributeModuleAddsTheDOptionInTheHelpOutput()
+ {
+ $this->given('the default Components setup')
+ ->when('calling the package with the help option')
+ ->then('the help will contain the option', '-D\s*DISTRIBUTE,\s*--distribute=DISTRIBUTE');
+ }
+
+ /**
+ * @scenario
+ */
+ public function theTheDOptionGeneratesAPackageDefinitionFile()
+ {
+ $this->given('the default Components setup')
+ ->when('calling the package with the distribute option and a path to a Horde framework component')
+ ->then('a package definition will be generated at the indicated location');
+ }
+}
\ No newline at end of file
);
$world['output'] = $this->_callUnstrictComponents();
break;
+ case 'calling the package with the distribute option and a path to a Horde framework component':
+ $_SERVER['argv'] = array(
+ 'horde-components',
+ '--distribute=' . $this->_getTemporaryDirectory(),
+ dirname(__FILE__) . '/fixture/framework/Install'
+ );
+ $world['output'] = $this->_callUnstrictComponents();
+ break;
default:
return $this->notImplemented($action);
}
$world['output']
);
break;
+ case 'a package definition will be generated at the indicated location':
+ $this->assertTrue(
+ file_exists(
+ $this->_temp_dir . DIRECTORY_SEPARATOR
+ . 'package.spec'
+ )
+ );
+ break;
default:
return $this->notImplemented($action);
}