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