From: Gunnar Wrobel
Date: Sun, 3 Oct 2010 17:40:36 +0000 (+0200)
Subject: Refactor the CI setup module.
X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=34da0eaf3b912f71492f622139625516d0d758f7;p=horde.git
Refactor the CI setup module.
---
diff --git a/components/lib/Components/Module/CiSetup.php b/components/lib/Components/Module/CiSetup.php
index e27d375ac..2704c6ad2 100644
--- a/components/lib/Components/Module/CiSetup.php
+++ b/components/lib/Components/Module/CiSetup.php
@@ -28,7 +28,7 @@
* @link http://pear.horde.org/index.php?package=Components
*/
class Components_Module_CiSetup
-implements Components_Module
+extends Components_Module_Base
{
public function getOptionGroupTitle()
{
@@ -67,73 +67,23 @@ implements Components_Module
'help' => 'the path to the PEAR installation holding the required analysis tools'
)
),
+ new Horde_Argv_Option(
+ '-R',
+ '--pearrc',
+ array(
+ 'action' => 'store',
+ 'help' => 'the path to the configuration of the PEAR installation'
+ )
+ ),
);
}
public function handle(Components_Config $config)
{
$options = $config->getOptions();
+ //@todo Split into two different runners here
if (!empty($options['cisetup']) | !empty($options['ciprebuild'])) {
- $this->run($config);
- }
- }
-
- public function run(Components_Config $config)
- {
- $options = $config->getOptions();
-
- $pear = new PEAR();
- $pear->setErrorHandling(PEAR_ERROR_DIE);
-
- $arguments = $config->getArguments();
- $pkgfile = $arguments[0] . DIRECTORY_SEPARATOR . 'package.xml';
- $name = basename($arguments[0]);
- if (basename(dirname($arguments[0])) == 'framework') {
- $origin = 'framework' . DIRECTORY_SEPARATOR . $name;
- } else {
- $origin = $name;
- }
- $test_path = strtr($name, '_', '/');
-
- $pkg = new PEAR_PackageFile(new PEAR_Config());
- $pf = $pkg->fromPackageFile($pkgfile, PEAR_VALIDATE_NORMAL);
- $description = $pf->getDescription();
-
- if (!isset($options['toolsdir'])) {
- $options['toolsdir'] = 'php-hudson-tools/workspace/pear/pear';
- }
-
- if (!empty($options['cisetup'])) {
- $in = file_get_contents(
- Components_Constants::getDataDirectory()
- . DIRECTORY_SEPARATOR . 'hudson-component-config.xml.template',
- 'r'
- );
- file_put_contents(
- $options['cisetup'] . DIRECTORY_SEPARATOR . 'config.xml',
- sprintf($in, $origin, 'horde', $options['toolsdir'], $description)
- );
- }
-
- if (!empty($options['ciprebuild'])) {
- $in = file_get_contents(
- Components_Constants::getDataDirectory()
- . DIRECTORY_SEPARATOR . 'hudson-component-build.xml.template',
- 'r'
- );
- file_put_contents(
- $options['ciprebuild'] . DIRECTORY_SEPARATOR . 'build.xml',
- sprintf($in, $options['toolsdir'])
- );
- $in = file_get_contents(
- Components_Constants::getDataDirectory()
- . DIRECTORY_SEPARATOR . 'hudson-component-phpunit.xml.template',
- 'r'
- );
- file_put_contents(
- $options['ciprebuild'] . DIRECTORY_SEPARATOR . 'phpunit.xml',
- sprintf($in, $name, $test_path)
- );
+ $this->_dependencies->getRunnerCiSetup()->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..b14541403
--- /dev/null
+++ b/components/lib/Components/Pear/Package.php
@@ -0,0 +1,116 @@
+
+ * @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