gnu: libdvdcss: Update to 1.4.3.
[jackhill/guix/guix.git] / gnu / packages / php.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016-2020 Julien Lepiller <julien@lepiller.eu>
3 ;;; Copyright © 2016 Marius Bakke <mbakke@fastmail.com>
4 ;;; Copyright © 2018, 2020, 2021 Tobias Geerinckx-Rice <me@tobias.gr>
5 ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
6 ;;; Copyright © 2019 Oleg Pykhalov <go.wigust@gmail.com>
7 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
8 ;;;
9 ;;; This file is part of GNU Guix.
10 ;;;
11 ;;; GNU Guix is free software; you can redistribute it and/or modify it
12 ;;; under the terms of the GNU General Public License as published by
13 ;;; the Free Software Foundation; either version 3 of the License, or (at
14 ;;; your option) any later version.
15 ;;;
16 ;;; GNU Guix is distributed in the hope that it will be useful, but
17 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;;; GNU General Public License for more details.
20 ;;;
21 ;;; You should have received a copy of the GNU General Public License
22 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23
24 (define-module (gnu packages php)
25 #:use-module (gnu packages)
26 #:use-module (gnu packages algebra)
27 #:use-module (gnu packages aspell)
28 #:use-module (gnu packages base)
29 #:use-module (gnu packages bison)
30 #:use-module (gnu packages compression)
31 #:use-module (gnu packages curl)
32 #:use-module (gnu packages cyrus-sasl)
33 #:use-module (gnu packages databases)
34 #:use-module (gnu packages dbm)
35 #:use-module (gnu packages fontutils)
36 #:use-module (gnu packages gd)
37 #:use-module (gnu packages gettext)
38 #:use-module (gnu packages glib)
39 #:use-module (gnu packages gnupg)
40 #:use-module (gnu packages icu4c)
41 #:use-module (gnu packages image)
42 #:use-module (gnu packages linux)
43 #:use-module (gnu packages multiprecision)
44 #:use-module (gnu packages openldap)
45 #:use-module (gnu packages pcre)
46 #:use-module (gnu packages pkg-config)
47 #:use-module (gnu packages readline)
48 #:use-module (gnu packages sqlite)
49 #:use-module (gnu packages textutils)
50 #:use-module (gnu packages tls)
51 #:use-module (gnu packages web)
52 #:use-module (gnu packages xml)
53 #:use-module (gnu packages xorg)
54 #:use-module (guix packages)
55 #:use-module (guix download)
56 #:use-module (guix build-system gnu)
57 #:use-module (guix utils)
58 #:use-module ((guix licenses) #:prefix license:))
59
60 (define-public php
61 (package
62 (name "php")
63 (version "7.4.16")
64 (home-page "https://secure.php.net/")
65 (source (origin
66 (method url-fetch)
67 (uri (string-append home-page "distributions/"
68 "php-" version ".tar.xz"))
69 (sha256
70 (base32
71 "12xr7w2mk8ab3igvbpi94ks2xfw2nqga9a6nxs94rvcdz3xcw5hw"))
72 (modules '((guix build utils)))
73 (snippet
74 '(with-directory-excursion "ext"
75 (for-each delete-file-recursively
76 ;; Some of the bundled libraries have no proper upstream.
77 ;; Ideally we'd extract these out as separate packages:
78 ;;"mbstring/libmbfl"
79 ;;"date/lib"
80 ;;"bcmath/libbcmath"
81 ;;"fileinfo/libmagic" ; a patched version of libmagic
82 '("gd/libgd"
83 "pcre/pcre2lib"
84 "xmlrpc/libxmlrpc"))
85 #t))))
86 (build-system gnu-build-system)
87 (arguments
88 `(#:configure-flags
89 (let-syntax ((with (syntax-rules ()
90 ((_ option input)
91 (string-append option "="
92 (assoc-ref %build-inputs input))))))
93 (list (with "--with-bz2" "bzip2")
94 (with "--with-curl" "curl")
95 (with "--with-gdbm" "gdbm")
96 (with "--with-gettext" "glibc") ; libintl.h
97 (with "--with-gmp" "gmp")
98 (with "--with-ldap" "openldap")
99 (with "--with-ldap-sasl" "cyrus-sasl")
100 (with "--with-pdo-pgsql" "postgresql")
101 (with "--with-pdo-sqlite" "sqlite")
102 (with "--with-pgsql" "postgresql")
103 ;; PHP’s Pspell extension, while retaining its current name,
104 ;; now uses the Aspell library.
105 (with "--with-pspell" "aspell")
106 (with "--with-readline" "readline")
107 (with "--with-sqlite3" "sqlite")
108 (with "--with-tidy" "tidy")
109 (with "--with-xsl" "libxslt")
110 (with "--with-zlib-dir" "zlib")
111 ;; We could add "--with-snmp", but it requires netsnmp that
112 ;; we don't have a package for. It is used to build the snmp
113 ;; extension of php.
114 "--with-external-pcre"
115 "--with-external-gd"
116 "--with-iconv"
117 "--with-openssl"
118 "--with-mysqli" ; Required for, e.g. wordpress
119 "--with-pdo-mysql"
120 "--with-zip"
121 "--with-zlib"
122 "--enable-bcmath" ; Required for, e.g. Zabbix frontend
123 "--enable-calendar"
124 "--enable-dba=shared"
125 "--enable-exif"
126 "--enable-flatfile"
127 "--enable-fpm"
128 "--enable-ftp"
129 "--enable-gd"
130 "--enable-inifile"
131 "--enable-intl"
132 "--enable-mbstring"
133 "--enable-pcntl"
134 "--enable-sockets"))
135 #:phases
136 (modify-phases %standard-phases
137 (add-after 'unpack 'do-not-record-build-flags
138 (lambda _
139 ;; Prevent configure flags from being stored and causing
140 ;; unnecessary runtime dependencies.
141 (substitute* "scripts/php-config.in"
142 (("@CONFIGURE_OPTIONS@") "")
143 (("@PHP_LDFLAGS@") ""))
144 ;; This file has ISO-8859-1 encoding.
145 (with-fluids ((%default-port-encoding "ISO-8859-1"))
146 (substitute* "main/build-defs.h.in"
147 (("@CONFIGURE_COMMAND@") "(omitted)")))
148 #t))
149 (add-before 'build 'patch-/bin/sh
150 (lambda _
151 (substitute* '("run-tests.php" "ext/standard/proc_open.c")
152 (("/bin/sh") (which "sh")))
153 #t))
154 (add-before 'check 'prepare-tests
155 (lambda _
156 ;; Some of these files have ISO-8859-1 encoding, whereas others
157 ;; use ASCII, so we can't use a "catch-all" find-files here.
158 (with-fluids ((%default-port-encoding "ISO-8859-1"))
159 (substitute* '("ext/mbstring/tests/mb_send_mail02.phpt"
160 "ext/mbstring/tests/mb_send_mail04.phpt"
161 "ext/mbstring/tests/mb_send_mail05.phpt"
162 "ext/mbstring/tests/mb_send_mail06.phpt")
163 (("/bin/cat") (which "cat"))))
164 (substitute* '("ext/mbstring/tests/mb_send_mail01.phpt"
165 "ext/mbstring/tests/mb_send_mail03.phpt"
166 "ext/mbstring/tests/bug52681.phpt"
167 "ext/standard/tests/general_functions/bug34794.phpt"
168 "ext/standard/tests/general_functions/bug44667.phpt"
169 "ext/standard/tests/general_functions/proc_open.phpt")
170 (("/bin/cat") (which "cat")))
171
172 ;; The encoding of this file is not recognized, so we simply drop it.
173 (delete-file "ext/mbstring/tests/mb_send_mail07.phpt")
174
175 (substitute* "ext/standard/tests/streams/bug60602.phpt"
176 (("'ls'") (string-append "'" (which "ls") "'")))
177
178 ,@(if (string-prefix? "arm" (or (%current-system)
179 (%current-target-system)))
180 ;; Drop tests known to fail on armhf.
181 '((for-each delete-file
182 (list
183 "ext/calendar/tests/unixtojd_error1.phpt"
184 ;; arm can be a lot slower, so a time-related test fails
185 "ext/fileinfo/tests/cve-2014-3538-nojit.phpt"
186 "ext/pcntl/tests/pcntl_unshare_01.phpt"
187 "ext/pcre/tests/bug76514.phpt"
188 "ext/pcre/tests/preg_match_error3.phpt"
189 "ext/pcre/tests/cache_limit.phpt"
190 "ext/sockets/tests/socket_getopt.phpt"
191 "ext/sockets/tests/socket_sendrecvmsg_error.phpt"
192 "ext/standard/tests/general_functions/var_export-locale.phpt"
193 "ext/standard/tests/general_functions/var_export_basic1.phpt"
194 "ext/intl/tests/timezone_getErrorCodeMessage_basic.phpt"
195 "ext/intl/tests/timezone_getOffset_error.phpt"
196 "sapi/cli/tests/cli_process_title_unix.phpt"
197 "sapi/cli/tests/upload_2G.phpt"
198 "Zend/tests/concat_003.phpt")))
199 '())
200
201 ;; Drop tests that are known to fail.
202 (for-each delete-file
203 '("ext/posix/tests/posix_getgrgid.phpt" ; Requires /etc/group.
204 "ext/posix/tests/posix_getgrnam_basic.phpt" ; Requires /etc/group.
205 "ext/sockets/tests/bug63000.phpt" ; Fails to detect OS.
206 "ext/sockets/tests/socket_shutdown.phpt" ; Requires DNS.
207 "ext/sockets/tests/socket_send.phpt" ; Likewise.
208 "ext/sockets/tests/mcast_ipv4_recv.phpt" ; Requires multicast.
209 ;; These needs /etc/services.
210 "ext/standard/tests/general_functions/getservbyname_basic.phpt"
211 "ext/standard/tests/general_functions/getservbyport_basic.phpt"
212 "ext/standard/tests/general_functions/getservbyport_variation1.phpt"
213 ;; And /etc/protocols.
214 "ext/standard/tests/network/getprotobyname_basic.phpt"
215 "ext/standard/tests/network/getprotobynumber_basic.phpt"
216 ;; And exotic locales.
217 "ext/standard/tests/strings/setlocale_basic1.phpt"
218 "ext/standard/tests/strings/setlocale_basic2.phpt"
219 "ext/standard/tests/strings/setlocale_basic3.phpt"
220 "ext/standard/tests/strings/setlocale_variation1.phpt"
221 ;; This failing test is skipped on PHP's Travis CI as it is
222 ;; supposedly inaccurate.
223 "ext/standard/tests/file/disk_free_space_basic.phpt"
224 ;; The following test erroneously expect the link
225 ;; count of a sub-directory to increase compared to
226 ;; its parent.
227 "ext/standard/tests/file/lstat_stat_variation8.phpt"
228 ;; This tests whether microseconds ‘differ enough’ and
229 ;; fails inconsistently on ‘fast’ machines.
230 "ext/date/tests/bug73837.phpt"
231
232 ;; XXX: These gd tests fails. Likely because our version
233 ;; is different from the (patched) bundled one.
234 ;; Here, gd quits immediately after "fatal libpng error"; while the
235 ;; test expects it to additionally return a "setjmp" error and warning.
236 "ext/gd/tests/bug39780_extern.phpt"
237 "ext/gd/tests/libgd00086_extern.phpt"
238 ;; Extra newline in gd-png output.
239 "ext/gd/tests/bug45799.phpt"
240 ;; Test expects generic "gd warning" but gets the actual function name.
241 "ext/gd/tests/createfromwbmp2_extern.phpt"
242 ;; This bug should have been fixed in gd 2.2.2.
243 ;; Is it a regression?
244 "ext/gd/tests/bug65148.phpt"
245 ;; This bug should have been fixed in the gd 2.2
246 ;; series. Perhaps a regression introduced by gd
247 ;; 2.3.0?
248 "ext/gd/tests/bug66590.phpt"
249 ;; This bug should have been fixed in the php-5.5
250 ;; series. Perhaps a regression introduced by gd
251 ;; 2.3.0?
252 "ext/gd/tests/bug70102.phpt"
253 ;; This bug should have been fixed in the php-5.6
254 ;; series. Perhaps a regression introduced by gd
255 ;; 2.3.0?
256 "ext/gd/tests/bug73869.phpt"
257 ;; Some WebP related tests fail.
258 "ext/gd/tests/webp_basic.phpt"
259 "ext/gd/tests/imagecreatefromstring_webp.phpt"
260 ;; Expected error message, but from the wrong function
261 "ext/gd/tests/bug77269.phpt"
262 ;; TODO: Enable these when libgd is built with xpm support.
263 "ext/gd/tests/xpm2gd.phpt"
264 "ext/gd/tests/xpm2jpg.phpt"
265 "ext/gd/tests/xpm2png.phpt"
266 ;; Whitespace difference, probably caused by a very
267 ;; long store path
268 "ext/gd/tests/bug77479.phpt"
269 ;; Expected invalid XBM but got EOF before image was
270 ;; complete. It's a warning in both cases and test
271 ;; result is the same.
272 "ext/gd/tests/bug77973.phpt"
273 ;; Test expects uninitialized value to be false, but
274 ;; instead gets "resource(5) of type (gd)".
275 "ext/gd/tests/bug79067.phpt"
276 ;; The following test fails with "The image size
277 ;; differs: expected 114x115, got 117x117".
278 "ext/gd/tests/bug79068.phpt"
279
280 ;; XXX: These iconv tests have the expected outcome,
281 ;; but with different error messages.
282 ;; Expects "illegal character", instead gets "unknown error (84)".
283 "ext/iconv/tests/bug52211.phpt"
284 "ext/iconv/tests/bug60494.phpt"
285 ;; Expects "wrong charset", gets unknown error (22).
286 "ext/iconv/tests/iconv_strlen_error2.phpt"
287 "ext/iconv/tests/iconv_substr_error2.phpt"
288 ;; Expects conversion error, gets "error condition Termsig=11".
289 "ext/iconv/tests/iconv_strpos_error2.phpt"
290 "ext/iconv/tests/iconv_strrpos_error2.phpt"
291 ;; Expects "invalid multibyte sequence" but got
292 ;; "unknown error".
293 "ext/iconv/tests/bug76249.phpt"
294
295 ;; XXX: These test failures appear legitimate, needs investigation.
296 ;; open_basedir() restriction failure.
297 "ext/curl/tests/bug61948-unix.phpt"
298 ;; Expects a false boolean, gets empty array from glob().
299 "ext/standard/tests/file/bug41655_1.phpt"
300 "ext/standard/tests/file/glob_variation5.phpt"
301 ;; The test expects an Array, but instead get the contents(?).
302 "ext/gd/tests/bug43073.phpt"
303 ;; imagettftext() returns wrong coordinates.
304 "ext/gd/tests/bug48732-mb.phpt"
305 "ext/gd/tests/bug48732.phpt"
306 ;; Similarly for imageftbbox().
307 "ext/gd/tests/bug48801-mb.phpt"
308 "ext/gd/tests/bug48801.phpt"
309 ;; Different expected output from imagecolorallocate().
310 "ext/gd/tests/bug53504.phpt"
311 ;; Wrong image size after scaling an image.
312 "ext/gd/tests/bug73272.phpt"
313 ;; Expects iconv to detect illegal characters, instead gets
314 ;; "unknown error (84)" and heap corruption(!).
315 "ext/iconv/tests/bug48147.phpt"
316 ;; Expects illegal character ".", gets "=?utf-8?Q?."
317 "ext/iconv/tests/bug51250.phpt"
318 ;; iconv throws "buffer length exceeded" on some string checks.
319 "ext/iconv/tests/iconv_mime_encode.phpt"
320 ;; file_get_contents(): iconv stream filter
321 ;; ("ISO-8859-1"=>"UTF-8") unknown error.
322 "ext/standard/tests/file/bug43008.phpt"
323 ;; Table data not created in sqlite(?).
324 "ext/pdo_sqlite/tests/bug_42589.phpt"
325 ;; Expects an Array with 3 preg_matches; gets 0.
326 "ext/pcre/tests/bug79846.phpt"
327 ;; Expects an empty Array; gets one with " " in it.
328 "ext/pcre/tests/bug80118.phpt"))
329
330 ;; Accomodate two extra openssl errors flanking the expected one:
331 ;; random number generator:RAND_{load,write}_file:Cannot open file
332 ;; This is due to an invalid $HOME, but changing it in the test
333 ;; still prints the first one & changing it globally is overkill.
334 (substitute* "ext/openssl/tests/bug80747.phpt"
335 ((".*error:%s:key size too small.*" match)
336 (string-append "%s\n" match "%s\n")))
337
338 ;; Skip tests requiring network access.
339 (setenv "SKIP_ONLINE_TESTS" "1")
340 ;; Without this variable, 'make test' passes regardless of failures.
341 (setenv "REPORT_EXIT_STATUS" "1")
342 ;; Skip tests requiring I/O facilities that are unavailable in the
343 ;; build environment
344 (setenv "SKIP_IO_CAPTURE_TESTS" "1")
345 #t)))
346 #:test-target "test"))
347 (inputs
348 `(("aspell" ,aspell)
349 ("bzip2" ,bzip2)
350 ("curl" ,curl)
351 ("cyrus-sasl" ,cyrus-sasl)
352 ("gd" ,gd)
353 ("gdbm" ,gdbm)
354 ("glibc" ,glibc)
355 ("gmp" ,gmp)
356 ("gnutls" ,gnutls)
357 ("icu4c" ,icu4c)
358 ("libgcrypt" ,libgcrypt)
359 ("libpng" ,libpng)
360 ("libxml2" ,libxml2)
361 ("libxslt" ,libxslt)
362 ("libx11" ,libx11)
363 ("libzip" ,libzip)
364 ("oniguruma" ,oniguruma)
365 ("openldap" ,openldap)
366 ("openssl" ,openssl)
367 ("pcre" ,pcre2)
368 ("postgresql" ,postgresql)
369 ("readline" ,readline)
370 ("sqlite" ,sqlite)
371 ("tidy" ,tidy)
372 ("zlib" ,zlib)))
373 (native-inputs
374 `(("pkg-config" ,pkg-config)
375 ("bison" ,bison)
376 ("intltool" ,intltool)
377 ("procps" ,procps))) ; for tests
378 (synopsis "PHP programming language")
379 (description
380 "PHP (PHP Hypertext Processor) is a server-side (CGI) scripting
381 language designed primarily for web development but is also used as
382 a general-purpose programming language. PHP code may be embedded into
383 HTML code, or it can be used in combination with various web template
384 systems, web content management systems and web frameworks." )
385 (license (list
386 (license:non-copyleft "file://LICENSE") ; The PHP license.
387 (license:non-copyleft "file://Zend/LICENSE") ; The Zend license.
388 license:lgpl2.1 ; ext/mbstring/libmbfl
389 license:lgpl2.1+ ; ext/bcmath/libbcmath
390 license:bsd-2 ; ext/fileinfo/libmagic
391 license:expat)))) ; ext/date/lib