public function getPackageFile(
$package_xml_path,
Components_Pear_InstallLocation $environment
- )
- {
+ ) {
$pkg = new PEAR_PackageFile($environment->getPearConfig());
return Components_Exception_Pear::catchError(
$pkg->fromPackageFile($package_xml_path, PEAR_VALIDATE_NORMAL)
public function getPackageFileFromTgz(
$package_tgz_path,
Components_Pear_InstallLocation $environment
- )
- {
+ ) {
$pkg = new PEAR_PackageFile($environment->getPearConfig());
return Components_Exception_Pear::catchError(
$pkg->fromTgzFile($package_tgz_path, PEAR_VALIDATE_NORMAL)
*/
public function createPackageFile(
$package_xml_dir
- )
- {
+ ) {
$environment = $this->_dependencies->getInstance('Components_Pear_InstallLocation');
$pkg = new PEAR_PackageFile_v2_rw();
- $pkg->setPackage('REPLACE');
+ $pkg->setPackage(basename($package_xml_dir));
$pkg->setDescription('REPLACE');
$pkg->setSummary('REPLACE');
$pkg->setReleaseVersion('0.0.1');
$root = new Components_Helper_Root(
$package->_options['packagedirectory']
);
+ $package->_options['roles'] = $this->_getRoles($root->getBase());
$package->_options['dir_roles'] = $this->_getMapping($root->getBase());
return new Components_Pear_Package_Contents_List(
$package->_options['packagedirectory'],
{
switch ($path) {
case 'horde/':
+ case 'imp/':
+ case 'ingo/':
+ case 'kronolith/':
+ case 'mnemo/':
+ case 'nag/':
+ case 'turba/':
return array(
- 'admin' => 'horde',
'bin' => 'script',
'config' => 'horde',
'script' => 'script',
'docs' => 'doc',
'js' => 'horde',
- 'lib' => 'horde',
+ 'locale' => 'horde',
'scripts' => 'data',
- 'services' => 'horde',
'test' => 'test',
'templates' => 'horde',
'themes' => 'horde',
'util' => 'horde',
);
- break;
default:
return array(
'bin' => 'script',
'scripts' => 'data',
'test' => 'test',
);
- break;
+ }
+ }
+
+ /**
+ * Return the default role mapping for the specific package.
+ *
+ * @param string $path The package path.
+ *
+ * @return array The mapping.
+ */
+ private function _getRoles($path)
+ {
+ switch ($path) {
+ case 'horde/':
+ case 'imp/':
+ case 'ingo/':
+ case 'kronolith/':
+ case 'mnemo/':
+ case 'nag/':
+ case 'turba/':
+ return array(
+ 'h' => 'src',
+ 'c' => 'src',
+ 'cpp' => 'src',
+ 'in' => 'src',
+ 'm4' => 'src',
+ 'w32' => 'src',
+ 'dll' => 'ext',
+ 'php' => 'horde',
+ 'html' => 'doc',
+ '*' => 'data',
+ );
+ default:
+ return array(
+ 'h' => 'src',
+ 'c' => 'src',
+ 'cpp' => 'src',
+ 'in' => 'src',
+ 'm4' => 'src',
+ 'w32' => 'src',
+ 'dll' => 'ext',
+ 'php' => 'php',
+ 'html' => 'doc',
+ '*' => 'data',
+ );
}
}
}
\ No newline at end of file
switch ($role) {
case 'horde':
$horde_role = true;
+ if (in_array(
+ $this->_package->getName(),
+ array('imp', 'ingo', 'kronolith', 'mnemo', 'nag', 'turba')
+ )) {
+ $prefix = $this->_package->getName() . '/';
+ } else {
+ $prefix = '';
+ }
$this->_package->addInstallAs(
- $file['attribs']['name'], $file['attribs']['name']
+ $file['attribs']['name'], $prefix . $file['attribs']['name']
);
break;
case 'doc':
}
$version = $package->getVersion() . 'dev' . strftime('%Y%m%d%H%M');
- $package->generateSnapshot($version, dirname($options['distribute']));
+ $package->generateSnapshot($version, $options['distribute']);
$build_template = new Components_Helper_Templates_Directory(
$this->_config_application->getTemplateDirectory(),
*/
require_once dirname(__FILE__) . '/../../../../../Autoload.php';
- //@require_once 'PEAR/Validate.php';
-
/**
* Test the handling of file lists.
*
{
public function setUp()
{
+ $this->_old_errorreporting = error_reporting(E_ALL & ~(E_STRICT | E_DEPRECATED));
+ error_reporting(E_ALL & ~(E_STRICT | E_DEPRECATED));
if (!defined('PEAR_VALIDATE_INSTALLING')) {
define('PEAR_VALIDATE_INSTALLING', 1);
define('PEAR_VALIDATE_NORMAL', 3);
}
}
+ public function tearDown()
+ {
+ error_reporting($this->_old_errorreporting);
+ }
+
/**
* @dataProvider provideFiles
*/
$this->_getFilelist($package)->update();
}
+ public function testApplication()
+ {
+ $package = $this->_getPackage(array('role' => 'horde', 'name' => 'a'));
+ $package->expects($this->once())
+ ->method('getUsesRole')
+ ->will($this->returnValue(array('role' => 'horde')));
+ $package->expects($this->any())
+ ->method('getName')
+ ->will($this->returnValue('imp'));
+ $package->expects($this->once())
+ ->method('addInstallAs')
+ ->with('a', 'imp/a');
+ $this->_getFilelist($package)->update();
+ }
+
private function _getPackage(array $contents)
{
$list = array('dir' => array('file' => array(array('attribs' => $contents))));