Here is a draft of Developer's Reference for packaging PHP PEAR modules. This is inspired by dh-make-php package and Webapps-Pear-Policy-Manual-DRAFT (in webapps SVN repository).

Index ?TableOfContents(2)

Packaging

Hierarchy

Upstream sources are in .tgz and contains package.xml and PEARLIBRARYNAME-x.y.z/ directory. Then, here is aborescence of source package:

$ ls php-PEARLIBRARYNAME-x.y.z-n
PEARLIBRARYNAME-x.y.z/
debian/
package.xml

debian/control

Package name should:

Package short description should:

Package description should:

Depends should:

Note we have PEAR 1.4.11 in php-pear etch package (version 5.2.0-8*), and if could be a good idea to use (>= 5.2.0-8) if possible to make backport easier.

debian/rules

There are two principal ways for actual pear packages : with cdbs or debhelper.

With CDBS, rules files is trivial (it's the principe ;):

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/pear.mk

With debhelper, please read /usr/share/cdbs/1/class/pear.mk file, see example below and read sources of existing packages (php-date...)

Note that are three ways to deal with register/unregister modules:

  1. no register
  2. register in 'postint and unregister in prerm

  3. put register files in binary packages

You should avoid to choose first way. And we should probably choose between second and third in order to have uniform packaging...

debian/copyright

PEAR modules could be under various licences : PHP, BSD, LGPL, Apache, MIT, etc. You should verify copyright in all files and write all copyright/authors.

Note: If your module is under PHP license, it should be version >= 3.01 If it's not, ask to upstream to upgrade to version 3.01 before uploading. BTW you should talk to upstream to convince them to switch to "standard" license like BSD or LGPL.

debian/watch

You should write a watch file looking like:

version=3
http://pear.php.net/package/PEARLIBRARYNAME/download /get/PEARLIBRARYNAME-([\d.]+)\.tgz

Concrete example

By default, dh-make-pear use CDBS. If you want debhelper, here is example for debian/rules file:

DEB_VERSION := $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ')
DEB_NOEPOCH_VERSION := $(shell echo $(DEB_VERSION) | cut -d: -f2-)
DEB_UPSTREAM_VERSION := $(shell echo $(DEB_NOEPOCH_VERSION) | sed 's/-[^-]*$$//')

PEAR ?= /usr/bin/pear
pear_pkg = $(shell ls |grep PEARLIBRARYNAME)
package = php-auth

configure: configure-stamp
configure-stamp:
    dh_testdir
    touch configure-stamp

build: build-stamp

build-stamp: configure-stamp
    dh_testdir
    touch build-stamp

clean:
    dh_testdir
    dh_testroot
    if [ -f $(pear_pkg)/package.xml ]; then \
        rm $(pear_pkg)/package.xml; \
    fi
    dh_clean build-stamp configure-stamp

install: build
    dh_testdir
    dh_testroot
    dh_clean -k 
    dh_installdirs

    # Add here commands to install the package into debian/package.
    cp package.xml $(pear_pkg)/package.xml;
    $(PEAR)  \
        -c debian/pearrc \
        -d include_path=/usr/share/php \
        -d php_bin=/usr/bin/php \
        -d bin_dir=/usr/bin \
        -d php_dir=/usr/share/php \
        -d data_dir=/usr/share/php/data \
        -d doc_dir=/usr/share/php/docs \
        -d test_dir=/usr/share/php/tests \
        install -n -f -P debian/$(package) $(pear_pkg)/package.xml
    
    # remove unwanted files
    rm -f debian/$(package)/usr/share/php/.filemap;
    rm -f debian/$(package)/usr/share/php/.lock;
    rm -rf debian/$(package)/usr/share/php/.channels;
    rm -rf debian/$(package)/usr/share/php/.depdblock;
    rm -rf debian/$(package)/usr/share/php/.depdb;
    rm -rf debian/$(package)/usr/share/php/.registry/.channel.pecl.php.net;
    rm -rf debian/$(package)/usr/share/php/.registry/.channel.__uri;
    rm -rf debian/$(package)/tmp

    # remove duplicated files, these files are in /usr/share/doc/package
    rm -rf debian/$(package)/usr/share/php/tests \
        debian/$(package)/usr/share/php/docs

# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: build install
    dh_testdir
    dh_testroot
    dh_installdocs
    dh_installexamples
    dh_installchangelogs 
    dh_compress
    dh_fixperms
    dh_installdeb
    dh_gencontrol
    dh_md5sums
    dh_builddeb

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure

get-orig-source:
    wget http://download.pear.php.net/package/PEARLIBRARYNAME-${DEB_UPSTREAM_VERSION}.tgz \
    -O php-PEARLIBRARYNAME_${DEB_UPSTREAM_VERSION}.orig.tar.gz

Collaborative Maintenance

There are more 400 PHP PEAR modules. We don't want have all this packages in Debian, but only packages required for webapps in Debian and maintained/high-quality modules with real use case.

If you are maintainer of PHP PEAR module

Note that your work is not only doing first package. You are Debian Maintainer and you must respond to bugs, follow upstream news (RSS feed, security issues), follow some lists (debian-devel-announce, webapps, pkg-php). You should also consider to join pkg-php alioth team and commit your package(s) in SVN repository.

If you want a new PHP PEAR module

If you want PHP PEAR module because your webapp use it, or because you think there is a use case, ask it by classical debian way : report a RFP (Request For Package) bug against wnpp. Here is an example of email for that:

To: submit@bugs.debian.org
Subject: RFP: PEARLIBRARYNAME -- PHP PEAR Module for ...
X-Debbugs-CC: pkg-php-maint@lists.alioth.debian.org

Package: wnpp
Severity: wishlist

 * Package name : PEARLIBRARYNAME
 * Version : x.y.z
 * Upstream Author : Name <somebody@some.org>
 * URL : http://http://pear.php.net/package/PEARLIBRARYNAME
 * License : (GPL, LGPL, BSD, MIT/X, etc.)
 Description : ...

--
John Doe

PEAR maintainers from pkg-php team will see if you request is admissible and packaging/uploading/maintaining.