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>
6 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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)
48 #:use-module (guix packages)
49 #:use-module (guix download)
50 #:use-module (guix build-system gnu)
51 #:use-module ((guix licenses) #:prefix license:))
57 (inherit (package-source gd))
58 (patches (search-patches "gd-fix-tests-on-i686.patch"
59 "gd-freetype-test-failure.patch"
60 "gd-CVE-2018-5711.patch"))))))
66 (home-page "https://secure.php.net/")
69 (uri (string-append home-page "distributions/"
70 name "-" version ".tar.xz"))
73 "123s0lbyz4fxr3kk91r4v658mk899dym36lggxnx9pwd2jyv25kr"))
74 (modules '((guix build utils)))
76 '(with-directory-excursion "ext"
77 (for-each delete-file-recursively
78 ;; Some of the bundled libraries have no proper upstream.
79 ;; Ideally we'd extract these out as separate packages:
83 ;;"fileinfo/libmagic" ; This is a patched version of libmagic.
91 (build-system gnu-build-system)
94 (let-syntax ((with (syntax-rules ()
96 (string-append option "="
97 (assoc-ref %build-inputs input))))))
98 (list (with "--with-bz2" "bzip2")
99 (with "--with-curl" "curl")
100 (with "--with-freetype-dir" "freetype")
101 (with "--with-gd" "gd")
102 (with "--with-gdbm" "gdbm")
103 (with "--with-gettext" "glibc") ; libintl.h
104 (with "--with-gmp" "gmp")
105 (with "--with-jpeg-dir" "libjpeg")
106 (with "--with-ldap" "openldap")
107 (with "--with-ldap-sasl" "cyrus-sasl")
108 (with "--with-libzip" "zip")
109 (with "--with-libxml-dir" "libxml2")
110 (with "--with-onig" "oniguruma")
111 (with "--with-pcre-dir" "pcre")
112 (with "--with-pcre-regex" "pcre")
113 (with "--with-pdo-pgsql" "postgresql")
114 (with "--with-pdo-sqlite" "sqlite")
115 (with "--with-pgsql" "postgresql")
116 (with "--with-png-dir" "libpng")
117 ;; PHP’s Pspell extension, while retaining its current name,
118 ;; now uses the Aspell library.
119 (with "--with-pspell" "aspell")
120 (with "--with-readline" "readline")
121 (with "--with-sqlite3" "sqlite")
122 (with "--with-tidy" "tidy")
123 (with "--with-webp-dir" "libwebp")
124 (with "--with-xpm-dir" "libxpm")
125 (with "--with-xsl" "libxslt")
126 (with "--with-zlib-dir" "zlib")
127 ;; We could add "--with-snmp", but it requires netsnmp that
128 ;; we don't have a package for. It is used to build the snmp
132 "--with-mysqli" ; Required for, e.g. wordpress
136 "--enable-dba=shared"
146 (modify-phases %standard-phases
147 (add-after 'unpack 'do-not-record-build-flags
149 ;; Prevent configure flags from being stored and causing
150 ;; unnecessary runtime dependencies.
151 (substitute* "scripts/php-config.in"
152 (("@CONFIGURE_OPTIONS@") "")
153 (("@PHP_LDFLAGS@") ""))
154 ;; This file has ISO-8859-1 encoding.
155 (with-fluids ((%default-port-encoding "ISO-8859-1"))
156 (substitute* "main/build-defs.h.in"
157 (("@CONFIGURE_COMMAND@") "(omitted)")))
159 (add-before 'build 'patch-/bin/sh
161 (substitute* '("run-tests.php" "ext/standard/proc_open.c")
162 (("/bin/sh") (which "sh")))
164 (add-before 'check 'prepare-tests
166 ;; Some of these files have ISO-8859-1 encoding, whereas others
167 ;; use ASCII, so we can't use a "catch-all" find-files here.
168 (with-fluids ((%default-port-encoding "ISO-8859-1"))
169 (substitute* '("ext/mbstring/tests/mb_send_mail02.phpt"
170 "ext/mbstring/tests/mb_send_mail04.phpt"
171 "ext/mbstring/tests/mb_send_mail05.phpt"
172 "ext/mbstring/tests/mb_send_mail06.phpt")
173 (("/bin/cat") (which "cat"))))
174 (substitute* '("ext/mbstring/tests/mb_send_mail01.phpt"
175 "ext/mbstring/tests/mb_send_mail03.phpt"
176 "ext/mbstring/tests/bug52861.phpt"
177 "ext/standard/tests/general_functions/bug34794.phpt"
178 "ext/standard/tests/general_functions/bug44667.phpt"
179 "ext/standard/tests/general_functions/proc_open.phpt")
180 (("/bin/cat") (which "cat")))
182 ;; The encoding of this file is not recognized, so we simply drop it.
183 (delete-file "ext/mbstring/tests/mb_send_mail07.phpt")
185 (substitute* "ext/standard/tests/streams/bug60602.phpt"
186 (("'ls'") (string-append "'" (which "ls") "'")))
188 ;; Drop tests that are known to fail.
189 (for-each delete-file
190 '("ext/posix/tests/posix_getgrgid.phpt" ; Requires /etc/group.
191 "ext/sockets/tests/bug63000.phpt" ; Fails to detect OS.
192 "ext/sockets/tests/socket_shutdown.phpt" ; Requires DNS.
193 "ext/sockets/tests/socket_send.phpt" ; Likewise.
194 "ext/sockets/tests/mcast_ipv4_recv.phpt" ; Requires multicast.
195 ;; These needs /etc/services.
196 "ext/standard/tests/general_functions/getservbyname_basic.phpt"
197 "ext/standard/tests/general_functions/getservbyport_basic.phpt"
198 "ext/standard/tests/general_functions/getservbyport_variation1.phpt"
199 ;; And /etc/protocols.
200 "ext/standard/tests/network/getprotobyname_basic.phpt"
201 "ext/standard/tests/network/getprotobynumber_basic.phpt"
202 ;; And exotic locales.
203 "ext/standard/tests/strings/setlocale_basic1.phpt"
204 "ext/standard/tests/strings/setlocale_basic2.phpt"
205 "ext/standard/tests/strings/setlocale_basic3.phpt"
206 "ext/standard/tests/strings/setlocale_variation1.phpt"
208 ;; XXX: These gd tests fails. Likely because our version
209 ;; is different from the (patched) bundled one.
210 ;; Here, gd quits immediately after "fatal libpng error"; while the
211 ;; test expects it to additionally return a "setjmp" error and warning.
212 "ext/gd/tests/bug39780_extern.phpt"
213 "ext/gd/tests/libgd00086_extern.phpt"
214 ;; Extra newline in gd-png output.
215 "ext/gd/tests/bug45799.phpt"
216 ;; Different error message than expected from imagecrop().
217 "ext/gd/tests/bug66356.phpt"
218 ;; Similarly for imagecreatefromgd2().
219 "ext/gd/tests/bug72339.phpt"
220 ;; Call to undefined function imageantialias(). They are
221 ;; supposed to fail anyway.
222 "ext/gd/tests/bug72482.phpt"
223 "ext/gd/tests/bug72482_2.phpt"
224 "ext/gd/tests/bug73213.phpt"
225 ;; Test expects generic "gd warning" but gets the actual function name.
226 "ext/gd/tests/createfromwbmp2_extern.phpt"
227 ;; This bug should have been fixed in gd 2.2.2.
228 ;; Is it a regression?
229 "ext/gd/tests/bug65148.phpt"
230 ;; TODO: Enable these when libgd is built with xpm support.
231 "ext/gd/tests/xpm2gd.phpt"
232 "ext/gd/tests/xpm2jpg.phpt"
233 "ext/gd/tests/xpm2png.phpt"
235 ;; XXX: These iconv tests have the expected outcome,
236 ;; but with different error messages.
237 ;; Expects "illegal character", instead gets "unknown error (84)".
238 "ext/iconv/tests/bug52211.phpt"
239 ;; Expects "wrong charset", gets unknown error (22).
240 "ext/iconv/tests/iconv_mime_decode_variation3.phpt"
241 "ext/iconv/tests/iconv_strlen_error2.phpt"
242 "ext/iconv/tests/iconv_strlen_variation2.phpt"
243 "ext/iconv/tests/iconv_substr_error2.phpt"
244 ;; Expects conversion error, gets "error condition Termsig=11".
245 "ext/iconv/tests/iconv_strpos_error2.phpt"
246 "ext/iconv/tests/iconv_strrpos_error2.phpt"
247 ;; Similar, but iterating over multiple values.
248 ;; iconv breaks the loop after the first error with Termsig=11.
249 "ext/iconv/tests/iconv_strpos_variation4.phpt"
250 "ext/iconv/tests/iconv_strrpos_variation3.phpt"
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"
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"))
293 ;; Skip tests requiring network access.
294 (setenv "SKIP_ONLINE_TESTS" "1")
295 ;; Without this variable, 'make test' passes regardless of failures.
296 (setenv "REPORT_EXIT_STATUS" "1")
297 ;; Skip tests requiring I/O facilities that are unavailable in the
299 (setenv "SKIP_IO_CAPTURE_TESTS" "1")
301 #:test-target "test"))
306 ("cyrus-sasl" ,cyrus-sasl)
307 ("freetype" ,freetype)
313 ("libgcrypt" ,libgcrypt)
321 ("oniguruma" ,oniguruma)
322 ("openldap" ,openldap)
325 ("postgresql" ,postgresql)
326 ("readline" ,readline)
332 `(("pkg-config" ,pkg-config)
334 ("intltool" ,intltool)
335 ("procps" ,procps))) ; For tests.
336 (synopsis "PHP programming language")
338 "PHP (PHP Hypertext Processor) is a server-side (CGI) scripting
339 language designed primarily for web development but is also used as
340 a general-purpose programming language. PHP code may be embedded into
341 HTML code, or it can be used in combination with various web template
342 systems, web content management systems and web frameworks." )
344 (license:non-copyleft "file://LICENSE") ; The PHP license.
345 (license:non-copyleft "file://Zend/LICENSE") ; The Zend license.
346 license:lgpl2.1 ; ext/mbstring/libmbfl
347 license:lgpl2.1+ ; ext/bcmath/libbcmath
348 license:bsd-2 ; ext/fileinfo/libmagic
349 license:expat)))) ; ext/date/lib