gnu: deutex: Update to 5.2.1.
[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)
30502f1d 39 #:use-module (gnu packages icu4c)
1845c2a4
JL
40 #:use-module (gnu packages image)
41 #:use-module (gnu packages linux)
42 #:use-module (gnu packages multiprecision)
43 #:use-module (gnu packages openldap)
44 #:use-module (gnu packages pcre)
45 #:use-module (gnu packages pkg-config)
46 #:use-module (gnu packages readline)
cd0322a3 47 #:use-module (gnu packages sqlite)
1845c2a4
JL
48 #:use-module (gnu packages textutils)
49 #:use-module (gnu packages tls)
50 #:use-module (gnu packages web)
51 #:use-module (gnu packages xml)
52 #:use-module (gnu packages xorg)
1845c2a4
JL
53 #:use-module (guix packages)
54 #:use-module (guix download)
55 #:use-module (guix build-system gnu)
1a3e7534 56 #:use-module (guix utils)
1845c2a4
JL
57 #:use-module ((guix licenses) #:prefix license:))
58
1845c2a4
JL
59(define-public php
60 (package
61 (name "php")
441f20a0 62 (version "7.4.1")
1845c2a4
JL
63 (home-page "https://secure.php.net/")
64 (source (origin
65 (method url-fetch)
66 (uri (string-append home-page "distributions/"
9b76aa10 67 "php-" version ".tar.xz"))
1845c2a4
JL
68 (sha256
69 (base32
441f20a0 70 "0qn7zwf2jzj3h7p4b1l79lf9gv236mycwkhgw15hj2fmpmkbh6sn"))
1845c2a4
JL
71 (modules '((guix build utils)))
72 (snippet
73 '(with-directory-excursion "ext"
74 (for-each delete-file-recursively
75 ;; Some of the bundled libraries have no proper upstream.
76 ;; Ideally we'd extract these out as separate packages:
77 ;;"mbstring/libmbfl"
78 ;;"date/lib"
79 ;;"bcmath/libbcmath"
61919f09 80 ;;"fileinfo/libmagic" ; a patched version of libmagic
1845c2a4 81 '("gd/libgd"
ebcb58c9 82 "pcre/pcre2lib"
23bb7a62 83 "xmlrpc/libxmlrpc"))
6cbee49d 84 #t))))
1845c2a4
JL
85 (build-system gnu-build-system)
86 (arguments
e8cfce43 87 `(#:configure-flags
1845c2a4
JL
88 (let-syntax ((with (syntax-rules ()
89 ((_ option input)
90 (string-append option "="
91 (assoc-ref %build-inputs input))))))
92 (list (with "--with-bz2" "bzip2")
93 (with "--with-curl" "curl")
1845c2a4
JL
94 (with "--with-gdbm" "gdbm")
95 (with "--with-gettext" "glibc") ; libintl.h
96 (with "--with-gmp" "gmp")
1845c2a4
JL
97 (with "--with-ldap" "openldap")
98 (with "--with-ldap-sasl" "cyrus-sasl")
1845c2a4
JL
99 (with "--with-pdo-pgsql" "postgresql")
100 (with "--with-pdo-sqlite" "sqlite")
101 (with "--with-pgsql" "postgresql")
1845c2a4
JL
102 ;; PHP’s Pspell extension, while retaining its current name,
103 ;; now uses the Aspell library.
104 (with "--with-pspell" "aspell")
105 (with "--with-readline" "readline")
106 (with "--with-sqlite3" "sqlite")
107 (with "--with-tidy" "tidy")
1845c2a4
JL
108 (with "--with-xsl" "libxslt")
109 (with "--with-zlib-dir" "zlib")
110 ;; We could add "--with-snmp", but it requires netsnmp that
111 ;; we don't have a package for. It is used to build the snmp
112 ;; extension of php.
23bb7a62
JL
113 "--with-external-pcre"
114 "--with-external-gd"
1845c2a4
JL
115 "--with-iconv"
116 "--with-openssl"
0e40b755 117 "--with-mysqli" ; Required for, e.g. wordpress
1845c2a4 118 "--with-pdo-mysql"
23bb7a62 119 "--with-zip"
1845c2a4 120 "--with-zlib"
4629d267 121 "--enable-bcmath" ; Required for, e.g. Zabbix frontend
1845c2a4
JL
122 "--enable-calendar"
123 "--enable-dba=shared"
124 "--enable-exif"
125 "--enable-flatfile"
126 "--enable-fpm"
127 "--enable-ftp"
23bb7a62 128 "--enable-gd"
1845c2a4 129 "--enable-inifile"
30502f1d 130 "--enable-intl"
1845c2a4
JL
131 "--enable-mbstring"
132 "--enable-pcntl"
23bb7a62 133 "--enable-sockets"))
1845c2a4
JL
134 #:phases
135 (modify-phases %standard-phases
136 (add-after 'unpack 'do-not-record-build-flags
137 (lambda _
138 ;; Prevent configure flags from being stored and causing
139 ;; unnecessary runtime dependencies.
140 (substitute* "scripts/php-config.in"
141 (("@CONFIGURE_OPTIONS@") "")
142 (("@PHP_LDFLAGS@") ""))
143 ;; This file has ISO-8859-1 encoding.
144 (with-fluids ((%default-port-encoding "ISO-8859-1"))
145 (substitute* "main/build-defs.h.in"
146 (("@CONFIGURE_COMMAND@") "(omitted)")))
147 #t))
148 (add-before 'build 'patch-/bin/sh
149 (lambda _
150 (substitute* '("run-tests.php" "ext/standard/proc_open.c")
151 (("/bin/sh") (which "sh")))
152 #t))
153 (add-before 'check 'prepare-tests
154 (lambda _
155 ;; Some of these files have ISO-8859-1 encoding, whereas others
156 ;; use ASCII, so we can't use a "catch-all" find-files here.
157 (with-fluids ((%default-port-encoding "ISO-8859-1"))
158 (substitute* '("ext/mbstring/tests/mb_send_mail02.phpt"
159 "ext/mbstring/tests/mb_send_mail04.phpt"
160 "ext/mbstring/tests/mb_send_mail05.phpt"
161 "ext/mbstring/tests/mb_send_mail06.phpt")
162 (("/bin/cat") (which "cat"))))
163 (substitute* '("ext/mbstring/tests/mb_send_mail01.phpt"
164 "ext/mbstring/tests/mb_send_mail03.phpt"
23bb7a62 165 "ext/mbstring/tests/bug52681.phpt"
1845c2a4
JL
166 "ext/standard/tests/general_functions/bug34794.phpt"
167 "ext/standard/tests/general_functions/bug44667.phpt"
168 "ext/standard/tests/general_functions/proc_open.phpt")
169 (("/bin/cat") (which "cat")))
60a50806 170
1845c2a4
JL
171 ;; The encoding of this file is not recognized, so we simply drop it.
172 (delete-file "ext/mbstring/tests/mb_send_mail07.phpt")
173
174 (substitute* "ext/standard/tests/streams/bug60602.phpt"
175 (("'ls'") (string-append "'" (which "ls") "'")))
176
9398152a
LC
177 ,@(if (string-prefix? "arm" (or (%current-system)
178 (%current-target-system)))
e8cfce43
JL
179 ;; Drop tests known to fail on armhf.
180 '((for-each delete-file
181 (list
182 "ext/calendar/tests/unixtojd_error1.phpt"
183 ;; arm can be a lot slower, so a time-related test fails
184 "ext/fileinfo/tests/cve-2014-3538-nojit.phpt"
185 "ext/pcre/tests/bug76514.phpt"
bd9d5dbb
JL
186 "ext/pcre/tests/preg_match_error3.phpt"
187 "ext/standard/tests/general_functions/var_export-locale.phpt"
23bb7a62
JL
188 "ext/standard/tests/general_functions/var_export_basic1.phpt"
189 "ext/intl/tests/timezone_getErrorCodeMessage_basic.phpt"
190 "ext/intl/tests/timezone_getOffset_error.phpt")))
9398152a 191 '())
e8cfce43 192
1845c2a4
JL
193 ;; Drop tests that are known to fail.
194 (for-each delete-file
195 '("ext/posix/tests/posix_getgrgid.phpt" ; Requires /etc/group.
23bb7a62 196 "ext/posix/tests/posix_getgrnam_basic.phpt" ; Requires /etc/group.
1845c2a4
JL
197 "ext/sockets/tests/bug63000.phpt" ; Fails to detect OS.
198 "ext/sockets/tests/socket_shutdown.phpt" ; Requires DNS.
199 "ext/sockets/tests/socket_send.phpt" ; Likewise.
200 "ext/sockets/tests/mcast_ipv4_recv.phpt" ; Requires multicast.
201 ;; These needs /etc/services.
202 "ext/standard/tests/general_functions/getservbyname_basic.phpt"
203 "ext/standard/tests/general_functions/getservbyport_basic.phpt"
204 "ext/standard/tests/general_functions/getservbyport_variation1.phpt"
205 ;; And /etc/protocols.
206 "ext/standard/tests/network/getprotobyname_basic.phpt"
207 "ext/standard/tests/network/getprotobynumber_basic.phpt"
208 ;; And exotic locales.
209 "ext/standard/tests/strings/setlocale_basic1.phpt"
210 "ext/standard/tests/strings/setlocale_basic2.phpt"
211 "ext/standard/tests/strings/setlocale_basic3.phpt"
212 "ext/standard/tests/strings/setlocale_variation1.phpt"
213
214 ;; XXX: These gd tests fails. Likely because our version
215 ;; is different from the (patched) bundled one.
216 ;; Here, gd quits immediately after "fatal libpng error"; while the
217 ;; test expects it to additionally return a "setjmp" error and warning.
218 "ext/gd/tests/bug39780_extern.phpt"
219 "ext/gd/tests/libgd00086_extern.phpt"
220 ;; Extra newline in gd-png output.
221 "ext/gd/tests/bug45799.phpt"
1845c2a4
JL
222 ;; Test expects generic "gd warning" but gets the actual function name.
223 "ext/gd/tests/createfromwbmp2_extern.phpt"
202e235e
JL
224 ;; This bug should have been fixed in gd 2.2.2.
225 ;; Is it a regression?
226 "ext/gd/tests/bug65148.phpt"
23bb7a62 227 ;; Expected error message, but from the wrong function
22fe9110 228 "ext/gd/tests/bug77269.phpt"
1845c2a4
JL
229 ;; TODO: Enable these when libgd is built with xpm support.
230 "ext/gd/tests/xpm2gd.phpt"
231 "ext/gd/tests/xpm2jpg.phpt"
232 "ext/gd/tests/xpm2png.phpt"
945723be
JL
233 ;; Whitespace difference, probably caused by a very
234 ;; long store path
235 "ext/gd/tests/bug77479.phpt"
27489e7f
JL
236 ;; Expected invalid XBM but got EOF before image was
237 ;; complete. It's a warning in both cases and test
238 ;; result is the same.
239 "ext/gd/tests/bug77973.phpt"
1845c2a4
JL
240
241 ;; XXX: These iconv tests have the expected outcome,
242 ;; but with different error messages.
243 ;; Expects "illegal character", instead gets "unknown error (84)".
244 "ext/iconv/tests/bug52211.phpt"
63657921 245 "ext/iconv/tests/bug60494.phpt"
1845c2a4 246 ;; Expects "wrong charset", gets unknown error (22).
1845c2a4 247 "ext/iconv/tests/iconv_strlen_error2.phpt"
1845c2a4
JL
248 "ext/iconv/tests/iconv_substr_error2.phpt"
249 ;; Expects conversion error, gets "error condition Termsig=11".
250 "ext/iconv/tests/iconv_strpos_error2.phpt"
251 "ext/iconv/tests/iconv_strrpos_error2.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.
23bb7a62 258 "ext/curl/tests/bug61948-unix.phpt"
1845c2a4
JL
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"
1845c2a4
JL
262 ;; The test expects an Array, but instead get the contents(?).
263 "ext/gd/tests/bug43073.phpt"
264 ;; imagettftext() returns wrong coordinates.
60a50806 265 "ext/gd/tests/bug48732-mb.phpt"
1845c2a4
JL
266 "ext/gd/tests/bug48732.phpt"
267 ;; Similarly for imageftbbox().
60a50806 268 "ext/gd/tests/bug48801-mb.phpt"
1845c2a4
JL
269 "ext/gd/tests/bug48801.phpt"
270 ;; Different expected output from imagecolorallocate().
271 "ext/gd/tests/bug53504.phpt"
272 ;; Wrong image size after scaling an image.
273 "ext/gd/tests/bug73272.phpt"
274 ;; Expects iconv to detect illegal characters, instead gets
275 ;; "unknown error (84)" and heap corruption(!).
276 "ext/iconv/tests/bug48147.phpt"
277 ;; Expects illegal character ".", gets "=?utf-8?Q?."
278 "ext/iconv/tests/bug51250.phpt"
1845c2a4
JL
279 ;; iconv throws "buffer length exceeded" on some string checks.
280 "ext/iconv/tests/iconv_mime_encode.phpt"
281 ;; file_get_contents(): iconv stream filter
282 ;; ("ISO-8859-1"=>"UTF-8") unknown error.
283 "ext/standard/tests/file/bug43008.phpt"
284 ;; Table data not created in sqlite(?).
23bb7a62 285 "ext/pdo_sqlite/tests/bug_42589.phpt"))
1845c2a4
JL
286
287 ;; Skip tests requiring network access.
288 (setenv "SKIP_ONLINE_TESTS" "1")
289 ;; Without this variable, 'make test' passes regardless of failures.
290 (setenv "REPORT_EXIT_STATUS" "1")
dd1f60ec
JL
291 ;; Skip tests requiring I/O facilities that are unavailable in the
292 ;; build environment
293 (setenv "SKIP_IO_CAPTURE_TESTS" "1")
1845c2a4
JL
294 #t)))
295 #:test-target "test"))
296 (inputs
297 `(("aspell" ,aspell)
298 ("bzip2" ,bzip2)
299 ("curl" ,curl)
300 ("cyrus-sasl" ,cyrus-sasl)
68a08dfb 301 ("gd" ,gd)
1845c2a4
JL
302 ("gdbm" ,gdbm)
303 ("glibc" ,glibc)
304 ("gmp" ,gmp)
60a50806 305 ("gnutls" ,gnutls)
30502f1d 306 ("icu4c" ,icu4c)
1845c2a4 307 ("libgcrypt" ,libgcrypt)
1845c2a4 308 ("libpng" ,libpng)
1845c2a4 309 ("libxml2" ,libxml2)
1845c2a4
JL
310 ("libxslt" ,libxslt)
311 ("libx11" ,libx11)
30502f1d 312 ("libzip" ,libzip)
5ec7c4a1 313 ("oniguruma" ,oniguruma)
1845c2a4
JL
314 ("openldap" ,openldap)
315 ("openssl" ,openssl)
a33925d1 316 ("pcre" ,pcre2)
1845c2a4
JL
317 ("postgresql" ,postgresql)
318 ("readline" ,readline)
3ad8cb41 319 ("sqlite" ,sqlite)
1845c2a4 320 ("tidy" ,tidy)
1845c2a4
JL
321 ("zlib" ,zlib)))
322 (native-inputs
323 `(("pkg-config" ,pkg-config)
324 ("bison" ,bison)
325 ("intltool" ,intltool)
61919f09 326 ("procps" ,procps))) ; for tests
1845c2a4
JL
327 (synopsis "PHP programming language")
328 (description
329 "PHP (PHP Hypertext Processor) is a server-side (CGI) scripting
330language designed primarily for web development but is also used as
331a general-purpose programming language. PHP code may be embedded into
332HTML code, or it can be used in combination with various web template
333systems, web content management systems and web frameworks." )
334 (license (list
335 (license:non-copyleft "file://LICENSE") ; The PHP license.
336 (license:non-copyleft "file://Zend/LICENSE") ; The Zend license.
337 license:lgpl2.1 ; ext/mbstring/libmbfl
338 license:lgpl2.1+ ; ext/bcmath/libbcmath
339 license:bsd-2 ; ext/fileinfo/libmagic
340 license:expat)))) ; ext/date/lib
1a3e7534
OP
341
342(define-public php-with-bcmath
8b6c91ba 343 (deprecated-package "php-with-bcmath" php))