/[gentoo-x86]/eclass/depend.php.eclass
Gentoo

Contents of /eclass/depend.php.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.37 - (show annotations) (download)
Fri Jul 17 18:29:39 2015 UTC (5 weeks, 6 days ago) by grknight
Branch: MAIN
CVS Tags: HEAD
Changes since 1.36: +1 -339 lines
Remove deprecated functions from depend.php.eclass as announced 30 days ago

1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/depend.php.eclass,v 1.36 2015/06/24 13:36:03 grknight Exp $
4
5 # @DEAD
6 # @ECLASS: depend.php.eclass
7 # @MAINTAINER:
8 # Gentoo PHP team <php-bugs@gentoo.org>
9 # @AUTHOR:
10 # Author: Stuart Herbert <stuart@gentoo.org>
11 # Author: Luca Longinotti <chtekk@gentoo.org>
12 # Author: Jakub Moc <jakub@gentoo.org> (documentation)
13 # @BLURB: Functions to allow ebuilds to depend on php5 and check for specific features.
14 # @DESCRIPTION:
15 # This eclass provides functions that allow ebuilds to depend on php5 and check
16 # for specific PHP features, SAPIs etc. Also provides dodoc-php wrapper to install
17 # documentation for PHP packages to php-specific location.
18 # This eclass is deprecated and is set to be removed 30 days after bug 552836 is resolved
19
20 inherit eutils multilib
21
22 # PHP5-only depend functions
23
24 # @FUNCTION: need_php5
25 # @DESCRIPTION:
26 # Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP5
27 # (with any SAPI).
28 need_php5() {
29 DEPEND="${DEPEND} =dev-lang/php-5*"
30 RDEPEND="${RDEPEND} =dev-lang/php-5*"
31 PHP_VERSION="5"
32 PHP_SHARED_CAT="php5"
33 }
34
35 # common settings go in here
36 uses_php5() {
37 # cache this
38 libdir=$(get_libdir)
39
40 PHPIZE="/usr/${libdir}/php5/bin/phpize"
41 PHPCONFIG="/usr/${libdir}/php5/bin/php-config"
42 PHPCLI="/usr/${libdir}/php5/bin/php"
43 PHPCGI="/usr/${libdir}/php5/bin/php-cgi"
44 PHP_PKG="$(best_version =dev-lang/php-5*)"
45 PHPPREFIX="/usr/${libdir}/php5"
46 EXT_DIR="$(${PHPCONFIG} --extension-dir 2>/dev/null)"
47
48 einfo
49 einfo "Using ${PHP_PKG}"
50 einfo
51 }
52
53 # general PHP depend functions
54
55 # @FUNCTION: need_php_httpd
56 # @DESCRIPTION:
57 # Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP
58 # (any version) with either cgi or apache2 SAPI.
59 need_php_httpd() {
60 DEPEND="${DEPEND} virtual/httpd-php"
61 RDEPEND="${RDEPEND} virtual/httpd-php"
62 }
63
64 # @FUNCTION: need_php
65 # @DESCRIPTION:
66 # Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP
67 # (any version with any SAPI).
68 need_php() {
69 DEPEND="${DEPEND} dev-lang/php"
70 RDEPEND="${RDEPEND} dev-lang/php"
71 PHP_SHARED_CAT="php"
72 }
73
74 # @FUNCTION: has_php
75 # @DESCRIPTION:
76 # Call this function from your pkg_setup, src_compile, src_install etc. if you
77 # need to know which PHP version is being used and where the PHP binaries/data
78 # are installed.
79 has_php() {
80 # Detect which PHP version we have installed
81 if has_version '=dev-lang/php-5*' ; then
82 PHP_VERSION="5"
83 else
84 die "Unable to find an installed dev-lang/php package"
85 fi
86
87 # If we get here, then PHP_VERSION tells us which version of PHP we
88 # want to use
89 uses_php${PHP_VERSION}
90 }
91
92 # @FUNCTION: require_php_with_use
93 # @USAGE: <list of USE flags>
94 # @DESCRIPTION:
95 # Call this function from pkg_setup if your package requires PHP compiled
96 # with specific USE flags. Returns if all of the listed USE flags are enabled.
97 # Dies if any of the listed USE flags are disabled.
98
99 # @VARIABLE: PHPCHECKNODIE
100 # @DESCRIPTION:
101 # You can set PHPCHECKNODIE to non-empty value in your ebuild to chain multiple
102 # require_php_with_(any)_use checks without making the ebuild die on every failure.
103 # This is useful in cases when certain PHP features are only required if specific
104 # USE flag(s) are enabled for that ebuild.
105 # @CODE
106 # Example:
107 #
108 # local flags="pcre session snmp sockets wddx"
109 # use mysql && flags="${flags} mysql"
110 # use postgres && flags="${flags} postgres"
111 # if ! PHPCHECKNODIE="yes" require_php_with_use ${flags} \
112 # || ! PHPCHECKNODIE="yes" require_php_with_any_use gd gd-external ; then
113 # die "Re-install ${PHP_PKG} with ${flags} and either gd or gd-external"
114 # fi
115 # @CODE
116 require_php_with_use() {
117 has_php
118
119 local missing_use=""
120 local x
121
122 einfo "Checking for required PHP feature(s) ..."
123
124 for x in $@ ; do
125 case $x in
126 pcre|spl|reflection|mhash)
127 eqawarn "require_php_with_use MUST NOT check for the pcre, spl, mhash or reflection USE flag."
128 eqawarn "These USE flags are removed from >=dev-lang/php-5.3 and your ebuild will break"
129 eqawarn "if you check the USE flags against PHP 5.3 ebuilds."
130 eqawarn "Please use USE dependencies from EAPI 2 instead"
131 ;;
132 esac
133
134 if ! built_with_use =${PHP_PKG} ${x} ; then
135 einfo " Discovered missing USE flag: ${x}"
136 missing_use="${missing_use} ${x}"
137 fi
138 done
139
140 if [[ -z "${missing_use}" ]] ; then
141 if [[ -z "${PHPCHECKNODIE}" ]] ; then
142 return
143 else
144 return 0
145 fi
146 fi
147
148 if [[ -z "${PHPCHECKNODIE}" ]] ; then
149 eerror
150 eerror "${PHP_PKG} needs to be re-installed with all of the following"
151 eerror "USE flags enabled:"
152 eerror
153 eerror " $@"
154 eerror
155 die "Missing PHP USE flags found"
156 else
157 return 1
158 fi
159 }
160
161
162 # ========================================================================
163 # require_*() functions
164 #
165 # These functions die() if PHP was built without the required features
166 # ========================================================================
167
168 # @FUNCTION: require_php_cgi
169 # @DESCRIPTION:
170 # Determines which installed PHP version has the CGI SAPI enabled.
171 # Useful for anything which needs to run PHP scripts depending on the CGI SAPI.
172 # @RETURN: die if feature is missing
173 require_php_cgi() {
174 # If PHP_PKG is set, then we have remembered our PHP settings
175 # from last time
176 if [[ -n ${PHP_PKG} ]] ; then
177 return
178 fi
179
180 local PHP_PACKAGE_FOUND=""
181
182 if has_version '=dev-lang/php-5*' ; then
183 PHP_PACKAGE_FOUND="1"
184 pkg="$(best_version '=dev-lang/php-5*')"
185 if built_with_use =${pkg} cgi ; then
186 PHP_VERSION="5"
187 fi
188 fi
189
190 if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then
191 die "Unable to find an installed dev-lang/php package"
192 fi
193
194 if [[ -z ${PHP_VERSION} ]] ; then
195 die "No PHP CGI installed. Re-emerge dev-lang/php with USE=cgi."
196 fi
197
198 # If we get here, then PHP_VERSION tells us which version of PHP we
199 # want to use
200 uses_php${PHP_VERSION}
201 }
202
203 # ========================================================================
204 # Misc functions
205 #
206 # These functions provide miscellaneous checks and functionality.
207 # ========================================================================
208
209 # @FUNCTION: dodoc-php
210 # @USAGE: <list of docs>
211 # @DESCRIPTION:
212 # Alternative to dodoc function for use in our PHP eclasses and ebuilds.
213 # Stored here because depend.php gets always sourced everywhere in the PHP
214 # ebuilds and eclasses. It simply is dodoc with a changed path to the docs.
215 # NOTE: No support for docinto is provided!
216 dodoc-php() {
217 if [[ $# -lt 1 ]] ; then
218 echo "$0: at least one argument needed" 1>&2
219 exit 1
220 fi
221
222 phpdocdir="/usr/share/doc/${CATEGORY}/${PF}/"
223
224 for x in $@ ; do
225 if [[ -s "${x}" ]] ; then
226 insinto "${phpdocdir}"
227 doins "${x}"
228 gzip -f -9 "${D}/${phpdocdir}/${x##*/}"
229 elif [[ ! -e "${x}" ]] ; then
230 echo "dodoc-php: ${x} does not exist" 1>&2
231 fi
232 done
233 }
234
235 # @FUNCTION: dohtml-php
236 # @USAGE: <list of html docs>
237 # @DESCRIPTION:
238 # Alternative to dohtml function for use in our PHP eclasses and ebuilds.
239 # Stored here because depend.php gets always sourced everywhere in the PHP
240 # ebuilds and eclasses. It simply is dohtml with a changed path to the docs.
241 # NOTE: No support for [-a|-A|-p|-x] options is provided!
242 dohtml-php() {
243 if [[ $# -lt 1 ]] ; then
244 echo "$0: at least one argument needed" 1>&2
245 exit 1
246 fi
247
248 phphtmldir="/usr/share/doc/${CATEGORY}/${PF}/html"
249
250 for x in $@ ; do
251 if [[ -s "${x}" ]] ; then
252 insinto "${phphtmldir}"
253 doins "${x}"
254 elif [[ ! -e "${x}" ]] ; then
255 echo "dohtml-php: ${x} does not exist" 1>&2
256 fi
257 done
258 }

  ViewVC Help
Powered by ViewVC 1.1.20