From 01291d9dd62bc076e39ac39cbe15ea2e0ff33156 Mon Sep 17 00:00:00 2001 From: Gunnar Wrobel Date: Thu, 23 Sep 2010 20:04:08 +0200 Subject: [PATCH] Intermediate components work --- components/lib/Components/Dependencies.php | 7 ++ .../lib/Components/Dependencies/Injector.php | 10 +++ components/lib/Components/Module/Distribute.php | 93 ++++++++++++++++++++++ components/lib/Components/Pear/InstallLocation.php | 3 + components/lib/Components/Pear/Package.php | 64 +++++++++++++++ components/lib/Components/Runner/Distribute.php | 67 ++++++++++++++++ components/package.xml | 2 + components/test/Components/StoryTestCase.php | 1 + 8 files changed, 247 insertions(+) create mode 100644 components/lib/Components/Module/Distribute.php create mode 100644 components/lib/Components/Pear/Package.php create mode 100644 components/lib/Components/Runner/Distribute.php diff --git a/components/lib/Components/Dependencies.php b/components/lib/Components/Dependencies.php index 229f907f9..1e60e126e 100644 --- a/components/lib/Components/Dependencies.php +++ b/components/lib/Components/Dependencies.php @@ -30,6 +30,13 @@ interface Components_Dependencies { /** + * Returns the distribution handler for a package. + * + * @return Components_Runner_Distribute The distribution handler. + */ + public function getRunnerDistribute(); + + /** * Returns the installer for a package. * * @return Components_Runner_Installer The installer. diff --git a/components/lib/Components/Dependencies/Injector.php b/components/lib/Components/Dependencies/Injector.php index 0cc4ca64e..2a749b0ac 100644 --- a/components/lib/Components/Dependencies/Injector.php +++ b/components/lib/Components/Dependencies/Injector.php @@ -43,6 +43,16 @@ implements Components_Dependencies } /** + * Returns the distribution handler for a package. + * + * @return Components_Runner_Distribute The distribution handler. + */ + public function getRunnerDistribute() + { + return $this->getInstance('Components_Runner_Distribute'); + } + + /** * Returns the installer for a package. * * @return Components_Runner_Installer The installer. diff --git a/components/lib/Components/Module/Distribute.php b/components/lib/Components/Module/Distribute.php new file mode 100644 index 000000000..c60f32f4c --- /dev/null +++ b/components/lib/Components/Module/Distribute.php @@ -0,0 +1,93 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Components + */ + +/** + * Components_Module_Distribute:: prepares a distribution package for a + * component. + * + * 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 + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Components + */ +class Components_Module_Distribute +extends Components_Module_Base +{ + /** + * Return the title for the option group representing this module. + * + * @return string The group title. + */ + public function getOptionGroupTitle() + { + return 'Distribute'; + } + + /** + * Return the description for the option group representing this module. + * + * @return string The group description. + */ + public function getOptionGroupDescription() + { + return 'This module prepares a distribution package (e.g. RPM, APT, Ebuild, ...) from a component.'; + } + + /** + * Return the options for this module. + * + * @return array The group options. + */ + public function getOptionGroupOptions() + { + return array( + new Horde_Argv_Option( + '-D', + '--distribute', + array( + 'action' => 'store', + 'help' => 'Prepare the component package in the specified DISTRIBUTE location' + ) + ), + new Horde_Argv_Option( + '-t', + '--template', + array( + 'action' => 'store', + 'help' => 'Location of a template that will be rewritten into the final package definition.' + ) + ), + ); + } + + /** + * Determine if this module should act. Run all required actions if it has + * been instructed to do so. + * + * @return NULL + */ + public function handle(Components_Config $config) + { + $options = $config->getOptions(); + if (!empty($options['distribute'])) { + $this->_dependencies->getRunnerDistribute()->run(); + } + } +} diff --git a/components/lib/Components/Pear/InstallLocation.php b/components/lib/Components/Pear/InstallLocation.php index e036690ee..86d91113c 100644 --- a/components/lib/Components/Pear/InstallLocation.php +++ b/components/lib/Components/Pear/InstallLocation.php @@ -170,6 +170,9 @@ class Components_Pear_InstallLocation if (!file_exists($this->_config_file)) { $this->createPearConfig(); } + if (!isset($GLOBALS['_PEAR_Config_instance'])) { + $GLOBALS['_PEAR_Config_instance'] = false; + } return PEAR_Config::singleton($this->_config_file); } diff --git a/components/lib/Components/Pear/Package.php b/components/lib/Components/Pear/Package.php new file mode 100644 index 000000000..2e5301d2b --- /dev/null +++ b/components/lib/Components/Pear/Package.php @@ -0,0 +1,64 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Components + */ + +/** + * Components_Pear_Package:: provides package handling mechanisms. + * + * 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 + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Components + */ +class Components_Pear_Package +{ + /** + * The output handler. + * + * @param Component_Output + */ + private $_output; + + /** + * The package representation. + * + * @param PEAR_PackageFile_v2 + */ + private $_package; + + /** + * Constructor. + * + * @param Component_Output $output The output handler. + */ + public function __construct(Components_Output $output) + { + $this->_output = $output; + } + + /** + * Define the package to work on. + * + * @param string $package_xml_patch Path to the package.xml file. + * + * @return NULL + */ + public function setPackage($package_xml_path) + { + } +} diff --git a/components/lib/Components/Runner/Distribute.php b/components/lib/Components/Runner/Distribute.php new file mode 100644 index 000000000..f2b5faa8e --- /dev/null +++ b/components/lib/Components/Runner/Distribute.php @@ -0,0 +1,67 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Components + */ + +/** + * Components_Runner_Distribute:: prepares a distribution package for a + * component. + * + * 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 + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Components + */ +class Components_Module_Installer +{ + /** + * The configuration for the current job. + * + * @var Components_Config + */ + private $_config; + + /** + * The package handler. + * + * @var Components_Pear_Package + */ + private $_package; + + /** + * Constructor. + * + * @param Components_Config $config The configuration for the current job. + * @param Components_Pear_Package $package Package handler. + */ + public function __construct( + Components_Config $config, + Components_Pear_Package $package + ) { + $this->_config = $config; + $this->_package = $package; + } + + public function run() + { + $options = $this->_config->getOptions(); + $arguments = $this->_config->getArguments(); + $location = realpath($options['distribute']); + + } +} diff --git a/components/package.xml b/components/package.xml index 14c4f057f..df21513a7 100644 --- a/components/package.xml +++ b/components/package.xml @@ -57,6 +57,7 @@ + @@ -169,6 +170,7 @@ + diff --git a/components/test/Components/StoryTestCase.php b/components/test/Components/StoryTestCase.php index 01fd6a228..a3937fbdd 100644 --- a/components/test/Components/StoryTestCase.php +++ b/components/test/Components/StoryTestCase.php @@ -99,6 +99,7 @@ extends PHPUnit_Extensions_Story_TestCase case 'calling the package with the install option and a Horde element': $_SERVER['argv'] = array( 'horde-components', + '--channelxmlpath=' . dirname(__FILE__) . '/fixture/channels', '--install=' . $this->_getTemporaryDirectory(), dirname(__FILE__) . '/../../' ); -- 2.11.0