projects/guix·blob java-team · refs

419 lines · 18.4 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 regex)
53 #:use-module (gnu packages sqlite)
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;; current PHP version
66;; actively supported until: 31 Dec 2027
67;; security support until: 31 Dec 2029
68(define-public php-8.5
69 (package
70 (name "php")
71 (version "8.5.9")
72 (home-page "https://www.php.net/")
73 (source
74 (origin
75 (method url-fetch)
76 (uri (string-append home-page "distributions/" "php-" version ".tar.xz"))
77 (sha256
78 (base32 "1x08nwwwqr73488n4vqgmv9abxnnhki3bnrcb4fspl5w4mgqbdqd"))
79 (patches
80 (search-patches "php-03-fix-ftp-certificate.patch"))
81 (modules '((guix build utils)))
82 (snippet
83 '(with-directory-excursion "ext"
84 (for-each delete-file-recursively
85 ;; Some of the bundled libraries have no proper upstream.
86 ;; Ideally we'd extract these out as separate packages:
87 ;; "mbstring/libmbfl"
88 ;; "date/lib"
89 ;; "bcmath/libbcmath"
90 ;; "fileinfo/libmagic" ; a patched version of libmagic
91 '("gd/libgd" "pcre/pcre2lib"))))))
92 (build-system gnu-build-system)
93 (arguments
94 (list
95 #:modules
96 `((ice-9 textual-ports)
97 ,@%default-gnu-imported-modules)
98 #:configure-flags
99 #~(let-syntax ((with (syntax-rules ()
100 ((_ option input)
101 (string-append
102 option "="
103 (assoc-ref %build-inputs input))))))
104 (list (with "--with-bz2" "bzip2")
105 (with "--with-curl" "curl")
106 (with "--with-gdbm" "gdbm")
107 (with "--with-gettext" "libc") ;libintl.h
108 (with "--with-gmp" "gmp")
109 (with "--with-ldap" "openldap")
110 (with "--with-ldap-sasl" "cyrus-sasl")
111 (with "--with-pdo-pgsql" "postgresql")
112 (with "--with-pdo-sqlite" "sqlite")
113 (with "--with-pgsql" "postgresql")
114 ;; PHP’s Pspell extension, while retaining its current name,
115 ;; now uses the Aspell library.
116 (with "--with-pspell" "aspell")
117 (with "--with-readline" "readline")
118 (with "--with-sodium" "libsodium")
119 (with "--with-sqlite3" "sqlite")
120 (with "--with-tidy" "tidy-html")
121 (with "--with-xsl" "libxslt")
122 (with "--with-zlib-dir" "zlib")
123 ;; We could add "--with-snmp", but it requires netsnmp that
124 ;; we don't have a package for. It is used to build the snmp
125 ;; extension of php.
126 "--with-external-pcre"
127 "--with-external-gd"
128 "--with-iconv"
129 "--with-openssl"
130 "--with-mysqli" ;Required for, e.g. wordpress
131 "--with-pdo-mysql"
132 "--with-zip"
133 "--with-zlib"
134 "--enable-bcmath" ;Required for, e.g. Zabbix frontend
135 "--enable-calendar"
136 "--enable-dba=shared"
137 "--enable-exif"
138 "--enable-flatfile"
139 "--enable-fpm"
140 "--enable-ftp"
141 "--enable-gd"
142 "--enable-inifile"
143 "--enable-intl"
144 "--enable-mbstring"
145 "--enable-pcntl"
146 "--enable-sockets"
147 "--enable-sysvsem" ;Required for, e.g. Nextcloud
148 "--enable-embed" ;Required for embed SAPI
149 "--enable-zts"
150 "--disable-zend-signals"
151 "--enable-zend-max-execution-timers"))
152 #:phases
153 #~(modify-phases %standard-phases
154 (add-after 'unpack 'do-not-record-build-flags
155 (lambda _
156 ;; Prevent configure flags from being stored and causing
157 ;; unnecessary runtime dependencies.
158 (substitute* "scripts/php-config.in"
159 (("@CONFIGURE_OPTIONS@")
160 "")
161 (("@PHP_LDFLAGS@")
162 ""))
163 ;; This file has ISO-8859-1 encoding.
164 (with-fluids ((%default-port-encoding "ISO-8859-1"))
165 (substitute* "main/build-defs.h.in"
166 (("@CONFIGURE_COMMAND@")
167 "(omitted)")))))
168 (add-before 'build 'patch-/bin/sh
169 (lambda _
170 (substitute* '("run-tests.php"
171 "ext/standard/proc_open.c")
172 (("/bin/sh")
173 (which "sh")))))
174 (add-before 'check 'prepare-tests
175 (lambda* (#:key parallel-tests? #:allow-other-keys)
176 ;; Some of these files have ISO-8859-1 encoding, whereas others
177 ;; use ASCII, so we can't use a "catch-all" find-files here.
178 (with-fluids ((%default-port-encoding "ISO-8859-1"))
179 (substitute* '("ext/mbstring/tests/mb_send_mail02.phpt"
180 "ext/mbstring/tests/mb_send_mail04.phpt"
181 "ext/mbstring/tests/mb_send_mail05.phpt"
182 "ext/mbstring/tests/mb_send_mail06.phpt")
183 (("/bin/cat")
184 (which "cat"))))
185 (substitute* '("ext/mbstring/tests/mb_send_mail01.phpt"
186 "ext/mbstring/tests/mb_send_mail03.phpt"
187 "ext/mbstring/tests/bug52681.phpt"
188 "ext/standard/tests/general_functions/bug34794.phpt"
189 "ext/standard/tests/general_functions/bug44667.phpt"
190 "ext/standard/tests/general_functions/proc_open.phpt")
191 (("/bin/cat")
192 (which "cat")))
193
194 ;; The encoding of this file is not recognized, so we simply drop it.
195 (delete-file "ext/mbstring/tests/mb_send_mail07.phpt")
196
197 (substitute* "ext/standard/tests/streams/bug60602.phpt"
198 (("'ls'")
199 (string-append "'"
200 (which "ls") "'")))
201
202 ;; Drop tests known to fail on different architectures:
203 (for-each
204 delete-file
205 #$(cond
206 ((target-arm32?)
207 '(list
208 "ext/calendar/tests/unixtojd_error1.phpt"
209 "ext/opcache/tests/preload_006.phpt"
210 "ext/opcache/tests/preload_011.phpt"
211 ;; arm can be a lot slower, so a time-related test fails
212 "ext/fileinfo/tests/cve-2014-3538-nojit.phpt"
213 "ext/pcntl/tests/pcntl_unshare_01.phpt"
214 "ext/pcre/tests/bug76514.phpt"
215 "ext/pcre/tests/preg_match_error3.phpt"
216 "ext/pcre/tests/cache_limit.phpt"
217 "ext/sockets/tests/socket_getopt.phpt"
218 "ext/sockets/tests/socket_sendrecvmsg_error.phpt"
219 "ext/standard/tests/general_functions/var_export-locale.phpt"
220 "ext/standard/tests/general_functions/var_export_basic1.phpt"
221 "ext/intl/tests/timezone_getErrorCodeMessage_basic.phpt"
222 "ext/intl/tests/timezone_getOffset_error.phpt"
223 "sapi/cli/tests/cli_process_title_unix.phpt"
224 "Zend/tests/concat_003.phpt"))
225 ((target-x86-32?)
226 '(list "ext/dba/tests/dba_gdbm.phpt"))
227 ((target-ppc32?)
228 '(list "sapi/phpdbg/tests/watch_001.phpt"
229 "sapi/phpdbg/tests/watch_003.phpt"
230 "sapi/phpdbg/tests/watch_004.phpt"))
231 ((target-ppc64le?)
232 '(list
233 ;; phpdbg watchpoints don't work.
234 ;; Bug tracked upstream at:
235 ;; https://bugs.php.net/bug.php?id=81408
236 "sapi/phpdbg/tests/watch_001.phpt"
237 "sapi/phpdbg/tests/watch_003.phpt"
238 "sapi/phpdbg/tests/watch_004.phpt"
239 "sapi/phpdbg/tests/watch_005.phpt"
240 "sapi/phpdbg/tests/watch_006.phpt"))
241 (else ''())))
242
243 ;; Drop tests that are known to fail.
244 (for-each
245 delete-file
246 '("ext/posix/tests/posix_getgrgid.phpt" ;Requires /etc/group.
247 "ext/posix/tests/posix_getgrnam_basic.phpt" ;Requires /etc/group.
248 "ext/sockets/tests/bug63000.phpt" ;Fails to detect OS.
249 ;; These need exotic locales.
250 "ext/standard/tests/strings/setlocale_basic1.phpt"
251 "ext/standard/tests/strings/setlocale_basic2.phpt"
252 "ext/standard/tests/strings/setlocale_basic3.phpt"
253 "ext/standard/tests/strings/setlocale_variation1.phpt"
254
255 ;; This test fails for unknown reason (see:
256 ;; <https://github.com/php/php-src/issues/19996>).
257 "ext/gd/tests/gh16559.phpt"
258
259 ;; Some WebP related tests fail.
260 "ext/gd/tests/webp_basic.phpt"
261 "ext/gd/tests/imagecreatefromstring_webp.phpt"
262 ;; TODO: Enable these when libgd is built with xpm support.
263 "ext/gd/tests/xpm2gd.phpt"
264 "ext/gd/tests/xpm2jpg.phpt"
265 "ext/gd/tests/xpm2png.phpt"
266 ;; AVIF support disabled
267 "ext/gd/tests/avif_decode_encode.phpt"
268 ;; Typo in expected outputs
269 "ext/gd/tests/bug72339.phpt"
270 ;; AVIF support disabled
271 "ext/gd/tests/imagecreatefromstring_avif.phpt"
272
273 ;; These tests fail due to issues in upstream gd
274 ;; 2.3.3 around BICUBIC interpolation. See
275 ;; https://github.com/libgd/libgd/issues/847
276 "ext/gd/tests/bug79676.phpt"
277 "ext/gd/tests/imageinterpolation_basic.phpt"
278 "ext/gd/tests/imagescale_preserve_ratio.phpt"
279
280 ;; XXX: These test failures appear legitimate, needs investigation.
281 ;; open_basedir() restriction failure.
282 "ext/curl/tests/curl_setopt_ssl.phpt"
283
284 ;; Fail because there is no "root" in the build container's
285 ;; /etc/passwd
286 "sapi/fpm/tests/bug68591-conf-test-group.phpt"
287 "sapi/fpm/tests/bug68591-conf-test-listen-group.phpt"
288 "sapi/fpm/tests/bug68591-conf-test-listen-owner.phpt"
289
290 ;; The test expects an Array, but instead get the contents(?).
291 "ext/gd/tests/bug43073.phpt"
292 ;; imagettftext() returns wrong coordinates.
293 "ext/gd/tests/bug48732-mb.phpt"
294 "ext/gd/tests/bug48732.phpt"
295 ;; Similarly for imageftbbox().
296 "ext/gd/tests/bug48801-mb.phpt"
297 "ext/gd/tests/bug48801.phpt"
298 ;; Different expected output from imagecolorallocate().
299 "ext/gd/tests/bug53504.phpt"
300 ;; This test sometimes exit with Termsig=11 (see:
301 ;; <https://github.com/php/php-src/issues/19996>).
302 "ext/gd/tests/bug65148.phpt"
303 ;; Wrong image size after scaling an image.
304 "ext/gd/tests/bug73272.phpt"
305 ;; PCRE with/without JIT gives different result
306 "ext/pcre/tests/gh11374.phpt"
307 "ext/pcre/tests/gh11956.phpt"
308 ;; reported bug only seems to affect windows
309 "ext/standard/tests/directory/bug74589_utf8.phpt"
310 ;; This test is flaky, appears racy when the test suite runs
311 ;; in parallel (see:
312 ;; <https://github.com/php/php-src/issues/19998>).
313 "ext/standard/tests/file/bug46347.phpt"
314 ;; this test seems to be unreliable/flaky
315 "sapi/cli/tests/php_cli_server_pdeathsig.phpt"
316 ;; This test fails on most architectures.
317 "sapi/cli/tests/upload_2G.phpt"))
318
319 ;; Accommodate two extra openssl errors flanking the expected one:
320 ;; random number generator:RAND_{load,write}_file:Cannot open file
321 ;; This is due to an invalid $HOME, but changing it in the test
322 ;; still prints the first one & changing it globally is overkill.
323 (substitute* "ext/openssl/tests/bug80747.phpt"
324 ((".*error:%s:key size too small.*" match)
325 (string-append "%s\n" match "%s\n")))
326
327 ;; Skip tests requiring network access.
328 (setenv "SKIP_ONLINE_TESTS" "1")
329 ;; Without this variable, 'make test' passes regardless of failures.
330 (setenv "REPORT_EXIT_STATUS" "1")
331 ;; Skip tests requiring I/O facilities that are unavailable in the
332 ;; build environment
333 (setenv "SKIP_IO_CAPTURE_TESTS" "1")
334 ;; Run tests in parallel.
335 (setenv "TEST_PHP_ARGS"
336 (format #f "-j~a" (if parallel-tests?
337 (parallel-job-count)
338 1))))))
339 #:test-target "test"))
340 (inputs
341 (list aspell
342 bzip2
343 curl
344 cyrus-sasl
345 fontconfig
346 freetype
347 gd
348 gdbm
349 gmp
350 gnutls
351 icu4c
352 libgcrypt
353 libjpeg-turbo
354 libpng
355 libpng
356 libsodium
357 libx11
358 libxml2
359 libxslt
360 libzip
361 oniguruma
362 openldap
363 openssl
364 pcre2
365 postgresql
366 readline
367 sqlite
368 tidy-html
369 zlib))
370 (native-inputs
371 (list autoconf ;to save the test report
372 bison
373 gettext-minimal
374 pkg-config
375 procps)) ;for tests
376 (synopsis "PHP programming language")
377 (description
378 "PHP (PHP Hypertext Processor) is a server-side (CGI) scripting
379language designed primarily for web development but is also used as
380a general-purpose programming language. PHP code may be embedded into
381HTML code, or it can be used in combination with various web template
382systems, web content management systems and web frameworks.")
383 (license (list (license:non-copyleft "file://LICENSE") ;The PHP license.
384 (license:non-copyleft "file://Zend/LICENSE") ;The Zend license.
385 license:lgpl2.1 ;ext/mbstring/libmbfl
386 license:lgpl2.1+ ;ext/bcmath/libbcmath
387 license:bsd-2 ;ext/fileinfo/libmagic
388 license:expat)))) ; ext/date/lib
389
390;; php should always point to the latest php version
391(define-public php php-8.5)
392
393;; older supported php version
394;; actively supported until: 31 Dec 2026
395;; security support until: 31 Dec 2028
396(define-public php-8.4
397 (package
398 (inherit php-8.5)
399 (home-page "https://www.php.net/")
400 (version "8.4.24")
401 (source
402 (origin
403 (method url-fetch)
404 (uri (string-append home-page "distributions/" "php-" version ".tar.xz"))
405 (sha256
406 (base32 "0c87q01ll6q1w1f23v448iqi1lh09dhqm9ygqlkl6vshm04vw9z1"))
407 (patches
408 (search-patches "php-03-fix-ftp-certificate.patch"))
409 (modules '((guix build utils)))
410 (snippet
411 '(with-directory-excursion "ext"
412 (for-each delete-file-recursively
413 ;; Some of the bundled libraries have no proper upstream.
414 ;; Ideally we'd extract these out as separate packages:
415 ;; "mbstring/libmbfl"
416 ;; "date/lib"
417 ;; "bcmath/libbcmath"
418 ;; "fileinfo/libmagic" ; a patched version of libmagic
419 '("gd/libgd" "pcre/pcre2lib"))))))))