Skip to content

Commit ebc3fbc

Browse files
committed
build/debian: eliminate hardcoded PHP 7.0 version
Preprocess debian/control file to set proper package name like php7.3-tarantool. Use the package name in debian/rules file to determine installation paths. Removed php7.0-dev dependency, because php-all-dev already depends on proper php7.?-dev package. This change allows to build a Deb package for distributions, which provides PHP version other then 7.0. Those builds will be enabled in CI in further commits. Details ------- It seems it is not possible to build a package with a conditional name (depending of a distribution). `man 5 deb-substvars` explicitly states that 'Package' field in debian/control can be parametrized using a substitution varible. Another possible way would be define several 'Package' fields in debian/control and build only one for each distribution. However I don't find a way to build only one package using `debuild` (it is used inside `packpack`). So it seems that the preprocessing is the only way to build, say, php7.0-tarantool package for Debian Stretch and php7.3-tarantool for Debian Buster. The preprocessing is performed from debian/prebuild.sh script, which is invoked by `packpack`. So nothing changed in the build process from a caller perspective.
1 parent e82fc7d commit ebc3fbc

File tree

3 files changed

+37
-13
lines changed

3 files changed

+37
-13
lines changed

debian/control renamed to debian/control.in

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ Source: php-tarantool
22
Priority: optional
33
Maintainer: Dmitry E. Oboukhov <[email protected]>
44
Build-Depends: debhelper (>= 8),
5-
php7.0-dev | php-all-dev,
5+
php-all-dev,
66
pkg-config
77
Section: php
88
Standards-Version: 3.9.4
99
Homepage: https://github.com/tarantool/tarantool-php
1010
VCS-Browser: https://github.com/tarantool/tarantool-php
1111
VCS-Git: git://github.com/tarantool/tarantool-php.git
1212

13-
Package: php7.0-tarantool
13+
# Package name is preprocessed in debian/prebuild.sh.
14+
Package: php${phpversion}-tarantool
1415
Architecture: any
1516
Priority: optional
1617
Conflicts: libtarantool-php

debian/prebuild.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/sh
2+
3+
set -exu # Strict shell (w/o -o pipefail)
4+
5+
# Preserve DEBIAN_FRONTEND=noninteractive. It prevents packages
6+
# like tzdata from asking configuration parameters interactively.
7+
#
8+
# See https://github.com/packpack/packpack/issues/7
9+
SUDO="sudo -E"
10+
11+
${SUDO} apt-get update > /dev/null
12+
${SUDO} apt-get -y install php-all-dev
13+
14+
phpversion=$(php-config --version | sed 's/^\([0-9]\+\.[0-9]\).*/\1/')
15+
16+
cd /build/php-tarantool-*
17+
sed -e "s/\${phpversion}/${phpversion}/" debian/control.in > debian/control
18+
rm debian/control.in

debian/rules

+16-11
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,32 @@
22

33
include /usr/share/cdbs/1/rules/debhelper.mk
44

5-
phpapi = $(shell php-config7.0 --phpapi)
5+
DEB_PACKAGE := $(strip $(shell egrep '^Package: ' debian/control | \
6+
cut -f 2 -d ':'))
7+
8+
phpversion = $(shell echo $(DEB_PACKAGE) | \
9+
sed -e 's/^php\([0-9.]\+\)-tarantool$$/\1/')
10+
phpapi = $(shell php-config$(phpversion) --phpapi)
611
version = $(shell dpkg-parsechangelog \
712
|grep ^Version|awk '{print $$2}'|sed 's/-.*//')
813

9-
makebuilddir/php7.0-tarantool::
14+
makebuilddir/php$(phpversion)-tarantool::
1015
phpize
1116
./configure
1217
make
13-
echo "php:Depends=phpapi-$(phpapi)" > debian/php7.0-tarantool.substvars
18+
echo "php:Depends=phpapi-$(phpapi)" > debian/php$(phpversion)-tarantool.substvars
1419

15-
install/php7.0-tarantool::
16-
install -m 0755 -d debian/php7.0-tarantool/usr/lib/php/$(phpapi)/
17-
install -m 0755 -d debian/php7.0-tarantool/etc/php/7.0/mods-available/
20+
install/php$(phpversion)-tarantool::
21+
install -m 0755 -d debian/php$(phpversion)-tarantool/usr/lib/php/$(phpapi)/
22+
install -m 0755 -d debian/php$(phpversion)-tarantool/etc/php/$(phpversion)/mods-available/
1823
install -m 0755 modules/tarantool.so \
19-
debian/php7.0-tarantool/usr/lib/php/$(phpapi)/
24+
debian/php$(phpversion)-tarantool/usr/lib/php/$(phpapi)/
2025
echo extension=tarantool.so \
21-
> debian/php7.0-tarantool/etc/php/7.0/mods-available/tarantool.ini
26+
> debian/php$(phpversion)-tarantool/etc/php/$(phpversion)/mods-available/tarantool.ini
2227
# Enable the extension.
23-
install -m 0755 -d debian/php7.0-tarantool/etc/php/7.0/cli/conf.d
24-
ln -s /etc/php/7.0/mods-available/tarantool.ini \
25-
debian/php7.0-tarantool/etc/php/7.0/cli/conf.d/50-tarantool.ini
28+
install -m 0755 -d debian/php$(phpversion)-tarantool/etc/php/$(phpversion)/cli/conf.d
29+
ln -s /etc/php/$(phpversion)/mods-available/tarantool.ini \
30+
debian/php$(phpversion)-tarantool/etc/php/$(phpversion)/cli/conf.d/50-tarantool.ini
2631

2732
clean::
2833
phpize --clean

0 commit comments

Comments
 (0)