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