Commit | Line | Data |
---|---|---|
1845c2a4 JL |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2016 Julien Lepiller <julien@lepiller.eu> | |
3 | ;;; Copyright © 2016 Marius Bakke <mbakke@fastmail.com> | |
d8216013 | 4 | ;;; Copyright © 2018, 2020 Tobias Geerinckx-Rice <me@tobias.gr> |
4629d267 | 5 | ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net> |
8b6c91ba | 6 | ;;; Copyright © 2019 Oleg Pykhalov <go.wigust@gmail.com> |
1eb343f9 | 7 | ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com> |
1845c2a4 JL |
8 | ;;; |
9 | ;;; This file is part of GNU Guix. | |
10 | ;;; | |
11 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
12 | ;;; under the terms of the GNU General Public License as published by | |
13 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
14 | ;;; your option) any later version. | |
15 | ;;; | |
16 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
17 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | ;;; GNU General Public License for more details. | |
20 | ;;; | |
21 | ;;; You should have received a copy of the GNU General Public License | |
22 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
23 | ||
24 | (define-module (gnu packages php) | |
25 | #:use-module (gnu packages) | |
26 | #:use-module (gnu packages algebra) | |
27 | #:use-module (gnu packages aspell) | |
28 | #:use-module (gnu packages base) | |
29 | #:use-module (gnu packages bison) | |
30 | #:use-module (gnu packages compression) | |
31 | #:use-module (gnu packages curl) | |
32 | #:use-module (gnu packages cyrus-sasl) | |
33 | #:use-module (gnu packages databases) | |
255d1bbe | 34 | #:use-module (gnu packages dbm) |
1845c2a4 JL |
35 | #:use-module (gnu packages fontutils) |
36 | #:use-module (gnu packages gd) | |
37 | #:use-module (gnu packages gettext) | |
38 | #:use-module (gnu packages glib) | |
39 | #:use-module (gnu packages gnupg) | |
30502f1d | 40 | #:use-module (gnu packages icu4c) |
1845c2a4 JL |
41 | #:use-module (gnu packages image) |
42 | #:use-module (gnu packages linux) | |
43 | #:use-module (gnu packages multiprecision) | |
44 | #:use-module (gnu packages openldap) | |
45 | #:use-module (gnu packages pcre) | |
46 | #:use-module (gnu packages pkg-config) | |
47 | #:use-module (gnu packages readline) | |
cd0322a3 | 48 | #:use-module (gnu packages sqlite) |
1845c2a4 JL |
49 | #:use-module (gnu packages textutils) |
50 | #:use-module (gnu packages tls) | |
51 | #:use-module (gnu packages web) | |
52 | #:use-module (gnu packages xml) | |
53 | #:use-module (gnu packages xorg) | |
1845c2a4 JL |
54 | #:use-module (guix packages) |
55 | #:use-module (guix download) | |
56 | #:use-module (guix build-system gnu) | |
1a3e7534 | 57 | #:use-module (guix utils) |
1845c2a4 JL |
58 | #:use-module ((guix licenses) #:prefix license:)) |
59 | ||
1845c2a4 JL |
60 | (define-public php |
61 | (package | |
62 | (name "php") | |
d8216013 | 63 | (version "7.4.4") |
1845c2a4 JL |
64 | (home-page "https://secure.php.net/") |
65 | (source (origin | |
66 | (method url-fetch) | |
67 | (uri (string-append home-page "distributions/" | |
9b76aa10 | 68 | "php-" version ".tar.xz")) |
1845c2a4 JL |
69 | (sha256 |
70 | (base32 | |
d8216013 | 71 | "0k57zj1z8kf8403rd72wymj08bswpa5ikcpzviw9mpykzp7c8wqq")) |
1845c2a4 JL |
72 | (modules '((guix build utils))) |
73 | (snippet | |
74 | '(with-directory-excursion "ext" | |
75 | (for-each delete-file-recursively | |
76 | ;; Some of the bundled libraries have no proper upstream. | |
77 | ;; Ideally we'd extract these out as separate packages: | |
78 | ;;"mbstring/libmbfl" | |
79 | ;;"date/lib" | |
80 | ;;"bcmath/libbcmath" | |
61919f09 | 81 | ;;"fileinfo/libmagic" ; a patched version of libmagic |
1845c2a4 | 82 | '("gd/libgd" |
ebcb58c9 | 83 | "pcre/pcre2lib" |
23bb7a62 | 84 | "xmlrpc/libxmlrpc")) |
6cbee49d | 85 | #t)))) |
1845c2a4 JL |
86 | (build-system gnu-build-system) |
87 | (arguments | |
e8cfce43 | 88 | `(#:configure-flags |
1845c2a4 JL |
89 | (let-syntax ((with (syntax-rules () |
90 | ((_ option input) | |
91 | (string-append option "=" | |
92 | (assoc-ref %build-inputs input)))))) | |
93 | (list (with "--with-bz2" "bzip2") | |
94 | (with "--with-curl" "curl") | |
1845c2a4 JL |
95 | (with "--with-gdbm" "gdbm") |
96 | (with "--with-gettext" "glibc") ; libintl.h | |
97 | (with "--with-gmp" "gmp") | |
1845c2a4 JL |
98 | (with "--with-ldap" "openldap") |
99 | (with "--with-ldap-sasl" "cyrus-sasl") | |
1845c2a4 JL |
100 | (with "--with-pdo-pgsql" "postgresql") |
101 | (with "--with-pdo-sqlite" "sqlite") | |
102 | (with "--with-pgsql" "postgresql") | |
1845c2a4 JL |
103 | ;; PHP’s Pspell extension, while retaining its current name, |
104 | ;; now uses the Aspell library. | |
105 | (with "--with-pspell" "aspell") | |
106 | (with "--with-readline" "readline") | |
107 | (with "--with-sqlite3" "sqlite") | |
108 | (with "--with-tidy" "tidy") | |
1845c2a4 JL |
109 | (with "--with-xsl" "libxslt") |
110 | (with "--with-zlib-dir" "zlib") | |
111 | ;; We could add "--with-snmp", but it requires netsnmp that | |
112 | ;; we don't have a package for. It is used to build the snmp | |
113 | ;; extension of php. | |
23bb7a62 JL |
114 | "--with-external-pcre" |
115 | "--with-external-gd" | |
1845c2a4 JL |
116 | "--with-iconv" |
117 | "--with-openssl" | |
0e40b755 | 118 | "--with-mysqli" ; Required for, e.g. wordpress |
1845c2a4 | 119 | "--with-pdo-mysql" |
23bb7a62 | 120 | "--with-zip" |
1845c2a4 | 121 | "--with-zlib" |
4629d267 | 122 | "--enable-bcmath" ; Required for, e.g. Zabbix frontend |
1845c2a4 JL |
123 | "--enable-calendar" |
124 | "--enable-dba=shared" | |
125 | "--enable-exif" | |
126 | "--enable-flatfile" | |
127 | "--enable-fpm" | |
128 | "--enable-ftp" | |
23bb7a62 | 129 | "--enable-gd" |
1845c2a4 | 130 | "--enable-inifile" |
30502f1d | 131 | "--enable-intl" |
1845c2a4 JL |
132 | "--enable-mbstring" |
133 | "--enable-pcntl" | |
23bb7a62 | 134 | "--enable-sockets")) |
1845c2a4 JL |
135 | #:phases |
136 | (modify-phases %standard-phases | |
137 | (add-after 'unpack 'do-not-record-build-flags | |
138 | (lambda _ | |
139 | ;; Prevent configure flags from being stored and causing | |
140 | ;; unnecessary runtime dependencies. | |
141 | (substitute* "scripts/php-config.in" | |
142 | (("@CONFIGURE_OPTIONS@") "") | |
143 | (("@PHP_LDFLAGS@") "")) | |
144 | ;; This file has ISO-8859-1 encoding. | |
145 | (with-fluids ((%default-port-encoding "ISO-8859-1")) | |
146 | (substitute* "main/build-defs.h.in" | |
147 | (("@CONFIGURE_COMMAND@") "(omitted)"))) | |
148 | #t)) | |
149 | (add-before 'build 'patch-/bin/sh | |
150 | (lambda _ | |
151 | (substitute* '("run-tests.php" "ext/standard/proc_open.c") | |
152 | (("/bin/sh") (which "sh"))) | |
153 | #t)) | |
154 | (add-before 'check 'prepare-tests | |
155 | (lambda _ | |
156 | ;; Some of these files have ISO-8859-1 encoding, whereas others | |
157 | ;; use ASCII, so we can't use a "catch-all" find-files here. | |
158 | (with-fluids ((%default-port-encoding "ISO-8859-1")) | |
159 | (substitute* '("ext/mbstring/tests/mb_send_mail02.phpt" | |
160 | "ext/mbstring/tests/mb_send_mail04.phpt" | |
161 | "ext/mbstring/tests/mb_send_mail05.phpt" | |
162 | "ext/mbstring/tests/mb_send_mail06.phpt") | |
163 | (("/bin/cat") (which "cat")))) | |
164 | (substitute* '("ext/mbstring/tests/mb_send_mail01.phpt" | |
165 | "ext/mbstring/tests/mb_send_mail03.phpt" | |
23bb7a62 | 166 | "ext/mbstring/tests/bug52681.phpt" |
1845c2a4 JL |
167 | "ext/standard/tests/general_functions/bug34794.phpt" |
168 | "ext/standard/tests/general_functions/bug44667.phpt" | |
169 | "ext/standard/tests/general_functions/proc_open.phpt") | |
170 | (("/bin/cat") (which "cat"))) | |
60a50806 | 171 | |
1845c2a4 JL |
172 | ;; The encoding of this file is not recognized, so we simply drop it. |
173 | (delete-file "ext/mbstring/tests/mb_send_mail07.phpt") | |
174 | ||
175 | (substitute* "ext/standard/tests/streams/bug60602.phpt" | |
176 | (("'ls'") (string-append "'" (which "ls") "'"))) | |
177 | ||
9398152a LC |
178 | ,@(if (string-prefix? "arm" (or (%current-system) |
179 | (%current-target-system))) | |
e8cfce43 JL |
180 | ;; Drop tests known to fail on armhf. |
181 | '((for-each delete-file | |
182 | (list | |
183 | "ext/calendar/tests/unixtojd_error1.phpt" | |
184 | ;; arm can be a lot slower, so a time-related test fails | |
185 | "ext/fileinfo/tests/cve-2014-3538-nojit.phpt" | |
186 | "ext/pcre/tests/bug76514.phpt" | |
bd9d5dbb JL |
187 | "ext/pcre/tests/preg_match_error3.phpt" |
188 | "ext/standard/tests/general_functions/var_export-locale.phpt" | |
23bb7a62 JL |
189 | "ext/standard/tests/general_functions/var_export_basic1.phpt" |
190 | "ext/intl/tests/timezone_getErrorCodeMessage_basic.phpt" | |
191 | "ext/intl/tests/timezone_getOffset_error.phpt"))) | |
9398152a | 192 | '()) |
e8cfce43 | 193 | |
1845c2a4 JL |
194 | ;; Drop tests that are known to fail. |
195 | (for-each delete-file | |
196 | '("ext/posix/tests/posix_getgrgid.phpt" ; Requires /etc/group. | |
23bb7a62 | 197 | "ext/posix/tests/posix_getgrnam_basic.phpt" ; Requires /etc/group. |
1845c2a4 JL |
198 | "ext/sockets/tests/bug63000.phpt" ; Fails to detect OS. |
199 | "ext/sockets/tests/socket_shutdown.phpt" ; Requires DNS. | |
200 | "ext/sockets/tests/socket_send.phpt" ; Likewise. | |
201 | "ext/sockets/tests/mcast_ipv4_recv.phpt" ; Requires multicast. | |
202 | ;; These needs /etc/services. | |
203 | "ext/standard/tests/general_functions/getservbyname_basic.phpt" | |
204 | "ext/standard/tests/general_functions/getservbyport_basic.phpt" | |
205 | "ext/standard/tests/general_functions/getservbyport_variation1.phpt" | |
206 | ;; And /etc/protocols. | |
207 | "ext/standard/tests/network/getprotobyname_basic.phpt" | |
208 | "ext/standard/tests/network/getprotobynumber_basic.phpt" | |
209 | ;; And exotic locales. | |
210 | "ext/standard/tests/strings/setlocale_basic1.phpt" | |
211 | "ext/standard/tests/strings/setlocale_basic2.phpt" | |
212 | "ext/standard/tests/strings/setlocale_basic3.phpt" | |
213 | "ext/standard/tests/strings/setlocale_variation1.phpt" | |
1eb343f9 MC |
214 | ;; This failing test is skipped on PHP's Travis CI as it is |
215 | ;; supposedly inaccurate. | |
216 | "ext/standard/tests/file/disk_free_space_basic.phpt" | |
217 | ;; The two following tests erroneously expect the link count | |
218 | ;; of a sub-directory to increase compared to its | |
219 | ;; parent. | |
220 | "ext/standard/tests/file/lstat_stat_variation8.phpt" | |
221 | "ext/standard/tests/file/lstat_stat_variation9.phpt" | |
1845c2a4 JL |
222 | |
223 | ;; XXX: These gd tests fails. Likely because our version | |
224 | ;; is different from the (patched) bundled one. | |
225 | ;; Here, gd quits immediately after "fatal libpng error"; while the | |
226 | ;; test expects it to additionally return a "setjmp" error and warning. | |
227 | "ext/gd/tests/bug39780_extern.phpt" | |
228 | "ext/gd/tests/libgd00086_extern.phpt" | |
229 | ;; Extra newline in gd-png output. | |
230 | "ext/gd/tests/bug45799.phpt" | |
1845c2a4 JL |
231 | ;; Test expects generic "gd warning" but gets the actual function name. |
232 | "ext/gd/tests/createfromwbmp2_extern.phpt" | |
202e235e JL |
233 | ;; This bug should have been fixed in gd 2.2.2. |
234 | ;; Is it a regression? | |
235 | "ext/gd/tests/bug65148.phpt" | |
23bb7a62 | 236 | ;; Expected error message, but from the wrong function |
22fe9110 | 237 | "ext/gd/tests/bug77269.phpt" |
1845c2a4 JL |
238 | ;; TODO: Enable these when libgd is built with xpm support. |
239 | "ext/gd/tests/xpm2gd.phpt" | |
240 | "ext/gd/tests/xpm2jpg.phpt" | |
241 | "ext/gd/tests/xpm2png.phpt" | |
945723be JL |
242 | ;; Whitespace difference, probably caused by a very |
243 | ;; long store path | |
244 | "ext/gd/tests/bug77479.phpt" | |
27489e7f JL |
245 | ;; Expected invalid XBM but got EOF before image was |
246 | ;; complete. It's a warning in both cases and test | |
247 | ;; result is the same. | |
248 | "ext/gd/tests/bug77973.phpt" | |
1eb343f9 MC |
249 | ;; Test expects uninitialized value to be false, but |
250 | ;; instead gets "resource(5) of type (gd)". | |
251 | "ext/gd/tests/bug79067.phpt" | |
252 | ;; The following test fails with "The image size | |
253 | ;; differs: expected 114x115, got 117x117". | |
254 | "ext/gd/tests/bug79068.phpt" | |
255 | ||
1845c2a4 JL |
256 | ;; XXX: These iconv tests have the expected outcome, |
257 | ;; but with different error messages. | |
258 | ;; Expects "illegal character", instead gets "unknown error (84)". | |
259 | "ext/iconv/tests/bug52211.phpt" | |
63657921 | 260 | "ext/iconv/tests/bug60494.phpt" |
1845c2a4 | 261 | ;; Expects "wrong charset", gets unknown error (22). |
1845c2a4 | 262 | "ext/iconv/tests/iconv_strlen_error2.phpt" |
1845c2a4 JL |
263 | "ext/iconv/tests/iconv_substr_error2.phpt" |
264 | ;; Expects conversion error, gets "error condition Termsig=11". | |
265 | "ext/iconv/tests/iconv_strpos_error2.phpt" | |
266 | "ext/iconv/tests/iconv_strrpos_error2.phpt" | |
16dc5ed0 JL |
267 | ;; Expects "invalid multibyte sequence" but got |
268 | ;; "unknown error". | |
269 | "ext/iconv/tests/bug76249.phpt" | |
1845c2a4 JL |
270 | |
271 | ;; XXX: These test failures appear legitimate, needs investigation. | |
272 | ;; open_basedir() restriction failure. | |
23bb7a62 | 273 | "ext/curl/tests/bug61948-unix.phpt" |
1845c2a4 JL |
274 | ;; Expects a false boolean, gets empty array from glob(). |
275 | "ext/standard/tests/file/bug41655_1.phpt" | |
276 | "ext/standard/tests/file/glob_variation5.phpt" | |
1845c2a4 JL |
277 | ;; The test expects an Array, but instead get the contents(?). |
278 | "ext/gd/tests/bug43073.phpt" | |
279 | ;; imagettftext() returns wrong coordinates. | |
60a50806 | 280 | "ext/gd/tests/bug48732-mb.phpt" |
1845c2a4 JL |
281 | "ext/gd/tests/bug48732.phpt" |
282 | ;; Similarly for imageftbbox(). | |
60a50806 | 283 | "ext/gd/tests/bug48801-mb.phpt" |
1845c2a4 JL |
284 | "ext/gd/tests/bug48801.phpt" |
285 | ;; Different expected output from imagecolorallocate(). | |
286 | "ext/gd/tests/bug53504.phpt" | |
287 | ;; Wrong image size after scaling an image. | |
288 | "ext/gd/tests/bug73272.phpt" | |
289 | ;; Expects iconv to detect illegal characters, instead gets | |
290 | ;; "unknown error (84)" and heap corruption(!). | |
291 | "ext/iconv/tests/bug48147.phpt" | |
292 | ;; Expects illegal character ".", gets "=?utf-8?Q?." | |
293 | "ext/iconv/tests/bug51250.phpt" | |
1845c2a4 JL |
294 | ;; iconv throws "buffer length exceeded" on some string checks. |
295 | "ext/iconv/tests/iconv_mime_encode.phpt" | |
296 | ;; file_get_contents(): iconv stream filter | |
297 | ;; ("ISO-8859-1"=>"UTF-8") unknown error. | |
298 | "ext/standard/tests/file/bug43008.phpt" | |
299 | ;; Table data not created in sqlite(?). | |
23bb7a62 | 300 | "ext/pdo_sqlite/tests/bug_42589.phpt")) |
1845c2a4 JL |
301 | |
302 | ;; Skip tests requiring network access. | |
303 | (setenv "SKIP_ONLINE_TESTS" "1") | |
304 | ;; Without this variable, 'make test' passes regardless of failures. | |
305 | (setenv "REPORT_EXIT_STATUS" "1") | |
dd1f60ec JL |
306 | ;; Skip tests requiring I/O facilities that are unavailable in the |
307 | ;; build environment | |
308 | (setenv "SKIP_IO_CAPTURE_TESTS" "1") | |
1845c2a4 JL |
309 | #t))) |
310 | #:test-target "test")) | |
311 | (inputs | |
312 | `(("aspell" ,aspell) | |
313 | ("bzip2" ,bzip2) | |
314 | ("curl" ,curl) | |
315 | ("cyrus-sasl" ,cyrus-sasl) | |
68a08dfb | 316 | ("gd" ,gd) |
1845c2a4 JL |
317 | ("gdbm" ,gdbm) |
318 | ("glibc" ,glibc) | |
319 | ("gmp" ,gmp) | |
60a50806 | 320 | ("gnutls" ,gnutls) |
30502f1d | 321 | ("icu4c" ,icu4c) |
1845c2a4 | 322 | ("libgcrypt" ,libgcrypt) |
1845c2a4 | 323 | ("libpng" ,libpng) |
1845c2a4 | 324 | ("libxml2" ,libxml2) |
1845c2a4 JL |
325 | ("libxslt" ,libxslt) |
326 | ("libx11" ,libx11) | |
30502f1d | 327 | ("libzip" ,libzip) |
5ec7c4a1 | 328 | ("oniguruma" ,oniguruma) |
1845c2a4 JL |
329 | ("openldap" ,openldap) |
330 | ("openssl" ,openssl) | |
a33925d1 | 331 | ("pcre" ,pcre2) |
1845c2a4 JL |
332 | ("postgresql" ,postgresql) |
333 | ("readline" ,readline) | |
3ad8cb41 | 334 | ("sqlite" ,sqlite) |
1845c2a4 | 335 | ("tidy" ,tidy) |
1845c2a4 JL |
336 | ("zlib" ,zlib))) |
337 | (native-inputs | |
338 | `(("pkg-config" ,pkg-config) | |
339 | ("bison" ,bison) | |
340 | ("intltool" ,intltool) | |
61919f09 | 341 | ("procps" ,procps))) ; for tests |
1845c2a4 JL |
342 | (synopsis "PHP programming language") |
343 | (description | |
344 | "PHP (PHP Hypertext Processor) is a server-side (CGI) scripting | |
345 | language designed primarily for web development but is also used as | |
346 | a general-purpose programming language. PHP code may be embedded into | |
347 | HTML code, or it can be used in combination with various web template | |
348 | systems, web content management systems and web frameworks." ) | |
349 | (license (list | |
350 | (license:non-copyleft "file://LICENSE") ; The PHP license. | |
351 | (license:non-copyleft "file://Zend/LICENSE") ; The Zend license. | |
352 | license:lgpl2.1 ; ext/mbstring/libmbfl | |
353 | license:lgpl2.1+ ; ext/bcmath/libbcmath | |
354 | license:bsd-2 ; ext/fileinfo/libmagic | |
355 | license:expat)))) ; ext/date/lib |