readline.scm 5.8 KB

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