- Add module for an initial empty PEAR template
+ - Allow filtering (see http://github.com/horde/horde/commit/404e8d1ea7c0bf99373aec2ce7f2534a442149b3)
+ Potentially check with git if the file is relevant or not.
+
- Add a commit module that automatically adds a changelog entry in
the notes section of the package.xml
public function getRunnerCiPrebuild();
/**
+ * Returns the snapshot packaging handler for a package.
+ *
+ * @return Components_Runner_DevPackage The snapshot handler.
+ */
+ public function getRunnerDevPackage();
+
+ /**
* Returns the distribution handler for a package.
*
* @return Components_Runner_Distribute The distribution handler.
}
/**
+ * Returns the snapshot packaging handler for a package.
+ *
+ * @return Components_Runner_DevPackage The snapshot handler.
+ */
+ public function getRunnerDevPackage()
+ {
+ return $this->getInstance('Components_Runner_DevPackage');
+ }
+
+ /**
* Returns the dependency list handler for a package.
*
* @return Components_Runner_Dependencies The dependency handler.
* @link http://pear.horde.org/index.php?package=Components
*/
class Components_Module_DevPackage
-implements Components_Module
+extends Components_Module_Base
{
public function getOptionGroupTitle()
{
{
$options = $config->getOptions();
if (!empty($options['devpackage'])) {
- $this->run($config);
+ $this->_dependencies->getRunnerDevPackage()->run();
}
}
-
- 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';
-
- $pkg = new PEAR_PackageFile(new PEAR_Config());
- $pf = $pkg->fromPackageFile($pkgfile, PEAR_VALIDATE_NORMAL);
- $pf->_packageInfo['version']['release'] = $pf->getVersion()
- . 'dev' . strftime('%Y%m%d%H%M');
- $gen = $pf->getDefaultGenerator();
- $tgzfile = $gen->toTgz(new PEAR_Common());
- }
}
}
/**
+ * Return the version for this package.
+ *
+ * @return string The package version.
+ */
+ public function getVersion()
+ {
+ return $this->_getPackageFile()->getVersion();
+ }
+
+ /**
+ * Return the license for this package.
+ *
+ * @return string The package license.
+ */
+ public function getLicense()
+ {
+ return $this->_getPackageFile()->getLicense();
+ }
+
+ /**
+ * Return the summary for this package.
+ *
+ * @return string The package summary.
+ */
+ public function getSummary()
+ {
+ return $this->_getPackageFile()->getSummary();
+ }
+
+ /**
* Update the content listing of the provided package.
*
* @param PEAR_PackageFileManager2 $package The package to update.
return $dependencies;
}
+ /**
+ * Generate a snapshot of the package using the provided version number.
+ *
+ * @param string $varsion The snapshot version.
+ *
+ * @return string The path to the snapshot.
+ */
+ public function generateSnapshot($version)
+ {
+ $pkg = $this->_getPackageFile();
+ $pkg->_packageInfo['version']['release'] = $version;
+ $pkg->setDate(date('Y-m-d'));
+ $pkg->setTime(date('H:i:s'));
+ ob_start();
+ $result = $pkg->getDefaultGenerator()
+ ->toTgz(new PEAR_Common());
+ $this->_output->pear(ob_get_clean());
+ if ($result instanceOf PEAR_Error) {
+ throw new Components_Exception($result->getMessage());
+ }
+ $this->_output->ok('Generated snapshot ' . $result);
+ return $result;
+ }
+
}
--- /dev/null
+<?php
+/**
+ * Components_Runner_DevPackage:: packages a snapshot.
+ *
+ * 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_DevPackage:: packages a snapshot.
+ *
+ * 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_Runner_DevPackage
+{
+ /**
+ * The configuration for the current job.
+ *
+ * @var Components_Config
+ */
+ private $_config;
+
+ /**
+ * The factory for PEAR dependencies.
+ *
+ * @var Components_Pear_Factory
+ */
+ private $_factory;
+
+ /**
+ * The output handler.
+ *
+ * @param Component_Output
+ */
+ private $_output;
+
+ /**
+ * Constructor.
+ *
+ * @param Components_Config $config The configuration for the current
+ * job.
+ * @param Components_Pear_Factory $factory The factory for PEAR
+ * dependencies.
+ * @param Component_Output $output The output handler.
+ */
+ public function __construct(
+ Components_Config $config,
+ Components_Pear_Factory $factory,
+ Components_Output $output
+ ) {
+ $this->_config = $config;
+ $this->_factory = $factory;
+ $this->_output = $output;
+ }
+
+ public function run()
+ {
+ $options = $this->_config->getOptions();
+ $arguments = $this->_config->getArguments();
+
+ $package = $this->_factory->createPackageForDefaultLocation(
+ $arguments[0] . DIRECTORY_SEPARATOR . 'package.xml'
+ );
+ $package->generateSnapshot(
+ $package->getVersion() . 'dev' . strftime('%Y%m%d%H%M')
+ );
+ }
+}
{
$options = $this->_config->getOptions();
$arguments = $this->_config->getArguments();
- $location = realpath($options['distribute']);
$template = null;
foreach (
);
}
+ $package = $this->_factory->createPackageForDefaultLocation(
+ $arguments[0] . DIRECTORY_SEPARATOR . 'package.xml'
+ );
+ $version = $package->getVersion() . 'dev' . strftime('%Y%m%d%H%M');
+ $package->generateSnapshot($version);
+
ob_start();
include $template->getPathname();
$packaging = ob_get_clean();
file_put_contents(
- realpath($options['distribute']) . DIRECTORY_SEPARATOR
- . substr($template->getBasename(), 11),
+ $options['distribute'],
$packaging
);
}
case 'calling the package with the distribute option and a path to a Horde framework component':
$_SERVER['argv'] = array(
'horde-components',
- '--distribute=' . $this->_getTemporaryDirectory(),
+ '--distribute=' . $this->_getTemporaryDirectory() . '/package.spec',
dirname(__FILE__) . '/fixture/framework/Install'
);
$world['output'] = $this->_callUnstrictComponents();