Merge branch 'master' into staging
[jackhill/guix/guix.git] / gnu / packages / readline.scm
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
22 (define-module (gnu packages readline)
23 #:use-module (guix licenses)
24 #:use-module (gnu packages)
25 #:use-module (gnu packages ncurses)
26 #:use-module (gnu packages perl)
27 #:use-module (guix packages)
28 #:use-module (guix download)
29 #:use-module (guix build-system gnu)
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")
51 (3 "1027kmymniizcy0zbdlrczxfx3clxcdln5yq05q9yzlc6y9slhwy")
52 (4 "0r3bbaf12iz8m02z6p3fzww2m365fhn71xmzab2p62gj54s6h9gr")
53 (5 "0lxpa4f72y2nsgj6fgrhjk2nmmxvccys6aciwfxwchb5f21rq5fa")))
54
55 (define-public readline
56 (package
57 (name "readline")
58 (version (string-append "7.0."
59 (number->string (length %patch-series-7.0))))
60 (source (origin
61 (method url-fetch)
62 (uri (string-append "mirror://gnu/readline/readline-"
63 (version-major+minor version) ".tar.gz"))
64 (sha256
65 (base32
66 "0d13sg9ksf982rrrmv5mb6a2p4ys9rvg9r71d6il0vr8hmql63bm"))
67 (patches (append
68 %patch-series-7.0
69 (search-patches "readline-link-ncurses.patch")))
70 (patch-flags '("-p0"))))
71 (build-system gnu-build-system)
72 (propagated-inputs `(("ncurses" ,ncurses)))
73 (arguments `(#:configure-flags
74 (list (string-append "LDFLAGS=-Wl,-rpath -Wl,"
75 (assoc-ref %build-inputs "ncurses")
76 "/lib")
77
78 ;; This test does an 'AC_TRY_RUN', which aborts when
79 ;; cross-compiling, so provide the correct answer.
80 ,@(if (%current-target-system)
81 '("bash_cv_wcwidth_broken=no")
82 '())
83 ;; MinGW: ncurses provides the termcap api.
84 ,@(if (target-mingw?)
85 '("bash_cv_termcap_lib=ncurses")
86 '()))
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
104 (define-public readline-6.2
105 (package (inherit readline)
106 (version "6.2")
107 (source (origin (inherit (package-source readline))
108 (method url-fetch)
109 (uri (string-append "mirror://gnu/readline/readline-"
110 version ".tar.gz"))
111 (patches (search-patches "readline-6.2-CVE-2014-2524.patch"))
112 (patch-flags '("-p0"))
113 (sha256
114 (base32
115 "10ckm2bd2rkxhvdmj7nmbsylmihw0abwcsnxf8y27305183rd9kr"))))))
116
117 (define-public rlwrap
118 (package
119 (name "rlwrap")
120 (version "0.43")
121 (source
122 (origin
123 (method url-fetch)
124 (uri (string-append "https://github.com/hanslub42/rlwrap/releases/"
125 "download/v" version "/"
126 name "-" version ".tar.gz"))
127 (sha256
128 (base32
129 "0bzb7ylk2770iv59v2d0gypb21y2xn87m299s9rqm6rdi2vx11lf"))))
130 (build-system gnu-build-system)
131 (native-inputs
132 `(("perl" ,perl)))
133 (inputs
134 `(("readline" ,readline)))
135 (synopsis "Wrapper to allow the editing of keyboard commands")
136 (description
137 "Rlwrap is a 'readline wrapper', a small utility that uses the GNU
138 readline library to allow the editing of keyboard input for any command. You
139 should consider rlwrap especially when you need user-defined completion (by way
140 of completion word lists) and persistent history, or if you want to program
141 'special effects' using the filter mechanism.")
142 (home-page "https://github.com/hanslub42/rlwrap")
143 (license gpl2+)))