curl.scm 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2013, 2014, 2015 Andreas Enge <andreas@enge.fr>
  3. ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
  4. ;;; Copyright © 2015 Tomáš Čech <sleep_walker@suse.cz>
  5. ;;; Copyright © 2015, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
  6. ;;; Copyright © 2016, 2017, 2019 Leo Famulari <leo@famulari.name>
  7. ;;; Copyright © 2017, 2019, 2020 Marius Bakke <mbakke@fastmail.com>
  8. ;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
  9. ;;; Copyright © 2017, 2018 Tobias Geerinckx-Rice <me@tobias.gr>
  10. ;;; Copyright © 2018 Roel Janssen <roel@gnu.org>
  11. ;;; Copyright © 2019, 2021 Ricardo Wurmus <rekado@elephly.net>
  12. ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
  13. ;;; Copyright © 2020 Dale Mellor <guix-devel-0brg6b@rdmp.org>
  14. ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  15. ;;; Copyright © 2021 Jean-Baptiste Volatier <jbv@pm.me>
  16. ;;; Copyright © 2021 Felix Gruber <felgru@posteo.net>
  17. ;;;
  18. ;;; This file is part of GNU Guix.
  19. ;;;
  20. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  21. ;;; under the terms of the GNU General Public License as published by
  22. ;;; the Free Software Foundation; either version 3 of the License, or (at
  23. ;;; your option) any later version.
  24. ;;;
  25. ;;; GNU Guix is distributed in the hope that it will be useful, but
  26. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  27. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  28. ;;; GNU General Public License for more details.
  29. ;;;
  30. ;;; You should have received a copy of the GNU General Public License
  31. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  32. (define-module (gnu packages curl)
  33. #:use-module ((guix licenses) #:prefix license:)
  34. #:use-module (guix packages)
  35. #:use-module (guix download)
  36. #:use-module (guix git-download)
  37. #:use-module (guix utils)
  38. #:use-module (guix build-system cmake)
  39. #:use-module (guix build-system copy)
  40. #:use-module (guix build-system gnu)
  41. #:use-module (guix build-system go)
  42. #:use-module (gnu packages)
  43. #:use-module (gnu packages compression)
  44. #:use-module (gnu packages golang)
  45. #:use-module (gnu packages guile)
  46. #:use-module (gnu packages kerberos)
  47. #:use-module (gnu packages libidn)
  48. #:use-module (gnu packages perl)
  49. #:use-module (gnu packages pkg-config)
  50. #:use-module (gnu packages python)
  51. #:use-module (gnu packages ssh)
  52. #:use-module (gnu packages tls)
  53. #:use-module (gnu packages web)
  54. #:use-module (srfi srfi-1))
  55. (define-public curl
  56. (package
  57. (name "curl")
  58. (version "7.77.0")
  59. (source (origin
  60. (method url-fetch)
  61. (uri (string-append "https://curl.haxx.se/download/curl-"
  62. version ".tar.xz"))
  63. (sha256
  64. (base32
  65. "0jsrc97vbghvljic997r9nypc9qqddcil2lzvv032br8ahn5hr0g"))
  66. (patches (search-patches "curl-use-ssl-cert-env.patch"
  67. "curl-7.77-tls-priority-string.patch"))))
  68. (build-system gnu-build-system)
  69. (outputs '("out"
  70. "doc")) ;1.2 MiB of man3 pages
  71. (inputs `(("gnutls" ,gnutls)
  72. ("libidn" ,libidn)
  73. ("mit-krb5" ,mit-krb5)
  74. ("nghttp2" ,nghttp2 "lib")
  75. ("zlib" ,zlib)))
  76. (native-inputs
  77. `(("nghttp2" ,nghttp2)
  78. ("perl" ,perl)
  79. ("pkg-config" ,pkg-config)
  80. ("python" ,python-minimal-wrapper)))
  81. (native-search-paths
  82. ;; These variables are introduced by curl-use-ssl-cert-env.patch.
  83. (list (search-path-specification
  84. (variable "SSL_CERT_DIR")
  85. (separator #f) ;single entry
  86. (files '("etc/ssl/certs")))
  87. (search-path-specification
  88. (variable "SSL_CERT_FILE")
  89. (file-type 'regular)
  90. (separator #f) ;single entry
  91. (files '("etc/ssl/certs/ca-certificates.crt")))
  92. ;; Note: This search path is respected by the `curl` command-line
  93. ;; tool only. Patching libcurl to read it too would bring no
  94. ;; advantages and require maintaining a more complex patch.
  95. (search-path-specification
  96. (variable "CURL_CA_BUNDLE")
  97. (file-type 'regular)
  98. (separator #f) ;single entry
  99. (files '("etc/ssl/certs/ca-certificates.crt")))))
  100. (arguments
  101. `(#:disallowed-references ("doc")
  102. #:configure-flags (list "--with-gnutls"
  103. (string-append "--with-gssapi="
  104. (assoc-ref %build-inputs "mit-krb5"))
  105. "--disable-static")
  106. #:phases
  107. (modify-phases %standard-phases
  108. (add-after 'unpack 'do-not-record-configure-flags
  109. (lambda _
  110. ;; Do not save the configure options to avoid unnecessary references.
  111. (substitute* "curl-config.in"
  112. (("@CONFIGURE_OPTIONS@")
  113. "\"not available\""))
  114. #t))
  115. (add-after
  116. 'install 'move-man3-pages
  117. (lambda* (#:key outputs #:allow-other-keys)
  118. ;; Move section 3 man pages to "doc".
  119. (let ((out (assoc-ref outputs "out"))
  120. (doc (assoc-ref outputs "doc")))
  121. (mkdir-p (string-append doc "/share/man"))
  122. (rename-file (string-append out "/share/man/man3")
  123. (string-append doc "/share/man/man3"))
  124. #t)))
  125. (replace
  126. 'check
  127. (lambda _
  128. (substitute* "tests/runtests.pl"
  129. (("/bin/sh") (which "sh")))
  130. ;; The top-level "make check" does "make -C tests quiet-test", which
  131. ;; is too quiet. Use the "test" target instead, which is more
  132. ;; verbose.
  133. (invoke "make" "-C" "tests" "test"))))))
  134. (synopsis "Command line tool for transferring data with URL syntax")
  135. (description
  136. "curl is a command line tool for transferring data with URL syntax,
  137. supporting DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAPS, LDAP,
  138. LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, Telnet and TFTP.
  139. curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP
  140. form based upload, proxies, cookies, file transfer resume, user+password
  141. authentication (Basic, Digest, NTLM, Negotiate, kerberos...), proxy
  142. tunneling, and so on.")
  143. (license (license:non-copyleft "file://COPYING"
  144. "See COPYING in the distribution."))
  145. (home-page "https://curl.haxx.se/")))
  146. (define-public curl-minimal
  147. (deprecated-package "curl-minimal" curl))
  148. (define-public curl-ssh
  149. (package/inherit curl
  150. (arguments
  151. (substitute-keyword-arguments (package-arguments curl)
  152. ((#:configure-flags flags)
  153. `(cons "--with-libssh2" ,flags))))
  154. (inputs
  155. `(("libssh2" ,libssh2)
  156. ,@(package-inputs curl)))
  157. (properties `((hidden? . #t)))))
  158. (define-public kurly
  159. (package
  160. (name "kurly")
  161. (version "1.2.2")
  162. (source (origin
  163. (method git-fetch)
  164. (uri (git-reference
  165. (url "https://gitlab.com/davidjpeacock/kurly.git")
  166. (commit (string-append "v" version))))
  167. (file-name (git-file-name name version))
  168. (sha256
  169. (base32
  170. "003jv2k45hg2svhjpy5253ccd250vi2r17x2zhm51iw54kgwxipm"))))
  171. (build-system go-build-system)
  172. (arguments
  173. `(#:import-path "gitlab.com/davidjpeacock/kurly"
  174. #:install-source? #f
  175. #:phases
  176. (modify-phases %standard-phases
  177. (add-after 'install 'install-documentation
  178. (lambda* (#:key import-path outputs #:allow-other-keys)
  179. (let* ((source (string-append "src/" import-path))
  180. (out (assoc-ref outputs "out"))
  181. (doc (string-append out "/share/doc/" ,name "-" ,version))
  182. (man (string-append out "/share/man/man1")))
  183. (with-directory-excursion source
  184. (install-file "README.md" doc)
  185. (mkdir-p man)
  186. (copy-file "doc/kurly.man"
  187. (string-append man "/kurly.1")))
  188. #t))))))
  189. (inputs
  190. `(("go-github-com-alsm-ioprogress" ,go-github-com-alsm-ioprogress)
  191. ("go-github-com-aki237-nscjar" ,go-github-com-aki237-nscjar)
  192. ("go-github-com-urfave-cli" ,go-github-com-urfave-cli)))
  193. (synopsis "Command-line HTTP client")
  194. (description "kurly is an alternative to the @code{curl} program written in
  195. Go. kurly is designed to operate in a similar manner to curl, with select
  196. features. Notably, kurly is not aiming for feature parity, but common flags and
  197. mechanisms particularly within the HTTP(S) realm are to be expected. kurly does
  198. not offer a replacement for libcurl.")
  199. (home-page "https://gitlab.com/davidjpeacock/kurly")
  200. (license license:asl2.0)))
  201. (define-public guile-curl
  202. (package
  203. (name "guile-curl")
  204. (version "0.9")
  205. (source (origin
  206. (method url-fetch)
  207. (uri (string-append "http://www.lonelycactus.com/tarball/"
  208. "guile_curl-" version ".tar.gz"))
  209. (sha256
  210. (base32
  211. "0y7wfhilfm6vzs0wyifrrc2pj9nsxfas905c7qa5cw4i6s74ypmi"))))
  212. (build-system gnu-build-system)
  213. (arguments
  214. `(#:modules (((guix build guile-build-system)
  215. #:select (target-guile-effective-version))
  216. ,@%gnu-build-system-modules)
  217. #:imported-modules ((guix build guile-build-system)
  218. ,@%gnu-build-system-modules)
  219. #:configure-flags (list (string-append
  220. "--with-guilesitedir="
  221. (assoc-ref %outputs "out")
  222. "/share/guile/site/"
  223. (target-guile-effective-version
  224. (assoc-ref %build-inputs "guile")))
  225. (string-append
  226. "-with-guileextensiondir="
  227. (assoc-ref %outputs "out")
  228. "/lib/guile/"
  229. (target-guile-effective-version
  230. (assoc-ref %build-inputs "guile"))
  231. "/extensions"))
  232. #:phases
  233. (modify-phases %standard-phases
  234. (add-after 'unpack 'patch-undefined-references
  235. (lambda* _
  236. (substitute* "module/curl.scm"
  237. ;; The following #defines are missing from our curl package
  238. ;; and therefore result in the evaluation of undefined symbols.
  239. ((",CURLOPT_HAPROXYPROTOCOL") "#f")
  240. ((",CURLOPT_DISALLOW_USERNAME_IN_URL") "#f")
  241. ((",CURLOPT_TIMEVALUE_LARGE") "#f")
  242. ((",CURLOPT_DNS_SHUFFLE_ADDRESSES") "#f")
  243. ((",CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS") "#f"))))
  244. (add-after 'install 'patch-extension-path
  245. (lambda* (#:key outputs #:allow-other-keys)
  246. (let* ((out (assoc-ref outputs "out"))
  247. (curl.scm (string-append
  248. out "/share/guile/site/"
  249. (target-guile-effective-version)
  250. "/curl.scm"))
  251. (curl.go (string-append
  252. out "/lib/guile/"
  253. (target-guile-effective-version)
  254. "/site-ccache/curl.go"))
  255. (ext (string-append out "/lib/guile/"
  256. (target-guile-effective-version)
  257. "/extensions/libguile-curl")))
  258. (substitute* curl.scm (("libguile-curl") ext))
  259. ;; The build system does not actually compile the Scheme module.
  260. ;; So we can compile it and put it in the right place in one go.
  261. (invoke "guild" "compile" curl.scm "-o" curl.go)))))))
  262. (native-inputs `(("pkg-config" ,pkg-config)))
  263. (inputs
  264. `(("curl" ,curl)
  265. ("guile" ,guile-3.0)))
  266. (home-page "http://www.lonelycactus.com/guile-curl.html")
  267. (synopsis "Curl bindings for Guile")
  268. (description "@code{guile-curl} is a project that has procedures that allow
  269. Guile to do client-side URL transfers, like requesting documents from HTTP or
  270. FTP servers. It is based on the curl library.")
  271. (license license:gpl3+)))
  272. (define-public guile2.2-curl
  273. (package
  274. (inherit guile-curl)
  275. (name "guile2.2-curl")
  276. (inputs
  277. `(("curl" ,curl)
  278. ("guile" ,guile-2.2)))))
  279. (define-public curlpp
  280. (package
  281. (name "curlpp")
  282. (version "0.8.1")
  283. (source
  284. (origin
  285. (method git-fetch)
  286. (uri (git-reference
  287. (url "https://github.com/jpbarrette/curlpp")
  288. (commit (string-append "v" version))))
  289. (sha256
  290. (base32 "1b0ylnnrhdax4kwjq64r1fk0i24n5ss6zfzf4hxwgslny01xiwrk"))
  291. (file-name (git-file-name name version))))
  292. (build-system cmake-build-system)
  293. ;; There are no build tests to be had.
  294. (arguments
  295. '(#:tests? #f))
  296. ;; The installed version needs the header files from the C library.
  297. (propagated-inputs
  298. `(("curl" ,curl)))
  299. (synopsis "C++ wrapper around libcURL")
  300. (description
  301. "This package provides a free and easy-to-use client-side C++ URL
  302. transfer library, supporting FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, DICT,
  303. FILE and LDAP; in particular it supports HTTPS certificates, HTTP POST, HTTP
  304. PUT, FTP uploading, kerberos, HTTP form based upload, proxies, cookies,
  305. user+password authentication, file transfer resume, http proxy tunneling and
  306. more!")
  307. (home-page "http://www.curlpp.org")
  308. (license license:expat)))
  309. (define-public h2c
  310. (package
  311. (name "h2c")
  312. (version "1.0")
  313. (source
  314. (origin
  315. (method git-fetch)
  316. (uri (git-reference
  317. (url "https://github.com/curl/h2c")
  318. (commit version)))
  319. (sha256
  320. (base32
  321. "1n8z6avzhg3yb330di2y9zymsps1qp1235p29kidcp4fkmn7fgb2"))
  322. (file-name (git-file-name name version))))
  323. (build-system copy-build-system)
  324. (arguments
  325. '(#:install-plan
  326. '(("./h2c" "bin/"))))
  327. (inputs
  328. `(("perl" ,perl)))
  329. (home-page "https://curl.se/h2c/")
  330. (synopsis "Convert HTTP headers to a curl command line")
  331. (description
  332. "Provided a set of HTTP request headers, h2c outputs how to invoke
  333. curl to obtain exactly that HTTP request.")
  334. (license license:expat)))