php.scm 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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. ;;; Copyright © 2021 Efraim Flashner <efraim@flashner.co.il>
  9. ;;;
  10. ;;; This file is part of GNU Guix.
  11. ;;;
  12. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  13. ;;; under the terms of the GNU General Public License as published by
  14. ;;; the Free Software Foundation; either version 3 of the License, or (at
  15. ;;; your option) any later version.
  16. ;;;
  17. ;;; GNU Guix is distributed in the hope that it will be useful, but
  18. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  19. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. ;;; GNU General Public License for more details.
  21. ;;;
  22. ;;; You should have received a copy of the GNU General Public License
  23. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  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 crypto)
  32. #:use-module (gnu packages curl)
  33. #:use-module (gnu packages cyrus-sasl)
  34. #:use-module (gnu packages databases)
  35. #:use-module (gnu packages dbm)
  36. #:use-module (gnu packages fontutils)
  37. #:use-module (gnu packages gd)
  38. #:use-module (gnu packages gettext)
  39. #:use-module (gnu packages gnupg)
  40. #:use-module (gnu packages icu4c)
  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)
  48. #:use-module (gnu packages sqlite)
  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)
  54. #:use-module (guix packages)
  55. #:use-module (guix download)
  56. #:use-module (guix build-system gnu)
  57. #:use-module (guix utils)
  58. #:use-module ((guix licenses) #:prefix license:))
  59. (define-public php
  60. (package
  61. (name "php")
  62. (version "8.2.2")
  63. (home-page "https://www.php.net/")
  64. (source (origin
  65. (method url-fetch)
  66. (uri (string-append home-page "distributions/"
  67. "php-" version ".tar.xz"))
  68. (sha256
  69. (base32
  70. "0czflx9ikxymjfgnzaifjx9kc30ww2x4063075hcifjjwqwami5x"))
  71. (patches
  72. (search-patches "php-fix-streams-copy-length.patch"))
  73. (modules '((guix build utils)))
  74. (snippet
  75. '(with-directory-excursion "ext"
  76. (for-each delete-file-recursively
  77. ;; Some of the bundled libraries have no proper upstream.
  78. ;; Ideally we'd extract these out as separate packages:
  79. ;;"mbstring/libmbfl"
  80. ;;"date/lib"
  81. ;;"bcmath/libbcmath"
  82. ;;"fileinfo/libmagic" ; a patched version of libmagic
  83. '("gd/libgd"
  84. "pcre/pcre2lib"))))))
  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" "libc") ; 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 (target-arm32?)
  174. ;; Drop tests known to fail on armhf.
  175. '((for-each delete-file
  176. (list
  177. "ext/calendar/tests/unixtojd_error1.phpt"
  178. "ext/opcache/tests/preload_006.phpt"
  179. "ext/opcache/tests/preload_011.phpt"
  180. ;; arm can be a lot slower, so a time-related test fails
  181. "ext/fileinfo/tests/cve-2014-3538-nojit.phpt"
  182. "ext/pcntl/tests/pcntl_unshare_01.phpt"
  183. "ext/pcre/tests/bug76514.phpt"
  184. "ext/pcre/tests/preg_match_error3.phpt"
  185. "ext/pcre/tests/cache_limit.phpt"
  186. "ext/sockets/tests/socket_getopt.phpt"
  187. "ext/sockets/tests/socket_sendrecvmsg_error.phpt"
  188. "ext/standard/tests/general_functions/var_export-locale.phpt"
  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"
  192. "sapi/cli/tests/cli_process_title_unix.phpt"
  193. "sapi/cli/tests/upload_2G.phpt"
  194. "Zend/tests/concat_003.phpt")))
  195. '())
  196. ,@(if (target-x86-32?)
  197. ;; Drop tests known to fail on i686.
  198. '((for-each delete-file
  199. (list
  200. "ext/dba/tests/dba_gdbm.phpt")))
  201. '())
  202. ,@(if (target-ppc64le?)
  203. ;; Drop tests known to fail on powerpc64le.
  204. '((for-each delete-file
  205. (list
  206. ;; phpdbg watchpoints don't work.
  207. ;; Bug tracked upstream at:
  208. ;; https://bugs.php.net/bug.php?id=81408
  209. "sapi/phpdbg/tests/watch_001.phpt"
  210. "sapi/phpdbg/tests/watch_003.phpt"
  211. "sapi/phpdbg/tests/watch_004.phpt"
  212. "sapi/phpdbg/tests/watch_005.phpt"
  213. "sapi/phpdbg/tests/watch_006.phpt")))
  214. '())
  215. ,@(if (target-riscv64?)
  216. ;; Drop tests known to fail on riscv64.
  217. '((for-each delete-file
  218. (list "sapi/cli/tests/upload_2G.phpt")))
  219. '())
  220. ;; Drop tests that are known to fail.
  221. (for-each delete-file
  222. '("ext/posix/tests/posix_getgrgid.phpt" ; Requires /etc/group.
  223. "ext/posix/tests/posix_getgrnam_basic.phpt" ; Requires /etc/group.
  224. "ext/sockets/tests/bug63000.phpt" ; Fails to detect OS.
  225. "ext/sockets/tests/socket_shutdown.phpt" ; Requires DNS.
  226. "ext/sockets/tests/socket_send.phpt" ; Likewise.
  227. "ext/sockets/tests/mcast_ipv4_recv.phpt" ; Requires multicast.
  228. ;; These needs /etc/services.
  229. "ext/standard/tests/general_functions/getservbyname_basic.phpt"
  230. "ext/standard/tests/general_functions/getservbyport_basic.phpt"
  231. "ext/standard/tests/general_functions/getservbyport_variation1.phpt"
  232. ;; And /etc/protocols.
  233. "ext/standard/tests/network/getprotobyname_basic.phpt"
  234. "ext/standard/tests/network/getprotobynumber_basic.phpt"
  235. ;; And exotic locales.
  236. "ext/standard/tests/strings/setlocale_basic1.phpt"
  237. "ext/standard/tests/strings/setlocale_basic2.phpt"
  238. "ext/standard/tests/strings/setlocale_basic3.phpt"
  239. "ext/standard/tests/strings/setlocale_variation1.phpt"
  240. ;; This failing test is skipped on PHP's Travis CI as it is
  241. ;; supposedly inaccurate.
  242. "ext/standard/tests/file/disk_free_space_basic.phpt"
  243. ;; The following test erroneously expect the link
  244. ;; count of a sub-directory to increase compared to
  245. ;; its parent.
  246. "ext/standard/tests/file/lstat_stat_variation8.phpt"
  247. ;; This tests whether microseconds ‘differ enough’ and
  248. ;; fails inconsistently on ‘fast’ machines.
  249. "ext/date/tests/bug73837.phpt"
  250. ;; XXX: These gd tests fails. Likely because our version
  251. ;; is different from the (patched) bundled one.
  252. ;; Here, gd quits immediately after "fatal libpng error"; while the
  253. ;; test expects it to additionally return a "setjmp" error and warning.
  254. "ext/gd/tests/bug39780_extern.phpt"
  255. "ext/gd/tests/libgd00086_extern.phpt"
  256. ;; Extra newline in gd-png output.
  257. "ext/gd/tests/bug45799.phpt"
  258. ;; Test expects generic "gd warning" but gets the actual function name.
  259. "ext/gd/tests/createfromwbmp2_extern.phpt"
  260. ;; This bug should have been fixed in gd 2.2.2.
  261. ;; Is it a regression?
  262. "ext/gd/tests/bug65148.phpt"
  263. ;; This bug should have been fixed in the gd 2.2
  264. ;; series. Perhaps a regression introduced by gd
  265. ;; 2.3.0?
  266. "ext/gd/tests/bug66590.phpt"
  267. ;; This bug should have been fixed in the php-5.5
  268. ;; series. Perhaps a regression introduced by gd
  269. ;; 2.3.0?
  270. "ext/gd/tests/bug70102.phpt"
  271. ;; This bug should have been fixed in the php-5.6
  272. ;; series. Perhaps a regression introduced by gd
  273. ;; 2.3.0?
  274. "ext/gd/tests/bug73869.phpt"
  275. ;; Some WebP related tests fail.
  276. "ext/gd/tests/webp_basic.phpt"
  277. "ext/gd/tests/imagecreatefromstring_webp.phpt"
  278. ;; TODO: Enable these when libgd is built with xpm support.
  279. "ext/gd/tests/xpm2gd.phpt"
  280. "ext/gd/tests/xpm2jpg.phpt"
  281. "ext/gd/tests/xpm2png.phpt"
  282. ;; Whitespace difference, probably caused by a very
  283. ;; long store path
  284. "ext/gd/tests/bug77479.phpt"
  285. ;; Expected invalid XBM but got EOF before image was
  286. ;; complete. It's a warning in both cases and test
  287. ;; result is the same.
  288. "ext/gd/tests/bug77973.phpt"
  289. ;; Test expects uninitialized value to be false, but
  290. ;; instead gets "resource(5) of type (gd)".
  291. "ext/gd/tests/bug79067.phpt"
  292. ;; The following test fails with "The image size
  293. ;; differs: expected 114x115, got 117x117".
  294. "ext/gd/tests/bug79068.phpt"
  295. ;; AVIF support disabled
  296. "ext/gd/tests/avif_decode_encode.phpt"
  297. ;; Typo in expected outputs
  298. "ext/gd/tests/bug72339.phpt"
  299. "ext/gd/tests/bug77272.phpt"
  300. "ext/gd/tests/bug66356.phpt"
  301. ;; AVIF support disabled
  302. "ext/gd/tests/imagecreatefromstring_avif.phpt"
  303. ;; XXX: These iconv tests have the expected outcome,
  304. ;; but with different error messages.
  305. ;; Expects "illegal character", instead gets "unknown error (84)".
  306. "ext/iconv/tests/bug52211.phpt"
  307. "ext/iconv/tests/bug60494.phpt"
  308. ;; Expects "wrong charset", gets unknown error (22).
  309. "ext/iconv/tests/iconv_strlen_error2.phpt"
  310. "ext/iconv/tests/iconv_substr_error2.phpt"
  311. ;; Expects conversion error, gets "error condition Termsig=11".
  312. "ext/iconv/tests/iconv_strpos_error2.phpt"
  313. "ext/iconv/tests/iconv_strrpos_error2.phpt"
  314. ;; Expects "invalid multibyte sequence" but got
  315. ;; "unknown error".
  316. "ext/iconv/tests/bug76249.phpt"
  317. ;; XXX: These test failures appear legitimate, needs investigation.
  318. ;; open_basedir() restriction failure.
  319. "ext/curl/tests/bug61948-unix.phpt"
  320. ;; Same error reason but error code slightly different
  321. "ext/curl/tests/curl_setopt_ssl.phpt"
  322. ;; Fail because there is no "root" in the build container's
  323. ;; /etc/passwd
  324. "sapi/fpm/tests/bug68591-conf-test-group.phpt"
  325. "sapi/fpm/tests/bug68591-conf-test-listen-group.phpt"
  326. "sapi/fpm/tests/bug68591-conf-test-listen-owner.phpt"
  327. ;; Wrong error name
  328. "ext/dba/tests/dba_gdbm_creation_matrix.phpt"
  329. ;; Expects a false boolean, gets empty array from glob().
  330. "ext/standard/tests/file/bug41655_1.phpt"
  331. "ext/standard/tests/file/glob_variation5.phpt"
  332. ;; The test expects an Array, but instead get the contents(?).
  333. "ext/gd/tests/bug43073.phpt"
  334. ;; imagettftext() returns wrong coordinates.
  335. "ext/gd/tests/bug48732-mb.phpt"
  336. "ext/gd/tests/bug48732.phpt"
  337. ;; Similarly for imageftbbox().
  338. "ext/gd/tests/bug48801-mb.phpt"
  339. "ext/gd/tests/bug48801.phpt"
  340. ;; Different expected output from imagecolorallocate().
  341. "ext/gd/tests/bug53504.phpt"
  342. ;; Wrong image size after scaling an image.
  343. "ext/gd/tests/bug73272.phpt"
  344. ;; Expects iconv to detect illegal characters, instead gets
  345. ;; "unknown error (84)" and heap corruption(!).
  346. "ext/iconv/tests/bug48147.phpt"
  347. ;; Expects illegal character ".", gets "=?utf-8?Q?."
  348. "ext/iconv/tests/bug51250.phpt"
  349. ;; iconv throws "buffer length exceeded" on some string checks.
  350. "ext/iconv/tests/iconv_mime_encode.phpt"
  351. ;; file_get_contents(): iconv stream filter
  352. ;; ("ISO-8859-1"=>"UTF-8") unknown error.
  353. "ext/standard/tests/file/bug43008.phpt"
  354. ;; Table data not created in sqlite(?).
  355. "ext/pdo_sqlite/tests/bug_42589.phpt"
  356. ;; Expects an Array with 3 preg_matches; gets 0.
  357. "ext/pcre/tests/bug79846.phpt"
  358. ;; Expects an empty Array; gets one with " " in it.
  359. "ext/pcre/tests/bug80118.phpt"
  360. ;; Renicing a process fails in the build environment.
  361. "ext/standard/tests/general_functions/proc_nice_basic.phpt"
  362. ;; Can fail on fast machines?
  363. "Zend/tests/bug74093.phpt"))
  364. ;; Accomodate two extra openssl errors flanking the expected one:
  365. ;; random number generator:RAND_{load,write}_file:Cannot open file
  366. ;; This is due to an invalid $HOME, but changing it in the test
  367. ;; still prints the first one & changing it globally is overkill.
  368. (substitute* "ext/openssl/tests/bug80747.phpt"
  369. ((".*error:%s:key size too small.*" match)
  370. (string-append "%s\n" match "%s\n")))
  371. ;; Skip tests requiring network access.
  372. (setenv "SKIP_ONLINE_TESTS" "1")
  373. ;; Without this variable, 'make test' passes regardless of failures.
  374. (setenv "REPORT_EXIT_STATUS" "1")
  375. ;; Skip tests requiring I/O facilities that are unavailable in the
  376. ;; build environment
  377. (setenv "SKIP_IO_CAPTURE_TESTS" "1"))))
  378. #:test-target "test"))
  379. (inputs
  380. `(("aspell" ,aspell)
  381. ("bzip2" ,bzip2)
  382. ("curl" ,curl)
  383. ("cyrus-sasl" ,cyrus-sasl)
  384. ("gd" ,gd)
  385. ("gdbm" ,gdbm)
  386. ("gmp" ,gmp)
  387. ("gnutls" ,gnutls)
  388. ("icu4c" ,icu4c)
  389. ("libgcrypt" ,libgcrypt)
  390. ("libpng" ,libpng)
  391. ("libsodium" ,libsodium)
  392. ("libxml2" ,libxml2)
  393. ("libxslt" ,libxslt)
  394. ("libx11" ,libx11)
  395. ("libzip" ,libzip)
  396. ("oniguruma" ,oniguruma)
  397. ("openldap" ,openldap)
  398. ("openssl" ,openssl-1.1)
  399. ("pcre" ,pcre2)
  400. ("postgresql" ,postgresql)
  401. ("readline" ,readline)
  402. ("sqlite" ,sqlite)
  403. ("tidy" ,tidy-html)
  404. ("zlib" ,zlib)))
  405. (native-inputs
  406. `(("pkg-config" ,pkg-config)
  407. ("bison" ,bison)
  408. ("gettext" ,gettext-minimal)
  409. ("procps" ,procps))) ; for tests
  410. (synopsis "PHP programming language")
  411. (description
  412. "PHP (PHP Hypertext Processor) is a server-side (CGI) scripting
  413. language designed primarily for web development but is also used as
  414. a general-purpose programming language. PHP code may be embedded into
  415. HTML code, or it can be used in combination with various web template
  416. systems, web content management systems and web frameworks." )
  417. (license (list
  418. (license:non-copyleft "file://LICENSE") ; The PHP license.
  419. (license:non-copyleft "file://Zend/LICENSE") ; The Zend license.
  420. license:lgpl2.1 ; ext/mbstring/libmbfl
  421. license:lgpl2.1+ ; ext/bcmath/libbcmath
  422. license:bsd-2 ; ext/fileinfo/libmagic
  423. license:expat)))) ; ext/date/lib