
https://github.com/gplessis/dotdeb-php/issues/154

https://github.com/gplessis/dotdeb-php/issues/88

https://packages.debian.org/unstable/php/

Imagine we want to package the Fileinfo extension for PHP5…

First, install all the needed packages (libmagic-dev is only needed here to build Fileinfo) :

# apt-get install dh-make-php php5-dev build-essential libmagic-dev debhelper

Then, export some needed environment variables, download the package

# export DEBFULLNAME="Firstname Lastname"
# export DEBEMAIL="your@email.tld"
# pecl download fileinfo
downloading Fileinfo-1.0.4.tgz ...
Starting to download Fileinfo-1.0.4.tgz (5,835 bytes)
.....done: 5,835 bytes
File /tmp/Fileinfo-1.0.4.tgz downloaded

Ok, let’s summon the magical dh-make-pecl command with the appropriate arguments :

# dh-make-pecl --phpversion 5 --prefix php5- Fileinfo-1.0.4.tgz
Creating debian source package: php-fileinfo-1.0.4
Upstream is: Ilia Alshanetsky
Guessing Maintainer: Firstname Lastname

No error message… Great! dh-make-pecl did its job, e.g. unarchived the tarball and created the php-fileinfo-1.0.4/debian/ subdirectory that contains all the packaging stuff.
“–phpversion 5” restricts the building process to PHP5 packages (PHP4 is obsolete!) and “–prefix” sets the prefix in the package’s name.

Let’s build the package!

# cd php-fileinfo-1.0.4/
# ./debian/rules binary
xsltproc --nonet --novalid debian/changelog.xsl package.xml > debian/Changelog
touch build-stamp
dh_testdir
...
dh_md5sums
dh_builddeb
dpkg-deb: building package `php5-fileinfo' in `../php5-fileinfo_1.0.4-1_i386.deb'.

That’s it! Let’s take a look at the content of the package…
