As a developer you will often have a high number of different libraries installed. This will usually not match the users situation that will be nearer to the minimal number of required libraries. This may turn out to be a problem when releasing packages as missing dependencies can be easily overlooked.
For releasing PHP PEAR packages it makes sense to get a separate PEAR environment for testing if the package to be release has a correct set of dependencies. If PEAR is already installed on the system, the steps for that are straight forward.
Setup the new repository
Create the test environment with
# mkdir ~/pear-test
A separate PEAR configuration will be needed there:
# pear config-create ~/pear-test ~/pear-test/.pearrc CONFIGURATION (CHANNEL PEAR.PHP.NET): ===================================== ...
All that is required to complete the test environment is the installation of PEAR itself:
# pear -c ~/pear-test/.pearrc install -o PEAR WARNING: channel "pear.php.net" has updated its protocols, use "channel-update pear.php.net" to update Did not download optional dependencies: pear/XML_RPC, use --alldeps to download automatically pear/PEAR can optionally use package "pear/XML_RPC" (version >= 1.4.0) downloading PEAR-1.7.2.tgz ... Starting to download PEAR-1.7.2.tgz (302,744 bytes) ..........................done: 302,744 bytes downloading Archive_Tar-1.3.2.tgz ... Starting to download Archive_Tar-1.3.2.tgz (17,150 bytes) ...done: 17,150 bytes downloading Structures_Graph-1.0.2.tgz ... Starting to download Structures_Graph-1.0.2.tgz (30,947 bytes) ...done: 30,947 bytes downloading Console_Getopt-1.2.3.tgz ... Starting to download Console_Getopt-1.2.3.tgz (4,011 bytes) ...done: 4,011 bytes install ok: channel://pear.php.net/Archive_Tar-1.3.2 install ok: channel://pear.php.net/Structures_Graph-1.0.2 install ok: channel://pear.php.net/Console_Getopt-1.2.3 install ok: channel://pear.php.net/PEAR-1.7.2 PEAR: Optional feature webinstaller available (PEAR's web-based installer) PEAR: Optional feature gtkinstaller available (PEAR's PHP-GTK-based installer) PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based installer) PEAR: To install optional features use "pear install pear/PEAR#featurename"
A real example
As I am currently working on releasing the Kolab modules in Horde as PEAR packages I'll provide this process as an example.
In order to wrap a PEAR package the appropriate channel needs to be known for pear. For horde packages this is pear.horde.org. This channel needs to be discovered first:
# ~/pear-test/pear/pear -c ~/pear-test/.pearrc channel-discover pear.horde.org Adding Channel "pear.horde.org" succeeded Discovery of channel "pear.horde.org" succeeded
The initial package to be released will be Kolab_Format. PEAR packaging happens with
# cd Kolab_Format # ~/pear-test/pear/pear -c ~/pear-test/.pearrc package package.xml Analyzing lib/Horde/Kolab/Format/XML/contact.php Analyzing lib/Horde/Kolab/Format/XML/distributionlist.php Analyzing lib/Horde/Kolab/Format/XML/event.php Analyzing lib/Horde/Kolab/Format/XML/hprefs.php Analyzing lib/Horde/Kolab/Format/XML/note.php Analyzing lib/Horde/Kolab/Format/XML/task.php Analyzing lib/Horde/Kolab/Format/Date.php Analyzing lib/Horde/Kolab/Format/XML.php Analyzing lib/Horde/Kolab/Format.php Package Horde_Kolab_Format-0.9.0.tgz done Tag the released code with `pear cvstag package.xml' (or set the CVS tag RELEASE_0_9_0 by hand)
As most Horde PEAR packages have not yet been marked stable PEAR will still refuse to install the new package:
# ~/pear-test/pear/pear -c ~/pear-test/.pearrc install Horde_Kolab_Format-0.9.0.tgz Failed to download horde/Horde_DOM within preferred state "stable", latest release is version 0.1.0, stability "alpha", use "channel://pear.horde.org/Horde_DOM-0.1.0" to install Failed to download horde/Horde_NLS within preferred state "stable", latest release is version 0.0.2, stability "alpha", use "channel://pear.horde.org/Horde_NLS-0.0.2" to install Failed to download horde/Horde_Util within preferred state "stable", latest release is version 0.0.2, stability "alpha", use "channel://pear.horde.org/Horde_Util-0.0.2" to install Did not download optional dependencies: horde/Horde_Prefs, use --alldeps to download automatically horde/Horde_Kolab_Format requires package "horde/Horde_DOM" (version >= 0.1.0) horde/Horde_Kolab_Format requires package "horde/Horde_NLS" horde/Horde_Kolab_Format requires package "horde/Horde_Util" horde/Horde_Kolab_Format can optionally use package "horde/Horde_Prefs" No valid packages found install failed
The required packages must be installed manually first:
# ~/pear-test/pear/pear -c ~/pear-test/.pearrc install channel://pear.horde.org/Horde_DOM-0.1.0 downloading Horde_DOM-0.1.0.tgz ... Starting to download Horde_DOM-0.1.0.tgz (4,256 bytes) .....done: 4,256 bytes install ok: channel://pear.horde.org/Horde_DOM-0.1.0 # ~/pear-test/pear/pear -c ~/pear-test/.pearrc install channel://pear.horde.org/Horde_Util-0.0.2 Did not download optional dependencies: horde/Horde_Browser, use --alldeps to download automatically horde/Horde_Util can optionally use package "horde/Horde_Browser" downloading Horde_Util-0.0.2.tgz ... Starting to download Horde_Util-0.0.2.tgz (16,603 bytes) ......done: 16,603 bytes install ok: channel://pear.horde.org/Horde_Util-0.0.2 # ~/pear-test/pear/pear -c ~/pear-test/.pearrc install channel://pear.horde.org/Horde_NLS-0.0.2 downloading Horde_NLS-0.0.2.tgz ... Starting to download Horde_NLS-0.0.2.tgz (75,779 bytes) .................done: 75,779 bytes install ok: channel://pear.horde.org/Horde_NLS-0.0.2
This time installation should suceed:
# ~/pear-test/pear/pear -c ~/pear-test/.pearrc install Horde_Kolab_Format-0.9.0.tgz Did not download optional dependencies: horde/Horde_Prefs, use --alldeps to download automatically horde/Horde_Kolab_Format can optionally use package "horde/Horde_Prefs" install ok: channel://pear.horde.org/Horde_Kolab_Format-0.9.0
All that is missing now is to tell PEAR that it should provide PHP only with one include directory: the one we just setup. Ensure that you replace USER with the name of the current user.
# ~/pear-test/pear/pear -c ~/pear-test/.pearrc config-set php_bin "`~/pear-test/pear/pear -c ~/pear-test/.pearrc config-get php_bin` -d include_path=/home/USER/pear-test/pear/php"
After installation succeeded the unit tests should be run in order to validate the dependencies. If the tests are based on PHPUnit then this tool will have to be installed first:
# ~/pear-test/pear/pear -c ~/pear-test/.pearrc channel-discover pear.phpunit.de Adding Channel "pear.phpunit.de" succeeded Discovery of channel "pear.phpunit.de" succeeded # ~/pear-test/pear/pear -c ~/pear-test/.pearrc install phpunit/PHPUnit
And now we can finally run the last check before releasing the PEAR package:
# cd ~/pear-test/pear/tests/Horde_Kolab_Format/Horde/Kolab/Format/ # ~/pear-test/pear/pear -c ~/pear-test/.pearrc run-tests -u
No comments:
Post a Comment