readline.scm 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2012, 2013, 2014, 2020 Ludovic Courtès <ludo@gnu.org>
  3. ;;; Copyright © 2016, 2019 Efraim Flashner <efraim@flashner.co.il>
  4. ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
  5. ;;; Copyright © 2018, 2021 Tobias Geerinckx-Rice <me@tobias.gr>
  6. ;;; Copyright © 2019, 2020 Marius Bakke <marius@gnu.org>
  7. ;;;
  8. ;;; This file is part of GNU Guix.
  9. ;;;
  10. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  11. ;;; under the terms of the GNU General Public License as published by
  12. ;;; the Free Software Foundation; either version 3 of the License, or (at
  13. ;;; your option) any later version.
  14. ;;;
  15. ;;; GNU Guix is distributed in the hope that it will be useful, but
  16. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. ;;; GNU General Public License for more details.
  19. ;;;
  20. ;;; You should have received a copy of the GNU General Public License
  21. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  22. (define-module (gnu packages readline)
  23. #:use-module (guix licenses)
  24. #:use-module (gnu packages)
  25. #:use-module (gnu packages autotools)
  26. #:use-module (gnu packages ncurses)
  27. #:use-module (gnu packages perl)
  28. #:use-module (guix packages)
  29. #:use-module (guix download)
  30. #:use-module (guix git-download)
  31. #:use-module (guix build-system gnu)
  32. #:use-module (guix utils)
  33. #:use-module (ice-9 format))
  34. (define (patch-url version seqno)
  35. (format #f "mirror://gnu/readline/readline-~a-patches/readline~a-~3,'0d"
  36. version (string-join (string-split version #\.) "") seqno))
  37. (define (readline-patch version seqno sha256-bv)
  38. "Return the origin of Readline patch SEQNO, with expected hash SHA256-BV"
  39. (origin
  40. (method url-fetch)
  41. (uri (patch-url version seqno))
  42. (sha256 sha256-bv)))
  43. (define-syntax-rule (patch-series version (seqno hash) ...)
  44. (list (readline-patch version seqno (base32 hash))
  45. ...))
  46. (define %patch-series-8.1
  47. (patch-series
  48. "8.1"
  49. (1 "0i4ikdqgcjnb40y2ss3lm09rq56zih5rzma3bib50dk3d1d4cak8")))
  50. (define %patch-series-7.0
  51. (patch-series
  52. "7.0"
  53. (1 "0xm3sxvwmss7ddyfb11n6pgcqd1aglnpy15g143vzcf75snb7hcs")
  54. (2 "0n1dxmqsbjgrfxb1hgk5c6lsraw4ncbnzxlsx7m35nym6lncjiw7")
  55. (3 "1027kmymniizcy0zbdlrczxfx3clxcdln5yq05q9yzlc6y9slhwy")
  56. (4 "0r3bbaf12iz8m02z6p3fzww2m365fhn71xmzab2p62gj54s6h9gr")
  57. (5 "0lxpa4f72y2nsgj6fgrhjk2nmmxvccys6aciwfxwchb5f21rq5fa")))
  58. (define-public readline
  59. (package
  60. (name "readline")
  61. (version (string-append "8.1."
  62. (number->string (length %patch-series-8.1))))
  63. (source (origin
  64. (method url-fetch)
  65. (uri (string-append "mirror://gnu/readline/readline-"
  66. (version-major+minor version) ".tar.gz"))
  67. (sha256
  68. (base32
  69. "00ibp0n9crbwx15k9vvckq5wsipw98b1px8pd8i34chy2gpb9kpq"))
  70. (patches (append %patch-series-8.1
  71. (search-patches "readline-link-ncurses.patch")))
  72. (patch-flags '("-p0"))))
  73. (build-system gnu-build-system)
  74. (propagated-inputs `(("ncurses" ,ncurses)))
  75. (arguments `(#:configure-flags
  76. (list (string-append "LDFLAGS=-Wl,-rpath -Wl,"
  77. (assoc-ref %build-inputs "ncurses")
  78. "/lib")
  79. ;; This test does an 'AC_TRY_RUN', which aborts when
  80. ;; cross-compiling, so provide the correct answer.
  81. ,@(if (%current-target-system)
  82. '("bash_cv_wcwidth_broken=no")
  83. '())
  84. ;; MinGW: ncurses provides the termcap api.
  85. ,@(if (target-mingw?)
  86. '("bash_cv_termcap_lib=ncurses")
  87. '()))
  88. ,@(if (target-mingw?)
  89. ;; MinGW: termcap in ncurses
  90. ;; some SIG_* #defined in _POSIX
  91. '(#:make-flags '("TERMCAP_LIB=-lncurses"
  92. "CPPFLAGS=-D_POSIX -D'chown(f,o,g)=0'"))
  93. '())))
  94. (synopsis "Edit command lines while typing, with history support")
  95. (description
  96. "The GNU readline library allows users to edit command lines as they
  97. are typed in. It can maintain a searchable history of previously entered
  98. commands, letting you easily recall, edit and re-enter past commands. It
  99. features both Emacs-like and vi-like keybindings, making its usage
  100. comfortable for anyone.")
  101. (license gpl3+)
  102. (home-page "https://savannah.gnu.org/projects/readline/")))
  103. (define-public readline-7
  104. (package (inherit readline)
  105. (name "readline")
  106. (version (string-append "7.0."
  107. (number->string (length %patch-series-7.0))))
  108. (source (origin
  109. (method url-fetch)
  110. (uri (string-append "mirror://gnu/readline/readline-"
  111. (version-major+minor version) ".tar.gz"))
  112. (sha256
  113. (base32
  114. "0d13sg9ksf982rrrmv5mb6a2p4ys9rvg9r71d6il0vr8hmql63bm"))
  115. (patches (append
  116. %patch-series-7.0
  117. (search-patches "readline-link-ncurses.patch")))
  118. (patch-flags '("-p0"))))))
  119. (define-public readline-6.2
  120. (package (inherit readline)
  121. (version "6.2")
  122. (source (origin (inherit (package-source readline))
  123. (method url-fetch)
  124. (uri (string-append "mirror://gnu/readline/readline-"
  125. version ".tar.gz"))
  126. (patches (search-patches "readline-6.2-CVE-2014-2524.patch"))
  127. (patch-flags '("-p0"))
  128. (sha256
  129. (base32
  130. "10ckm2bd2rkxhvdmj7nmbsylmihw0abwcsnxf8y27305183rd9kr"))))))
  131. (define-public rlwrap
  132. (package
  133. (name "rlwrap")
  134. (version "0.45.2")
  135. (source
  136. (origin
  137. (method git-fetch)
  138. (uri (git-reference
  139. (url "https://github.com/hanslub42/rlwrap")
  140. (commit (string-append "v" version))))
  141. (file-name (git-file-name name version))
  142. (sha256
  143. (base32 "1irlcdvj1ddxkfzwa7l2djxgp5xbqch9vaajk2s32x1h5cxl1f5r"))))
  144. (build-system gnu-build-system)
  145. (native-inputs
  146. `(("autoconf" ,autoconf)
  147. ("automake" ,automake)
  148. ("perl" ,perl)))
  149. (inputs
  150. `(("readline" ,readline)))
  151. (synopsis "Wrapper to allow the editing of keyboard commands")
  152. (description
  153. "Rlwrap is a 'readline wrapper', a small utility that uses the GNU
  154. readline library to allow the editing of keyboard input for any command. You
  155. should consider rlwrap especially when you need user-defined completion (by way
  156. of completion word lists) and persistent history, or if you want to program
  157. `special effects' using the filter mechanism.")
  158. (home-page "https://github.com/hanslub42/rlwrap")
  159. (license gpl2+)))