From 8201d060ab4aefa352a655d3fc0d546f11f9514a Mon Sep 17 00:00:00 2001 From: Minh-Quan TRAN Date: Wed, 18 Dec 2019 15:13:56 +0100 Subject: [PATCH 1/5] add kafka extension --- install-php-extensions | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/install-php-extensions b/install-php-extensions index c59bf88..50206dd 100755 --- a/install-php-extensions +++ b/install-php-extensions @@ -431,6 +431,14 @@ buildRequiredPackageLists () { pthreads@alpine) buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS" ;; + rdkafka@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent librdkafka" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile librdkafka-dev" + ;; + rdkafka@debian) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent librdkafka++1" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile librdkafka-dev" + ;; recode@alpine) buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent recode" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile recode-dev" @@ -893,6 +901,11 @@ installPECLModule () { installPECLModule_actual="$2-2.0.10" fi ;; + rdkafka) + if test ! -z "$(apt-cache show librdkafka++1 | grep -E '^Version: 0.9')"; then + installPECLModule_actual="$2-3.1.3" + fi + ;; redis) if test $1 -le 506; then installPECLModule_actual="$2-4.3.0" From b289f2d7e9713a4350b19474ace509c3be9cf759 Mon Sep 17 00:00:00 2001 From: Minh-Quan TRAN Date: Wed, 18 Dec 2019 16:01:52 +0100 Subject: [PATCH 2/5] handle alpine for kafka --- data/supported-extensions | 1 + install-php-extensions | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/data/supported-extensions b/data/supported-extensions index 96cb068..00bca06 100644 --- a/data/supported-extensions +++ b/data/supported-extensions @@ -42,6 +42,7 @@ pgsql 5.6 7.0 7.1 7.2 7.3 7.4 protobuf 5.6 7.0 7.1 7.2 7.3 7.4 pspell 5.6 7.0 7.1 7.2 7.3 7.4 pthreads 5.6 7.0 +rdkafka 7.0 7.1 7.2 7.3 7.4 recode 5.6 7.0 7.1 7.2 7.3 redis 5.6 7.0 7.1 7.2 7.3 7.4 shmop 5.6 7.0 7.1 7.2 7.3 7.4 diff --git a/install-php-extensions b/install-php-extensions index 50206dd..f2af355 100755 --- a/install-php-extensions +++ b/install-php-extensions @@ -902,9 +902,20 @@ installPECLModule () { fi ;; rdkafka) - if test ! -z "$(apt-cache show librdkafka++1 | grep -E '^Version: 0.9')"; then - installPECLModule_actual="$2-3.1.3" - fi + case "$(getDistro)" in + alpine) + # lowest version on alpine is 0.9 + if test ! -z "$(apk search librdkafka | grep -E '^librdkafka-0.9')"; then + installPECLModule_actual="$2-3.1.3" + fi + ;; + debian) + # lowest version on debian is 0.8 (jessie), 0.9 (stretch) + if test ! -z "$(apt-cache show librdkafka++1 | grep -E -e '^Version: 0.9' -e '^Version: 0.8')"; then + installPECLModule_actual="$2-3.1.3" + fi + ;; + esac ;; redis) if test $1 -le 506; then From 6d3a226a3d7cad76e93dcc2eae488a260b478390 Mon Sep 17 00:00:00 2001 From: Quan TRAN Date: Wed, 18 Dec 2019 17:44:20 +0100 Subject: [PATCH 3/5] Update supported-extensions --- data/supported-extensions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/supported-extensions b/data/supported-extensions index 00bca06..790a4e0 100644 --- a/data/supported-extensions +++ b/data/supported-extensions @@ -42,7 +42,7 @@ pgsql 5.6 7.0 7.1 7.2 7.3 7.4 protobuf 5.6 7.0 7.1 7.2 7.3 7.4 pspell 5.6 7.0 7.1 7.2 7.3 7.4 pthreads 5.6 7.0 -rdkafka 7.0 7.1 7.2 7.3 7.4 +rdkafka 5.6 7.0 7.1 7.2 7.3 7.4 recode 5.6 7.0 7.1 7.2 7.3 redis 5.6 7.0 7.1 7.2 7.3 7.4 shmop 5.6 7.0 7.1 7.2 7.3 7.4 From 0a514973a55db616aeb6d35ee7565c285a57fd9b Mon Sep 17 00:00:00 2001 From: Quan TRAN Date: Wed, 18 Dec 2019 19:17:26 +0100 Subject: [PATCH 4/5] Update install-php-extensions --- install-php-extensions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-php-extensions b/install-php-extensions index f2af355..6e6cee9 100755 --- a/install-php-extensions +++ b/install-php-extensions @@ -433,7 +433,7 @@ buildRequiredPackageLists () { ;; rdkafka@alpine) buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent librdkafka" - buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile librdkafka-dev" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS librdkafka-dev" ;; rdkafka@debian) buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent librdkafka++1" From c1807e9cfc163d563e4b8d4c71ffe1428342e143 Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Thu, 19 Dec 2019 10:14:38 +0100 Subject: [PATCH 5/5] Generalize checking APT/APK package versions --- install-php-extensions | 65 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 8 deletions(-) diff --git a/install-php-extensions b/install-php-extensions index 6e6cee9..1c5555b 100755 --- a/install-php-extensions +++ b/install-php-extensions @@ -647,6 +647,52 @@ installRequiredPackages () { esac } +# Get the version of an installed APT/APK package +# +# Arguments: +# $1: the name of the installed package +# +# Output: +# The numeric part of the package version, with from 1 to 3 numbers +# +# Example: +# 1 +# 1.2 +# 1.2.3 +getInstalledPackageVersion() { + case "$(getDistro)" in + alpine) + apk info "$1" | head -n1 | cut -c $(( ${#1} + 2 ))- | grep -o -E '^[0-9]+(\.[0-9]+){0,2}' + ;; + debian) + dpkg-query --showformat='${Version}' --show "$1" 2>/dev/null | grep -o -E '^[0-9]+(\.[0-9]+){0,2}' + ;; + esac +} + +# Compare two versions +# +# Arguments: +# $1: the first version +# $2: the second version +# +# Output +# -1 if $1 is less than $2 +# 0 if $1 is the same as $2 +# 1 if $1 is greater than $2 +compareVersions() { + compareVersions_v1="$1.0.0" + compareVersions_v2="$2.0.0" + compareVersions_vMin="$(printf '%s\n%s' "${compareVersions_v1}" "${compareVersions_v2}" | sort -t '.' -n -k1,1 -k2,2 -k3,3 | head -n 1)" + if test "$compareVersions_vMin" != "$compareVersions_v1"; then + echo '1' + elif test "$compareVersions_vMin" = "$compareVersions_v2"; then + echo '0' + else + echo '-1' + fi +} + # Install a bundled PHP module given its handle # # Arguments: @@ -902,20 +948,23 @@ installPECLModule () { fi ;; rdkafka) + installPECLModule_tmp= case "$(getDistro)" in alpine) - # lowest version on alpine is 0.9 - if test ! -z "$(apk search librdkafka | grep -E '^librdkafka-0.9')"; then - installPECLModule_actual="$2-3.1.3" - fi + installPECLModule_tmp='librdkafka' ;; debian) - # lowest version on debian is 0.8 (jessie), 0.9 (stretch) - if test ! -z "$(apt-cache show librdkafka++1 | grep -E -e '^Version: 0.9' -e '^Version: 0.8')"; then - installPECLModule_actual="$2-3.1.3" - fi + installPECLModule_tmp='librdkafka++1' ;; esac + if test -n "$installPECLModule_tmp"; then + installPECLModule_tmp="$(getInstalledPackageVersion "$installPECLModule_tmp")" + if test -n "$installPECLModule_tmp"; then + if test $(compareVersions "$installPECLModule_tmp" '0.11.0') -lt 0; then + installPECLModule_actual="$2-3.1.3" + fi + fi + fi ;; redis) if test $1 -le 506; then