From 94798dc81432ea6b831fe2bd4276f22e47fbc336 Mon Sep 17 00:00:00 2001 From: Gunnar Wrobel
Date: Wed, 13 Oct 2010 23:54:11 +0200
Subject: [PATCH] Add the packaging tool.
---
components/TODO | 4 --
components/data/distribute_package.spec | 2 +
components/lib/Components/Module/Distribute.php | 4 +-
components/lib/Components/Runner/Distribute.php | 59 +++++++++++++++++++---
components/package.xml | 28 ++++++++--
.../Components/Module/DistributeTest.php | 57 +++++++++++++++++++++
components/test/Components/StoryTestCase.php | 16 ++++++
7 files changed, 154 insertions(+), 16 deletions(-)
create mode 100644 components/data/distribute_package.spec
create mode 100644 components/test/Components/Integration/Components/Module/DistributeTest.php
diff --git a/components/TODO b/components/TODO
index 01bc3494d..e8bdc8aa3 100644
--- a/components/TODO
+++ b/components/TODO
@@ -4,8 +4,6 @@
- Document usage
- - Do the distribution runner.
-
- Add module for generating component documentation.
- Add module for an initial empty PEAR template
@@ -21,6 +19,4 @@
- Allow absolute/relative paths as arguments
- - Fail on missing dependencies in a decent way
-
- WWW frontend
diff --git a/components/data/distribute_package.spec b/components/data/distribute_package.spec
new file mode 100644
index 000000000..38e9b831c
--- /dev/null
+++ b/components/data/distribute_package.spec
@@ -0,0 +1,2 @@
+ 'store',
- 'help' => 'Prepare the component package in the specified DISTRIBUTE location'
+ 'help' => 'Prepare the package definition for the component in the specified DISTRIBUTE location'
)
),
);
diff --git a/components/lib/Components/Runner/Distribute.php b/components/lib/Components/Runner/Distribute.php
index e437e36ac..e0f59761c 100644
--- a/components/lib/Components/Runner/Distribute.php
+++ b/components/lib/Components/Runner/Distribute.php
@@ -37,24 +37,36 @@ class Components_Runner_Distribute
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()
@@ -63,5 +75,38 @@ class Components_Runner_Distribute
$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
+ );
}
}
diff --git a/components/package.xml b/components/package.xml
index d14185ea6..fd11f2f1a 100644
--- a/components/package.xml
+++ b/components/package.xml
@@ -24,8 +24,8 @@