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

Contents of /eclass/depend.php.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.37 - (hide annotations) (download)
Fri Jul 17 18:29:39 2015 UTC (6 weeks, 3 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 grknight 1.33 # Copyright 1999-2015 Gentoo Foundation
2 stuart 1.1 # Distributed under the terms of the GNU General Public License v2
3 grknight 1.37 # $Header: /var/cvsroot/gentoo-x86/eclass/depend.php.eclass,v 1.36 2015/06/24 13:36:03 grknight Exp $
4 jokey 1.21
5 grknight 1.36 # @DEAD
6 vapier 1.30 # @ECLASS: depend.php.eclass
7     # @MAINTAINER:
8     # Gentoo PHP team <php-bugs@gentoo.org>
9     # @AUTHOR:
10 jokey 1.21 # Author: Stuart Herbert <stuart@gentoo.org>
11     # Author: Luca Longinotti <chtekk@gentoo.org>
12     # Author: Jakub Moc <jakub@gentoo.org> (documentation)
13 mabi 1.26 # @BLURB: Functions to allow ebuilds to depend on php5 and check for specific features.
14 jokey 1.21 # @DESCRIPTION:
15 mabi 1.26 # This eclass provides functions that allow ebuilds to depend on php5 and check
16 jokey 1.21 # for specific PHP features, SAPIs etc. Also provides dodoc-php wrapper to install
17     # documentation for PHP packages to php-specific location.
18 grknight 1.36 # This eclass is deprecated and is set to be removed 30 days after bug 552836 is resolved
19 chtekk 1.18
20 grknight 1.35 inherit eutils multilib
21 stuart 1.1
22 trapni 1.4 # PHP5-only depend functions
23 jokey 1.21
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 chtekk 1.12 need_php5() {
29 stuart 1.1 DEPEND="${DEPEND} =dev-lang/php-5*"
30     RDEPEND="${RDEPEND} =dev-lang/php-5*"
31 chtekk 1.12 PHP_VERSION="5"
32 stuart 1.1 PHP_SHARED_CAT="php5"
33     }
34    
35     # common settings go in here
36 chtekk 1.12 uses_php5() {
37 stuart 1.1 # 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 armin76 1.22 PHP_PKG="$(best_version =dev-lang/php-5*)"
45 stuart 1.1 PHPPREFIX="/usr/${libdir}/php5"
46 armin76 1.22 EXT_DIR="$(${PHPCONFIG} --extension-dir 2>/dev/null)"
47 stuart 1.1
48     einfo
49     einfo "Using ${PHP_PKG}"
50     einfo
51     }
52    
53 trapni 1.4 # general PHP depend functions
54 jokey 1.21
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 chtekk 1.12 need_php_httpd() {
60 trapni 1.4 DEPEND="${DEPEND} virtual/httpd-php"
61     RDEPEND="${RDEPEND} virtual/httpd-php"
62     }
63    
64 jokey 1.21 # @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 chtekk 1.12 need_php() {
69 stuart 1.1 DEPEND="${DEPEND} dev-lang/php"
70     RDEPEND="${RDEPEND} dev-lang/php"
71     PHP_SHARED_CAT="php"
72     }
73    
74 jokey 1.21 # @FUNCTION: has_php
75     # @DESCRIPTION:
76     # Call this function from your pkg_setup, src_compile, src_install etc. if you
77 swegener 1.23 # need to know which PHP version is being used and where the PHP binaries/data
78 jokey 1.21 # are installed.
79 chtekk 1.12 has_php() {
80 armin76 1.25 # 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 chtekk 1.12 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 jokey 1.21 # @FUNCTION: require_php_with_use
93     # @USAGE: <list of USE flags>
94     # @DESCRIPTION:
95 chtekk 1.12 # Call this function from pkg_setup if your package requires PHP compiled
96 jokey 1.21 # 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 stuart 1.1
99 jokey 1.21 # @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 swegener 1.23 # This is useful in cases when certain PHP features are only required if specific
104 jokey 1.21 # 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 chtekk 1.12 require_php_with_use() {
117 stuart 1.1 has_php
118    
119 chtekk 1.11 local missing_use=""
120 stuart 1.1 local x
121    
122 chtekk 1.14 einfo "Checking for required PHP feature(s) ..."
123 stuart 1.1
124     for x in $@ ; do
125 olemarkus 1.27 case $x in
126 olemarkus 1.28 pcre|spl|reflection|mhash)
127     eqawarn "require_php_with_use MUST NOT check for the pcre, spl, mhash or reflection USE flag."
128 olemarkus 1.27 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 grknight 1.35 if ! built_with_use =${PHP_PKG} ${x} ; then
135 chtekk 1.14 einfo " Discovered missing USE flag: ${x}"
136 stuart 1.1 missing_use="${missing_use} ${x}"
137     fi
138     done
139    
140 chtekk 1.15 if [[ -z "${missing_use}" ]] ; then
141     if [[ -z "${PHPCHECKNODIE}" ]] ; then
142     return
143     else
144     return 0
145     fi
146 stuart 1.1 fi
147    
148 chtekk 1.15 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 stuart 1.1 }
160    
161 chtekk 1.12
162 stuart 1.1 # ========================================================================
163     # require_*() functions
164     #
165 chtekk 1.12 # These functions die() if PHP was built without the required features
166 stuart 1.1 # ========================================================================
167    
168 jokey 1.21 # @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 chtekk 1.12 require_php_cgi() {
174     # If PHP_PKG is set, then we have remembered our PHP settings
175 hollow 1.3 # from last time
176 chtekk 1.11 if [[ -n ${PHP_PKG} ]] ; then
177 hollow 1.3 return
178     fi
179    
180 chtekk 1.12 local PHP_PACKAGE_FOUND=""
181    
182 sebastian 1.9 if has_version '=dev-lang/php-5*' ; then
183 chtekk 1.12 PHP_PACKAGE_FOUND="1"
184 armin76 1.22 pkg="$(best_version '=dev-lang/php-5*')"
185 grknight 1.35 if built_with_use =${pkg} cgi ; then
186 chtekk 1.12 PHP_VERSION="5"
187 hollow 1.3 fi
188 sebastian 1.9 fi
189 chtekk 1.11
190     if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then
191 hollow 1.3 die "Unable to find an installed dev-lang/php package"
192     fi
193    
194 chtekk 1.11 if [[ -z ${PHP_VERSION} ]] ; then
195 hoffie 1.20 die "No PHP CGI installed. Re-emerge dev-lang/php with USE=cgi."
196 hollow 1.3 fi
197    
198 chtekk 1.12 # If we get here, then PHP_VERSION tells us which version of PHP we
199 hollow 1.3 # want to use
200 stuart 1.1 uses_php${PHP_VERSION}
201     }
202    
203 chtekk 1.6 # ========================================================================
204     # Misc functions
205     #
206     # These functions provide miscellaneous checks and functionality.
207     # ========================================================================
208    
209 jokey 1.21 # @FUNCTION: dodoc-php
210     # @USAGE: <list of docs>
211     # @DESCRIPTION:
212     # Alternative to dodoc function for use in our PHP eclasses and ebuilds.
213 swegener 1.23 # Stored here because depend.php gets always sourced everywhere in the PHP
214 jokey 1.21 # ebuilds and eclasses. It simply is dodoc with a changed path to the docs.
215     # NOTE: No support for docinto is provided!
216 chtekk 1.12 dodoc-php() {
217     if [[ $# -lt 1 ]] ; then
218 chtekk 1.6 echo "$0: at least one argument needed" 1>&2
219     exit 1
220     fi
221    
222 armin76 1.24 phpdocdir="/usr/share/doc/${CATEGORY}/${PF}/"
223 chtekk 1.6
224 armin76 1.24 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 chtekk 1.6 fi
247    
248 armin76 1.24 phphtmldir="/usr/share/doc/${CATEGORY}/${PF}/html"
249    
250 chtekk 1.12 for x in $@ ; do
251     if [[ -s "${x}" ]] ; then
252 armin76 1.24 insinto "${phphtmldir}"
253     doins "${x}"
254 chtekk 1.12 elif [[ ! -e "${x}" ]] ; then
255 armin76 1.24 echo "dohtml-php: ${x} does not exist" 1>&2
256 chtekk 1.6 fi
257     done
258     }

  ViewVC Help
Powered by ViewVC 1.1.20