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