projects/guix·blob bootstrap-team · refs

380 lines · 17.0 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, 2025 Maxim Cournoyer <[email protected]>
8;;; Copyright © 2021, 2023 Efraim Flashner <[email protected]>
9;;; Copyright © 2023 Timo Wilken <[email protected]>
10;;; Copyright © 2025 Ashish SHUKLA <[email protected]>
11;;;
12;;; This file is part of GNU Guix.
13;;;
14;;; GNU Guix is free software; you can redistribute it and/or modify it
15;;; under the terms of the GNU General Public License as published by
16;;; the Free Software Foundation; either version 3 of the License, or (at
17;;; your option) any later version.
18;;;
19;;; GNU Guix is distributed in the hope that it will be useful, but
20;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22;;; GNU General Public License for more details.
23;;;
24;;; You should have received a copy of the GNU General Public License
25;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26
27(define-module (gnu packages php)
28 #:use-module (gnu packages)
29 #:use-module (gnu packages algebra)
30 #:use-module (gnu packages aspell)
31 #:use-module (gnu packages autotools)
32 #:use-module (gnu packages base)
33 #:use-module (gnu packages bison)
34 #:use-module (gnu packages compression)
35 #:use-module (gnu packages crypto)
36 #:use-module (gnu packages curl)
37 #:use-module (gnu packages cyrus-sasl)
38 #:use-module (gnu packages databases)
39 #:use-module (gnu packages dbm)
40 #:use-module (gnu packages fontutils)
41 #:use-module (gnu packages gd)
42 #:use-module (gnu packages gettext)
43 #:use-module (gnu packages gnupg)
44 #:use-module (gnu packages icu4c)
45 #:use-module (gnu packages image)
46 #:use-module (gnu packages linux)
47 #:use-module (gnu packages multiprecision)
48 #:use-module (gnu packages openldap)
49 #:use-module (gnu packages pcre)
50 #:use-module (gnu packages pkg-config)
51 #:use-module (gnu packages readline)
52 #:use-module (gnu packages sqlite)
53 #:use-module (gnu packages textutils)
54 #:use-module (gnu packages tls)
55 #:use-module (gnu packages web)
56 #:use-module (gnu packages xml)
57 #:use-module (gnu packages xorg)
58 #:use-module (guix packages)
59 #:use-module (guix download)
60 #:use-module (guix gexp)
61 #:use-module (guix build-system gnu)
62 #:use-module (guix utils)
63 #:use-module ((guix licenses) #:prefix license:))
64
65(define-public php
66 (package
67 (name "php")
68 (version "8.5.2")
69 (home-page "https://www.php.net/")
70 (source
71 (origin
72 (method url-fetch)
73 (uri (string-append home-page "distributions/" "php-" version ".tar.xz"))
74 (sha256
75 (base32 "1wc12f5s2cxgys59qxkm6hxl8yx48bpmhj6n1lwzf1i81aqajxfb"))
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" "pcre/pcre2lib"))))))
87 (build-system gnu-build-system)
88 (arguments
89 (list
90 #:configure-flags
91 #~(let-syntax ((with (syntax-rules ()
92 ((_ option input)
93 (string-append
94 option "="
95 (assoc-ref %build-inputs input))))))
96 (list (with "--with-bz2" "bzip2")
97 (with "--with-curl" "curl")
98 (with "--with-gdbm" "gdbm")
99 (with "--with-gettext" "libc") ;libintl.h
100 (with "--with-gmp" "gmp")
101 (with "--with-ldap" "openldap")
102 (with "--with-ldap-sasl" "cyrus-sasl")
103 (with "--with-pdo-pgsql" "postgresql")
104 (with "--with-pdo-sqlite" "sqlite")
105 (with "--with-pgsql" "postgresql")
106 ;; PHP’s Pspell extension, while retaining its current name,
107 ;; now uses the Aspell library.
108 (with "--with-pspell" "aspell")
109 (with "--with-readline" "readline")
110 (with "--with-sodium" "libsodium")
111 (with "--with-sqlite3" "sqlite")
112 (with "--with-tidy" "tidy-html")
113 (with "--with-xsl" "libxslt")
114 (with "--with-zlib-dir" "zlib")
115 ;; We could add "--with-snmp", but it requires netsnmp that
116 ;; we don't have a package for. It is used to build the snmp
117 ;; extension of php.
118 "--with-external-pcre"
119 "--with-external-gd"
120 "--with-iconv"
121 "--with-openssl"
122 "--with-mysqli" ;Required for, e.g. wordpress
123 "--with-pdo-mysql"
124 "--with-zip"
125 "--with-zlib"
126 "--enable-bcmath" ;Required for, e.g. Zabbix frontend
127 "--enable-calendar"
128 "--enable-dba=shared"
129 "--enable-exif"
130 "--enable-flatfile"
131 "--enable-fpm"
132 "--enable-ftp"
133 "--enable-gd"
134 "--enable-inifile"
135 "--enable-intl"
136 "--enable-mbstring"
137 "--enable-pcntl"
138 "--enable-sockets"
139 "--enable-sysvsem" ;Required for, e.g. Nextcloud
140 "--enable-embed" ;Required for embed SAPI
141 "--enable-zts"
142 "--disable-zend-signals"
143 "--enable-zend-max-execution-timers"))
144 #:phases
145 #~(modify-phases %standard-phases
146 (add-after 'unpack 'do-not-record-build-flags
147 (lambda _
148 ;; Prevent configure flags from being stored and causing
149 ;; unnecessary runtime dependencies.
150 (substitute* "scripts/php-config.in"
151 (("@CONFIGURE_OPTIONS@")
152 "")
153 (("@PHP_LDFLAGS@")
154 ""))
155 ;; This file has ISO-8859-1 encoding.
156 (with-fluids ((%default-port-encoding "ISO-8859-1"))
157 (substitute* "main/build-defs.h.in"
158 (("@CONFIGURE_COMMAND@")
159 "(omitted)")))))
160 (add-before 'build 'patch-/bin/sh
161 (lambda _
162 (substitute* '("run-tests.php"
163 "ext/standard/proc_open.c")
164 (("/bin/sh")
165 (which "sh")))))
166 (add-before 'check 'prepare-tests
167 (lambda* (#:key parallel-tests? #:allow-other-keys)
168 ;; Some of these files have ISO-8859-1 encoding, whereas others
169 ;; use ASCII, so we can't use a "catch-all" find-files here.
170 (with-fluids ((%default-port-encoding "ISO-8859-1"))
171 (substitute* '("ext/mbstring/tests/mb_send_mail02.phpt"
172 "ext/mbstring/tests/mb_send_mail04.phpt"
173 "ext/mbstring/tests/mb_send_mail05.phpt"
174 "ext/mbstring/tests/mb_send_mail06.phpt")
175 (("/bin/cat")
176 (which "cat"))))
177 (substitute* '("ext/mbstring/tests/mb_send_mail01.phpt"
178 "ext/mbstring/tests/mb_send_mail03.phpt"
179 "ext/mbstring/tests/bug52681.phpt"
180 "ext/standard/tests/general_functions/bug34794.phpt"
181 "ext/standard/tests/general_functions/bug44667.phpt"
182 "ext/standard/tests/general_functions/proc_open.phpt")
183 (("/bin/cat")
184 (which "cat")))
185
186 ;; The encoding of this file is not recognized, so we simply drop it.
187 (delete-file "ext/mbstring/tests/mb_send_mail07.phpt")
188
189 (substitute* "ext/standard/tests/streams/bug60602.phpt"
190 (("'ls'")
191 (string-append "'"
192 (which "ls") "'")))
193
194 ;; Drop tests known to fail on different architectures:
195 (for-each
196 delete-file
197 #$(cond
198 ((target-arm32?)
199 '(list
200 "ext/calendar/tests/unixtojd_error1.phpt"
201 "ext/opcache/tests/preload_006.phpt"
202 "ext/opcache/tests/preload_011.phpt"
203 ;; arm can be a lot slower, so a time-related test fails
204 "ext/fileinfo/tests/cve-2014-3538-nojit.phpt"
205 "ext/pcntl/tests/pcntl_unshare_01.phpt"
206 "ext/pcre/tests/bug76514.phpt"
207 "ext/pcre/tests/preg_match_error3.phpt"
208 "ext/pcre/tests/cache_limit.phpt"
209 "ext/sockets/tests/socket_getopt.phpt"
210 "ext/sockets/tests/socket_sendrecvmsg_error.phpt"
211 "ext/standard/tests/general_functions/var_export-locale.phpt"
212 "ext/standard/tests/general_functions/var_export_basic1.phpt"
213 "ext/intl/tests/timezone_getErrorCodeMessage_basic.phpt"
214 "ext/intl/tests/timezone_getOffset_error.phpt"
215 "sapi/cli/tests/cli_process_title_unix.phpt"
216 "Zend/tests/concat_003.phpt"))
217 ((target-x86-32?)
218 '(list "ext/dba/tests/dba_gdbm.phpt"))
219 ((target-ppc32?)
220 '(list "sapi/phpdbg/tests/watch_001.phpt"
221 "sapi/phpdbg/tests/watch_003.phpt"
222 "sapi/phpdbg/tests/watch_004.phpt"))
223 ((target-ppc64le?)
224 '(list
225 ;; phpdbg watchpoints don't work.
226 ;; Bug tracked upstream at:
227 ;; https://bugs.php.net/bug.php?id=81408
228 "sapi/phpdbg/tests/watch_001.phpt"
229 "sapi/phpdbg/tests/watch_003.phpt"
230 "sapi/phpdbg/tests/watch_004.phpt"
231 "sapi/phpdbg/tests/watch_005.phpt"
232 "sapi/phpdbg/tests/watch_006.phpt"))
233 (else ''())))
234
235 ;; Drop tests that are known to fail.
236 (for-each
237 delete-file
238 '("ext/posix/tests/posix_getgrgid.phpt" ;Requires /etc/group.
239 "ext/posix/tests/posix_getgrnam_basic.phpt" ;Requires /etc/group.
240 "ext/sockets/tests/bug63000.phpt" ;Fails to detect OS.
241 ;; These need exotic locales.
242 "ext/standard/tests/strings/setlocale_basic1.phpt"
243 "ext/standard/tests/strings/setlocale_basic2.phpt"
244 "ext/standard/tests/strings/setlocale_basic3.phpt"
245 "ext/standard/tests/strings/setlocale_variation1.phpt"
246
247 ;; This test fails for unknown reason (see:
248 ;; <https://github.com/php/php-src/issues/19996>).
249 "ext/gd/tests/gh16559.phpt"
250
251 ;; Some WebP related tests fail.
252 "ext/gd/tests/webp_basic.phpt"
253 "ext/gd/tests/imagecreatefromstring_webp.phpt"
254 ;; TODO: Enable these when libgd is built with xpm support.
255 "ext/gd/tests/xpm2gd.phpt"
256 "ext/gd/tests/xpm2jpg.phpt"
257 "ext/gd/tests/xpm2png.phpt"
258 ;; AVIF support disabled
259 "ext/gd/tests/avif_decode_encode.phpt"
260 ;; Typo in expected outputs
261 "ext/gd/tests/bug72339.phpt"
262 ;; AVIF support disabled
263 "ext/gd/tests/imagecreatefromstring_avif.phpt"
264
265 ;; These tests fail due to issues in upstream gd
266 ;; 2.3.3 around BICUBIC interpolation. See
267 ;; https://github.com/libgd/libgd/issues/847
268 "ext/gd/tests/bug79676.phpt"
269 "ext/gd/tests/imageinterpolation_basic.phpt"
270 "ext/gd/tests/imagescale_preserve_ratio.phpt"
271
272 ;; XXX: These test failures appear legitimate, needs investigation.
273 ;; open_basedir() restriction failure.
274 "ext/curl/tests/curl_setopt_ssl.phpt"
275
276 ;; Fail because there is no "root" in the build container's
277 ;; /etc/passwd
278 "sapi/fpm/tests/bug68591-conf-test-group.phpt"
279 "sapi/fpm/tests/bug68591-conf-test-listen-group.phpt"
280 "sapi/fpm/tests/bug68591-conf-test-listen-owner.phpt"
281
282 ;; The test expects an Array, but instead get the contents(?).
283 "ext/gd/tests/bug43073.phpt"
284 ;; imagettftext() returns wrong coordinates.
285 "ext/gd/tests/bug48732-mb.phpt"
286 "ext/gd/tests/bug48732.phpt"
287 ;; Similarly for imageftbbox().
288 "ext/gd/tests/bug48801-mb.phpt"
289 "ext/gd/tests/bug48801.phpt"
290 ;; Different expected output from imagecolorallocate().
291 "ext/gd/tests/bug53504.phpt"
292 ;; This test sometimes exit with Termsig=11 (see:
293 ;; <https://github.com/php/php-src/issues/19996>).
294 "ext/gd/tests/bug65148.phpt"
295 ;; Wrong image size after scaling an image.
296 "ext/gd/tests/bug73272.phpt"
297 ;; PCRE with/without JIT gives different result
298 "ext/pcre/tests/gh11374.phpt"
299 "ext/pcre/tests/gh11956.phpt"
300 ;; reported bug only seems to affect windows
301 "ext/standard/tests/directory/bug74589_utf8.phpt"
302 ;; This test is flaky, appears racy when the test suite runs
303 ;; in parallel (see:
304 ;; <https://github.com/php/php-src/issues/19998>).
305 "ext/standard/tests/file/bug46347.phpt"
306 ;; this test seems to be unreliable/flaky
307 "sapi/cli/tests/php_cli_server_pdeathsig.phpt"
308 ;; This test fails on most architectures.
309 "sapi/cli/tests/upload_2G.phpt"))
310
311 ;; Accomodate two extra openssl errors flanking the expected one:
312 ;; random number generator:RAND_{load,write}_file:Cannot open file
313 ;; This is due to an invalid $HOME, but changing it in the test
314 ;; still prints the first one & changing it globally is overkill.
315 (substitute* "ext/openssl/tests/bug80747.phpt"
316 ((".*error:%s:key size too small.*" match)
317 (string-append "%s\n" match "%s\n")))
318
319 ;; Skip tests requiring network access.
320 (setenv "SKIP_ONLINE_TESTS" "1")
321 ;; Without this variable, 'make test' passes regardless of failures.
322 (setenv "REPORT_EXIT_STATUS" "1")
323 ;; Skip tests requiring I/O facilities that are unavailable in the
324 ;; build environment
325 (setenv "SKIP_IO_CAPTURE_TESTS" "1")
326 ;; Run tests in parallel.
327 (setenv "TEST_PHP_ARGS"
328 (format #f "-j~a" (if parallel-tests?
329 (parallel-job-count)
330 1))))))
331 #:test-target "test"))
332 (inputs
333 (list aspell
334 bzip2
335 curl
336 cyrus-sasl
337 fontconfig
338 freetype
339 gd
340 gdbm
341 gmp
342 gnutls
343 icu4c
344 libgcrypt
345 libjpeg-turbo
346 libpng
347 libpng
348 libsodium
349 libx11
350 libxml2
351 libxslt
352 libzip
353 oniguruma
354 openldap
355 openssl
356 pcre2
357 postgresql
358 readline
359 sqlite
360 tidy-html
361 zlib))
362 (native-inputs
363 (list autoconf ;to save the test report
364 bison
365 gettext-minimal
366 pkg-config
367 procps)) ;for tests
368 (synopsis "PHP programming language")
369 (description
370 "PHP (PHP Hypertext Processor) is a server-side (CGI) scripting
371language designed primarily for web development but is also used as
372a general-purpose programming language. PHP code may be embedded into
373HTML code, or it can be used in combination with various web template
374systems, web content management systems and web frameworks.")
375 (license (list (license:non-copyleft "file://LICENSE") ;The PHP license.
376 (license:non-copyleft "file://Zend/LICENSE") ;The Zend license.
377 license:lgpl2.1 ;ext/mbstring/libmbfl
378 license:lgpl2.1+ ;ext/bcmath/libbcmath
379 license:bsd-2 ;ext/fileinfo/libmagic
380 license:expat)))) ; ext/date/lib