I want to create a .deb package of PHP 7.1 for Debian with the PHP modules I want.

Here the steps I have followed.

  1. Downloading PHP sources

    wget http://fr2.php.net/get/php-7.1.7.tar.bz2/from/this/mirror
    tar xvf mirror
    mv mirror php_7.1.7.orig.tar.bz2
    cd php-7.1.7/

Here I can compile PHP 7.1, no problem. If I want to build the package, I follow those steps:

  1. Preparing the packaging:

    export DEBFULLNAME="Shanx Shanxou"
    dh_make -e shanx@example.com
    apt-get install debhelper cdbs lintian build-essential fakeroot devscripts pbuilder dh-make debootstrap
    vim debian/control

In that file I modify the Build-Depends: line with:

Build-Depends: debhelper (>= 9), autotools-dev, mawk, file, libxml2-dev:amd64, libxml2:amd64, bison, perl-modules, libfakeroot:amd64, perl, mime-support, libmagic1:amd64    , autoconf, build-essential, git-core, libbz2-dev, libcurl4-openssl-dev, libfreetype6-dev, libicu-dev, libjpeg-dev, libmcrypt-dev, libpng-dev, libpspell-dev, libreadline    -dev, libssl-dev, libxml2-dev, pkg-config, libc-client-dev, libkrb5-dev, libpq-dev, libxslt-dev
  1. The packaging:

    debuild -S -sa --lintian-opts -i
    cd ..
    pbuilder create
    pbuilder update --extrapackages "libc-client-dev pkg-config libssl-dev libreadline-dev libpspell-dev libpng-dev libmcrypt-dev libjpeg-dev libfreetype6-dev libcurl4-openssl-dev libbz2-dev git-core mime-support libfakeroot bison libkrb5-dev libxml2-dev  debhelper"
    pbuilder build *.dsc
  2. The result:

    mkdir: cannot create directory '/usr/lib/x86_64-linux-gnu/extensions': Permission denied
    mkdir: cannot create directory '/usr/lib/x86_64-linux-gnu/extensions/no-debug-non-zts-20160303': No such file or directory
    Makefile:160: recipe for target 'install-modules' failed
    make[1]: *** [install-modules] Error 1
    make[1]: Leaving directory '/tmp/buildd/php-7.1.7'
    dh_auto_install: make -j1 install DESTDIR=/tmp/buildd/php-7.1.7/debian/php AM_UPDATE_INFO_DIR=no returned exit code 2
    debian/rules:22: recipe for target 'binary' failed
    make: *** [binary] Error 2
    dpkg-buildpackage: error: fakeroot debian/rules binary gave error exit status 2
    E: Failed autobuilding of package
    I: unmounting dev/pts filesystem
    I: unmounting run/shm filesystem
    I: unmounting proc filesystem
    I: cleaning the build env
    I: removing directory /var/cache/pbuilder/build//14827 and its subdirectories

But the directory and the file have been created by the packaging process:

# ls /usr/lib/x86_64-linux-gnu/extensions
  1. The questions

Is my packaging process valid?

If so, what could be the causes of the error?

EDIT: @Stephen Kitt answer did the trick. Just to not, you have to use actual tabulations (not space) and not forget to reexecute debuild -S -sa --lintian-opts -i after the modification.

EDITbis : New question here Installing a created .deb package

  • What does dpkg -L php output on the other VM? (Also, note that common practice here when someone answers your question in a useful way, is to accept the answer, not edit your question to ask another question.) – Stephen Kitt Aug 2 '17 at 9:52
  • Sorry, I was not sure if it was the same question or not. I've created a new question: unix.stackexchange.com/questions/383404/… – Shan-x Aug 2 '17 at 9:58

I would have used the existing Debian PHP 7.1 package instead...

Anyway, to answer your question, your packaging process as described is valid. To answer properly we’d need to see your debian/control and debian/rules files in detail, but the error you’re seeing is easy to fix: the PHP source doesn’t use DESTDIR, it needs an INSTALL_ROOT variable instead. In debian/rules:

        dh_auto_install -- INSTALL_ROOT=$(CURDIR)/debian/php

since you appear to be building a single php binary package.

| improve this answer | |
  • The same error is still there. Do you have any other hint? – Shan-x Aug 2 '17 at 8:33
  • Could you edit your question to include the contents of debian/rules? – Stephen Kitt Aug 2 '17 at 8:36
  • Quesetion edited with my further experiments. It still doesn't work, but it is getting better. – Shan-x Aug 2 '17 at 9:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.