From 2cad8f700849d06000ccfc1d877a0c6bf508d090 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 8 Nov 2018 17:03:56 +0100 Subject: add upstream patches from merged PRs add weak dependencies on geolite2 databases --- 4b3e00c2b4f33124dbc2cf94f472c66d5c44b4cc.patch | 29 ++++++++++++ 73320ff0c35fe102944eae1fb4ed36bfb7d63b18.patch | 49 +++++++++++++++++++++ PHPINFO | 4 +- REFLECTION | 14 ++++++ c8bf723822ef48f722b78cff240e886cb5907edd.patch | 61 ++++++++++++++++++++++++++ d4d7845adb0b08d294a9255d9254b5f5cc6aba80.patch | 50 +++++++++++++++++++++ php-maxminddb.spec | 27 +++++++++++- 7 files changed, 231 insertions(+), 3 deletions(-) create mode 100644 4b3e00c2b4f33124dbc2cf94f472c66d5c44b4cc.patch create mode 100644 73320ff0c35fe102944eae1fb4ed36bfb7d63b18.patch create mode 100644 c8bf723822ef48f722b78cff240e886cb5907edd.patch create mode 100644 d4d7845adb0b08d294a9255d9254b5f5cc6aba80.patch diff --git a/4b3e00c2b4f33124dbc2cf94f472c66d5c44b4cc.patch b/4b3e00c2b4f33124dbc2cf94f472c66d5c44b4cc.patch new file mode 100644 index 0000000..bf199f8 --- /dev/null +++ b/4b3e00c2b4f33124dbc2cf94f472c66d5c44b4cc.patch @@ -0,0 +1,29 @@ +From 4b3e00c2b4f33124dbc2cf94f472c66d5c44b4cc Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Wed, 7 Nov 2018 18:01:38 +0100 +Subject: [PATCH] fux typo + raise minimal version to 1.0.0 + +--- + ext/config.m4 | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/ext/config.m4 b/ext/config.m4 +index efddab5..675e00c 100644 +--- a/ext/config.m4 ++++ b/ext/config.m4 +@@ -12,13 +12,13 @@ if test $PHP_MAXMINDDB != "no"; then + AC_MSG_CHECKING(for libmaxminddb) + if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libmaxminddb; then + dnl retrieve build options from pkg-config +- if $PKG_CONFIG libzip --atleast-version 0; then ++ if $PKG_CONFIG libmaxminddb --atleast-version 1.0.0; then + LIBMAXMINDDB_INC=`$PKG_CONFIG libmaxminddb --cflags` + LIBMAXMINDDB_LIB=`$PKG_CONFIG libmaxminddb --libs` + LIBMAXMINDDB_VER=`$PKG_CONFIG libmaxminddb --modversion` + AC_MSG_RESULT(found version $LIBMAXMINDDB_VER) + else +- AC_MSG_ERROR(system libmaxminddb must be upgraded to version >= 0) ++ AC_MSG_ERROR(system libmaxminddb must be upgraded to version >= 1.0.0) + fi + PHP_EVAL_LIBLINE($LIBMAXMINDDB_LIB, MAXMINDDB_SHARED_LIBADD) + PHP_EVAL_INCLINE($LIBMAXMINDDB_INC) diff --git a/73320ff0c35fe102944eae1fb4ed36bfb7d63b18.patch b/73320ff0c35fe102944eae1fb4ed36bfb7d63b18.patch new file mode 100644 index 0000000..8bb6a66 --- /dev/null +++ b/73320ff0c35fe102944eae1fb4ed36bfb7d63b18.patch @@ -0,0 +1,49 @@ +From 73320ff0c35fe102944eae1fb4ed36bfb7d63b18 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Wed, 7 Nov 2018 14:18:00 +0100 +Subject: [PATCH] add MINFO method, and display both extension and library + versions + +--- + ext/maxminddb.c | 14 +++++++++++++- + 1 file changed, 13 insertions(+), 1 deletion(-) + +diff --git a/ext/maxminddb.c b/ext/maxminddb.c +index c0177df..6fd758f 100644 +--- a/ext/maxminddb.c ++++ b/ext/maxminddb.c +@@ -20,6 +20,7 @@ + #include + #include + #include "Zend/zend_exceptions.h" ++#include "ext/standard/info.h" + #include + + #ifdef ZTS +@@ -546,6 +547,17 @@ PHP_MINIT_FUNCTION(maxminddb){ + return SUCCESS; + } + ++static PHP_MINFO_FUNCTION(maxminddb) ++{ ++ php_info_print_table_start(); ++ ++ php_info_print_table_row(2, "MaxMind DB Reader", "enabled"); ++ php_info_print_table_row(2, "maxminddb extension version", PHP_MAXMINDDB_VERSION); ++ php_info_print_table_row(2, "libmaxminddb library version", MMDB_lib_version()); ++ ++ php_info_print_table_end(); ++} ++ + zend_module_entry maxminddb_module_entry = { + STANDARD_MODULE_HEADER, + PHP_MAXMINDDB_EXTNAME, +@@ -554,7 +566,7 @@ zend_module_entry maxminddb_module_entry = { + NULL, + NULL, + NULL, +- NULL, ++ PHP_MINFO(maxminddb), + PHP_MAXMINDDB_VERSION, + STANDARD_MODULE_PROPERTIES + }; diff --git a/PHPINFO b/PHPINFO index dda4c0f..d47b009 100644 --- a/PHPINFO +++ b/PHPINFO @@ -1,4 +1,6 @@ maxminddb -Version => 1.3.0 +MaxMind DB Reader => enabled +maxminddb extension version => 1.3.0 +libmaxminddb library version => 1.2.0 diff --git a/REFLECTION b/REFLECTION index 063d28e..502a5c1 100644 --- a/REFLECTION +++ b/REFLECTION @@ -17,15 +17,29 @@ Extension [ extension #113 maxminddb version 1.3.0 ] { - Methods [4] { Method [ public method __construct ] { + + - Parameters [1] { + Parameter #0 [ $db_file ] + } } Method [ public method close ] { + + - Parameters [0] { + } } Method [ public method get ] { + + - Parameters [1] { + Parameter #0 [ $ip_address ] + } } Method [ public method metadata ] { + + - Parameters [0] { + } } } } diff --git a/c8bf723822ef48f722b78cff240e886cb5907edd.patch b/c8bf723822ef48f722b78cff240e886cb5907edd.patch new file mode 100644 index 0000000..37efc3c --- /dev/null +++ b/c8bf723822ef48f722b78cff240e886cb5907edd.patch @@ -0,0 +1,61 @@ +From c8bf723822ef48f722b78cff240e886cb5907edd Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Wed, 7 Nov 2018 14:28:11 +0100 +Subject: [PATCH] add missing arginfo + +--- + ext/maxminddb.c | 19 +++++++++++++++---- + 1 file changed, 15 insertions(+), 4 deletions(-) + +diff --git a/ext/maxminddb.c b/ext/maxminddb.c +index c0177df..428ec65 100644 +--- a/ext/maxminddb.c ++++ b/ext/maxminddb.c +@@ -115,6 +115,10 @@ static inline maxminddb_obj *php_maxminddb_fetch_object(zend_object *obj TSRMLS_ + #endif + } + ++ZEND_BEGIN_ARG_INFO_EX(arginfo_maxmindbreader_construct, 0, 0, 1) ++ ZEND_ARG_INFO(0, db_file) ++ZEND_END_ARG_INFO() ++ + PHP_METHOD(MaxMind_Db_Reader, __construct){ + char *db_file = NULL; + strsize_t name_len; +@@ -150,6 +154,10 @@ PHP_METHOD(MaxMind_Db_Reader, __construct){ + mmdb_obj->mmdb = mmdb; + } + ++ZEND_BEGIN_ARG_INFO_EX(arginfo_maxmindbreader_get, 0, 0, 1) ++ ZEND_ARG_INFO(0, ip_address) ++ZEND_END_ARG_INFO() ++ + PHP_METHOD(MaxMind_Db_Reader, get){ + char *ip_address = NULL; + strsize_t name_len; +@@ -225,6 +233,9 @@ PHP_METHOD(MaxMind_Db_Reader, get){ + MMDB_free_entry_data_list(entry_data_list); + } + ++ZEND_BEGIN_ARG_INFO_EX(arginfo_maxmindbreader_void, 0, 0, 0) ++ZEND_END_ARG_INFO() ++ + PHP_METHOD(MaxMind_Db_Reader, metadata){ + if (ZEND_NUM_ARGS() != 0) { + THROW_EXCEPTION("InvalidArgumentException", +@@ -520,11 +531,11 @@ static zend_object_value maxminddb_create_handler( + + /* *INDENT-OFF* */ + static zend_function_entry maxminddb_methods[] = { +- PHP_ME(MaxMind_Db_Reader, __construct, NULL, ++ PHP_ME(MaxMind_Db_Reader, __construct, arginfo_maxmindbreader_construct, + ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) +- PHP_ME(MaxMind_Db_Reader, close, NULL, ZEND_ACC_PUBLIC) +- PHP_ME(MaxMind_Db_Reader, get, NULL, ZEND_ACC_PUBLIC) +- PHP_ME(MaxMind_Db_Reader, metadata, NULL, ZEND_ACC_PUBLIC) ++ PHP_ME(MaxMind_Db_Reader, close, arginfo_maxmindbreader_void, ZEND_ACC_PUBLIC) ++ PHP_ME(MaxMind_Db_Reader, get, arginfo_maxmindbreader_get, ZEND_ACC_PUBLIC) ++ PHP_ME(MaxMind_Db_Reader, metadata, arginfo_maxmindbreader_void, ZEND_ACC_PUBLIC) + { NULL, NULL, NULL } + }; + /* *INDENT-ON* */ diff --git a/d4d7845adb0b08d294a9255d9254b5f5cc6aba80.patch b/d4d7845adb0b08d294a9255d9254b5f5cc6aba80.patch new file mode 100644 index 0000000..d45ff8d --- /dev/null +++ b/d4d7845adb0b08d294a9255d9254b5f5cc6aba80.patch @@ -0,0 +1,50 @@ +From d4d7845adb0b08d294a9255d9254b5f5cc6aba80 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Wed, 7 Nov 2018 14:05:06 +0100 +Subject: [PATCH] retrieve build options from pkg-config + +--- + ext/config.m4 | 25 +++++++++++++++++++++++-- + 1 file changed, 23 insertions(+), 2 deletions(-) + +diff --git a/ext/config.m4 b/ext/config.m4 +index a08bb2c..efddab5 100644 +--- a/ext/config.m4 ++++ b/ext/config.m4 +@@ -6,13 +6,34 @@ PHP_ARG_ENABLE(maxminddb-debug, for MaxMind DB debug support, + [ --enable-maxminddb-debug Enable enable MaxMind DB deubg support], no, no) + + if test $PHP_MAXMINDDB != "no"; then +- PHP_CHECK_LIBRARY(maxminddb, MMDB_open) ++ ++ AC_PATH_PROG(PKG_CONFIG, pkg-config, no) ++ ++ AC_MSG_CHECKING(for libmaxminddb) ++ if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libmaxminddb; then ++ dnl retrieve build options from pkg-config ++ if $PKG_CONFIG libzip --atleast-version 0; then ++ LIBMAXMINDDB_INC=`$PKG_CONFIG libmaxminddb --cflags` ++ LIBMAXMINDDB_LIB=`$PKG_CONFIG libmaxminddb --libs` ++ LIBMAXMINDDB_VER=`$PKG_CONFIG libmaxminddb --modversion` ++ AC_MSG_RESULT(found version $LIBMAXMINDDB_VER) ++ else ++ AC_MSG_ERROR(system libmaxminddb must be upgraded to version >= 0) ++ fi ++ PHP_EVAL_LIBLINE($LIBMAXMINDDB_LIB, MAXMINDDB_SHARED_LIBADD) ++ PHP_EVAL_INCLINE($LIBMAXMINDDB_INC) ++ else ++ AC_MSG_RESULT(pkg-config information missing) ++ AC_MSG_WARN(will use libmaxmxinddb from compiler default path) ++ ++ PHP_CHECK_LIBRARY(maxminddb, MMDB_open) ++ PHP_ADD_LIBRARY(maxminddb, 1, MAXMINDDB_SHARED_LIBADD) ++ fi + + if test $PHP_MAXMINDDB_DEBUG != "no"; then + CFLAGS="$CFLAGS -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror" + fi + +- PHP_ADD_LIBRARY(maxminddb, 1, MAXMINDDB_SHARED_LIBADD) + PHP_SUBST(MAXMINDDB_SHARED_LIBADD) + + PHP_NEW_EXTENSION(maxminddb, maxminddb.c, $ext_shared) diff --git a/php-maxminddb.spec b/php-maxminddb.spec index a9a0eb5..4b3e7b5 100644 --- a/php-maxminddb.spec +++ b/php-maxminddb.spec @@ -25,19 +25,30 @@ Summary: MaxMind DB Reader extension Name: %{?sub_prefix}php-maxminddb Version: 1.3.0 -Release: 1%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} +Release: 2%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} License: ASL 2.0 URL: https://github.com/%{gh_owner}/%{gh_project} Source0: %{pkg_name}-%{version}-%{gh_short}.tgz Source1: makesrc.sh +# Upstream patches +Patch0: https://github.com/maxmind/MaxMind-DB-Reader-php/commit/d4d7845adb0b08d294a9255d9254b5f5cc6aba80.patch +Patch1: https://github.com/maxmind/MaxMind-DB-Reader-php/commit/73320ff0c35fe102944eae1fb4ed36bfb7d63b18.patch +Patch2: https://github.com/maxmind/MaxMind-DB-Reader-php/commit/c8bf723822ef48f722b78cff240e886cb5907edd.patch +Patch3: https://github.com/maxmind/MaxMind-DB-Reader-php/commit/4b3e00c2b4f33124dbc2cf94f472c66d5c44b4cc.patch + BuildRequires: %{?scl_prefix}php-devel -BuildRequires: libmaxminddb-devel +BuildRequires: pkgconfig(libmaxminddb) >= 1.0.0 Requires: %{?scl_prefix}php(zend-abi) = %{php_zend_api} Requires: %{?scl_prefix}php(api) = %{php_core_api} %{?_sclreq:Requires: %{?scl_prefix}runtime%{?_sclreq}%{?_isa}} +# Weak dependencies +%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8 +Recommends: geolite2-country +Suggests: geolite2-city +%endif %if "%{?vendor}" == "Remi Collet" && 0%{!?scl:1} && 0%{?rhel} %if "%{php_version}" > "5.6" @@ -81,6 +92,11 @@ Package built for PHP %(%{__php} -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSIO %prep %setup -q -n %{gh_project}-%{gh_commit} +%patch0 -p1 -b up0 +%patch1 -p1 -b up1 +%patch2 -p1 -b up2 +%patch3 -p1 -b up3 + mv ext NTS cd NTS @@ -187,5 +203,12 @@ REPORT_EXIT_STATUS=1 \ %changelog +* Thu Nov 8 2018 Remi Collet - 1.3.0-2 +- add upstream patches from merged PRs +- add weak dependencies on geolite2 databases + * Wed Nov 7 2018 Remi Collet - 1.3.0-1 - new package, version 1.3.0 +- open https://github.com/maxmind/MaxMind-DB-Reader-php/pull/73 pkg-config +- open https://github.com/maxmind/MaxMind-DB-Reader-php/pull/74 MINFO +- open https://github.com/maxmind/MaxMind-DB-Reader-php/pull/75 arginfo -- cgit