| 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2016 Julien Lepiller <julien@lepiller.eu> |
| 3 | ;;; Copyright © 2016 Marius Bakke <mbakke@fastmail.com> |
| 4 | ;;; |
| 5 | ;;; This file is part of GNU Guix. |
| 6 | ;;; |
| 7 | ;;; GNU Guix is free software; you can redistribute it and/or modify it |
| 8 | ;;; under the terms of the GNU General Public License as published by |
| 9 | ;;; the Free Software Foundation; either version 3 of the License, or (at |
| 10 | ;;; your option) any later version. |
| 11 | ;;; |
| 12 | ;;; GNU Guix is distributed in the hope that it will be useful, but |
| 13 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | ;;; GNU General Public License for more details. |
| 16 | ;;; |
| 17 | ;;; You should have received a copy of the GNU General Public License |
| 18 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. |
| 19 | |
| 20 | (define-module (gnu packages php) |
| 21 | #:use-module (gnu packages) |
| 22 | #:use-module (gnu packages algebra) |
| 23 | #:use-module (gnu packages aspell) |
| 24 | #:use-module (gnu packages base) |
| 25 | #:use-module (gnu packages bison) |
| 26 | #:use-module (gnu packages compression) |
| 27 | #:use-module (gnu packages curl) |
| 28 | #:use-module (gnu packages cyrus-sasl) |
| 29 | #:use-module (gnu packages databases) |
| 30 | #:use-module (gnu packages fontutils) |
| 31 | #:use-module (gnu packages gd) |
| 32 | #:use-module (gnu packages gettext) |
| 33 | #:use-module (gnu packages glib) |
| 34 | #:use-module (gnu packages gnupg) |
| 35 | #:use-module (gnu packages image) |
| 36 | #:use-module (gnu packages linux) |
| 37 | #:use-module (gnu packages multiprecision) |
| 38 | #:use-module (gnu packages openldap) |
| 39 | #:use-module (gnu packages pcre) |
| 40 | #:use-module (gnu packages pkg-config) |
| 41 | #:use-module (gnu packages readline) |
| 42 | #:use-module (gnu packages textutils) |
| 43 | #:use-module (gnu packages tls) |
| 44 | #:use-module (gnu packages web) |
| 45 | #:use-module (gnu packages xml) |
| 46 | #:use-module (gnu packages xorg) |
| 47 | #:use-module (guix packages) |
| 48 | #:use-module (guix download) |
| 49 | #:use-module (guix build-system gnu) |
| 50 | #:use-module ((guix licenses) #:prefix license:)) |
| 51 | |
| 52 | (define-public php |
| 53 | (package |
| 54 | (name "php") |
| 55 | (version "7.1.11") |
| 56 | (home-page "https://secure.php.net/") |
| 57 | (source (origin |
| 58 | (method url-fetch) |
| 59 | (uri (string-append home-page "distributions/" |
| 60 | name "-" version ".tar.xz")) |
| 61 | (sha256 |
| 62 | (base32 |
| 63 | "0gl9hk4888fjirrd4s73mdabhiqam0c45406a7fgw6njszlr6h07")) |
| 64 | (modules '((guix build utils))) |
| 65 | (snippet |
| 66 | '(with-directory-excursion "ext" |
| 67 | (for-each delete-file-recursively |
| 68 | ;; Some of the bundled libraries have no proper upstream. |
| 69 | ;; Ideally we'd extract these out as separate packages: |
| 70 | ;;"mbstring/libmbfl" |
| 71 | ;;"date/lib" |
| 72 | ;;"bcmath/libbcmath" |
| 73 | ;;"fileinfo/libmagic" ; This is a patched version of libmagic. |
| 74 | '("gd/libgd" |
| 75 | "mbstring/oniguruma" |
| 76 | "pcre/pcrelib" |
| 77 | "sqlite3/libsqlite" |
| 78 | "xmlrpc/libxmlrpc" |
| 79 | "zip/lib")))))) |
| 80 | (build-system gnu-build-system) |
| 81 | (arguments |
| 82 | '(#:configure-flags |
| 83 | (let-syntax ((with (syntax-rules () |
| 84 | ((_ option input) |
| 85 | (string-append option "=" |
| 86 | (assoc-ref %build-inputs input)))))) |
| 87 | (list (with "--with-bz2" "bzip2") |
| 88 | (with "--with-curl" "curl") |
| 89 | (with "--with-freetype-dir" "freetype") |
| 90 | (with "--with-gd" "gd") |
| 91 | (with "--with-gdbm" "gdbm") |
| 92 | (with "--with-gettext" "glibc") ; libintl.h |
| 93 | (with "--with-gmp" "gmp") |
| 94 | (with "--with-jpeg-dir" "libjpeg") |
| 95 | (with "--with-ldap" "openldap") |
| 96 | (with "--with-ldap-sasl" "cyrus-sasl") |
| 97 | (with "--with-libzip" "zip") |
| 98 | (with "--with-libxml-dir" "libxml2") |
| 99 | (with "--with-onig" "oniguruma") |
| 100 | (with "--with-pcre-dir" "pcre") |
| 101 | (with "--with-pcre-regex" "pcre") |
| 102 | (with "--with-pdo-pgsql" "postgresql") |
| 103 | (with "--with-pdo-sqlite" "sqlite") |
| 104 | (with "--with-pgsql" "postgresql") |
| 105 | (with "--with-png-dir" "libpng") |
| 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-sqlite3" "sqlite") |
| 111 | (with "--with-tidy" "tidy") |
| 112 | (with "--with-webp-dir" "libwebp") |
| 113 | (with "--with-xpm-dir" "libxpm") |
| 114 | (with "--with-xsl" "libxslt") |
| 115 | (with "--with-zlib-dir" "zlib") |
| 116 | ;; We could add "--with-snmp", but it requires netsnmp that |
| 117 | ;; we don't have a package for. It is used to build the snmp |
| 118 | ;; extension of php. |
| 119 | "--with-iconv" |
| 120 | "--with-openssl" |
| 121 | "--with-mysqli" ; Required for, e.g. wordpress |
| 122 | "--with-pdo-mysql" |
| 123 | "--with-zlib" |
| 124 | "--enable-calendar" |
| 125 | "--enable-dba=shared" |
| 126 | "--enable-exif" |
| 127 | "--enable-flatfile" |
| 128 | "--enable-fpm" |
| 129 | "--enable-ftp" |
| 130 | "--enable-inifile" |
| 131 | "--enable-mbstring" |
| 132 | "--enable-pcntl" |
| 133 | "--enable-sockets")) |
| 134 | #:phases |
| 135 | (modify-phases %standard-phases |
| 136 | (add-after 'unpack 'do-not-record-build-flags |
| 137 | (lambda _ |
| 138 | ;; Prevent configure flags from being stored and causing |
| 139 | ;; unnecessary runtime dependencies. |
| 140 | (substitute* "scripts/php-config.in" |
| 141 | (("@CONFIGURE_OPTIONS@") "") |
| 142 | (("@PHP_LDFLAGS@") "")) |
| 143 | ;; This file has ISO-8859-1 encoding. |
| 144 | (with-fluids ((%default-port-encoding "ISO-8859-1")) |
| 145 | (substitute* "main/build-defs.h.in" |
| 146 | (("@CONFIGURE_COMMAND@") "(omitted)"))) |
| 147 | #t)) |
| 148 | (add-before 'build 'patch-/bin/sh |
| 149 | (lambda _ |
| 150 | (substitute* '("run-tests.php" "ext/standard/proc_open.c") |
| 151 | (("/bin/sh") (which "sh"))) |
| 152 | #t)) |
| 153 | (add-before 'check 'prepare-tests |
| 154 | (lambda _ |
| 155 | ;; Some of these files have ISO-8859-1 encoding, whereas others |
| 156 | ;; use ASCII, so we can't use a "catch-all" find-files here. |
| 157 | (with-fluids ((%default-port-encoding "ISO-8859-1")) |
| 158 | (substitute* '("ext/mbstring/tests/mb_send_mail02.phpt" |
| 159 | "ext/mbstring/tests/mb_send_mail04.phpt" |
| 160 | "ext/mbstring/tests/mb_send_mail05.phpt" |
| 161 | "ext/mbstring/tests/mb_send_mail06.phpt") |
| 162 | (("/bin/cat") (which "cat")))) |
| 163 | (substitute* '("ext/mbstring/tests/mb_send_mail01.phpt" |
| 164 | "ext/mbstring/tests/mb_send_mail03.phpt" |
| 165 | "ext/mbstring/tests/bug52861.phpt" |
| 166 | "ext/standard/tests/general_functions/bug34794.phpt" |
| 167 | "ext/standard/tests/general_functions/bug44667.phpt" |
| 168 | "ext/standard/tests/general_functions/proc_open.phpt") |
| 169 | (("/bin/cat") (which "cat"))) |
| 170 | |
| 171 | ;; The encoding of this file is not recognized, so we simply drop it. |
| 172 | (delete-file "ext/mbstring/tests/mb_send_mail07.phpt") |
| 173 | |
| 174 | (substitute* "ext/standard/tests/streams/bug60602.phpt" |
| 175 | (("'ls'") (string-append "'" (which "ls") "'"))) |
| 176 | |
| 177 | ;; Drop tests that are known to fail. |
| 178 | (for-each delete-file |
| 179 | '("ext/posix/tests/posix_getgrgid.phpt" ; Requires /etc/group. |
| 180 | "ext/sockets/tests/bug63000.phpt" ; Fails to detect OS. |
| 181 | "ext/sockets/tests/socket_shutdown.phpt" ; Requires DNS. |
| 182 | "ext/sockets/tests/socket_send.phpt" ; Likewise. |
| 183 | "ext/sockets/tests/mcast_ipv4_recv.phpt" ; Requires multicast. |
| 184 | ;; These needs /etc/services. |
| 185 | "ext/standard/tests/general_functions/getservbyname_basic.phpt" |
| 186 | "ext/standard/tests/general_functions/getservbyport_basic.phpt" |
| 187 | "ext/standard/tests/general_functions/getservbyport_variation1.phpt" |
| 188 | ;; And /etc/protocols. |
| 189 | "ext/standard/tests/network/getprotobyname_basic.phpt" |
| 190 | "ext/standard/tests/network/getprotobynumber_basic.phpt" |
| 191 | ;; And exotic locales. |
| 192 | "ext/standard/tests/strings/setlocale_basic1.phpt" |
| 193 | "ext/standard/tests/strings/setlocale_basic2.phpt" |
| 194 | "ext/standard/tests/strings/setlocale_basic3.phpt" |
| 195 | "ext/standard/tests/strings/setlocale_variation1.phpt" |
| 196 | |
| 197 | ;; XXX: These gd tests fails. Likely because our version |
| 198 | ;; is different from the (patched) bundled one. |
| 199 | ;; Here, gd quits immediately after "fatal libpng error"; while the |
| 200 | ;; test expects it to additionally return a "setjmp" error and warning. |
| 201 | "ext/gd/tests/bug39780_extern.phpt" |
| 202 | "ext/gd/tests/libgd00086_extern.phpt" |
| 203 | ;; Extra newline in gd-png output. |
| 204 | "ext/gd/tests/bug45799.phpt" |
| 205 | ;; Different error message than expected from imagecrop(). |
| 206 | "ext/gd/tests/bug66356.phpt" |
| 207 | ;; Similarly for imagecreatefromgd2(). |
| 208 | "ext/gd/tests/bug72339.phpt" |
| 209 | ;; Call to undefined function imageantialias(). They are |
| 210 | ;; supposed to fail anyway. |
| 211 | "ext/gd/tests/bug72482.phpt" |
| 212 | "ext/gd/tests/bug72482_2.phpt" |
| 213 | "ext/gd/tests/bug73213.phpt" |
| 214 | ;; Test expects generic "gd warning" but gets the actual function name. |
| 215 | "ext/gd/tests/createfromwbmp2_extern.phpt" |
| 216 | ;; TODO: Enable these when libgd is built with xpm support. |
| 217 | "ext/gd/tests/xpm2gd.phpt" |
| 218 | "ext/gd/tests/xpm2jpg.phpt" |
| 219 | "ext/gd/tests/xpm2png.phpt" |
| 220 | |
| 221 | ;; XXX: These iconv tests have the expected outcome, |
| 222 | ;; but with different error messages. |
| 223 | ;; Expects "illegal character", instead gets "unknown error (84)". |
| 224 | "ext/iconv/tests/bug52211.phpt" |
| 225 | ;; Expects "wrong charset", gets unknown error (22). |
| 226 | "ext/iconv/tests/iconv_mime_decode_variation3.phpt" |
| 227 | "ext/iconv/tests/iconv_strlen_error2.phpt" |
| 228 | "ext/iconv/tests/iconv_strlen_variation2.phpt" |
| 229 | "ext/iconv/tests/iconv_substr_error2.phpt" |
| 230 | ;; Expects conversion error, gets "error condition Termsig=11". |
| 231 | "ext/iconv/tests/iconv_strpos_error2.phpt" |
| 232 | "ext/iconv/tests/iconv_strrpos_error2.phpt" |
| 233 | ;; Similar, but iterating over multiple values. |
| 234 | ;; iconv breaks the loop after the first error with Termsig=11. |
| 235 | "ext/iconv/tests/iconv_strpos_variation4.phpt" |
| 236 | "ext/iconv/tests/iconv_strrpos_variation3.phpt" |
| 237 | |
| 238 | ;; XXX: These test failures appear legitimate, needs investigation. |
| 239 | ;; open_basedir() restriction failure. |
| 240 | "ext/curl/tests/bug61948.phpt" |
| 241 | ;; Expects a false boolean, gets empty array from glob(). |
| 242 | "ext/standard/tests/file/bug41655_1.phpt" |
| 243 | "ext/standard/tests/file/glob_variation5.phpt" |
| 244 | ;; Test output is correct, but in wrong order. |
| 245 | "ext/standard/tests/streams/proc_open_bug64438.phpt" |
| 246 | ;; The test expects an Array, but instead get the contents(?). |
| 247 | "ext/gd/tests/bug43073.phpt" |
| 248 | ;; imagettftext() returns wrong coordinates. |
| 249 | "ext/gd/tests/bug48732-mb.phpt" |
| 250 | "ext/gd/tests/bug48732.phpt" |
| 251 | ;; Similarly for imageftbbox(). |
| 252 | "ext/gd/tests/bug48801-mb.phpt" |
| 253 | "ext/gd/tests/bug48801.phpt" |
| 254 | ;; Different expected output from imagecolorallocate(). |
| 255 | "ext/gd/tests/bug53504.phpt" |
| 256 | ;; Wrong image size after scaling an image. |
| 257 | "ext/gd/tests/bug73272.phpt" |
| 258 | ;; Expects iconv to detect illegal characters, instead gets |
| 259 | ;; "unknown error (84)" and heap corruption(!). |
| 260 | "ext/iconv/tests/bug48147.phpt" |
| 261 | ;; Expects illegal character ".", gets "=?utf-8?Q?." |
| 262 | "ext/iconv/tests/bug51250.phpt" |
| 263 | ;; @iconv() does not return expected output. |
| 264 | "ext/iconv/tests/iconv003.phpt" |
| 265 | ;; iconv throws "buffer length exceeded" on some string checks. |
| 266 | "ext/iconv/tests/iconv_mime_encode.phpt" |
| 267 | ;; file_get_contents(): iconv stream filter |
| 268 | ;; ("ISO-8859-1"=>"UTF-8") unknown error. |
| 269 | "ext/standard/tests/file/bug43008.phpt" |
| 270 | ;; Table data not created in sqlite(?). |
| 271 | "ext/pdo_sqlite/tests/bug_42589.phpt")) |
| 272 | |
| 273 | ;; Skip tests requiring network access. |
| 274 | (setenv "SKIP_ONLINE_TESTS" "1") |
| 275 | ;; Without this variable, 'make test' passes regardless of failures. |
| 276 | (setenv "REPORT_EXIT_STATUS" "1") |
| 277 | #t))) |
| 278 | #:test-target "test")) |
| 279 | (inputs |
| 280 | `(("aspell" ,aspell) |
| 281 | ("bzip2" ,bzip2) |
| 282 | ("curl" ,curl) |
| 283 | ("cyrus-sasl" ,cyrus-sasl) |
| 284 | ("freetype" ,freetype) |
| 285 | ("gd" ,gd) |
| 286 | ("gdbm" ,gdbm) |
| 287 | ("glibc" ,glibc) |
| 288 | ("gmp" ,gmp) |
| 289 | ("gnutls" ,gnutls) |
| 290 | ("libgcrypt" ,libgcrypt) |
| 291 | ("libjpeg" ,libjpeg) |
| 292 | ("libpng" ,libpng) |
| 293 | ("libwebp" ,libwebp) |
| 294 | ("libxml2" ,libxml2) |
| 295 | ("libxpm" ,libxpm) |
| 296 | ("libxslt" ,libxslt) |
| 297 | ("libx11" ,libx11) |
| 298 | ("oniguruma" ,oniguruma) |
| 299 | ("openldap" ,openldap) |
| 300 | ("openssl" ,openssl) |
| 301 | ("pcre" ,pcre) |
| 302 | ("postgresql" ,postgresql) |
| 303 | ("readline" ,readline) |
| 304 | ("sqlite" ,sqlite) |
| 305 | ("tidy" ,tidy) |
| 306 | ("zip" ,zip) |
| 307 | ("zlib" ,zlib))) |
| 308 | (native-inputs |
| 309 | `(("pkg-config" ,pkg-config) |
| 310 | ("bison" ,bison) |
| 311 | ("intltool" ,intltool) |
| 312 | ("procps" ,procps))) ; For tests. |
| 313 | (synopsis "PHP programming language") |
| 314 | (description |
| 315 | "PHP (PHP Hypertext Processor) is a server-side (CGI) scripting |
| 316 | language designed primarily for web development but is also used as |
| 317 | a general-purpose programming language. PHP code may be embedded into |
| 318 | HTML code, or it can be used in combination with various web template |
| 319 | systems, web content management systems and web frameworks." ) |
| 320 | (license (list |
| 321 | (license:non-copyleft "file://LICENSE") ; The PHP license. |
| 322 | (license:non-copyleft "file://Zend/LICENSE") ; The Zend license. |
| 323 | license:lgpl2.1 ; ext/mbstring/libmbfl |
| 324 | license:lgpl2.1+ ; ext/bcmath/libbcmath |
| 325 | license:bsd-2 ; ext/fileinfo/libmagic |
| 326 | license:expat)))) ; ext/date/lib |