Differences between revisions 2 and 3
Revision 2 as of 2007-09-16 22:14:05
Size: 6521
Comment: First (real) draft
Revision 3 as of 2007-09-16 22:26:38
Size: 6524
Comment:
Deletions are marked like this. Additions are marked like this.
Line 46: Line 46:
There are two principal ways for existing packages : with cdbs or debhelper. There are two principal ways for actual pear packages : with cdbs or debhelper.

Here is a draft of up-to-date policy for packaging PHP modules. This is inspired by dh-make-php package and Webapps-Pear-Policy-Manual-DRAFT.

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:

  • be prefixed with 'php-'
  • be lowercased
  • have all underscores be replaced by dashes

Package short description should:

  • begin with "PHP Pear module(s) for"...
  • be inspired from <summary> in package.xml

Package description should:

Depends should:

  • have php-pear, probably versionned (See <dependencies> in package.xml)

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 :

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 and see existing packages (php-date, ...)

Note that you don't need your module register itself in postint, or unregister in prerm. There was long discussion about it and it is the final decision (like in dh-php-make package).

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

  • Download PEAR module from pear.php.net, for example FOO_Bar
  • Exec dh-make-pear FOO_Bar-1.2.3.tgz

  • Correct php-foo-bar-1.2.3/debian/control (Depends:, add "PHP PEAR module for" in short description, add Homepage in long description)
  • Correct php-foo-bar-1.2.3/debian/copyright
  • Verify, build, verify, test (install, remove, etcetera) with classical tools (pbuilder, lintian, linda).

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 duplicated files, these files are in /usr/share/doc/package
    rm -rf debian/$(package)/usr/share/php/tests \
        debian/$(package)/usr/share/php/docs

    # remove unwanted files
    rm -rf debian/$(package)/usr/share/php/.[a-z]* \
        debian/$(package)/tmp

# 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.