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