From b3803ce60bdcb0676386e8eff1893316bb57be4b Mon Sep 17 00:00:00 2001 From: Michael Penick Date: Mon, 15 May 2017 19:25:28 -0700 Subject: [PATCH] Separated DEB packaging for PHP versions --- ext/packaging/build_deb.sh | 30 ++++--- .../{debian => debian-php5.6}/cassandra.ini | 0 .../{debian => debian-php5.6}/compat | 0 .../{debian => debian-php5.6}/control | 13 ++- .../{debian => debian-php5.6}/copyright | 2 +- .../php5.6-cassandra-driver.php} | 0 ext/packaging/debian-php5.6/rules | 49 +++++++++++ .../{debian => debian-php5.6}/source/format | 0 ext/packaging/debian-php7.0/cassandra.ini | 1 + ext/packaging/debian-php7.0/compat | 1 + ext/packaging/debian-php7.0/control | 21 +++++ ext/packaging/debian-php7.0/copyright | 9 ++ .../debian-php7.0/php7.0-cassandra-driver.php | 1 + ext/packaging/debian-php7.0/rules | 49 +++++++++++ ext/packaging/debian-php7.0/source/format | 1 + ext/packaging/debian/changelog | 5 -- ext/packaging/debian/rules | 83 ------------------- 17 files changed, 156 insertions(+), 109 deletions(-) rename ext/packaging/{debian => debian-php5.6}/cassandra.ini (100%) rename ext/packaging/{debian => debian-php5.6}/compat (100%) rename ext/packaging/{debian => debian-php5.6}/control (63%) rename ext/packaging/{debian => debian-php5.6}/copyright (88%) rename ext/packaging/{debian/php-cassandra-driver.php => debian-php5.6/php5.6-cassandra-driver.php} (100%) create mode 100755 ext/packaging/debian-php5.6/rules rename ext/packaging/{debian => debian-php5.6}/source/format (100%) create mode 100644 ext/packaging/debian-php7.0/cassandra.ini create mode 100644 ext/packaging/debian-php7.0/compat create mode 100644 ext/packaging/debian-php7.0/control create mode 100644 ext/packaging/debian-php7.0/copyright create mode 100644 ext/packaging/debian-php7.0/php7.0-cassandra-driver.php create mode 100755 ext/packaging/debian-php7.0/rules create mode 100644 ext/packaging/debian-php7.0/source/format delete mode 100644 ext/packaging/debian/changelog delete mode 100755 ext/packaging/debian/rules diff --git a/ext/packaging/build_deb.sh b/ext/packaging/build_deb.sh index c74cb16e8..06475640e 100755 --- a/ext/packaging/build_deb.sh +++ b/ext/packaging/build_deb.sh @@ -56,23 +56,27 @@ check_command "dch" "debhelper" check_command "lsb_release" "lsb-release" pecl_name="cassandra" -pecl_version=$(header_version "../version.h") version=$(header_version_full "../version.h") release=1 dist=$(lsb_release -s -c) base="php-driver-$version" files="config.m4 php_driver.c php_driver.h php_driver_globals.h php_driver_types.h version.h src util" -echo "Building version $version" -libuv_version=$(dpkg -s libuv | grep 'Version' | awk '{ print $2 }') +if [[ -z $1 ]]; then + php_version=$(php-config --version | sed -rn 's/^([0-9]+)\.([0-9]+)(.*)/\1.\2/p') +else + php_version=$1 +fi + +debian_dir="debian-php$php_version" -if [[ -e $libuv_version ]]; then - echo "'libuv' required, but not installed" - exit 1 +if [[ ! -e $debian_dir ]]; then + echo "PHP $php_version not supported" + exit -1 fi -echo "Using libuv version $libuv_version" +echo "Building version $version with PHP $php_version" if [[ -d build ]]; then read -p "Build directory exists, remove? [y|n] " -n 1 -r @@ -84,18 +88,18 @@ fi mkdir -p "build/$base" echo "Copying files" -mkdir -p "build/$base/$pecl_name-$pecl_version" cp ../package.xml "build/$base" for file in $files; do - cp -r "../$file" "build/$base/$pecl_name-$pecl_version/$file" + cp -r "../$file" "build/$base/$file" done -cp -r debian "build/$base" + +cp -r $debian_dir "build/$base/debian" pushd "build/$base" echo "Updating changlog" -dch -m -v "$version-$release" -D $dist "Version $version" - +dch -M --create --package "php$php_version-cassandra-driver" -v "$version-$release" -D $dist "Version $version" echo "Building package:" nprocs=$(grep -e '^processor' -c /proc/cpuinfo) -DEB_BUILD_OPTIONS="parallel=$nprocs" debuild -i -b -uc -us +DEB_BUILD_OPTIONS="parallel=$nprocs" debuild -e PHP_VERSION="$php_version" -i -b -uc -us + popd diff --git a/ext/packaging/debian/cassandra.ini b/ext/packaging/debian-php5.6/cassandra.ini similarity index 100% rename from ext/packaging/debian/cassandra.ini rename to ext/packaging/debian-php5.6/cassandra.ini diff --git a/ext/packaging/debian/compat b/ext/packaging/debian-php5.6/compat similarity index 100% rename from ext/packaging/debian/compat rename to ext/packaging/debian-php5.6/compat diff --git a/ext/packaging/debian/control b/ext/packaging/debian-php5.6/control similarity index 63% rename from ext/packaging/debian/control rename to ext/packaging/debian-php5.6/control index 91bc3e7b4..0af3d055e 100644 --- a/ext/packaging/debian/control +++ b/ext/packaging/debian-php5.6/control @@ -1,22 +1,21 @@ -Source: php-cassandra-driver +Source: php5.6-cassandra-driver Section: php Priority: optional Maintainer: Michael Penick Build-Depends: debhelper (>= 9~), dh-php (>= 0.10~), - php5.6-dev, - php7.0-dev, + php-all-dev, pkg-config, - cassandra-cpp-driver-dev (>= 2.6.0) + cassandra-cpp-driver-dev (>= 2.7.0) Homepage: http://datastax.github.io/php-driver/ -Package: php-cassandra-driver +Package: php5.6-cassandra-driver Architecture: any Depends: ${misc:Depends}, ${php:Depends}, ${shlibs:Depends}, - cassandra-cpp-driver (>= 2.6.0) + cassandra-cpp-driver (>= 2.7.0) Provides: ${php:Provides} -Description: A modern, feature-rich and highly tunable PHP client library for +Description: Modern, feature-rich and highly tunable PHP client library for Apache Cassandra (1.2+) and DataStax Enterprise (3.1+) using exclusively Cassandra's binary protocol and Cassandra Query Language v3. diff --git a/ext/packaging/debian/copyright b/ext/packaging/debian-php5.6/copyright similarity index 88% rename from ext/packaging/debian/copyright rename to ext/packaging/debian-php5.6/copyright index 654d116dd..feffe50c2 100644 --- a/ext/packaging/debian/copyright +++ b/ext/packaging/debian-php5.6/copyright @@ -1,5 +1,5 @@ Format: http://dep.debian.net/deps/dep5 -Upstream-Name: php-cassandra-driver +Upstream-Name: php5.6-cassandra-driver Source: https://github.com/datastax/php-driver Files: * diff --git a/ext/packaging/debian/php-cassandra-driver.php b/ext/packaging/debian-php5.6/php5.6-cassandra-driver.php similarity index 100% rename from ext/packaging/debian/php-cassandra-driver.php rename to ext/packaging/debian-php5.6/php5.6-cassandra-driver.php diff --git a/ext/packaging/debian-php5.6/rules b/ext/packaging/debian-php5.6/rules new file mode 100755 index 000000000..ff1894aad --- /dev/null +++ b/ext/packaging/debian-php5.6/rules @@ -0,0 +1,49 @@ +#!/usr/bin/make -f + +# Copied from dh-php: /usr/share/dh-php/pkg-pecl.mk + +# See debhelper(7) (uncomment to enable) +# output every command that modifies files on the build system. +#DH_VERBOSE = 1 + +# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/* +DPKG_EXPORT_BUILDFLAGS = 1 +include /usr/share/dpkg/default.mk + +# see FEATURE AREAS in dpkg-buildflags(1) +export DEB_BUILD_MAINT_OPTIONS = hardening=+all + +# see ENVIRONMENT in dpkg-buildflags(1) +# package maintainers to append CFLAGS +export DEB_CFLAGS_MAINT_APPEND = -Wall +# package maintainers to append LDFLAGS +export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed + +# Don't ever use RPATH on Debian +export PHP_RPATH=no + +export DH_PHP_VERSIONS = $(PHP_VERSION) + +PECL_NAME := cassandra-driver +INSTALL_ROOT = $(CURDIR)/debian/php$(PHP_VERSION)-cassandra-driver + +%: + dh $@ --with php + +override_dh_auto_configure: + phpize$(PHP_VERSION) + dh_auto_configure -- --with-cassandra --with-php-config=/usr/bin/php-config$(PHP_VERSION) $(PECL_CONFIGURE_MAINT_APPEND) + +override_dh_auto_build: + dh_auto_build -- -j$(NUMJOBS) + +override_dh_auto_install: + dh_auto_install -- INSTALL_ROOT=$(INSTALL_ROOT) + +override_dh_gencontrol: ,:=, +override_dh_gencontrol: + dh_gencontrol -- "-Vphp:Provides=$(addprefix php,$(addsuffix -$(PECL_NAME)$(,) ,$(PHP_VERSION)))" + +override_dh_php: + dh_php -p php$(PHP_VERSION)-$(PECL_NAME) + diff --git a/ext/packaging/debian/source/format b/ext/packaging/debian-php5.6/source/format similarity index 100% rename from ext/packaging/debian/source/format rename to ext/packaging/debian-php5.6/source/format diff --git a/ext/packaging/debian-php7.0/cassandra.ini b/ext/packaging/debian-php7.0/cassandra.ini new file mode 100644 index 000000000..9dec4e58a --- /dev/null +++ b/ext/packaging/debian-php7.0/cassandra.ini @@ -0,0 +1 @@ +extension=cassandra.so diff --git a/ext/packaging/debian-php7.0/compat b/ext/packaging/debian-php7.0/compat new file mode 100644 index 000000000..ec635144f --- /dev/null +++ b/ext/packaging/debian-php7.0/compat @@ -0,0 +1 @@ +9 diff --git a/ext/packaging/debian-php7.0/control b/ext/packaging/debian-php7.0/control new file mode 100644 index 000000000..8df4b22b1 --- /dev/null +++ b/ext/packaging/debian-php7.0/control @@ -0,0 +1,21 @@ +Source: php7.0-cassandra-driver +Section: php +Priority: optional +Maintainer: Michael Penick +Build-Depends: debhelper (>= 9~), + dh-php (>= 0.10~), + php-all-dev, + pkg-config, + cassandra-cpp-driver-dev (>= 2.7.0) +Homepage: http://datastax.github.io/php-driver/ + +Package: php7.0-cassandra-driver +Architecture: any +Depends: ${misc:Depends}, + ${php:Depends}, + ${shlibs:Depends}, + cassandra-cpp-driver (>= 2.7.0) +Provides: ${php:Provides} +Description: Modern, feature-rich and highly tunable PHP client library for + Apache Cassandra (1.2+) and DataStax Enterprise (3.1+) using exclusively + Cassandra's binary protocol and Cassandra Query Language v3. diff --git a/ext/packaging/debian-php7.0/copyright b/ext/packaging/debian-php7.0/copyright new file mode 100644 index 000000000..26e0b328f --- /dev/null +++ b/ext/packaging/debian-php7.0/copyright @@ -0,0 +1,9 @@ +Format: http://dep.debian.net/deps/dep5 +Upstream-Name: php7.0-cassandra-driver +Source: https://github.com/datastax/php-driver + +Files: * +Copyright: Copyright 2014-2017 DataStax +License: Apache-2.0 + On Debian systems, the complete text of the Apache License Version 2.0 + can be found in `/usr/share/common-licenses/Apache-2.0'. diff --git a/ext/packaging/debian-php7.0/php7.0-cassandra-driver.php b/ext/packaging/debian-php7.0/php7.0-cassandra-driver.php new file mode 100644 index 000000000..286184276 --- /dev/null +++ b/ext/packaging/debian-php7.0/php7.0-cassandra-driver.php @@ -0,0 +1 @@ +mod debian/cassandra.ini diff --git a/ext/packaging/debian-php7.0/rules b/ext/packaging/debian-php7.0/rules new file mode 100755 index 000000000..ff1894aad --- /dev/null +++ b/ext/packaging/debian-php7.0/rules @@ -0,0 +1,49 @@ +#!/usr/bin/make -f + +# Copied from dh-php: /usr/share/dh-php/pkg-pecl.mk + +# See debhelper(7) (uncomment to enable) +# output every command that modifies files on the build system. +#DH_VERBOSE = 1 + +# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/* +DPKG_EXPORT_BUILDFLAGS = 1 +include /usr/share/dpkg/default.mk + +# see FEATURE AREAS in dpkg-buildflags(1) +export DEB_BUILD_MAINT_OPTIONS = hardening=+all + +# see ENVIRONMENT in dpkg-buildflags(1) +# package maintainers to append CFLAGS +export DEB_CFLAGS_MAINT_APPEND = -Wall +# package maintainers to append LDFLAGS +export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed + +# Don't ever use RPATH on Debian +export PHP_RPATH=no + +export DH_PHP_VERSIONS = $(PHP_VERSION) + +PECL_NAME := cassandra-driver +INSTALL_ROOT = $(CURDIR)/debian/php$(PHP_VERSION)-cassandra-driver + +%: + dh $@ --with php + +override_dh_auto_configure: + phpize$(PHP_VERSION) + dh_auto_configure -- --with-cassandra --with-php-config=/usr/bin/php-config$(PHP_VERSION) $(PECL_CONFIGURE_MAINT_APPEND) + +override_dh_auto_build: + dh_auto_build -- -j$(NUMJOBS) + +override_dh_auto_install: + dh_auto_install -- INSTALL_ROOT=$(INSTALL_ROOT) + +override_dh_gencontrol: ,:=, +override_dh_gencontrol: + dh_gencontrol -- "-Vphp:Provides=$(addprefix php,$(addsuffix -$(PECL_NAME)$(,) ,$(PHP_VERSION)))" + +override_dh_php: + dh_php -p php$(PHP_VERSION)-$(PECL_NAME) + diff --git a/ext/packaging/debian-php7.0/source/format b/ext/packaging/debian-php7.0/source/format new file mode 100644 index 000000000..163aaf8d8 --- /dev/null +++ b/ext/packaging/debian-php7.0/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/ext/packaging/debian/changelog b/ext/packaging/debian/changelog deleted file mode 100644 index 155249f2c..000000000 --- a/ext/packaging/debian/changelog +++ /dev/null @@ -1,5 +0,0 @@ -php-cassandra-driver (0.0.1-1) stable; urgency=low - - * Initial release - - -- Michael Penick Fri, 30 Dec 2016 15:15:00 -0500 diff --git a/ext/packaging/debian/rules b/ext/packaging/debian/rules deleted file mode 100755 index a92758d8c..000000000 --- a/ext/packaging/debian/rules +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/make -f - -# Copied from dh-php: /usr/share/dh-php/pkg-pecl.mk - -# See debhelper(7) (uncomment to enable) -# output every command that modifies files on the build system. -#DH_VERBOSE = 1 - -# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/* -DPKG_EXPORT_BUILDFLAGS = 1 -include /usr/share/dpkg/default.mk - -# see FEATURE AREAS in dpkg-buildflags(1) -export DEB_BUILD_MAINT_OPTIONS = hardening=+all - -# see ENVIRONMENT in dpkg-buildflags(1) -# package maintainers to append CFLAGS -export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic -# package maintainers to append LDFLAGS -export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed - -# Don't ever use RPATH on Debian -export PHP_RPATH=no - -PHP_VERSIONS := $(shell /usr/sbin/phpquery -V) - -PECL_NAME := $(if $(PECL_NAME_OVERRIDE),$(PECL_NAME_OVERRIDE),$(subst php-,,$(DEB_SOURCE))) -INSTALL_ROOT = $(CURDIR)/debian/php-$(PECL_NAME) - -# find corresponding package-PHP_MAJOR.PHP_MINOR.xml, package-PHP_MAJOR.xml or package.xml -$(foreach ver,$(PHP_VERSIONS),$(eval PACKAGE_XML_$(ver) := $(word 1,$(wildcard package-$(ver).xml package-$(basename $(ver)).xml package.xml)))) -# fill DH_PHP_VERSIONS with versions that have corresponding package.xml and are not outside the specification -$(foreach ver,$(PHP_VERSIONS),$(eval PHP_MIN_VER_$(ver) := $(if $(PACKAGE_XML_$(ver)),$(shell xml2 < $(PACKAGE_XML_$(ver)) | sed -ne "s,^/package/dependencies/required/php/min=\([0-9]\+\.[0-9]\+\).*,\1,p"),))) -$(foreach ver,$(PHP_VERSIONS),$(eval PHP_MAX_VER_$(ver) := $(if $(PACKAGE_XML_$(ver)),$(shell xml2 < $(PACKAGE_XML_$(ver)) | sed -ne "s,^/package/dependencies/required/php/max=\([0-9]\+\.[0-9]\+\).*,\1,p"),))) -MIN_PHP_VERSIONS := $(foreach ver,$(PHP_VERSIONS),$(if $(PHP_MIN_VER_$(ver)),$(shell dpkg --compare-versions "$(PHP_MIN_VER_$(ver))" le "$(ver)" && echo "$(ver)"),$(ver))) -MAX_PHP_VERSIONS := $(foreach ver,$(MIN_PHP_VERSIONS),$(if $(PHP_MAX_VER_$(ver)),$(shell dpkg --compare-versions "$(PHP_MAX_VER_$(ver))" gt "$(ver)" && echo "$(ver)"),$(ver))) -export DH_PHP_VERSIONS = $(if $(DH_PHP_VERSIONS_OVERRIDE),$(DH_PHP_VERSIONS_OVERRIDE),$(foreach ver,$(MAX_PHP_VERSIONS),$(if $(PACKAGE_XML_$(ver)),$(ver)))) - -# for each ver in $(DH_PHP_VERSIONS), look into each corresponding package.xml for upstream PECL version -$(foreach ver,$(DH_PHP_VERSIONS),$(eval PECL_SOURCE_$(ver) := $(if $(PACKAGE_XML_$(ver)),$(shell xml2 < $(PACKAGE_XML_$(ver)) | sed -ne "s,^/package/name=,,p")-$(shell xml2 < $(PACKAGE_XML_$(ver)) | sed -ne "s,^/package/version/release=,,p"),undefined))) - -CONFIGURE_TARGETS = $(addprefix configure-,$(addsuffix -stamp,$(DH_PHP_VERSIONS))) -BUILD_TARGETS = $(addprefix build-,$(addsuffix -stamp,$(DH_PHP_VERSIONS))) -INSTALL_TARGETS = $(addprefix install-,$(addsuffix -stamp,$(DH_PHP_VERSIONS))) -CLEAN_TARGETS = $(addprefix clean-,$(addsuffix -stamp,$(DH_PHP_VERSIONS))) - -%: - dh $@ --with php - -override_dh_auto_configure: $(CONFIGURE_TARGETS) -override_dh_auto_build: $(BUILD_TARGETS) -override_dh_auto_install: $(INSTALL_TARGETS) -override_dh_auto_clean: $(CLEAN_TARGETS) - -rm -f $(CONFIGURE_TARGETS) $(BUILD_TARGETS) $(INSTALL_TARGETS) $(CLEAN_TARGETS) - -clean-%-stamp: SOURCE_DIR = build-$(*) -clean-%-stamp: - rm -rf $(SOURCE_DIR) - touch clean-$*-stamp - -configure-%-stamp: SOURCE_DIR = build-$(*) -configure-%-stamp: - cp -a $(PECL_SOURCE_$(*)) $(SOURCE_DIR) - cd $(SOURCE_DIR) && phpize$(*) - dh_auto_configure --sourcedirectory=$(SOURCE_DIR) -- --enable-$(PECL_NAME) --with-php-config=/usr/bin/php-config$* $(PECL_CONFIGURE_MAINT_APPEND) - touch configure-$(*)-stamp - -build-%-stamp: SOURCE_DIR = build-$(*) -build-%-stamp: - dh_auto_build --sourcedirectory=$(SOURCE_DIR) - touch build-$*-stamp - -install-%-stamp: SOURCE_DIR = build-$(*) -install-%-stamp: - dh_auto_install --sourcedirectory=$(SOURCE_DIR) -- INSTALL_ROOT=$(INSTALL_ROOT) - touch install-$*-stamp - -override_dh_gencontrol: ,:=, -override_dh_gencontrol: - dh_gencontrol -- "-Vphp:Provides=$(addprefix php,$(addsuffix -$(PECL_NAME)$(,) ,$(DH_PHP_VERSIONS)))" - -override_dh_php: - dh_php -p php-$(PECL_NAME)