Packaging MidCOM with PEAR

The number of components and libraries in MidCOM is raising rapidly, especially as both Aegir and OpenPSA are being rewritten on it. As now all MidCOM packages ship in the distribution, this causes lots of unnecessary clutter on systems.

New packaging policy

I’m now proposing to improve the situation by packaging MidCOM using the PEAR package format. This would enable us to change the distribution strategy so that

  • MidCOM framework ships as its own package
  • Each component has its own package
  • MidCOM distribution includes a meta package that depends on a set of core components
  • The core components would be chosen from the best quality and most general MidCOM components, and would include things like de.linkm.taviewer
  • Rest of the components could then be installed one-by-one using the PEAR installer

Besides removing clutter, PEAR packaging would also enable components and libraries to clearly state their dependencies from both MidCOM world and PEAR packages. This would promote code reuse and closer cooperation with the PEAR community.

Proof of concept

To test this approach, I created a package definition for the net.nemein.personnel component. It seemed quite easy to define the component in PEAR’s format, although the package name had to use underscores instead of dots as class path separator, making it net_nemein_personnel.

The package seemed to work quite well:

$ pear package-validate package.xml
Validation: 0 error(s), 0 warning(s)

$ pear package package.xml

$ sudo pear install net_nemein_personnel-1.0.tgz
install ok: net_nemein_personnel 1.0

$ ls /usr/lib/php/midcom/lib/net/nemein/personnel/
admin.php       locale          navigation.php  viewer.php
config          midcom          style
$ ls /usr/lib/php/docs/net_nemein_personnel/documentation/

$ sudo pear uninstall net_nemein_personnel
uninstall ok: net_nemein_personnel

With this experience, it looks like we should be able to quite easily create the package definitions for MidCOM files, and possibly also automate part of this work using the PEAR PackageFileManager tool or some custom script.

The only real change required in MidCOM to make the PEAR packaging work would be to change midcom-template to load MidCOM by default from the PEAR installation directory.

Distribution mechanisms

Once the packages have been done we have several options for distributing them:

  1. Just providing them as downloads on the Midgard site
  2. Setting up our own PEAR 1.4 channel
  3. Contributing the packages to the actual PEAR repository, and midgard-php to PECL

The first of these options would be the easiest, and is probably the right way to start. We can consider the others with better time.

In the other news: congratulations, Torben!

Read more Midgard posts.