Merge branch 'staging' into core-updates
[jackhill/guix/guix.git] / gnu / packages / readline.scm
CommitLineData
233e7676 1;;; GNU Guix --- Functional package management for GNU
f6d47eb6 2;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
2cb4f940 3;;; Copyright © 2016, 2019 Efraim Flashner <efraim@flashner.co.il>
ae12d586 4;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
f1fac6b8 5;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
d7316c77 6;;; Copyright © 2019 Marius Bakke <mbakke@fastmail.com>
c44899a2 7;;;
233e7676 8;;; This file is part of GNU Guix.
c44899a2 9;;;
233e7676 10;;; GNU Guix is free software; you can redistribute it and/or modify it
c44899a2
LC
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;;;
233e7676 15;;; GNU Guix is distributed in the hope that it will be useful, but
c44899a2
LC
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
233e7676 21;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
c44899a2 22
1ffa7090 23(define-module (gnu packages readline)
4a44e743 24 #:use-module (guix licenses)
59a43334 25 #:use-module (gnu packages)
1ffa7090 26 #:use-module (gnu packages ncurses)
a2285798 27 #:use-module (gnu packages perl)
c44899a2 28 #:use-module (guix packages)
87f5d366 29 #:use-module (guix download)
ae12d586 30 #:use-module (guix build-system gnu)
371193ec
MB
31 #:use-module (guix utils)
32 #:use-module (ice-9 format))
33
f7511ff1
MB
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))
371193ec 37
f7511ff1 38(define (readline-patch version seqno sha256)
371193ec
MB
39 "Return the origin of Readline patch SEQNO, with expected hash SHA256"
40 (origin
41 (method url-fetch)
f7511ff1 42 (uri (patch-url version seqno))
371193ec
MB
43 (sha256 sha256)))
44
f7511ff1
MB
45(define-syntax-rule (patch-series version (seqno hash) ...)
46 (list (readline-patch version seqno (base32 hash))
371193ec
MB
47 ...))
48
d7316c77
MB
49(define %patch-series-8.0
50 (patch-series
51 "8.0"
52 (1 "0sfh7wn0pr743xspnb1zndxndlv9rc0hcg14cbw5cmyg6f4ykrfq")))
53
371193ec
MB
54(define %patch-series-7.0
55 (patch-series
f7511ff1 56 "7.0"
371193ec
MB
57 (1 "0xm3sxvwmss7ddyfb11n6pgcqd1aglnpy15g143vzcf75snb7hcs")
58 (2 "0n1dxmqsbjgrfxb1hgk5c6lsraw4ncbnzxlsx7m35nym6lncjiw7")
463ad503
MB
59 (3 "1027kmymniizcy0zbdlrczxfx3clxcdln5yq05q9yzlc6y9slhwy")
60 (4 "0r3bbaf12iz8m02z6p3fzww2m365fhn71xmzab2p62gj54s6h9gr")
61 (5 "0lxpa4f72y2nsgj6fgrhjk2nmmxvccys6aciwfxwchb5f21rq5fa")))
c44899a2
LC
62
63(define-public readline
a850cbdd
MB
64 (package
65 (name "readline")
d7316c77
MB
66 (version (string-append "8.0."
67 (number->string (length %patch-series-8.0))))
a850cbdd
MB
68 (source (origin
69 (method url-fetch)
70 (uri (string-append "mirror://gnu/readline/readline-"
71 (version-major+minor version) ".tar.gz"))
72 (sha256
73 (base32
2cb4f940 74 "0qg4924hf4hg0r0wbx2chswsr08734536fh5iagkd3a7f4czafg3"))
d7316c77
MB
75 (patches (append %patch-series-8.0
76 (search-patches "readline-link-ncurses.patch")))
a850cbdd
MB
77 (patch-flags '("-p0"))))
78 (build-system gnu-build-system)
79 (propagated-inputs `(("ncurses" ,ncurses)))
80 (arguments `(#:configure-flags
81 (list (string-append "LDFLAGS=-Wl,-rpath -Wl,"
82 (assoc-ref %build-inputs "ncurses")
83 "/lib")
f6d47eb6 84
a850cbdd
MB
85 ;; This test does an 'AC_TRY_RUN', which aborts when
86 ;; cross-compiling, so provide the correct answer.
87 ,@(if (%current-target-system)
88 '("bash_cv_wcwidth_broken=no")
89 '())
90 ;; MinGW: ncurses provides the termcap api.
91 ,@(if (target-mingw?)
92 '("bash_cv_termcap_lib=ncurses")
93 '()))
4500581a 94
a850cbdd
MB
95 ,@(if (target-mingw?)
96 ;; MinGW: termcap in ncurses
97 ;; some SIG_* #defined in _POSIX
98 '(#:make-flags '("TERMCAP_LIB=-lncurses"
99 "CPPFLAGS=-D_POSIX -D'chown(f,o,g)=0'"))
100 '())))
101 (synopsis "Edit command lines while typing, with history support")
102 (description
103 "The GNU readline library allows users to edit command lines as they
a22dc0c4
LC
104are typed in. It can maintain a searchable history of previously entered
105commands, letting you easily recall, edit and re-enter past commands. It
106features both Emacs-like and vi-like keybindings, making its usage
107comfortable for anyone.")
a850cbdd
MB
108 (license gpl3+)
109 (home-page "https://savannah.gnu.org/projects/readline/")))
50322c84 110
2cb4f940
EF
111(define-public readline-7
112 (package (inherit readline)
113 (name "readline")
114 (version (string-append "7.0."
115 (number->string (length %patch-series-7.0))))
116 (source (origin
117 (method url-fetch)
118 (uri (string-append "mirror://gnu/readline/readline-"
119 (version-major+minor version) ".tar.gz"))
120 (sha256
121 (base32
122 "0d13sg9ksf982rrrmv5mb6a2p4ys9rvg9r71d6il0vr8hmql63bm"))
123 (patches (append
124 %patch-series-7.0
125 (search-patches "readline-link-ncurses.patch")))
126 (patch-flags '("-p0"))))))
127
50322c84
LC
128(define-public readline-6.2
129 (package (inherit readline)
130 (version "6.2")
131 (source (origin (inherit (package-source readline))
132 (method url-fetch)
133 (uri (string-append "mirror://gnu/readline/readline-"
134 version ".tar.gz"))
d9721bcf
LF
135 (patches (search-patches "readline-6.2-CVE-2014-2524.patch"))
136 (patch-flags '("-p0"))
50322c84
LC
137 (sha256
138 (base32
139 "10ckm2bd2rkxhvdmj7nmbsylmihw0abwcsnxf8y27305183rd9kr"))))))
a2285798
EF
140
141(define-public rlwrap
142 (package
143 (name "rlwrap")
f1fac6b8 144 (version "0.43")
a2285798
EF
145 (source
146 (origin
147 (method url-fetch)
f1fac6b8
TGR
148 (uri (string-append "https://github.com/hanslub42/rlwrap/releases/"
149 "download/v" version "/"
150 name "-" version ".tar.gz"))
a2285798
EF
151 (sha256
152 (base32
f1fac6b8 153 "0bzb7ylk2770iv59v2d0gypb21y2xn87m299s9rqm6rdi2vx11lf"))))
a2285798 154 (build-system gnu-build-system)
f1fac6b8
TGR
155 (native-inputs
156 `(("perl" ,perl)))
a2285798
EF
157 (inputs
158 `(("readline" ,readline)))
159 (synopsis "Wrapper to allow the editing of keyboard commands")
160 (description
161 "Rlwrap is a 'readline wrapper', a small utility that uses the GNU
162readline library to allow the editing of keyboard input for any command. You
163should consider rlwrap especially when you need user-defined completion (by way
164of completion word lists) and persistent history, or if you want to program
165'special effects' using the filter mechanism.")
f1fac6b8 166 (home-page "https://github.com/hanslub42/rlwrap")
a2285798 167 (license gpl2+)))