- Document usage
- - Allow offline installs and testing
-
- Add module for an initial empty PEAR template
- Fix variable replacements when updating the package.xml
public function addPackageFromPackage($channel, $package)
{
$installer = $this->getInstallationHandler();
- $this->_output->warn(
- sprintf(
- 'Adding package %s via network.',
- $package
- )
- );
- ob_start();
- $installer->doInstall(
- 'install',
- array(
- //'force' => true,
- 'channel' => $channel,
- ),
- array($package)
- );
- $this->_output->pear(ob_get_clean());
+ if ($local = $this->_identifyMatchingLocalPackage($package)) {
+ ob_start();
+ $installer->doInstall(
+ 'install',
+ array(
+ 'offline' => true
+ ),
+ array($local)
+ );
+ $this->_output->pear(ob_get_clean());
+ } else {
+ $this->_output->warn(
+ sprintf(
+ 'Adding package %s via network.',
+ $package
+ )
+ );
+ ob_start();
+ $installer->doInstall(
+ 'install',
+ array(
+ 'channel' => $channel,
+ ),
+ array($package)
+ );
+ }
$this->_output->ok(
sprintf(
'Successfully added package %s',
)
);
}
+
+ private function _identifyMatchingLocalPackage($package)
+ {
+ foreach (new DirectoryIterator($this->_source_directory) as $file) {
+ if (preg_match('/' . $package . '-[0-9]+(\.[0-9]+)+([a-z0-9]+)?/', $file->getBasename('.tgz'), $matches)) {
+ return $file->getPathname();
+ }
+ }
+ return false;
+ }
}
--- /dev/null
+<?php
+/**
+ * Test the Installer module.
+ *
+ * PHP version 5
+ *
+ * @category Horde
+ * @package Components
+ * @subpackage UnitTests
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Components
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../../../Autoload.php';
+
+/**
+ * Test the Installer module.
+ *
+ * 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
+ * @subpackage UnitTests
+ * @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_Integration_Components_Module_InstallerTest
+extends Components_StoryTestCase
+{
+ /**
+ * @scenario
+ */
+ public function theInstallerModuleAddsTheIOptionInTheHelpOutput()
+ {
+ $this->given('the default Components setup')
+ ->when('calling the package with the help option')
+ ->then('the help will contain the "i" option.');
+ }
+
+ /**
+ * @scenario
+ */
+ public function theTheIOptionInstallsThePackageFromTheCurrentTree()
+ {
+ $this->given('the default Components setup')
+ ->when('calling the package with the install option and a path to a Horde framework component')
+ ->then('a new PEAR configuration file will be installed')
+ ->and('the dummy PEAR package will be installed')
+ ->and('the non-Horde dependencies of the component will get installed')
+ ->and('the Horde dependencies of the component will get installed from the current tree')
+ ->and('the component will be installed')
+ ->and('the installation requires no network access.');
+ }
+}
\ No newline at end of file
* understand.
*/
- /**
- * @scenario
- */
- public function theInstallerModuleAddsTheIOptionInTheHelpOutput()
- {
- $this->given('the default Components setup')
- ->when('calling the package with the help option')
- ->then('the help will contain the "i" option.');
- }
-
- /**
- * @scenario
- */
- public function theTheIOptionInstallsThePackageFromTheCurrentTree()
- {
- $this->given('the default Components setup')
- ->when('calling the package with the install option and a Horde element')
- ->then('a new PEAR configuration file will be installed')
- ->and('the PEAR package will be installed')
- ->and('the non-Horde dependencies of the Horde element will get installed from the network.')
- ->and('the Horde dependencies of the Horde element will get installed from the current tree.')
- ->and('the Components library will be installed');
- }
}
\ No newline at end of file
);
$world['output'] = $this->_callUnstrictComponents();
break;
- case 'calling the package with the install option and a Horde element':
+ case 'calling the package with the install option and a path to a Horde framework component':
$_SERVER['argv'] = array(
'horde-components',
'--channelxmlpath=' . dirname(__FILE__) . '/fixture/channels',
+ '--sourcepath=' . dirname(__FILE__) . '/fixture/packages',
'--install=' . $this->_getTemporaryDirectory(),
- dirname(__FILE__) . '/../../'
+ dirname(__FILE__) . '/fixture/framework/Install'
);
$world['output'] = $this->_callUnstrictComponents();
break;
file_exists($this->_temp_dir . DIRECTORY_SEPARATOR . '.pearrc')
);
break;
- case 'the PEAR package will be installed':
+ case 'the dummy PEAR package will be installed':
$this->assertTrue(
file_exists(
$this->_temp_dir . DIRECTORY_SEPARATOR
)
);
break;
- case 'the non-Horde dependencies of the Horde element will get installed from the network.':
+ case 'the non-Horde dependencies of the component will get installed':
$this->assertTrue(
file_exists(
$this->_temp_dir . DIRECTORY_SEPARATOR
. 'pear' . DIRECTORY_SEPARATOR
. 'php' . DIRECTORY_SEPARATOR
- . 'PEAR' . DIRECTORY_SEPARATOR
- . 'PackageFileManager2.php'
+ . 'Console.php'
)
);
break;
- case 'the Horde dependencies of the Horde element will get installed from the current tree.':
+ case 'the Horde dependencies of the component will get installed from the current tree':
$this->assertTrue(
file_exists(
$this->_temp_dir . DIRECTORY_SEPARATOR
. 'pear' . DIRECTORY_SEPARATOR
. 'php' . DIRECTORY_SEPARATOR
- . 'Horde' . DIRECTORY_SEPARATOR
- . 'Autoloader.php'
+ . 'Dependency.php'
)
);
break;
)
);
break;
+ case 'the component will be installed':
+ $this->assertTrue(
+ file_exists(
+ $this->_temp_dir . DIRECTORY_SEPARATOR
+ . 'pear' . DIRECTORY_SEPARATOR
+ . 'php' . DIRECTORY_SEPARATOR
+ . 'Install.php'
+ )
+ );
+ break;
case 'the CI configuration will be installed.':
$this->assertTrue(
file_exists(
)
);
break;
+ case 'the installation requires no network access.':
+ $this->assertNotContains(
+ 'network',
+ $world['output']
+ );
+ break;
case 'the CI build script will be installed.':
$this->assertTrue(
file_exists(
--- /dev/null
+<?php
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<package packagerversion="1.9.0" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
+ <name>Dependency</name>
+ <channel>pear.php.net</channel>
+ <summary>Test fixture.</summary>
+ <description>A dummy package.xml used for testing the Components package.</description>
+ <lead>
+ <name>Gunnar Wrobel</name>
+ <user>wrobel</user>
+ <email>p@rdus.de</email>
+ <active>yes</active>
+ </lead>
+ <date>2010-08-22</date>
+ <time>21:12:03</time>
+ <version>
+ <release>0.0.1</release>
+ <api>0.0.1</api>
+ </version>
+ <stability>
+ <release>alpha</release>
+ <api>alpha</api>
+ </stability>
+ <license uri="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html">LGPL</license>
+ <notes>
+* Initial release
+ </notes>
+ <contents>
+ <dir baseinstalldir="/" name="/">
+ <dir name="lib">
+ <file name="Dependency.php" role="php" />
+ </dir> <!-- /lib -->
+ </dir> <!-- / -->
+ </contents>
+ <dependencies>
+ <required>
+ <php>
+ <min>5.0.0</min>
+ </php>
+ <pearinstaller>
+ <min>1.7.0</min>
+ </pearinstaller>
+ <package>
+ <name>Console_Getopt</name>
+ <channel>pear.php.net</channel>
+ </package>
+ </required>
+ </dependencies>
+ <phprelease>
+ <filelist>
+ <install as="Dependency.php" name="lib/Dependency.php" />
+ </filelist>
+ </phprelease>
+ <changelog>
+ <release>
+ <version>
+ <release>0.0.1</release>
+ <api>0.0.1</api>
+ </version>
+ <stability>
+ <release>alpha</release>
+ <api>alpha</api>
+ </stability>
+ <date>2010-08-22</date>
+ <license uri="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html">LGPL</license>
+ <notes>
+* Initial release
+ </notes>
+ </release>
+ </changelog>
+</package>
--- /dev/null
+<?php
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<package packagerversion="1.9.0" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
+ <name>Install</name>
+ <channel>pear.php.net</channel>
+ <summary>Test fixture.</summary>
+ <description>A dummy package.xml used for testing the Components package.</description>
+ <lead>
+ <name>Gunnar Wrobel</name>
+ <user>wrobel</user>
+ <email>p@rdus.de</email>
+ <active>yes</active>
+ </lead>
+ <date>2010-08-22</date>
+ <time>21:12:03</time>
+ <version>
+ <release>0.0.1</release>
+ <api>0.0.1</api>
+ </version>
+ <stability>
+ <release>alpha</release>
+ <api>alpha</api>
+ </stability>
+ <license uri="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html">LGPL</license>
+ <notes>
+* Initial release
+ </notes>
+ <contents>
+ <dir baseinstalldir="/" name="/">
+ <dir name="lib">
+ <file name="Install.php" role="php" />
+ </dir> <!-- /lib -->
+ </dir> <!-- / -->
+ </contents>
+ <dependencies>
+ <required>
+ <php>
+ <min>5.0.0</min>
+ </php>
+ <pearinstaller>
+ <min>1.7.0</min>
+ </pearinstaller>
+ <package>
+ <name>Dependency</name>
+ <channel>pear.horde.org</channel>
+ </package>
+ </required>
+ </dependencies>
+ <phprelease>
+ <filelist>
+ <install as="Install.php" name="lib/Install.php" />
+ </filelist>
+ </phprelease>
+ <changelog>
+ <release>
+ <version>
+ <release>0.0.1</release>
+ <api>0.0.1</api>
+ </version>
+ <stability>
+ <release>alpha</release>
+ <api>alpha</api>
+ </stability>
+ <date>2010-08-22</date>
+ <license uri="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html">LGPL</license>
+ <notes>
+* Initial release
+ </notes>
+ </release>
+ </changelog>
+</package>
--- /dev/null
+<?php
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<package packagerversion="1.9.0" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
+ <name>Console_Getopt</name>
+ <channel>pear.php.net</channel>
+ <summary>Test fixture.</summary>
+ <description>A dummy PEAR package used for testing the Components package.</description>
+ <lead>
+ <name>Gunnar Wrobel</name>
+ <user>wrobel</user>
+ <email>p@rdus.de</email>
+ <active>yes</active>
+ </lead>
+ <date>2010-10-04</date>
+ <time>21:12:03</time>
+ <version>
+ <release>1.9.1</release>
+ <api>1.9.1</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <license uri="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html">LGPL</license>
+ <notes>
+* Initial release
+ </notes>
+ <contents>
+ <dir baseinstalldir="/" name="/">
+ <dir name="lib">
+ <file name="Console.php" role="php" />
+ </dir> <!-- /lib -->
+ </dir> <!-- / -->
+ </contents>
+ <dependencies>
+ <required>
+ <php>
+ <min>5.0.0</min>
+ </php>
+ <pearinstaller>
+ <min>1.7.0</min>
+ </pearinstaller>
+ </required>
+ </dependencies>
+ <phprelease>
+ <filelist>
+ <install as="Console.php" name="lib/Console.php" />
+ </filelist>
+ </phprelease>
+ <changelog>
+ <release>
+ <version>
+ <release>0.0.1</release>
+ <api>0.0.1</api>
+ </version>
+ <stability>
+ <release>alpha</release>
+ <api>alpha</api>
+ </stability>
+ <date>2010-08-22</date>
+ <license uri="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html">LGPL</license>
+ <notes>
+* Initial release
+ </notes>
+ </release>
+ </changelog>
+</package>
--- /dev/null
+<?php
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<package packagerversion="1.9.0" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
+ <name>PEAR</name>
+ <channel>pear.php.net</channel>
+ <summary>Test fixture.</summary>
+ <description>A dummy PEAR package used for testing the Components package.</description>
+ <lead>
+ <name>Gunnar Wrobel</name>
+ <user>wrobel</user>
+ <email>p@rdus.de</email>
+ <active>yes</active>
+ </lead>
+ <date>2010-10-04</date>
+ <time>21:12:03</time>
+ <version>
+ <release>1.9.1</release>
+ <api>1.9.1</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <license uri="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html">LGPL</license>
+ <notes>
+* Initial release
+ </notes>
+ <contents>
+ <dir baseinstalldir="/" name="/">
+ <dir name="lib">
+ <file name="PEAR.php" role="php" />
+ </dir> <!-- /lib -->
+ </dir> <!-- / -->
+ </contents>
+ <dependencies>
+ <required>
+ <php>
+ <min>5.0.0</min>
+ </php>
+ <pearinstaller>
+ <min>1.7.0</min>
+ </pearinstaller>
+ </required>
+ </dependencies>
+ <phprelease>
+ <filelist>
+ <install as="PEAR.php" name="lib/PEAR.php" />
+ </filelist>
+ </phprelease>
+ <changelog>
+ <release>
+ <version>
+ <release>0.0.1</release>
+ <api>0.0.1</api>
+ </version>
+ <stability>
+ <release>alpha</release>
+ <api>alpha</api>
+ </stability>
+ <date>2010-08-22</date>
+ <license uri="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html">LGPL</license>
+ <notes>
+* Initial release
+ </notes>
+ </release>
+ </changelog>
+</package>