Intermediate components work
authorGunnar Wrobel <p@rdus.de>
Thu, 23 Sep 2010 18:04:08 +0000 (20:04 +0200)
committerGunnar Wrobel <p@rdus.de>
Thu, 23 Sep 2010 18:04:08 +0000 (20:04 +0200)
components/lib/Components/Dependencies.php
components/lib/Components/Dependencies/Injector.php
components/lib/Components/Module/Distribute.php [new file with mode: 0644]
components/lib/Components/Pear/InstallLocation.php
components/lib/Components/Pear/Package.php [new file with mode: 0644]
components/lib/Components/Runner/Distribute.php [new file with mode: 0644]
components/package.xml
components/test/Components/StoryTestCase.php

index 229f907..1e60e12 100644 (file)
 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.
index 0cc4ca6..2a749b0 100644 (file)
@@ -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 (file)
index 0000000..c60f32f
--- /dev/null
@@ -0,0 +1,93 @@
+<?php
+/**
+ * Components_Module_Distribute:: prepares a distribution package for a
+ * component.
+ *
+ * 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_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 <wrobel@pardus.de>
+ * @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();
+        }
+    }
+}
index e036690..86d9111 100644 (file)
@@ -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 (file)
index 0000000..2e5301d
--- /dev/null
@@ -0,0 +1,64 @@
+<?php
+/**
+ * Components_Pear_Package:: provides package handling mechanisms.
+ *
+ * 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_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 <wrobel@pardus.de>
+ * @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 (file)
index 0000000..f2b5faa
--- /dev/null
@@ -0,0 +1,67 @@
+<?php
+/**
+ * Components_Runner_Distribute:: prepares a distribution package for a
+ * component.
+ *
+ * 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_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 <wrobel@pardus.de>
+ * @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']);
+
+    }
+}
index 14c4f05..df21513 100644 (file)
@@ -57,6 +57,7 @@
       <file name="Base.php" role="php" />
       <file name="CiSetup.php" role="php" />
       <file name="DevPackage.php" role="php" />
+      <file name="Distribute.php" role="php" />
       <file name="Installer.php" role="php" />
       <file name="PearPackageXml.php" role="php" />
      </dir> <!-- /lib/Components/Module -->
    <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/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/Module/PearPackageXml.php" name="lib/Components/Module/PearPackageXml.php" />
    <install as="Components/Pear/InstallLocation.php" name="lib/Components/Pear/InstallLocation.php" />
index 01fd6a2..a3937fb 100644 (file)
@@ -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__) . '/../../'
             );