From 80d52ea829aac43e9a067b6a8f3e010c221de717 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sun, 5 Nov 2017 17:52:19 -0500 Subject: [PATCH] dev-php/maxmind-db-reader: new PHP interface to the MaxMind databases. Add the new (Composer-based) PHP interface to the MaxMind binary database format. This lets you query the newer "mmdb" files directly, from PHP code. There is an optional C extension that can be built with USE=extension, and which ostensibly (but I have not tested this) improves performance through the use of dev-libs/libmaxminddb. Thanks to Steffen Weber for the initial ebuild. Reported-by: Steffen Weber Closes: https://bugs.gentoo.org/511088 Package-Manager: Portage-2.3.8, Repoman-2.3.3 --- dev-php/maxmind-db-reader/Manifest | 1 + dev-php/maxmind-db-reader/files/autoload.php | 6 ++ .../maxmind-db-reader-1.2.0.ebuild | 85 +++++++++++++++++++ dev-php/maxmind-db-reader/metadata.xml | 16 ++++ 4 files changed, 108 insertions(+) create mode 100644 dev-php/maxmind-db-reader/Manifest create mode 100644 dev-php/maxmind-db-reader/files/autoload.php create mode 100644 dev-php/maxmind-db-reader/maxmind-db-reader-1.2.0.ebuild create mode 100644 dev-php/maxmind-db-reader/metadata.xml diff --git a/dev-php/maxmind-db-reader/Manifest b/dev-php/maxmind-db-reader/Manifest new file mode 100644 index 000000000000..b4042bc78051 --- /dev/null +++ b/dev-php/maxmind-db-reader/Manifest @@ -0,0 +1 @@ +DIST MaxMind-DB-Reader-php-1.2.0.tar.gz 17488 SHA256 b1d0166ac9d7a2df2ec33c2fd3e2ccfcb556f013c8f58df3610e08bbf7e9c383 SHA512 2965c5348ec787e503c04322961b00fe7806cd95c5f711efd9833adc0acb21f0c40cab1983868f8ea0bb4e8576186d83e1e1913b203aab999f3870ea298a9b2a WHIRLPOOL 6059929c7b6e10ceafc4d50b7b2af2162c5a6e3b4dfc7390bd6b7adebca69de1847a01632e63c4b7de09581fdbd3c21dabe3c5182346d503228fd8e0112ad366 diff --git a/dev-php/maxmind-db-reader/files/autoload.php b/dev-php/maxmind-db-reader/files/autoload.php new file mode 100644 index 000000000000..45e8c2dfba31 --- /dev/null +++ b/dev-php/maxmind-db-reader/files/autoload.php @@ -0,0 +1,6 @@ + ${MY_P}.tar.gz" + +LICENSE="Apache-2.0" +SLOT="0" +KEYWORDS="~amd64" +IUSE="extension test" + +COMMON_DEPEND="extension? ( dev-libs/libmaxminddb )" +DEPEND="${COMMON_DEPEND}" +RDEPEND="${COMMON_DEPEND} + dev-php/fedora-autoloader" + +src_unpack() { + # Don't make copies of the source tree if they won't be used. + if use extension; then + php-ext-source-r3_src_unpack + else + default + fi +} + +src_prepare(){ + # We need to call eapply_user ourselves, because it may be skipped + # if either the "extension" USE flag is not set, or if the user's + # PHP_TARGETS is essentially empty. In the latter case, the eclass + # src_prepare does nothing. We only call the eclass phase conditionally + # because the correct version of e.g. "phpize" may not be there + # unless USE=extension is set. + eapply_user + use extension && php-ext-source-r3_src_prepare +} + +src_configure() { + # The eclass phase will try to run the ./configure script even if it + # doesn't exist (in contrast to the default src_configure), so we + # need to skip it if the eclass src_prepare (that creates said + # script) is not run. + use extension && php-ext-source-r3_src_configure +} + +src_compile() { + # Avoids the same problem as in src_configure. + use extension && php-ext-source-r3_src_compile +} + +src_install() { + dodoc CHANGELOG.md README.md + insinto /usr/share/php + doins -r src/MaxMind + insinto /usr/share/php/MaxMind/Db + doins "${FILESDIR}/autoload.php" + + use extension && php-ext-source-r3_src_install +} + +src_test() { + # The PHP API has its own set of tests that isn't shipped with the + # release tarballs at the moment (github issues 55). + use extension && php-ext-source-r3_src_test +} + +pkg_postinst(){ + elog "${PN} has been installed in /usr/share/php/MaxMind/Db/." + elog "To use it in a script, require('MaxMind/Db/autoload.php')," + elog "and then most of the examples in the documentation should" + elog "work without further modification." +} diff --git a/dev-php/maxmind-db-reader/metadata.xml b/dev-php/maxmind-db-reader/metadata.xml new file mode 100644 index 000000000000..c6051cdbefb0 --- /dev/null +++ b/dev-php/maxmind-db-reader/metadata.xml @@ -0,0 +1,16 @@ + + + + + php-bugs@gentoo.org + PHP + + + + Build the C extension that uses dev-libs/libmaxminddb + + + + maxmind/MaxMind-DB-Reader-php + + -- 2.26.2