php.scm 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2016-2020 Julien Lepiller <julien@lepiller.eu>
  3. ;;; Copyright © 2016 Marius Bakke <mbakke@fastmail.com>
  4. ;;; Copyright © 2018, 2020, 2021 Tobias Geerinckx-Rice <me@tobias.gr>
  5. ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
  6. ;;; Copyright © 2019 Oleg Pykhalov <go.wigust@gmail.com>
  7. ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
  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. (define-module (gnu packages php)
  24. #:use-module (gnu packages)
  25. #:use-module (gnu packages algebra)
  26. #:use-module (gnu packages aspell)
  27. #:use-module (gnu packages base)
  28. #:use-module (gnu packages bison)
  29. #:use-module (gnu packages compression)
  30. #:use-module (gnu packages crypto)
  31. #:use-module (gnu packages curl)
  32. #:use-module (gnu packages cyrus-sasl)
  33. #:use-module (gnu packages databases)
  34. #:use-module (gnu packages dbm)
  35. #:use-module (gnu packages fontutils)
  36. #:use-module (gnu packages gd)
  37. #:use-module (gnu packages gettext)
  38. #:use-module (gnu packages gnupg)
  39. #:use-module (gnu packages icu4c)
  40. #:use-module (gnu packages image)
  41. #:use-module (gnu packages linux)
  42. #:use-module (gnu packages multiprecision)
  43. #:use-module (gnu packages openldap)
  44. #:use-module (gnu packages pcre)
  45. #:use-module (gnu packages pkg-config)
  46. #:use-module (gnu packages readline)
  47. #:use-module (gnu packages sqlite)
  48. #:use-module (gnu packages textutils)
  49. #:use-module (gnu packages tls)
  50. #:use-module (gnu packages web)
  51. #:use-module (gnu packages xml)
  52. #:use-module (gnu packages xorg)
  53. #:use-module (guix packages)
  54. #:use-module (guix download)
  55. #:use-module (guix build-system gnu)
  56. #:use-module (guix utils)
  57. #:use-module ((guix licenses) #:prefix license:))
  58. (define-public php
  59. (package
  60. (name "php")
  61. (version "7.4.22")
  62. (home-page "https://secure.php.net/")
  63. (source (origin
  64. (method url-fetch)
  65. (uri (string-append home-page "distributions/"
  66. "php-" version ".tar.xz"))
  67. (sha256
  68. (base32
  69. "1s5xjy1cchlg0vfxic73wy2wip8spfjr094hzzyc76plsbbqq1wf"))
  70. (patches (search-patches "php-bug-74093-test.patch"))
  71. (modules '((guix build utils)))
  72. (snippet
  73. '(with-directory-excursion "ext"
  74. (for-each delete-file-recursively
  75. ;; Some of the bundled libraries have no proper upstream.
  76. ;; Ideally we'd extract these out as separate packages:
  77. ;;"mbstring/libmbfl"
  78. ;;"date/lib"
  79. ;;"bcmath/libbcmath"
  80. ;;"fileinfo/libmagic" ; a patched version of libmagic
  81. '("gd/libgd"
  82. "pcre/pcre2lib"
  83. "xmlrpc/libxmlrpc"))
  84. #t))))
  85. (build-system gnu-build-system)
  86. (arguments
  87. `(#:configure-flags
  88. (let-syntax ((with (syntax-rules ()
  89. ((_ option input)
  90. (string-append option "="
  91. (assoc-ref %build-inputs input))))))
  92. (list (with "--with-bz2" "bzip2")
  93. (with "--with-curl" "curl")
  94. (with "--with-gdbm" "gdbm")
  95. (with "--with-gettext" "glibc") ; libintl.h
  96. (with "--with-gmp" "gmp")
  97. (with "--with-ldap" "openldap")
  98. (with "--with-ldap-sasl" "cyrus-sasl")
  99. (with "--with-pdo-pgsql" "postgresql")
  100. (with "--with-pdo-sqlite" "sqlite")
  101. (with "--with-pgsql" "postgresql")
  102. ;; PHP’s Pspell extension, while retaining its current name,
  103. ;; now uses the Aspell library.
  104. (with "--with-pspell" "aspell")
  105. (with "--with-readline" "readline")
  106. (with "--with-sodium" "libsodium")
  107. (with "--with-sqlite3" "sqlite")
  108. (with "--with-tidy" "tidy")
  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.
  114. "--with-external-pcre"
  115. "--with-external-gd"
  116. "--with-iconv"
  117. "--with-openssl"
  118. "--with-mysqli" ; Required for, e.g. wordpress
  119. "--with-pdo-mysql"
  120. "--with-zip"
  121. "--with-zlib"
  122. "--enable-bcmath" ; Required for, e.g. Zabbix frontend
  123. "--enable-calendar"
  124. "--enable-dba=shared"
  125. "--enable-exif"
  126. "--enable-flatfile"
  127. "--enable-fpm"
  128. "--enable-ftp"
  129. "--enable-gd"
  130. "--enable-inifile"
  131. "--enable-intl"
  132. "--enable-mbstring"
  133. "--enable-pcntl"
  134. "--enable-sockets"))
  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. (add-before 'build 'patch-/bin/sh
  149. (lambda _
  150. (substitute* '("run-tests.php" "ext/standard/proc_open.c")
  151. (("/bin/sh") (which "sh")))))
  152. (add-before 'check 'prepare-tests
  153. (lambda _
  154. ;; Some of these files have ISO-8859-1 encoding, whereas others
  155. ;; use ASCII, so we can't use a "catch-all" find-files here.
  156. (with-fluids ((%default-port-encoding "ISO-8859-1"))
  157. (substitute* '("ext/mbstring/tests/mb_send_mail02.phpt"
  158. "ext/mbstring/tests/mb_send_mail04.phpt"
  159. "ext/mbstring/tests/mb_send_mail05.phpt"
  160. "ext/mbstring/tests/mb_send_mail06.phpt")
  161. (("/bin/cat") (which "cat"))))
  162. (substitute* '("ext/mbstring/tests/mb_send_mail01.phpt"
  163. "ext/mbstring/tests/mb_send_mail03.phpt"
  164. "ext/mbstring/tests/bug52681.phpt"
  165. "ext/standard/tests/general_functions/bug34794.phpt"
  166. "ext/standard/tests/general_functions/bug44667.phpt"
  167. "ext/standard/tests/general_functions/proc_open.phpt")
  168. (("/bin/cat") (which "cat")))
  169. ;; The encoding of this file is not recognized, so we simply drop it.
  170. (delete-file "ext/mbstring/tests/mb_send_mail07.phpt")
  171. (substitute* "ext/standard/tests/streams/bug60602.phpt"
  172. (("'ls'") (string-append "'" (which "ls") "'")))
  173. ,@(if (string-prefix? "arm" (or (%current-system)
  174. (%current-target-system)))
  175. ;; Drop tests known to fail on armhf.
  176. '((for-each delete-file
  177. (list
  178. "ext/calendar/tests/unixtojd_error1.phpt"
  179. ;; arm can be a lot slower, so a time-related test fails
  180. "ext/fileinfo/tests/cve-2014-3538-nojit.phpt"
  181. "ext/pcntl/tests/pcntl_unshare_01.phpt"
  182. "ext/pcre/tests/bug76514.phpt"
  183. "ext/pcre/tests/preg_match_error3.phpt"
  184. "ext/pcre/tests/cache_limit.phpt"
  185. "ext/sockets/tests/socket_getopt.phpt"
  186. "ext/sockets/tests/socket_sendrecvmsg_error.phpt"
  187. "ext/standard/tests/general_functions/var_export-locale.phpt"
  188. "ext/standard/tests/general_functions/var_export_basic1.phpt"
  189. "ext/intl/tests/timezone_getErrorCodeMessage_basic.phpt"
  190. "ext/intl/tests/timezone_getOffset_error.phpt"
  191. "sapi/cli/tests/cli_process_title_unix.phpt"
  192. "sapi/cli/tests/upload_2G.phpt"
  193. "Zend/tests/concat_003.phpt")))
  194. '())
  195. ,@(if (target-ppc64le?)
  196. ;; Drop tests known to fail on powerpc64le.
  197. '((for-each delete-file
  198. (list
  199. ;; phpdbg watchpoints don't work.
  200. ;; Bug tracked upstream at:
  201. ;; https://bugs.php.net/bug.php?id=81408
  202. "sapi/phpdbg/tests/watch_001.phpt"
  203. "sapi/phpdbg/tests/watch_003.phpt"
  204. "sapi/phpdbg/tests/watch_004.phpt"
  205. "sapi/phpdbg/tests/watch_005.phpt"
  206. "sapi/phpdbg/tests/watch_006.phpt")))
  207. '())
  208. ;; Drop tests that are known to fail.
  209. (for-each delete-file
  210. '("ext/posix/tests/posix_getgrgid.phpt" ; Requires /etc/group.
  211. "ext/posix/tests/posix_getgrnam_basic.phpt" ; Requires /etc/group.
  212. "ext/sockets/tests/bug63000.phpt" ; Fails to detect OS.
  213. "ext/sockets/tests/socket_shutdown.phpt" ; Requires DNS.
  214. "ext/sockets/tests/socket_send.phpt" ; Likewise.
  215. "ext/sockets/tests/mcast_ipv4_recv.phpt" ; Requires multicast.
  216. ;; These needs /etc/services.
  217. "ext/standard/tests/general_functions/getservbyname_basic.phpt"
  218. "ext/standard/tests/general_functions/getservbyport_basic.phpt"
  219. "ext/standard/tests/general_functions/getservbyport_variation1.phpt"
  220. ;; And /etc/protocols.
  221. "ext/standard/tests/network/getprotobyname_basic.phpt"
  222. "ext/standard/tests/network/getprotobynumber_basic.phpt"
  223. ;; And exotic locales.
  224. "ext/standard/tests/strings/setlocale_basic1.phpt"
  225. "ext/standard/tests/strings/setlocale_basic2.phpt"
  226. "ext/standard/tests/strings/setlocale_basic3.phpt"
  227. "ext/standard/tests/strings/setlocale_variation1.phpt"
  228. ;; This failing test is skipped on PHP's Travis CI as it is
  229. ;; supposedly inaccurate.
  230. "ext/standard/tests/file/disk_free_space_basic.phpt"
  231. ;; The following test erroneously expect the link
  232. ;; count of a sub-directory to increase compared to
  233. ;; its parent.
  234. "ext/standard/tests/file/lstat_stat_variation8.phpt"
  235. ;; This tests whether microseconds ‘differ enough’ and
  236. ;; fails inconsistently on ‘fast’ machines.
  237. "ext/date/tests/bug73837.phpt"
  238. ;; XXX: These gd tests fails. Likely because our version
  239. ;; is different from the (patched) bundled one.
  240. ;; Here, gd quits immediately after "fatal libpng error"; while the
  241. ;; test expects it to additionally return a "setjmp" error and warning.
  242. "ext/gd/tests/bug39780_extern.phpt"
  243. "ext/gd/tests/libgd00086_extern.phpt"
  244. ;; Extra newline in gd-png output.
  245. "ext/gd/tests/bug45799.phpt"
  246. ;; Test expects generic "gd warning" but gets the actual function name.
  247. "ext/gd/tests/createfromwbmp2_extern.phpt"
  248. ;; This bug should have been fixed in gd 2.2.2.
  249. ;; Is it a regression?
  250. "ext/gd/tests/bug65148.phpt"
  251. ;; This bug should have been fixed in the gd 2.2
  252. ;; series. Perhaps a regression introduced by gd
  253. ;; 2.3.0?
  254. "ext/gd/tests/bug66590.phpt"
  255. ;; This bug should have been fixed in the php-5.5
  256. ;; series. Perhaps a regression introduced by gd
  257. ;; 2.3.0?
  258. "ext/gd/tests/bug70102.phpt"
  259. ;; This bug should have been fixed in the php-5.6
  260. ;; series. Perhaps a regression introduced by gd
  261. ;; 2.3.0?
  262. "ext/gd/tests/bug73869.phpt"
  263. ;; Some WebP related tests fail.
  264. "ext/gd/tests/webp_basic.phpt"
  265. "ext/gd/tests/imagecreatefromstring_webp.phpt"
  266. ;; Expected error message, but from the wrong function
  267. "ext/gd/tests/bug77269.phpt"
  268. ;; TODO: Enable these when libgd is built with xpm support.
  269. "ext/gd/tests/xpm2gd.phpt"
  270. "ext/gd/tests/xpm2jpg.phpt"
  271. "ext/gd/tests/xpm2png.phpt"
  272. ;; Whitespace difference, probably caused by a very
  273. ;; long store path
  274. "ext/gd/tests/bug77479.phpt"
  275. ;; Expected invalid XBM but got EOF before image was
  276. ;; complete. It's a warning in both cases and test
  277. ;; result is the same.
  278. "ext/gd/tests/bug77973.phpt"
  279. ;; Test expects uninitialized value to be false, but
  280. ;; instead gets "resource(5) of type (gd)".
  281. "ext/gd/tests/bug79067.phpt"
  282. ;; The following test fails with "The image size
  283. ;; differs: expected 114x115, got 117x117".
  284. "ext/gd/tests/bug79068.phpt"
  285. ;; XXX: These iconv tests have the expected outcome,
  286. ;; but with different error messages.
  287. ;; Expects "illegal character", instead gets "unknown error (84)".
  288. "ext/iconv/tests/bug52211.phpt"
  289. "ext/iconv/tests/bug60494.phpt"
  290. ;; Expects "wrong charset", gets unknown error (22).
  291. "ext/iconv/tests/iconv_strlen_error2.phpt"
  292. "ext/iconv/tests/iconv_substr_error2.phpt"
  293. ;; Expects conversion error, gets "error condition Termsig=11".
  294. "ext/iconv/tests/iconv_strpos_error2.phpt"
  295. "ext/iconv/tests/iconv_strrpos_error2.phpt"
  296. ;; Expects "invalid multibyte sequence" but got
  297. ;; "unknown error".
  298. "ext/iconv/tests/bug76249.phpt"
  299. ;; XXX: These test failures appear legitimate, needs investigation.
  300. ;; open_basedir() restriction failure.
  301. "ext/curl/tests/bug61948-unix.phpt"
  302. ;; Expects a false boolean, gets empty array from glob().
  303. "ext/standard/tests/file/bug41655_1.phpt"
  304. "ext/standard/tests/file/glob_variation5.phpt"
  305. ;; The test expects an Array, but instead get the contents(?).
  306. "ext/gd/tests/bug43073.phpt"
  307. ;; imagettftext() returns wrong coordinates.
  308. "ext/gd/tests/bug48732-mb.phpt"
  309. "ext/gd/tests/bug48732.phpt"
  310. ;; Similarly for imageftbbox().
  311. "ext/gd/tests/bug48801-mb.phpt"
  312. "ext/gd/tests/bug48801.phpt"
  313. ;; Different expected output from imagecolorallocate().
  314. "ext/gd/tests/bug53504.phpt"
  315. ;; Wrong image size after scaling an image.
  316. "ext/gd/tests/bug73272.phpt"
  317. ;; Expects iconv to detect illegal characters, instead gets
  318. ;; "unknown error (84)" and heap corruption(!).
  319. "ext/iconv/tests/bug48147.phpt"
  320. ;; Expects illegal character ".", gets "=?utf-8?Q?."
  321. "ext/iconv/tests/bug51250.phpt"
  322. ;; iconv throws "buffer length exceeded" on some string checks.
  323. "ext/iconv/tests/iconv_mime_encode.phpt"
  324. ;; file_get_contents(): iconv stream filter
  325. ;; ("ISO-8859-1"=>"UTF-8") unknown error.
  326. "ext/standard/tests/file/bug43008.phpt"
  327. ;; Table data not created in sqlite(?).
  328. "ext/pdo_sqlite/tests/bug_42589.phpt"
  329. ;; Expects an Array with 3 preg_matches; gets 0.
  330. "ext/pcre/tests/bug79846.phpt"
  331. ;; Expects an empty Array; gets one with " " in it.
  332. "ext/pcre/tests/bug80118.phpt"
  333. ;; Renicing a process fails in the build environment.
  334. "ext/standard/tests/general_functions/proc_nice_basic.phpt"
  335. ;; Can fail on fast machines?
  336. "Zend/tests/bug74093.phpt"))
  337. ;; Accomodate two extra openssl errors flanking the expected one:
  338. ;; random number generator:RAND_{load,write}_file:Cannot open file
  339. ;; This is due to an invalid $HOME, but changing it in the test
  340. ;; still prints the first one & changing it globally is overkill.
  341. (substitute* "ext/openssl/tests/bug80747.phpt"
  342. ((".*error:%s:key size too small.*" match)
  343. (string-append "%s\n" match "%s\n")))
  344. ;; Skip tests requiring network access.
  345. (setenv "SKIP_ONLINE_TESTS" "1")
  346. ;; Without this variable, 'make test' passes regardless of failures.
  347. (setenv "REPORT_EXIT_STATUS" "1")
  348. ;; Skip tests requiring I/O facilities that are unavailable in the
  349. ;; build environment
  350. (setenv "SKIP_IO_CAPTURE_TESTS" "1"))))
  351. #:test-target "test"))
  352. (inputs
  353. `(("aspell" ,aspell)
  354. ("bzip2" ,bzip2)
  355. ("curl" ,curl)
  356. ("cyrus-sasl" ,cyrus-sasl)
  357. ("gd" ,gd)
  358. ("gdbm" ,gdbm)
  359. ("glibc" ,glibc)
  360. ("gmp" ,gmp)
  361. ("gnutls" ,gnutls)
  362. ("icu4c" ,icu4c)
  363. ("libgcrypt" ,libgcrypt)
  364. ("libpng" ,libpng)
  365. ("libsodium" ,libsodium)
  366. ("libxml2" ,libxml2)
  367. ("libxslt" ,libxslt)
  368. ("libx11" ,libx11)
  369. ("libzip" ,libzip)
  370. ("oniguruma" ,oniguruma)
  371. ("openldap" ,openldap)
  372. ("openssl" ,openssl)
  373. ("pcre" ,pcre2)
  374. ("postgresql" ,postgresql)
  375. ("readline" ,readline)
  376. ("sqlite" ,sqlite)
  377. ("tidy" ,tidy)
  378. ("zlib" ,zlib)))
  379. (native-inputs
  380. `(("pkg-config" ,pkg-config)
  381. ("bison" ,bison)
  382. ("gettext" ,gettext-minimal)
  383. ("procps" ,procps))) ; for tests
  384. (synopsis "PHP programming language")
  385. (description
  386. "PHP (PHP Hypertext Processor) is a server-side (CGI) scripting
  387. language designed primarily for web development but is also used as
  388. a general-purpose programming language. PHP code may be embedded into
  389. HTML code, or it can be used in combination with various web template
  390. systems, web content management systems and web frameworks." )
  391. (license (list
  392. (license:non-copyleft "file://LICENSE") ; The PHP license.
  393. (license:non-copyleft "file://Zend/LICENSE") ; The Zend license.
  394. license:lgpl2.1 ; ext/mbstring/libmbfl
  395. license:lgpl2.1+ ; ext/bcmath/libbcmath
  396. license:bsd-2 ; ext/fileinfo/libmagic
  397. license:expat)))) ; ext/date/lib