projects/guix·blob wip-postfix · refs

441 lines · 22.7 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;;; Copyright © 2023 Timo Wilken <[email protected]>
10;;;
11;;; This file is part of GNU Guix.
12;;;
13;;; GNU Guix is free software; you can redistribute it and/or modify it
14;;; under the terms of the GNU General Public License as published by
15;;; the Free Software Foundation; either version 3 of the License, or (at
16;;; your option) any later version.
17;;;
18;;; GNU Guix is distributed in the hope that it will be useful, but
19;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21;;; GNU General Public License for more details.
22;;;
23;;; You should have received a copy of the GNU General Public License
24;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25
26(define-module (gnu packages php)
27 #:use-module (gnu packages)
28 #:use-module (gnu packages algebra)
29 #:use-module (gnu packages aspell)
30 #:use-module (gnu packages base)
31 #:use-module (gnu packages bison)
32 #:use-module (gnu packages compression)
33 #:use-module (gnu packages crypto)
34 #:use-module (gnu packages curl)
35 #:use-module (gnu packages cyrus-sasl)
36 #:use-module (gnu packages databases)
37 #:use-module (gnu packages dbm)
38 #:use-module (gnu packages fontutils)
39 #:use-module (gnu packages gd)
40 #:use-module (gnu packages gettext)
41 #:use-module (gnu packages gnupg)
42 #:use-module (gnu packages icu4c)
43 #:use-module (gnu packages image)
44 #:use-module (gnu packages linux)
45 #:use-module (gnu packages multiprecision)
46 #:use-module (gnu packages openldap)
47 #:use-module (gnu packages pcre)
48 #:use-module (gnu packages pkg-config)
49 #:use-module (gnu packages readline)
50 #:use-module (gnu packages sqlite)
51 #:use-module (gnu packages textutils)
52 #:use-module (gnu packages tls)
53 #:use-module (gnu packages web)
54 #:use-module (gnu packages xml)
55 #:use-module (gnu packages xorg)
56 #:use-module (guix packages)
57 #:use-module (guix download)
58 #:use-module (guix build-system gnu)
59 #:use-module (guix utils)
60 #:use-module ((guix licenses) #:prefix license:))
61
62(define-public php
63 (package
64 (name "php")
65 (version "8.2.2")
66 (home-page "https://www.php.net/")
67 (source (origin
68 (method url-fetch)
69 (uri (string-append home-page "distributions/"
70 "php-" version ".tar.xz"))
71 (sha256
72 (base32
73 "0czflx9ikxymjfgnzaifjx9kc30ww2x4063075hcifjjwqwami5x"))
74 (patches
75 (search-patches "php-fix-streams-copy-length.patch"))
76 (modules '((guix build utils)))
77 (snippet
78 '(with-directory-excursion "ext"
79 (for-each delete-file-recursively
80 ;; Some of the bundled libraries have no proper upstream.
81 ;; Ideally we'd extract these out as separate packages:
82 ;;"mbstring/libmbfl"
83 ;;"date/lib"
84 ;;"bcmath/libbcmath"
85 ;;"fileinfo/libmagic" ; a patched version of libmagic
86 '("gd/libgd"
87 "pcre/pcre2lib"))))))
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 "--enable-sysvsem")) ; Required for, e.g. Nextcloud
139 #:phases
140 (modify-phases %standard-phases
141 (add-after 'unpack 'do-not-record-build-flags
142 (lambda _
143 ;; Prevent configure flags from being stored and causing
144 ;; unnecessary runtime dependencies.
145 (substitute* "scripts/php-config.in"
146 (("@CONFIGURE_OPTIONS@") "")
147 (("@PHP_LDFLAGS@") ""))
148 ;; This file has ISO-8859-1 encoding.
149 (with-fluids ((%default-port-encoding "ISO-8859-1"))
150 (substitute* "main/build-defs.h.in"
151 (("@CONFIGURE_COMMAND@") "(omitted)")))))
152 (add-before 'build 'patch-/bin/sh
153 (lambda _
154 (substitute* '("run-tests.php" "ext/standard/proc_open.c")
155 (("/bin/sh") (which "sh")))))
156 (add-before 'check 'prepare-tests
157 (lambda _
158 ;; Some of these files have ISO-8859-1 encoding, whereas others
159 ;; use ASCII, so we can't use a "catch-all" find-files here.
160 (with-fluids ((%default-port-encoding "ISO-8859-1"))
161 (substitute* '("ext/mbstring/tests/mb_send_mail02.phpt"
162 "ext/mbstring/tests/mb_send_mail04.phpt"
163 "ext/mbstring/tests/mb_send_mail05.phpt"
164 "ext/mbstring/tests/mb_send_mail06.phpt")
165 (("/bin/cat") (which "cat"))))
166 (substitute* '("ext/mbstring/tests/mb_send_mail01.phpt"
167 "ext/mbstring/tests/mb_send_mail03.phpt"
168 "ext/mbstring/tests/bug52681.phpt"
169 "ext/standard/tests/general_functions/bug34794.phpt"
170 "ext/standard/tests/general_functions/bug44667.phpt"
171 "ext/standard/tests/general_functions/proc_open.phpt")
172 (("/bin/cat") (which "cat")))
173
174 ;; The encoding of this file is not recognized, so we simply drop it.
175 (delete-file "ext/mbstring/tests/mb_send_mail07.phpt")
176
177 (substitute* "ext/standard/tests/streams/bug60602.phpt"
178 (("'ls'") (string-append "'" (which "ls") "'")))
179
180 ,@(if (target-arm32?)
181 ;; Drop tests known to fail on armhf.
182 '((for-each delete-file
183 (list
184 "ext/calendar/tests/unixtojd_error1.phpt"
185 "ext/opcache/tests/preload_006.phpt"
186 "ext/opcache/tests/preload_011.phpt"
187 ;; arm can be a lot slower, so a time-related test fails
188 "ext/fileinfo/tests/cve-2014-3538-nojit.phpt"
189 "ext/pcntl/tests/pcntl_unshare_01.phpt"
190 "ext/pcre/tests/bug76514.phpt"
191 "ext/pcre/tests/preg_match_error3.phpt"
192 "ext/pcre/tests/cache_limit.phpt"
193 "ext/sockets/tests/socket_getopt.phpt"
194 "ext/sockets/tests/socket_sendrecvmsg_error.phpt"
195 "ext/standard/tests/general_functions/var_export-locale.phpt"
196 "ext/standard/tests/general_functions/var_export_basic1.phpt"
197 "ext/intl/tests/timezone_getErrorCodeMessage_basic.phpt"
198 "ext/intl/tests/timezone_getOffset_error.phpt"
199 "sapi/cli/tests/cli_process_title_unix.phpt"
200 "sapi/cli/tests/upload_2G.phpt"
201 "Zend/tests/concat_003.phpt")))
202 '())
203
204 ,@(if (target-x86-32?)
205 ;; Drop tests known to fail on i686.
206 '((for-each delete-file
207 (list
208 "ext/dba/tests/dba_gdbm.phpt")))
209 '())
210
211 ,@(if (target-ppc64le?)
212 ;; Drop tests known to fail on powerpc64le.
213 '((for-each delete-file
214 (list
215 ;; phpdbg watchpoints don't work.
216 ;; Bug tracked upstream at:
217 ;; https://bugs.php.net/bug.php?id=81408
218 "sapi/phpdbg/tests/watch_001.phpt"
219 "sapi/phpdbg/tests/watch_003.phpt"
220 "sapi/phpdbg/tests/watch_004.phpt"
221 "sapi/phpdbg/tests/watch_005.phpt"
222 "sapi/phpdbg/tests/watch_006.phpt")))
223 '())
224
225 ,@(if (target-riscv64?)
226 ;; Drop tests known to fail on riscv64.
227 '((for-each delete-file
228 (list "sapi/cli/tests/upload_2G.phpt")))
229 '())
230
231 ;; Drop tests that are known to fail.
232 (for-each delete-file
233 '("ext/posix/tests/posix_getgrgid.phpt" ; Requires /etc/group.
234 "ext/posix/tests/posix_getgrnam_basic.phpt" ; Requires /etc/group.
235 "ext/sockets/tests/bug63000.phpt" ; Fails to detect OS.
236 "ext/sockets/tests/socket_shutdown.phpt" ; Requires DNS.
237 "ext/sockets/tests/socket_send.phpt" ; Likewise.
238 "ext/sockets/tests/mcast_ipv4_recv.phpt" ; Requires multicast.
239 ;; These needs /etc/services.
240 "ext/standard/tests/general_functions/getservbyname_basic.phpt"
241 "ext/standard/tests/general_functions/getservbyport_basic.phpt"
242 "ext/standard/tests/general_functions/getservbyport_variation1.phpt"
243 ;; And /etc/protocols.
244 "ext/standard/tests/network/getprotobyname_basic.phpt"
245 "ext/standard/tests/network/getprotobynumber_basic.phpt"
246 ;; And exotic locales.
247 "ext/standard/tests/strings/setlocale_basic1.phpt"
248 "ext/standard/tests/strings/setlocale_basic2.phpt"
249 "ext/standard/tests/strings/setlocale_basic3.phpt"
250 "ext/standard/tests/strings/setlocale_variation1.phpt"
251 ;; This failing test is skipped on PHP's Travis CI as it is
252 ;; supposedly inaccurate.
253 "ext/standard/tests/file/disk_free_space_basic.phpt"
254 ;; The following test erroneously expect the link
255 ;; count of a sub-directory to increase compared to
256 ;; its parent.
257 "ext/standard/tests/file/lstat_stat_variation8.phpt"
258 ;; This tests whether microseconds ‘differ enough’ and
259 ;; fails inconsistently on ‘fast’ machines.
260 "ext/date/tests/bug73837.phpt"
261
262 ;; XXX: These gd tests fails. Likely because our version
263 ;; is different from the (patched) bundled one.
264 ;; Here, gd quits immediately after "fatal libpng error"; while the
265 ;; test expects it to additionally return a "setjmp" error and warning.
266 "ext/gd/tests/bug39780_extern.phpt"
267 "ext/gd/tests/libgd00086_extern.phpt"
268 ;; Extra newline in gd-png output.
269 "ext/gd/tests/bug45799.phpt"
270 ;; Test expects generic "gd warning" but gets the actual function name.
271 "ext/gd/tests/createfromwbmp2_extern.phpt"
272 ;; This bug should have been fixed in gd 2.2.2.
273 ;; Is it a regression?
274 "ext/gd/tests/bug65148.phpt"
275 ;; This bug should have been fixed in the gd 2.2
276 ;; series. Perhaps a regression introduced by gd
277 ;; 2.3.0?
278 "ext/gd/tests/bug66590.phpt"
279 ;; This bug should have been fixed in the php-5.5
280 ;; series. Perhaps a regression introduced by gd
281 ;; 2.3.0?
282 "ext/gd/tests/bug70102.phpt"
283 ;; This bug should have been fixed in the php-5.6
284 ;; series. Perhaps a regression introduced by gd
285 ;; 2.3.0?
286 "ext/gd/tests/bug73869.phpt"
287 ;; Some WebP related tests fail.
288 "ext/gd/tests/webp_basic.phpt"
289 "ext/gd/tests/imagecreatefromstring_webp.phpt"
290 ;; TODO: Enable these when libgd is built with xpm support.
291 "ext/gd/tests/xpm2gd.phpt"
292 "ext/gd/tests/xpm2jpg.phpt"
293 "ext/gd/tests/xpm2png.phpt"
294 ;; Whitespace difference, probably caused by a very
295 ;; long store path
296 "ext/gd/tests/bug77479.phpt"
297 ;; Expected invalid XBM but got EOF before image was
298 ;; complete. It's a warning in both cases and test
299 ;; result is the same.
300 "ext/gd/tests/bug77973.phpt"
301 ;; Test expects uninitialized value to be false, but
302 ;; instead gets "resource(5) of type (gd)".
303 "ext/gd/tests/bug79067.phpt"
304 ;; The following test fails with "The image size
305 ;; differs: expected 114x115, got 117x117".
306 "ext/gd/tests/bug79068.phpt"
307 ;; AVIF support disabled
308 "ext/gd/tests/avif_decode_encode.phpt"
309 ;; Typo in expected outputs
310 "ext/gd/tests/bug72339.phpt"
311 "ext/gd/tests/bug77272.phpt"
312 "ext/gd/tests/bug66356.phpt"
313 ;; AVIF support disabled
314 "ext/gd/tests/imagecreatefromstring_avif.phpt"
315
316 ;; XXX: These iconv tests have the expected outcome,
317 ;; but with different error messages.
318 ;; Expects "illegal character", instead gets "unknown error (84)".
319 "ext/iconv/tests/bug52211.phpt"
320 "ext/iconv/tests/bug60494.phpt"
321 ;; Expects "wrong charset", gets unknown error (22).
322 "ext/iconv/tests/iconv_strlen_error2.phpt"
323 "ext/iconv/tests/iconv_substr_error2.phpt"
324 ;; Expects conversion error, gets "error condition Termsig=11".
325 "ext/iconv/tests/iconv_strpos_error2.phpt"
326 "ext/iconv/tests/iconv_strrpos_error2.phpt"
327 ;; Expects "invalid multibyte sequence" but got
328 ;; "unknown error".
329 "ext/iconv/tests/bug76249.phpt"
330
331 ;; XXX: These test failures appear legitimate, needs investigation.
332 ;; open_basedir() restriction failure.
333 "ext/curl/tests/bug61948-unix.phpt"
334 ;; Same error reason but error code slightly different
335 "ext/curl/tests/curl_setopt_ssl.phpt"
336
337 ;; Fail because there is no "root" in the build container's
338 ;; /etc/passwd
339 "sapi/fpm/tests/bug68591-conf-test-group.phpt"
340 "sapi/fpm/tests/bug68591-conf-test-listen-group.phpt"
341 "sapi/fpm/tests/bug68591-conf-test-listen-owner.phpt"
342
343 ;; Wrong error name
344 "ext/dba/tests/dba_gdbm_creation_matrix.phpt"
345 ;; Expects a false boolean, gets empty array from glob().
346 "ext/standard/tests/file/bug41655_1.phpt"
347 "ext/standard/tests/file/glob_variation5.phpt"
348 ;; The test expects an Array, but instead get the contents(?).
349 "ext/gd/tests/bug43073.phpt"
350 ;; imagettftext() returns wrong coordinates.
351 "ext/gd/tests/bug48732-mb.phpt"
352 "ext/gd/tests/bug48732.phpt"
353 ;; Similarly for imageftbbox().
354 "ext/gd/tests/bug48801-mb.phpt"
355 "ext/gd/tests/bug48801.phpt"
356 ;; Different expected output from imagecolorallocate().
357 "ext/gd/tests/bug53504.phpt"
358 ;; Wrong image size after scaling an image.
359 "ext/gd/tests/bug73272.phpt"
360 ;; Expects iconv to detect illegal characters, instead gets
361 ;; "unknown error (84)" and heap corruption(!).
362 "ext/iconv/tests/bug48147.phpt"
363 ;; Expects illegal character ".", gets "=?utf-8?Q?."
364 "ext/iconv/tests/bug51250.phpt"
365 ;; iconv throws "buffer length exceeded" on some string checks.
366 "ext/iconv/tests/iconv_mime_encode.phpt"
367 ;; file_get_contents(): iconv stream filter
368 ;; ("ISO-8859-1"=>"UTF-8") unknown error.
369 "ext/standard/tests/file/bug43008.phpt"
370 ;; Table data not created in sqlite(?).
371 "ext/pdo_sqlite/tests/bug_42589.phpt"
372 ;; Expects an Array with 3 preg_matches; gets 0.
373 "ext/pcre/tests/bug79846.phpt"
374 ;; Expects an empty Array; gets one with " " in it.
375 "ext/pcre/tests/bug80118.phpt"
376 ;; Renicing a process fails in the build environment.
377 "ext/standard/tests/general_functions/proc_nice_basic.phpt"
378 ;; Can fail on fast machines?
379 "Zend/tests/bug74093.phpt"))
380
381 ;; Accomodate two extra openssl errors flanking the expected one:
382 ;; random number generator:RAND_{load,write}_file:Cannot open file
383 ;; This is due to an invalid $HOME, but changing it in the test
384 ;; still prints the first one & changing it globally is overkill.
385 (substitute* "ext/openssl/tests/bug80747.phpt"
386 ((".*error:%s:key size too small.*" match)
387 (string-append "%s\n" match "%s\n")))
388
389 ;; Skip tests requiring network access.
390 (setenv "SKIP_ONLINE_TESTS" "1")
391 ;; Without this variable, 'make test' passes regardless of failures.
392 (setenv "REPORT_EXIT_STATUS" "1")
393 ;; Skip tests requiring I/O facilities that are unavailable in the
394 ;; build environment
395 (setenv "SKIP_IO_CAPTURE_TESTS" "1"))))
396 #:test-target "test"))
397 (inputs
398 `(("aspell" ,aspell)
399 ("bzip2" ,bzip2)
400 ("curl" ,curl)
401 ("cyrus-sasl" ,cyrus-sasl)
402 ("gd" ,gd)
403 ("gdbm" ,gdbm)
404 ("gmp" ,gmp)
405 ("gnutls" ,gnutls)
406 ("icu4c" ,icu4c)
407 ("libgcrypt" ,libgcrypt)
408 ("libpng" ,libpng)
409 ("libsodium" ,libsodium)
410 ("libxml2" ,libxml2)
411 ("libxslt" ,libxslt)
412 ("libx11" ,libx11)
413 ("libzip" ,libzip)
414 ("oniguruma" ,oniguruma)
415 ("openldap" ,openldap)
416 ("openssl" ,openssl-1.1)
417 ("pcre" ,pcre2)
418 ("postgresql" ,postgresql)
419 ("readline" ,readline)
420 ("sqlite" ,sqlite)
421 ("tidy" ,tidy-html)
422 ("zlib" ,zlib)))
423 (native-inputs
424 `(("pkg-config" ,pkg-config)
425 ("bison" ,bison)
426 ("gettext" ,gettext-minimal)
427 ("procps" ,procps))) ; for tests
428 (synopsis "PHP programming language")
429 (description
430 "PHP (PHP Hypertext Processor) is a server-side (CGI) scripting
431language designed primarily for web development but is also used as
432a general-purpose programming language. PHP code may be embedded into
433HTML code, or it can be used in combination with various web template
434systems, web content management systems and web frameworks." )
435 (license (list
436 (license:non-copyleft "file://LICENSE") ; The PHP license.
437 (license:non-copyleft "file://Zend/LICENSE") ; The Zend license.
438 license:lgpl2.1 ; ext/mbstring/libmbfl
439 license:lgpl2.1+ ; ext/bcmath/libbcmath
440 license:bsd-2 ; ext/fileinfo/libmagic
441 license:expat)))) ; ext/date/lib