dev-php/maxmind-db-reader: Fix SRC_URI; Drop 7-0; RESTRICT on USE test
[gentoo.git] / dev-php / maxmind-db-reader / maxmind-db-reader-1.4.1.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="7"
5
6 MY_PN="MaxMind-DB-Reader-php"
7 MY_P="${MY_PN}-${PV}"
8 S="${WORKDIR}/${MY_P}"
9 PHP_EXT_S="${S}/ext"
10 PHP_EXT_NAME="maxminddb"
11 PHP_EXT_OPTIONAL_USE="extension"
12
13 USE_PHP="php5-6 php7-1 php7-2 php7-3"
14
15 inherit php-ext-source-r3
16
17 DESCRIPTION="PHP reader for the MaxMind database format"
18 HOMEPAGE="https://github.com/maxmind/${MY_PN}"
19 SRC_URI="https://github.com/maxmind/${MY_PN}/archive/v${PV}.tar.gz -> ${MY_P}.tar.gz"
20
21 LICENSE="Apache-2.0"
22 SLOT="0"
23 KEYWORDS="~amd64"
24 IUSE="extension test"
25 RESTRICT="!test? ( test )"
26
27 DEPEND="extension? ( dev-libs/libmaxminddb )"
28 RDEPEND="${DEPEND}"
29
30 src_prepare(){
31         # We need to call eapply_user ourselves, because it may be skipped
32         # if either the "extension" USE flag is not set, or if the user's
33         # PHP_TARGETS is essentially empty. In the latter case, the eclass
34         # src_prepare does nothing. We only call the eclass phase conditionally
35         # because the correct version of e.g. "phpize" may not be there
36         # unless USE=extension is set.
37         if use extension ; then
38                 php-ext-source-r3_src_prepare
39         else
40                 default
41         fi
42 }
43
44 src_configure() {
45         # The eclass phase will try to run the ./configure script even if it
46         # doesn't exist (in contrast to the default src_configure), so we
47         # need to skip it if the eclass src_prepare (that creates said
48         # script) is not run.
49         use extension && php-ext-source-r3_src_configure
50 }
51
52 src_compile() {
53         # Avoids the same problem as in src_configure.
54         use extension && php-ext-source-r3_src_compile
55 }
56
57 src_install() {
58         dodoc CHANGELOG.md README.md
59         insinto /usr/share/php
60         doins -r src/MaxMind
61         insinto /usr/share/php/MaxMind/Db
62         doins autoload.php
63
64         use extension && php-ext-source-r3_src_install
65 }
66
67 src_test() {
68         # The PHP API has its own set of tests that isn't shipped with the
69         # release tarballs at the moment (github issues 55).
70         use extension && php-ext-source-r3_src_test
71 }
72
73 pkg_postinst(){
74         elog "${PN} has been installed in /usr/share/php/MaxMind/Db/."
75         elog "To use it in a script, require('MaxMind/Db/autoload.php'),"
76         elog "and then most of the examples in the documentation should"
77         elog "work without further modification."
78 }