PHP packaging

From Wikitech

We currently use modified Debian packages to install PHP on appservers and in Docker images. These packages are available from apt.wikimedia.org in a dedicated component for others to use, like CI and MediaWiki-Vagrant.

Differences from Debian

Aside from custom patches we want to apply, the packages are slightly different. Starting with PHP 7.4, all packages are named php7.4-foo (instead of the versionless php-foo). This is implemented by patching dh-php:

In an extension package, the binary package name also needs to be changed, including any potential dependencies. Any php-foo.* files also need to be renamed to php7.4-foo.*

Initial forking

If you want to fork a new package from Debian, clone the Git repository from Salsa, adjust the packaging as explained above, and build the package:

$ https_proxy="http://webproxy:8080" gbp clone https://salsa.debian.org/php-team/pecl/php-pcov
$ cd php-pcov/
$ git checkout debian/bullseye
$ git checkout -b wikimedia/php74
$ # Make changes to the debian/ directory
$ # Add a changelog entry with +wmf1~buster1 appended to the version
$ PHP74="yes" gbp buildpackage --git-debian-branch=wikimedia/php74 --git-dist=buster-wikimedia -sa

Modifying a package

If you need to patch or modify a package already in our repository, use the latest .dsc to create a new Git repo. You can find the URL of the .dsc by looking in the pool.

$ gbp import-dsc --allow-unauthenticated https://apt.wikimedia.org/wikimedia/pool/component/php74/p/php-pcov/php-pcov_1.0.6-4%2Bwmf1~buster1.dsc 
$ cd php-pcov
$ # Make your changes, bump changelog
$ PHP74="yes" gbp buildpackage --git-dist=buster-wikimedia