I needed to build a quick pear channel for a library I had built – here’s all it takes:
For this example, we’ll assume your Google project is named: myproject
First, we need to check out the root of your Google Code project, so we can place the channel files here, away from your source code files.
svn checkout https://myproject.googlecode.com/svn/ myproject --username mygoogleusername
Now that we have a checkout, let’s build the channel:
wget "http://svn.php.net/viewvc/pear2/sandbox/SimpleChannelServer/trunk/pearscs.phar?view=co" -O pearscs.phar
Using a recent version of PHP 5.3, let’s execute the pearscs.phar file, and create the channel for the project:
php pearscs.phar create myproject.googlecode.com/svn myproject
Now commit the files to your repository, and let’s try discovering your pear channel.
pear channel-discover myproject.googlecode.com/svn/
You should see the following message, telling you that the channel was added successfully:
Adding Channel "myproject.googlecode.com/svn" succeeded Discovery of channel "myproject.googlecode.com/svn/" succeeded
Now let’s create our pear package. PEAR has many tools available to aid in package creation. To get up and running quickly, we’ll start from an example and modify it for our own needs.
Download http://simplecas.googlecode.com/svn/trunk/makepackage.php and save it to your local project as trunk/makepackage.php
Modify this file to use your channel name, package name, release information and maintainer info.
Now let’s create the package:
php makepackage.php pear package
Now you should have a file myproject-0.1.0.tgz
Let’s release the package to the world, substitute the lead name with your handle:
php pearscs.phar release trunk/myproject-0.1.0.tgz leadhandle
This will add the distribution files to the /get/ directory, and update the channel xml files. There’s a small issue with using Google code to host the xml files, and that’s that the content-type needs to be sent as application/xml or text/xml for the channel files to be read correctly, so set the mime-type property for the xml files.
find . -name '*.xml' | xargs svn propset svn:mime-type application/xml
Now commit these files to your repository, and let’s try installing the package!
pear install myproject/myproject-0.1.0
If everything went correctly, pear should have installed the package. Now when you create a new release, just run the release command, update the mime-type on the xml files and commit your changes.
FYI – the package I needed a channel for is SimpleCAS a PHP5 library for authenticating users against a JA-SIG Central Authentication Service.
There are a couple gotchas for phar packaging. Here’s some info that might ease some problems with creating or opening phars or PEAR packages:
* Make sure you have zlib! ./configure –with-zlib
* php.ini settings
[phar] phar.readonly = 0 phar.require_hash = 0