gnu: mono: Make build reproducible.
[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
1845c2a4
JL
53(define-public php
54 (package
55 (name "php")
0dd60c1c 56 (version "7.2.12")
1845c2a4
JL
57 (home-page "https://secure.php.net/")
58 (source (origin
59 (method url-fetch)
60 (uri (string-append home-page "distributions/"
61 name "-" version ".tar.xz"))
62 (sha256
63 (base32
0dd60c1c 64 "1qbz2j9kzqxxp0mmx02zavvz20ji7izqdnri25g1mrwyhz60974q"))
1845c2a4
JL
65 (modules '((guix build utils)))
66 (snippet
67 '(with-directory-excursion "ext"
68 (for-each delete-file-recursively
69 ;; Some of the bundled libraries have no proper upstream.
70 ;; Ideally we'd extract these out as separate packages:
71 ;;"mbstring/libmbfl"
72 ;;"date/lib"
73 ;;"bcmath/libbcmath"
74 ;;"fileinfo/libmagic" ; This is a patched version of libmagic.
75 '("gd/libgd"
76 "mbstring/oniguruma"
77 "pcre/pcrelib"
78 "sqlite3/libsqlite"
79 "xmlrpc/libxmlrpc"
6cbee49d
MW
80 "zip/lib"))
81 #t))))
1845c2a4
JL
82 (build-system gnu-build-system)
83 (arguments
84 '(#:configure-flags
85 (let-syntax ((with (syntax-rules ()
86 ((_ option input)
87 (string-append option "="
88 (assoc-ref %build-inputs input))))))
89 (list (with "--with-bz2" "bzip2")
90 (with "--with-curl" "curl")
91 (with "--with-freetype-dir" "freetype")
92 (with "--with-gd" "gd")
93 (with "--with-gdbm" "gdbm")
94 (with "--with-gettext" "glibc") ; libintl.h
95 (with "--with-gmp" "gmp")
96 (with "--with-jpeg-dir" "libjpeg")
97 (with "--with-ldap" "openldap")
98 (with "--with-ldap-sasl" "cyrus-sasl")
99 (with "--with-libzip" "zip")
100 (with "--with-libxml-dir" "libxml2")
101 (with "--with-onig" "oniguruma")
102 (with "--with-pcre-dir" "pcre")
103 (with "--with-pcre-regex" "pcre")
104 (with "--with-pdo-pgsql" "postgresql")
105 (with "--with-pdo-sqlite" "sqlite")
106 (with "--with-pgsql" "postgresql")
107 (with "--with-png-dir" "libpng")
108 ;; PHP’s Pspell extension, while retaining its current name,
109 ;; now uses the Aspell library.
110 (with "--with-pspell" "aspell")
111 (with "--with-readline" "readline")
112 (with "--with-sqlite3" "sqlite")
113 (with "--with-tidy" "tidy")
114 (with "--with-webp-dir" "libwebp")
115 (with "--with-xpm-dir" "libxpm")
116 (with "--with-xsl" "libxslt")
117 (with "--with-zlib-dir" "zlib")
118 ;; We could add "--with-snmp", but it requires netsnmp that
119 ;; we don't have a package for. It is used to build the snmp
120 ;; extension of php.
121 "--with-iconv"
122 "--with-openssl"
0e40b755 123 "--with-mysqli" ; Required for, e.g. wordpress
1845c2a4
JL
124 "--with-pdo-mysql"
125 "--with-zlib"
126 "--enable-calendar"
127 "--enable-dba=shared"
128 "--enable-exif"
129 "--enable-flatfile"
130 "--enable-fpm"
131 "--enable-ftp"
132 "--enable-inifile"
133 "--enable-mbstring"
134 "--enable-pcntl"
4cd1d1c1 135 "--enable-sockets"))
1845c2a4
JL
136 #:phases
137 (modify-phases %standard-phases
138 (add-after 'unpack 'do-not-record-build-flags
139 (lambda _
140 ;; Prevent configure flags from being stored and causing
141 ;; unnecessary runtime dependencies.
142 (substitute* "scripts/php-config.in"
143 (("@CONFIGURE_OPTIONS@") "")
144 (("@PHP_LDFLAGS@") ""))
145 ;; This file has ISO-8859-1 encoding.
146 (with-fluids ((%default-port-encoding "ISO-8859-1"))
147 (substitute* "main/build-defs.h.in"
148 (("@CONFIGURE_COMMAND@") "(omitted)")))
149 #t))
150 (add-before 'build 'patch-/bin/sh
151 (lambda _
152 (substitute* '("run-tests.php" "ext/standard/proc_open.c")
153 (("/bin/sh") (which "sh")))
154 #t))
155 (add-before 'check 'prepare-tests
156 (lambda _
157 ;; Some of these files have ISO-8859-1 encoding, whereas others
158 ;; use ASCII, so we can't use a "catch-all" find-files here.
159 (with-fluids ((%default-port-encoding "ISO-8859-1"))
160 (substitute* '("ext/mbstring/tests/mb_send_mail02.phpt"
161 "ext/mbstring/tests/mb_send_mail04.phpt"
162 "ext/mbstring/tests/mb_send_mail05.phpt"
163 "ext/mbstring/tests/mb_send_mail06.phpt")
164 (("/bin/cat") (which "cat"))))
165 (substitute* '("ext/mbstring/tests/mb_send_mail01.phpt"
166 "ext/mbstring/tests/mb_send_mail03.phpt"
167 "ext/mbstring/tests/bug52861.phpt"
168 "ext/standard/tests/general_functions/bug34794.phpt"
169 "ext/standard/tests/general_functions/bug44667.phpt"
170 "ext/standard/tests/general_functions/proc_open.phpt")
171 (("/bin/cat") (which "cat")))
60a50806 172
1845c2a4
JL
173 ;; The encoding of this file is not recognized, so we simply drop it.
174 (delete-file "ext/mbstring/tests/mb_send_mail07.phpt")
175
176 (substitute* "ext/standard/tests/streams/bug60602.phpt"
177 (("'ls'") (string-append "'" (which "ls") "'")))
178
0dd60c1c
JL
179 ;; The expected output is slightly different from what is given,
180 ;; in a section that's not related to the actual test
181 (substitute* "sapi/cli/tests/upload_2G.phpt"
182 (("Test\\\\n") "Test\n\n"))
183
1845c2a4
JL
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"
202e235e
JL
223 ;; This bug should have been fixed in gd 2.2.2.
224 ;; Is it a regression?
225 "ext/gd/tests/bug65148.phpt"
1845c2a4
JL
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"
63657921 235 "ext/iconv/tests/bug60494.phpt"
1845c2a4
JL
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"
16dc5ed0
JL
248 ;; Expects "invalid multibyte sequence" but got
249 ;; "unknown error".
250 "ext/iconv/tests/bug76249.phpt"
1845c2a4
JL
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.
60a50806 263 "ext/gd/tests/bug48732-mb.phpt"
1845c2a4
JL
264 "ext/gd/tests/bug48732.phpt"
265 ;; Similarly for imageftbbox().
60a50806 266 "ext/gd/tests/bug48801-mb.phpt"
1845c2a4
JL
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(?).
dd1f60ec
JL
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"
16dc5ed0
JL
291 "ext/ldap/tests/ldap_set_option_error.phpt"
292
293 ;; Sometimes cannot start the LDAP server.
294 "ext/ldap/tests/bug76248.phpt"))
1845c2a4
JL
295
296 ;; Skip tests requiring network access.
297 (setenv "SKIP_ONLINE_TESTS" "1")
298 ;; Without this variable, 'make test' passes regardless of failures.
299 (setenv "REPORT_EXIT_STATUS" "1")
dd1f60ec
JL
300 ;; Skip tests requiring I/O facilities that are unavailable in the
301 ;; build environment
302 (setenv "SKIP_IO_CAPTURE_TESTS" "1")
1845c2a4
JL
303 #t)))
304 #:test-target "test"))
305 (inputs
306 `(("aspell" ,aspell)
307 ("bzip2" ,bzip2)
308 ("curl" ,curl)
309 ("cyrus-sasl" ,cyrus-sasl)
310 ("freetype" ,freetype)
68a08dfb 311 ("gd" ,gd)
1845c2a4
JL
312 ("gdbm" ,gdbm)
313 ("glibc" ,glibc)
314 ("gmp" ,gmp)
60a50806 315 ("gnutls" ,gnutls)
1845c2a4
JL
316 ("libgcrypt" ,libgcrypt)
317 ("libjpeg" ,libjpeg)
318 ("libpng" ,libpng)
319 ("libwebp" ,libwebp)
320 ("libxml2" ,libxml2)
321 ("libxpm" ,libxpm)
322 ("libxslt" ,libxslt)
323 ("libx11" ,libx11)
d5019f9c 324 ("oniguruma" ,oniguruma-5)
1845c2a4
JL
325 ("openldap" ,openldap)
326 ("openssl" ,openssl)
327 ("pcre" ,pcre)
328 ("postgresql" ,postgresql)
329 ("readline" ,readline)
3ad8cb41 330 ("sqlite" ,sqlite)
1845c2a4
JL
331 ("tidy" ,tidy)
332 ("zip" ,zip)
333 ("zlib" ,zlib)))
334 (native-inputs
335 `(("pkg-config" ,pkg-config)
336 ("bison" ,bison)
337 ("intltool" ,intltool)
338 ("procps" ,procps))) ; For tests.
339 (synopsis "PHP programming language")
340 (description
341 "PHP (PHP Hypertext Processor) is a server-side (CGI) scripting
342language designed primarily for web development but is also used as
343a general-purpose programming language. PHP code may be embedded into
344HTML code, or it can be used in combination with various web template
345systems, web content management systems and web frameworks." )
346 (license (list
347 (license:non-copyleft "file://LICENSE") ; The PHP license.
348 (license:non-copyleft "file://Zend/LICENSE") ; The Zend license.
349 license:lgpl2.1 ; ext/mbstring/libmbfl
350 license:lgpl2.1+ ; ext/bcmath/libbcmath
351 license:bsd-2 ; ext/fileinfo/libmagic
352 license:expat)))) ; ext/date/lib