php.scm 16 KB

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