Commit | Line | Data |
---|---|---|
1845c2a4 JL |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2016 Julien Lepiller <julien@lepiller.eu> | |
3 | ;;; Copyright © 2016 Marius Bakke <mbakke@fastmail.com> | |
bb47da4a | 4 | ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr> |
1845c2a4 JL |
5 | ;;; |
6 | ;;; This file is part of GNU Guix. | |
7 | ;;; | |
8 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
9 | ;;; under the terms of the GNU General Public License as published by | |
10 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
11 | ;;; your option) any later version. | |
12 | ;;; | |
13 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
14 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | ;;; GNU General Public License for more details. | |
17 | ;;; | |
18 | ;;; You should have received a copy of the GNU General Public License | |
19 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
20 | ||
21 | (define-module (gnu packages php) | |
22 | #:use-module (gnu packages) | |
23 | #:use-module (gnu packages algebra) | |
24 | #:use-module (gnu packages aspell) | |
25 | #:use-module (gnu packages base) | |
26 | #:use-module (gnu packages bison) | |
27 | #:use-module (gnu packages compression) | |
28 | #:use-module (gnu packages curl) | |
29 | #:use-module (gnu packages cyrus-sasl) | |
30 | #:use-module (gnu packages databases) | |
31 | #:use-module (gnu packages fontutils) | |
32 | #:use-module (gnu packages gd) | |
33 | #:use-module (gnu packages gettext) | |
34 | #:use-module (gnu packages glib) | |
35 | #:use-module (gnu packages gnupg) | |
36 | #:use-module (gnu packages image) | |
37 | #:use-module (gnu packages linux) | |
38 | #:use-module (gnu packages multiprecision) | |
39 | #:use-module (gnu packages openldap) | |
40 | #:use-module (gnu packages pcre) | |
41 | #:use-module (gnu packages pkg-config) | |
42 | #:use-module (gnu packages readline) | |
43 | #:use-module (gnu packages textutils) | |
44 | #:use-module (gnu packages tls) | |
45 | #:use-module (gnu packages web) | |
46 | #:use-module (gnu packages xml) | |
47 | #:use-module (gnu packages xorg) | |
1845c2a4 JL |
48 | #:use-module (guix packages) |
49 | #:use-module (guix download) | |
50 | #:use-module (guix build-system gnu) | |
1a3e7534 | 51 | #:use-module (guix utils) |
1845c2a4 JL |
52 | #:use-module ((guix licenses) #:prefix license:)) |
53 | ||
1845c2a4 JL |
54 | (define-public php |
55 | (package | |
56 | (name "php") | |
ebcb58c9 | 57 | (version "7.3.0") |
1845c2a4 JL |
58 | (home-page "https://secure.php.net/") |
59 | (source (origin | |
60 | (method url-fetch) | |
61 | (uri (string-append home-page "distributions/" | |
62 | name "-" version ".tar.xz")) | |
63 | (sha256 | |
64 | (base32 | |
ebcb58c9 | 65 | "1db0lm84hynilrjj3k1s7skp1y2gl4ip1ihr7662i2xgannmq6bx")) |
1845c2a4 JL |
66 | (modules '((guix build utils))) |
67 | (snippet | |
68 | '(with-directory-excursion "ext" | |
69 | (for-each delete-file-recursively | |
70 | ;; Some of the bundled libraries have no proper upstream. | |
71 | ;; Ideally we'd extract these out as separate packages: | |
72 | ;;"mbstring/libmbfl" | |
73 | ;;"date/lib" | |
74 | ;;"bcmath/libbcmath" | |
75 | ;;"fileinfo/libmagic" ; This is a patched version of libmagic. | |
76 | '("gd/libgd" | |
77 | "mbstring/oniguruma" | |
ebcb58c9 | 78 | "pcre/pcre2lib" |
1845c2a4 JL |
79 | "sqlite3/libsqlite" |
80 | "xmlrpc/libxmlrpc" | |
6cbee49d MW |
81 | "zip/lib")) |
82 | #t)))) | |
1845c2a4 JL |
83 | (build-system gnu-build-system) |
84 | (arguments | |
85 | '(#:configure-flags | |
86 | (let-syntax ((with (syntax-rules () | |
87 | ((_ option input) | |
88 | (string-append option "=" | |
89 | (assoc-ref %build-inputs input)))))) | |
90 | (list (with "--with-bz2" "bzip2") | |
91 | (with "--with-curl" "curl") | |
92 | (with "--with-freetype-dir" "freetype") | |
93 | (with "--with-gd" "gd") | |
94 | (with "--with-gdbm" "gdbm") | |
95 | (with "--with-gettext" "glibc") ; libintl.h | |
96 | (with "--with-gmp" "gmp") | |
97 | (with "--with-jpeg-dir" "libjpeg") | |
98 | (with "--with-ldap" "openldap") | |
99 | (with "--with-ldap-sasl" "cyrus-sasl") | |
100 | (with "--with-libzip" "zip") | |
101 | (with "--with-libxml-dir" "libxml2") | |
102 | (with "--with-onig" "oniguruma") | |
103 | (with "--with-pcre-dir" "pcre") | |
104 | (with "--with-pcre-regex" "pcre") | |
105 | (with "--with-pdo-pgsql" "postgresql") | |
106 | (with "--with-pdo-sqlite" "sqlite") | |
107 | (with "--with-pgsql" "postgresql") | |
108 | (with "--with-png-dir" "libpng") | |
109 | ;; PHP’s Pspell extension, while retaining its current name, | |
110 | ;; now uses the Aspell library. | |
111 | (with "--with-pspell" "aspell") | |
112 | (with "--with-readline" "readline") | |
113 | (with "--with-sqlite3" "sqlite") | |
114 | (with "--with-tidy" "tidy") | |
115 | (with "--with-webp-dir" "libwebp") | |
116 | (with "--with-xpm-dir" "libxpm") | |
117 | (with "--with-xsl" "libxslt") | |
118 | (with "--with-zlib-dir" "zlib") | |
119 | ;; We could add "--with-snmp", but it requires netsnmp that | |
120 | ;; we don't have a package for. It is used to build the snmp | |
121 | ;; extension of php. | |
122 | "--with-iconv" | |
123 | "--with-openssl" | |
0e40b755 | 124 | "--with-mysqli" ; Required for, e.g. wordpress |
1845c2a4 JL |
125 | "--with-pdo-mysql" |
126 | "--with-zlib" | |
127 | "--enable-calendar" | |
128 | "--enable-dba=shared" | |
129 | "--enable-exif" | |
130 | "--enable-flatfile" | |
131 | "--enable-fpm" | |
132 | "--enable-ftp" | |
133 | "--enable-inifile" | |
134 | "--enable-mbstring" | |
135 | "--enable-pcntl" | |
4cd1d1c1 | 136 | "--enable-sockets")) |
1845c2a4 JL |
137 | #:phases |
138 | (modify-phases %standard-phases | |
139 | (add-after 'unpack 'do-not-record-build-flags | |
140 | (lambda _ | |
141 | ;; Prevent configure flags from being stored and causing | |
142 | ;; unnecessary runtime dependencies. | |
143 | (substitute* "scripts/php-config.in" | |
144 | (("@CONFIGURE_OPTIONS@") "") | |
145 | (("@PHP_LDFLAGS@") "")) | |
146 | ;; This file has ISO-8859-1 encoding. | |
147 | (with-fluids ((%default-port-encoding "ISO-8859-1")) | |
148 | (substitute* "main/build-defs.h.in" | |
149 | (("@CONFIGURE_COMMAND@") "(omitted)"))) | |
150 | #t)) | |
151 | (add-before 'build 'patch-/bin/sh | |
152 | (lambda _ | |
153 | (substitute* '("run-tests.php" "ext/standard/proc_open.c") | |
154 | (("/bin/sh") (which "sh"))) | |
155 | #t)) | |
156 | (add-before 'check 'prepare-tests | |
157 | (lambda _ | |
158 | ;; Some of these files have ISO-8859-1 encoding, whereas others | |
159 | ;; use ASCII, so we can't use a "catch-all" find-files here. | |
160 | (with-fluids ((%default-port-encoding "ISO-8859-1")) | |
161 | (substitute* '("ext/mbstring/tests/mb_send_mail02.phpt" | |
162 | "ext/mbstring/tests/mb_send_mail04.phpt" | |
163 | "ext/mbstring/tests/mb_send_mail05.phpt" | |
164 | "ext/mbstring/tests/mb_send_mail06.phpt") | |
165 | (("/bin/cat") (which "cat")))) | |
166 | (substitute* '("ext/mbstring/tests/mb_send_mail01.phpt" | |
167 | "ext/mbstring/tests/mb_send_mail03.phpt" | |
168 | "ext/mbstring/tests/bug52861.phpt" | |
169 | "ext/standard/tests/general_functions/bug34794.phpt" | |
170 | "ext/standard/tests/general_functions/bug44667.phpt" | |
171 | "ext/standard/tests/general_functions/proc_open.phpt") | |
172 | (("/bin/cat") (which "cat"))) | |
60a50806 | 173 | |
1845c2a4 JL |
174 | ;; The encoding of this file is not recognized, so we simply drop it. |
175 | (delete-file "ext/mbstring/tests/mb_send_mail07.phpt") | |
176 | ||
177 | (substitute* "ext/standard/tests/streams/bug60602.phpt" | |
178 | (("'ls'") (string-append "'" (which "ls") "'"))) | |
179 | ||
180 | ;; Drop tests that are known to fail. | |
181 | (for-each delete-file | |
182 | '("ext/posix/tests/posix_getgrgid.phpt" ; Requires /etc/group. | |
183 | "ext/sockets/tests/bug63000.phpt" ; Fails to detect OS. | |
184 | "ext/sockets/tests/socket_shutdown.phpt" ; Requires DNS. | |
185 | "ext/sockets/tests/socket_send.phpt" ; Likewise. | |
186 | "ext/sockets/tests/mcast_ipv4_recv.phpt" ; Requires multicast. | |
187 | ;; These needs /etc/services. | |
188 | "ext/standard/tests/general_functions/getservbyname_basic.phpt" | |
189 | "ext/standard/tests/general_functions/getservbyport_basic.phpt" | |
190 | "ext/standard/tests/general_functions/getservbyport_variation1.phpt" | |
191 | ;; And /etc/protocols. | |
192 | "ext/standard/tests/network/getprotobyname_basic.phpt" | |
193 | "ext/standard/tests/network/getprotobynumber_basic.phpt" | |
194 | ;; And exotic locales. | |
195 | "ext/standard/tests/strings/setlocale_basic1.phpt" | |
196 | "ext/standard/tests/strings/setlocale_basic2.phpt" | |
197 | "ext/standard/tests/strings/setlocale_basic3.phpt" | |
198 | "ext/standard/tests/strings/setlocale_variation1.phpt" | |
199 | ||
200 | ;; XXX: These gd tests fails. Likely because our version | |
201 | ;; is different from the (patched) bundled one. | |
202 | ;; Here, gd quits immediately after "fatal libpng error"; while the | |
203 | ;; test expects it to additionally return a "setjmp" error and warning. | |
204 | "ext/gd/tests/bug39780_extern.phpt" | |
205 | "ext/gd/tests/libgd00086_extern.phpt" | |
206 | ;; Extra newline in gd-png output. | |
207 | "ext/gd/tests/bug45799.phpt" | |
208 | ;; Different error message than expected from imagecrop(). | |
209 | "ext/gd/tests/bug66356.phpt" | |
210 | ;; Similarly for imagecreatefromgd2(). | |
211 | "ext/gd/tests/bug72339.phpt" | |
212 | ;; Call to undefined function imageantialias(). They are | |
213 | ;; supposed to fail anyway. | |
214 | "ext/gd/tests/bug72482.phpt" | |
215 | "ext/gd/tests/bug72482_2.phpt" | |
216 | "ext/gd/tests/bug73213.phpt" | |
217 | ;; Test expects generic "gd warning" but gets the actual function name. | |
218 | "ext/gd/tests/createfromwbmp2_extern.phpt" | |
202e235e JL |
219 | ;; This bug should have been fixed in gd 2.2.2. |
220 | ;; Is it a regression? | |
221 | "ext/gd/tests/bug65148.phpt" | |
1845c2a4 JL |
222 | ;; TODO: Enable these when libgd is built with xpm support. |
223 | "ext/gd/tests/xpm2gd.phpt" | |
224 | "ext/gd/tests/xpm2jpg.phpt" | |
225 | "ext/gd/tests/xpm2png.phpt" | |
226 | ||
227 | ;; XXX: These iconv tests have the expected outcome, | |
228 | ;; but with different error messages. | |
229 | ;; Expects "illegal character", instead gets "unknown error (84)". | |
230 | "ext/iconv/tests/bug52211.phpt" | |
63657921 | 231 | "ext/iconv/tests/bug60494.phpt" |
1845c2a4 JL |
232 | ;; Expects "wrong charset", gets unknown error (22). |
233 | "ext/iconv/tests/iconv_mime_decode_variation3.phpt" | |
234 | "ext/iconv/tests/iconv_strlen_error2.phpt" | |
235 | "ext/iconv/tests/iconv_strlen_variation2.phpt" | |
236 | "ext/iconv/tests/iconv_substr_error2.phpt" | |
237 | ;; Expects conversion error, gets "error condition Termsig=11". | |
238 | "ext/iconv/tests/iconv_strpos_error2.phpt" | |
239 | "ext/iconv/tests/iconv_strrpos_error2.phpt" | |
240 | ;; Similar, but iterating over multiple values. | |
241 | ;; iconv breaks the loop after the first error with Termsig=11. | |
242 | "ext/iconv/tests/iconv_strpos_variation4.phpt" | |
243 | "ext/iconv/tests/iconv_strrpos_variation3.phpt" | |
16dc5ed0 JL |
244 | ;; Expects "invalid multibyte sequence" but got |
245 | ;; "unknown error". | |
246 | "ext/iconv/tests/bug76249.phpt" | |
1845c2a4 JL |
247 | |
248 | ;; XXX: These test failures appear legitimate, needs investigation. | |
249 | ;; open_basedir() restriction failure. | |
250 | "ext/curl/tests/bug61948.phpt" | |
251 | ;; Expects a false boolean, gets empty array from glob(). | |
252 | "ext/standard/tests/file/bug41655_1.phpt" | |
253 | "ext/standard/tests/file/glob_variation5.phpt" | |
254 | ;; Test output is correct, but in wrong order. | |
255 | "ext/standard/tests/streams/proc_open_bug64438.phpt" | |
256 | ;; The test expects an Array, but instead get the contents(?). | |
257 | "ext/gd/tests/bug43073.phpt" | |
258 | ;; imagettftext() returns wrong coordinates. | |
60a50806 | 259 | "ext/gd/tests/bug48732-mb.phpt" |
1845c2a4 JL |
260 | "ext/gd/tests/bug48732.phpt" |
261 | ;; Similarly for imageftbbox(). | |
60a50806 | 262 | "ext/gd/tests/bug48801-mb.phpt" |
1845c2a4 JL |
263 | "ext/gd/tests/bug48801.phpt" |
264 | ;; Different expected output from imagecolorallocate(). | |
265 | "ext/gd/tests/bug53504.phpt" | |
266 | ;; Wrong image size after scaling an image. | |
267 | "ext/gd/tests/bug73272.phpt" | |
268 | ;; Expects iconv to detect illegal characters, instead gets | |
269 | ;; "unknown error (84)" and heap corruption(!). | |
270 | "ext/iconv/tests/bug48147.phpt" | |
271 | ;; Expects illegal character ".", gets "=?utf-8?Q?." | |
272 | "ext/iconv/tests/bug51250.phpt" | |
273 | ;; @iconv() does not return expected output. | |
274 | "ext/iconv/tests/iconv003.phpt" | |
275 | ;; iconv throws "buffer length exceeded" on some string checks. | |
276 | "ext/iconv/tests/iconv_mime_encode.phpt" | |
277 | ;; file_get_contents(): iconv stream filter | |
278 | ;; ("ISO-8859-1"=>"UTF-8") unknown error. | |
279 | "ext/standard/tests/file/bug43008.phpt" | |
280 | ;; Table data not created in sqlite(?). | |
dd1f60ec JL |
281 | "ext/pdo_sqlite/tests/bug_42589.phpt" |
282 | ||
283 | ;; Small variation in output. | |
284 | "ext/mbstring/tests/mb_ereg_variation3.phpt" | |
285 | "ext/mbstring/tests/mb_ereg_replace_variation1.phpt" | |
286 | "ext/mbstring/tests/bug72994.phpt" | |
16dc5ed0 JL |
287 | "ext/ldap/tests/ldap_set_option_error.phpt" |
288 | ||
289 | ;; Sometimes cannot start the LDAP server. | |
ebcb58c9 OP |
290 | "ext/ldap/tests/bug76248.phpt" |
291 | ||
292 | ;; Bug #76909 preg_match difference between 7.3 and < 7.3 | |
293 | "ext/pcre/tests/bug76909.phpt")) | |
1845c2a4 JL |
294 | |
295 | ;; Skip tests requiring network access. | |
296 | (setenv "SKIP_ONLINE_TESTS" "1") | |
297 | ;; Without this variable, 'make test' passes regardless of failures. | |
298 | (setenv "REPORT_EXIT_STATUS" "1") | |
dd1f60ec JL |
299 | ;; Skip tests requiring I/O facilities that are unavailable in the |
300 | ;; build environment | |
301 | (setenv "SKIP_IO_CAPTURE_TESTS" "1") | |
1845c2a4 JL |
302 | #t))) |
303 | #:test-target "test")) | |
304 | (inputs | |
305 | `(("aspell" ,aspell) | |
306 | ("bzip2" ,bzip2) | |
307 | ("curl" ,curl) | |
308 | ("cyrus-sasl" ,cyrus-sasl) | |
309 | ("freetype" ,freetype) | |
68a08dfb | 310 | ("gd" ,gd) |
1845c2a4 JL |
311 | ("gdbm" ,gdbm) |
312 | ("glibc" ,glibc) | |
313 | ("gmp" ,gmp) | |
60a50806 | 314 | ("gnutls" ,gnutls) |
1845c2a4 JL |
315 | ("libgcrypt" ,libgcrypt) |
316 | ("libjpeg" ,libjpeg) | |
317 | ("libpng" ,libpng) | |
318 | ("libwebp" ,libwebp) | |
319 | ("libxml2" ,libxml2) | |
320 | ("libxpm" ,libxpm) | |
321 | ("libxslt" ,libxslt) | |
322 | ("libx11" ,libx11) | |
d5019f9c | 323 | ("oniguruma" ,oniguruma-5) |
1845c2a4 JL |
324 | ("openldap" ,openldap) |
325 | ("openssl" ,openssl) | |
ebcb58c9 | 326 | ("pcre" ,pcre2) |
1845c2a4 JL |
327 | ("postgresql" ,postgresql) |
328 | ("readline" ,readline) | |
3ad8cb41 | 329 | ("sqlite" ,sqlite) |
1845c2a4 JL |
330 | ("tidy" ,tidy) |
331 | ("zip" ,zip) | |
332 | ("zlib" ,zlib))) | |
333 | (native-inputs | |
334 | `(("pkg-config" ,pkg-config) | |
335 | ("bison" ,bison) | |
336 | ("intltool" ,intltool) | |
337 | ("procps" ,procps))) ; For tests. | |
338 | (synopsis "PHP programming language") | |
339 | (description | |
340 | "PHP (PHP Hypertext Processor) is a server-side (CGI) scripting | |
341 | language designed primarily for web development but is also used as | |
342 | a general-purpose programming language. PHP code may be embedded into | |
343 | HTML code, or it can be used in combination with various web template | |
344 | systems, web content management systems and web frameworks." ) | |
345 | (license (list | |
346 | (license:non-copyleft "file://LICENSE") ; The PHP license. | |
347 | (license:non-copyleft "file://Zend/LICENSE") ; The Zend license. | |
348 | license:lgpl2.1 ; ext/mbstring/libmbfl | |
349 | license:lgpl2.1+ ; ext/bcmath/libbcmath | |
350 | license:bsd-2 ; ext/fileinfo/libmagic | |
351 | license:expat)))) ; ext/date/lib | |
1a3e7534 OP |
352 | |
353 | (define-public php-with-bcmath | |
354 | (package | |
355 | (inherit php) | |
356 | (name "php-with-bcmath") | |
357 | (arguments | |
358 | (substitute-keyword-arguments (package-arguments php) | |
359 | ((#:configure-flags flags) | |
360 | `(cons "--enable-bcmath" ,flags)))))) |