Creating a .deb package for PHP 7.1

General Tech Bugs & Fixes 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

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
no-debug-non-zts-20160303
  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

profilepic.png
manpreet 2 years ago

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:

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

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


0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

tuteehub community

Join Our Community Today

Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.

tuteehub community