projects/guix·blob version-1.4.0 · refs

409 lines · 21.3 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2016-2020 Julien Lepiller <[email protected]>
3;;; Copyright © 2016 Marius Bakke <[email protected]>
4;;; Copyright © 2018, 2020, 2021 Tobias Geerinckx-Rice <[email protected]>
5;;; Copyright © 2018 Ricardo Wurmus <[email protected]>
6;;; Copyright © 2019 Oleg Pykhalov <[email protected]>
7;;; Copyright © 2020 Maxim Cournoyer <[email protected]>
8;;; Copyright © 2021 Efraim Flashner <[email protected]>
9;;;
10;;; This file is part of GNU Guix.
11;;;
12;;; GNU Guix is free software; you can redistribute it and/or modify it
13;;; under the terms of the GNU General Public License as published by
14;;; the Free Software Foundation; either version 3 of the License, or (at
15;;; your option) any later version.
16;;;
17;;; GNU Guix is distributed in the hope that it will be useful, but
18;;; WITHOUT ANY WARRANTY; without even the implied warranty of
19;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20;;; GNU General Public License for more details.
21;;;
22;;; You should have received a copy of the GNU General Public License
23;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
24
25(define-module (gnu packages php)
26 #:use-module (gnu packages)
27 #:use-module (gnu packages algebra)
28 #:use-module (gnu packages aspell)
29 #:use-module (gnu packages base)
30 #:use-module (gnu packages bison)
31 #:use-module (gnu packages compression)
32 #:use-module (gnu packages crypto)
33 #:use-module (gnu packages curl)
34 #:use-module (gnu packages cyrus-sasl)
35 #:use-module (gnu packages databases)
36 #:use-module (gnu packages dbm)
37 #:use-module (gnu packages fontutils)
38 #:use-module (gnu packages gd)
39 #:use-module (gnu packages gettext)
40 #:use-module (gnu packages gnupg)
41 #:use-module (gnu packages icu4c)
42 #:use-module (gnu packages image)
43 #:use-module (gnu packages linux)
44 #:use-module (gnu packages multiprecision)
45 #:use-module (gnu packages openldap)
46 #:use-module (gnu packages pcre)
47 #:use-module (gnu packages pkg-config)
48 #:use-module (gnu packages readline)
49 #:use-module (gnu packages sqlite)
50 #:use-module (gnu packages textutils)
51 #:use-module (gnu packages tls)
52 #:use-module (gnu packages web)
53 #:use-module (gnu packages xml)
54 #:use-module (gnu packages xorg)
55 #:use-module (guix packages)
56 #:use-module (guix download)
57 #:use-module (guix build-system gnu)
58 #:use-module (guix utils)
59 #:use-module ((guix licenses) #:prefix license:))
60
61(define-public php
62 (package
63 (name "php")
64 (version "7.4.30")
65 (home-page "https://secure.php.net/")
66 (source (origin
67 (method url-fetch)
68 (uri (string-append home-page "distributions/"
69 "php-" version ".tar.xz"))
70 (sha256
71 (base32
72 "03d7icwys4ikl45q3rgsxv1m3i7kfxhykpx75nn7jzn6697s6wpa"))
73 (patches (search-patches "php-bug-74093-test.patch"
74 "php-curl-compat.patch"))
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" ; a patched version of libmagic
85 '("gd/libgd"
86 "pcre/pcre2lib"
87 "xmlrpc/libxmlrpc"))))))
88 (build-system gnu-build-system)
89 (arguments
90 `(#:configure-flags
91 (let-syntax ((with (syntax-rules ()
92 ((_ option input)
93 (string-append option "="
94 (assoc-ref %build-inputs input))))))
95 (list (with "--with-bz2" "bzip2")
96 (with "--with-curl" "curl")
97 (with "--with-gdbm" "gdbm")
98 (with "--with-gettext" "libc") ; libintl.h
99 (with "--with-gmp" "gmp")
100 (with "--with-ldap" "openldap")
101 (with "--with-ldap-sasl" "cyrus-sasl")
102 (with "--with-pdo-pgsql" "postgresql")
103 (with "--with-pdo-sqlite" "sqlite")
104 (with "--with-pgsql" "postgresql")
105 ;; PHP’s Pspell extension, while retaining its current name,
106 ;; now uses the Aspell library.
107 (with "--with-pspell" "aspell")
108 (with "--with-readline" "readline")
109 (with "--with-sodium" "libsodium")
110 (with "--with-sqlite3" "sqlite")
111 (with "--with-tidy" "tidy")
112 (with "--with-xsl" "libxslt")
113 (with "--with-zlib-dir" "zlib")
114 ;; We could add "--with-snmp", but it requires netsnmp that
115 ;; we don't have a package for. It is used to build the snmp
116 ;; extension of php.
117 "--with-external-pcre"
118 "--with-external-gd"
119 "--with-iconv"
120 "--with-openssl"
121 "--with-mysqli" ; Required for, e.g. wordpress
122 "--with-pdo-mysql"
123 "--with-zip"
124 "--with-zlib"
125 "--enable-bcmath" ; Required for, e.g. Zabbix frontend
126 "--enable-calendar"
127 "--enable-dba=shared"
128 "--enable-exif"
129 "--enable-flatfile"
130 "--enable-fpm"
131 "--enable-ftp"
132 "--enable-gd"
133 "--enable-inifile"
134 "--enable-intl"
135 "--enable-mbstring"
136 "--enable-pcntl"
137 "--enable-sockets"))
138 #:phases
139 (modify-phases %standard-phases
140 (add-after 'unpack 'do-not-record-build-flags
141 (lambda _
142 ;; Prevent configure flags from being stored and causing
143 ;; unnecessary runtime dependencies.
144 (substitute* "scripts/php-config.in"
145 (("@CONFIGURE_OPTIONS@") "")
146 (("@PHP_LDFLAGS@") ""))
147 ;; This file has ISO-8859-1 encoding.
148 (with-fluids ((%default-port-encoding "ISO-8859-1"))
149 (substitute* "main/build-defs.h.in"
150 (("@CONFIGURE_COMMAND@") "(omitted)")))))
151 (add-before 'build 'patch-/bin/sh
152 (lambda _
153 (substitute* '("run-tests.php" "ext/standard/proc_open.c")
154 (("/bin/sh") (which "sh")))))
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/bug52681.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")))
172
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
179 ,@(if (string-prefix? "arm" (or (%current-system)
180 (%current-target-system)))
181 ;; Drop tests known to fail on armhf.
182 '((for-each delete-file
183 (list
184 "ext/calendar/tests/unixtojd_error1.phpt"
185 ;; arm can be a lot slower, so a time-related test fails
186 "ext/fileinfo/tests/cve-2014-3538-nojit.phpt"
187 "ext/pcntl/tests/pcntl_unshare_01.phpt"
188 "ext/pcre/tests/bug76514.phpt"
189 "ext/pcre/tests/preg_match_error3.phpt"
190 "ext/pcre/tests/cache_limit.phpt"
191 "ext/sockets/tests/socket_getopt.phpt"
192 "ext/sockets/tests/socket_sendrecvmsg_error.phpt"
193 "ext/standard/tests/general_functions/var_export-locale.phpt"
194 "ext/standard/tests/general_functions/var_export_basic1.phpt"
195 "ext/intl/tests/timezone_getErrorCodeMessage_basic.phpt"
196 "ext/intl/tests/timezone_getOffset_error.phpt"
197 "sapi/cli/tests/cli_process_title_unix.phpt"
198 "sapi/cli/tests/upload_2G.phpt"
199 "Zend/tests/concat_003.phpt")))
200 '())
201
202 ,@(if (target-ppc64le?)
203 ;; Drop tests known to fail on powerpc64le.
204 '((for-each delete-file
205 (list
206 ;; phpdbg watchpoints don't work.
207 ;; Bug tracked upstream at:
208 ;; https://bugs.php.net/bug.php?id=81408
209 "sapi/phpdbg/tests/watch_001.phpt"
210 "sapi/phpdbg/tests/watch_003.phpt"
211 "sapi/phpdbg/tests/watch_004.phpt"
212 "sapi/phpdbg/tests/watch_005.phpt"
213 "sapi/phpdbg/tests/watch_006.phpt")))
214 '())
215
216 ;; Drop tests that are known to fail.
217 (for-each delete-file
218 '("ext/posix/tests/posix_getgrgid.phpt" ; Requires /etc/group.
219 "ext/posix/tests/posix_getgrnam_basic.phpt" ; Requires /etc/group.
220 "ext/sockets/tests/bug63000.phpt" ; Fails to detect OS.
221 "ext/sockets/tests/socket_shutdown.phpt" ; Requires DNS.
222 "ext/sockets/tests/socket_send.phpt" ; Likewise.
223 "ext/sockets/tests/mcast_ipv4_recv.phpt" ; Requires multicast.
224 ;; These needs /etc/services.
225 "ext/standard/tests/general_functions/getservbyname_basic.phpt"
226 "ext/standard/tests/general_functions/getservbyport_basic.phpt"
227 "ext/standard/tests/general_functions/getservbyport_variation1.phpt"
228 ;; And /etc/protocols.
229 "ext/standard/tests/network/getprotobyname_basic.phpt"
230 "ext/standard/tests/network/getprotobynumber_basic.phpt"
231 ;; And exotic locales.
232 "ext/standard/tests/strings/setlocale_basic1.phpt"
233 "ext/standard/tests/strings/setlocale_basic2.phpt"
234 "ext/standard/tests/strings/setlocale_basic3.phpt"
235 "ext/standard/tests/strings/setlocale_variation1.phpt"
236 ;; This failing test is skipped on PHP's Travis CI as it is
237 ;; supposedly inaccurate.
238 "ext/standard/tests/file/disk_free_space_basic.phpt"
239 ;; The following test erroneously expect the link
240 ;; count of a sub-directory to increase compared to
241 ;; its parent.
242 "ext/standard/tests/file/lstat_stat_variation8.phpt"
243 ;; This tests whether microseconds ‘differ enough’ and
244 ;; fails inconsistently on ‘fast’ machines.
245 "ext/date/tests/bug73837.phpt"
246
247 ;; XXX: These gd tests fails. Likely because our version
248 ;; is different from the (patched) bundled one.
249 ;; Here, gd quits immediately after "fatal libpng error"; while the
250 ;; test expects it to additionally return a "setjmp" error and warning.
251 "ext/gd/tests/bug39780_extern.phpt"
252 "ext/gd/tests/libgd00086_extern.phpt"
253 ;; Extra newline in gd-png output.
254 "ext/gd/tests/bug45799.phpt"
255 ;; Test expects generic "gd warning" but gets the actual function name.
256 "ext/gd/tests/createfromwbmp2_extern.phpt"
257 ;; This bug should have been fixed in gd 2.2.2.
258 ;; Is it a regression?
259 "ext/gd/tests/bug65148.phpt"
260 ;; This bug should have been fixed in the gd 2.2
261 ;; series. Perhaps a regression introduced by gd
262 ;; 2.3.0?
263 "ext/gd/tests/bug66590.phpt"
264 ;; This bug should have been fixed in the php-5.5
265 ;; series. Perhaps a regression introduced by gd
266 ;; 2.3.0?
267 "ext/gd/tests/bug70102.phpt"
268 ;; This bug should have been fixed in the php-5.6
269 ;; series. Perhaps a regression introduced by gd
270 ;; 2.3.0?
271 "ext/gd/tests/bug73869.phpt"
272 ;; Some WebP related tests fail.
273 "ext/gd/tests/webp_basic.phpt"
274 "ext/gd/tests/imagecreatefromstring_webp.phpt"
275 ;; Expected error message, but from the wrong function
276 "ext/gd/tests/bug77269.phpt"
277 ;; TODO: Enable these when libgd is built with xpm support.
278 "ext/gd/tests/xpm2gd.phpt"
279 "ext/gd/tests/xpm2jpg.phpt"
280 "ext/gd/tests/xpm2png.phpt"
281 ;; Whitespace difference, probably caused by a very
282 ;; long store path
283 "ext/gd/tests/bug77479.phpt"
284 ;; Expected invalid XBM but got EOF before image was
285 ;; complete. It's a warning in both cases and test
286 ;; result is the same.
287 "ext/gd/tests/bug77973.phpt"
288 ;; Test expects uninitialized value to be false, but
289 ;; instead gets "resource(5) of type (gd)".
290 "ext/gd/tests/bug79067.phpt"
291 ;; The following test fails with "The image size
292 ;; differs: expected 114x115, got 117x117".
293 "ext/gd/tests/bug79068.phpt"
294
295 ;; XXX: These iconv tests have the expected outcome,
296 ;; but with different error messages.
297 ;; Expects "illegal character", instead gets "unknown error (84)".
298 "ext/iconv/tests/bug52211.phpt"
299 "ext/iconv/tests/bug60494.phpt"
300 ;; Expects "wrong charset", gets unknown error (22).
301 "ext/iconv/tests/iconv_strlen_error2.phpt"
302 "ext/iconv/tests/iconv_substr_error2.phpt"
303 ;; Expects conversion error, gets "error condition Termsig=11".
304 "ext/iconv/tests/iconv_strpos_error2.phpt"
305 "ext/iconv/tests/iconv_strrpos_error2.phpt"
306 ;; Expects "invalid multibyte sequence" but got
307 ;; "unknown error".
308 "ext/iconv/tests/bug76249.phpt"
309
310 ;; XXX: These test failures appear legitimate, needs investigation.
311 ;; open_basedir() restriction failure.
312 "ext/curl/tests/bug61948-unix.phpt"
313 ;; Expects a false boolean, gets empty array from glob().
314 "ext/standard/tests/file/bug41655_1.phpt"
315 "ext/standard/tests/file/glob_variation5.phpt"
316 ;; The test expects an Array, but instead get the contents(?).
317 "ext/gd/tests/bug43073.phpt"
318 ;; imagettftext() returns wrong coordinates.
319 "ext/gd/tests/bug48732-mb.phpt"
320 "ext/gd/tests/bug48732.phpt"
321 ;; Similarly for imageftbbox().
322 "ext/gd/tests/bug48801-mb.phpt"
323 "ext/gd/tests/bug48801.phpt"
324 ;; Different expected output from imagecolorallocate().
325 "ext/gd/tests/bug53504.phpt"
326 ;; Wrong image size after scaling an image.
327 "ext/gd/tests/bug73272.phpt"
328 ;; Expects iconv to detect illegal characters, instead gets
329 ;; "unknown error (84)" and heap corruption(!).
330 "ext/iconv/tests/bug48147.phpt"
331 ;; Expects illegal character ".", gets "=?utf-8?Q?."
332 "ext/iconv/tests/bug51250.phpt"
333 ;; iconv throws "buffer length exceeded" on some string checks.
334 "ext/iconv/tests/iconv_mime_encode.phpt"
335 ;; file_get_contents(): iconv stream filter
336 ;; ("ISO-8859-1"=>"UTF-8") unknown error.
337 "ext/standard/tests/file/bug43008.phpt"
338 ;; Table data not created in sqlite(?).
339 "ext/pdo_sqlite/tests/bug_42589.phpt"
340 ;; Expects an Array with 3 preg_matches; gets 0.
341 "ext/pcre/tests/bug79846.phpt"
342 ;; Expects an empty Array; gets one with " " in it.
343 "ext/pcre/tests/bug80118.phpt"
344 ;; Renicing a process fails in the build environment.
345 "ext/standard/tests/general_functions/proc_nice_basic.phpt"
346 ;; Can fail on fast machines?
347 "Zend/tests/bug74093.phpt"))
348
349 ;; Accomodate two extra openssl errors flanking the expected one:
350 ;; random number generator:RAND_{load,write}_file:Cannot open file
351 ;; This is due to an invalid $HOME, but changing it in the test
352 ;; still prints the first one & changing it globally is overkill.
353 (substitute* "ext/openssl/tests/bug80747.phpt"
354 ((".*error:%s:key size too small.*" match)
355 (string-append "%s\n" match "%s\n")))
356
357 ;; Skip tests requiring network access.
358 (setenv "SKIP_ONLINE_TESTS" "1")
359 ;; Without this variable, 'make test' passes regardless of failures.
360 (setenv "REPORT_EXIT_STATUS" "1")
361 ;; Skip tests requiring I/O facilities that are unavailable in the
362 ;; build environment
363 (setenv "SKIP_IO_CAPTURE_TESTS" "1"))))
364 #:test-target "test"))
365 (inputs
366 `(("aspell" ,aspell)
367 ("bzip2" ,bzip2)
368 ("curl" ,curl)
369 ("cyrus-sasl" ,cyrus-sasl)
370 ("gd" ,gd)
371 ("gdbm" ,gdbm)
372 ("gmp" ,gmp)
373 ("gnutls" ,gnutls)
374 ("icu4c" ,icu4c)
375 ("libgcrypt" ,libgcrypt)
376 ("libpng" ,libpng)
377 ("libsodium" ,libsodium)
378 ("libxml2" ,libxml2)
379 ("libxslt" ,libxslt)
380 ("libx11" ,libx11)
381 ("libzip" ,libzip)
382 ("oniguruma" ,oniguruma)
383 ("openldap" ,openldap)
384 ("openssl" ,openssl-1.1)
385 ("pcre" ,pcre2)
386 ("postgresql" ,postgresql)
387 ("readline" ,readline)
388 ("sqlite" ,sqlite)
389 ("tidy" ,tidy)
390 ("zlib" ,zlib)))
391 (native-inputs
392 `(("pkg-config" ,pkg-config)
393 ("bison" ,bison)
394 ("gettext" ,gettext-minimal)
395 ("procps" ,procps))) ; for tests
396 (synopsis "PHP programming language")
397 (description
398 "PHP (PHP Hypertext Processor) is a server-side (CGI) scripting
399language designed primarily for web development but is also used as
400a general-purpose programming language. PHP code may be embedded into
401HTML code, or it can be used in combination with various web template
402systems, web content management systems and web frameworks." )
403 (license (list
404 (license:non-copyleft "file://LICENSE") ; The PHP license.
405 (license:non-copyleft "file://Zend/LICENSE") ; The Zend license.
406 license:lgpl2.1 ; ext/mbstring/libmbfl
407 license:lgpl2.1+ ; ext/bcmath/libbcmath
408 license:bsd-2 ; ext/fileinfo/libmagic
409 license:expat)))) ; ext/date/lib