gnu: emacs-sly: Update to 20200228.
[jackhill/guix/guix.git] / gnu / packages / bash.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2019 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2015, 2017 Leo Famulari <leo@famulari.name>
5 ;;; Copyright © 2016, 2017, 2018, 2019 Efraim Flashner <efraim@flashner.co.il>
6 ;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
7 ;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
8 ;;;
9 ;;; This file is part of GNU Guix.
10 ;;;
11 ;;; GNU Guix is free software; you can redistribute it and/or modify it
12 ;;; under the terms of the GNU General Public License as published by
13 ;;; the Free Software Foundation; either version 3 of the License, or (at
14 ;;; your option) any later version.
15 ;;;
16 ;;; GNU Guix is distributed in the hope that it will be useful, but
17 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;;; GNU General Public License for more details.
20 ;;;
21 ;;; You should have received a copy of the GNU General Public License
22 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23
24 (define-module (gnu packages bash)
25 #:use-module (guix licenses)
26 #:use-module (gnu packages)
27 #:use-module (gnu packages bootstrap)
28 #:use-module (gnu packages ncurses)
29 #:use-module (gnu packages readline)
30 #:use-module (gnu packages bison)
31 #:use-module (gnu packages linux)
32 #:use-module (guix packages)
33 #:use-module (guix download)
34 #:use-module (guix git-download)
35 #:use-module (guix utils)
36 #:use-module (guix gexp)
37 #:use-module (guix monads)
38 #:use-module (guix store)
39 #:use-module (guix build-system gnu)
40 #:autoload (guix gnupg) (gnupg-verify*)
41 #:autoload (gcrypt hash) (port-sha256)
42 #:autoload (guix base32) (bytevector->nix-base32-string)
43 #:use-module (srfi srfi-1)
44 #:use-module (srfi srfi-26)
45 #:use-module (ice-9 format))
46
47 (define (patch-url seqno)
48 "Return the URL of Bash patch number SEQNO."
49 (format #f "mirror://gnu/bash/bash-5.0-patches/bash50-~3,'0d" seqno))
50
51 (define (bash-patch seqno sha256)
52 "Return the origin of Bash patch SEQNO, with expected hash SHA256"
53 (origin
54 (method url-fetch)
55 (uri (patch-url seqno))
56 (sha256 sha256)))
57
58 (define-syntax-rule (patch-series (seqno hash) ...)
59 (list (bash-patch seqno (base32 hash))
60 ...))
61
62 (define %patch-series-5.0
63 ;; This is the current patches series for 5.0, generated using
64 ;; 'download-patches' below.
65 (patch-series
66 (1 "12bjfdy6bg8nhyw27bdgxn7h4paylx8d927skfmi9pxd1wgrxzpj")
67 (2 "01w7yrzmz10mw06ys0546vhl7isv2v402ziyvfd7k67588spvs47")
68 (3 "0ny81ridp5n0j69hb8ixrc7dmxybby54jbsz5hikly8kgg1wvssf")
69 (4 "021gqqvgydixkrmqss64b6srfdlkvnx88lyfzpxfrn5d6bc7li0l")
70 (5 "0xl2kyzm84nlyklrqzkn73ixabhzfhn9x91lzcmis89cppclvxav")
71 (6 "0844749ixk1z60437nkznzms1f0nzh9an62kj7sny6r0zyk2k1fn")
72 (7 "16xg37gp1b8zlj5969w8mcrparwqlcbj9695vn3qhgb7wdz1xd0p")))
73
74 (define (download-patches store count)
75 "Download COUNT Bash patches into store. Return a list of
76 number/base32-hash tuples, directly usable in the 'patch-series' form."
77 (unfold (cut > <> count)
78 (lambda (number)
79 (let* ((patch (download-to-store store (patch-url number)))
80 (sig (download-to-store store
81 (string-append (patch-url number)
82 ".sig"))))
83 (unless (eq? 'valid-signature (gnupg-verify* sig patch))
84 (error "failed to verify signature" patch))
85
86 (list number
87 (bytevector->nix-base32-string
88 (call-with-input-file patch port-sha256)))))
89 1+
90 1))
91
92 (define-public bash
93 (let* ((cppflags (string-join '("-DDEFAULT_PATH_VALUE='\"/no-such-path\"'"
94 "-DSTANDARD_UTILS_PATH='\"/no-such-path\"'"
95 "-DNON_INTERACTIVE_LOGIN_SHELLS"
96 "-DSSH_SOURCE_BASHRC")
97 " "))
98 (configure-flags
99 ``("--with-installed-readline"
100 ,,(string-append "CPPFLAGS=" cppflags)
101 ,(string-append
102 "LDFLAGS=-Wl,-rpath -Wl,"
103 (assoc-ref %build-inputs "readline")
104 "/lib"
105 " -Wl,-rpath -Wl,"
106 (assoc-ref %build-inputs "ncurses")
107 "/lib")))
108 (version "5.0"))
109 (package
110 (name "bash")
111 (source (origin
112 (method url-fetch)
113 (uri (string-append
114 "mirror://gnu/bash/bash-" version ".tar.gz"))
115 (sha256
116 (base32
117 "0kgvfwqdcd90waczf4gx39xnrxzijhjrzyzv7s8v4w31qqm0za5l"))
118 (patch-flags '("-p0"))
119 (patches %patch-series-5.0)))
120 (version (string-append version "." (number->string (length %patch-series-5.0))))
121 (build-system gnu-build-system)
122
123 (outputs '("out"
124 "doc" ;1.7 MiB of HTML and extra files
125 "include")) ;headers used by extensions
126 (inputs `(("readline" ,readline)
127 ("ncurses" ,ncurses))) ;TODO: add texinfo
128 (arguments
129 `(;; When cross-compiling, `configure' incorrectly guesses that job
130 ;; control is missing.
131 #:configure-flags ,(if (%current-target-system)
132 `(cons* "bash_cv_job_control_missing=no"
133 ,configure-flags)
134 configure-flags)
135
136 ;; Bash is reportedly not parallel-safe. See, for instance,
137 ;; <http://patches.openembedded.org/patch/32745/> and
138 ;; <http://git.buildroot.net/buildroot/commit/?h=79e2d802a>.
139 #:parallel-build? #f
140 #:parallel-tests? #f
141
142 ;; XXX: The tests have a lot of hard-coded paths, so disable them
143 ;; for now.
144 #:tests? #f
145
146 #:modules ((srfi srfi-26)
147 (guix build utils)
148 (guix build gnu-build-system))
149
150 #:phases
151 (modify-phases %standard-phases
152 (add-after 'install 'install-sh-symlink
153 (lambda* (#:key outputs #:allow-other-keys)
154 ;; Add a `sh' -> `bash' link.
155 (let ((out (assoc-ref outputs "out")))
156 (with-directory-excursion (string-append out "/bin")
157 (symlink "bash" "sh")
158 #t))))
159
160 (add-after 'install 'move-development-files
161 (lambda* (#:key outputs #:allow-other-keys)
162 ;; Move 'Makefile.inc' and 'bash.pc' to "include" to avoid
163 ;; circular references among the outputs.
164 (let ((out (assoc-ref outputs "out"))
165 (include (assoc-ref outputs "include"))
166 (lib (cut string-append <> "/lib/bash")))
167 (mkdir-p (lib include))
168 (rename-file (string-append (lib out)
169 "/Makefile.inc")
170 (string-append (lib include)
171 "/Makefile.inc"))
172 (rename-file (string-append out "/lib/pkgconfig")
173 (string-append include
174 "/lib/pkgconfig"))
175
176 ;; Don't capture the absolute file name of 'install' to avoid
177 ;; retaining a dependency on Coreutils.
178 (substitute* (string-append (lib include)
179 "/Makefile.inc")
180 (("^INSTALL =.*")
181 "INSTALL = install -c\n"))
182 #t))))))
183
184 (native-search-paths
185 (list (search-path-specification ;new in 4.4
186 (variable "BASH_LOADABLES_PATH")
187 (files '("lib/bash")))))
188
189 (synopsis "The GNU Bourne-Again SHell")
190 (description
191 "Bash is the shell, or command-line interpreter, of the GNU system. It
192 is compatible with the Bourne Shell, but it also integrates useful features
193 from the Korn Shell and the C Shell and new improvements of its own. It
194 allows command-line editing, unlimited command history, shell functions and
195 aliases, and job control while still allowing most sh scripts to be run
196 without modification.")
197 (license gpl3+)
198 (home-page "https://www.gnu.org/software/bash/"))))
199
200 (define-public bash-minimal
201 ;; A stripped-down Bash for non-interactive use.
202 (package (inherit bash)
203 (name "bash-minimal")
204 (inputs '()) ; no readline, no curses
205
206 ;; No "include" output because there's no support for loadable modules.
207 (outputs (delete "include" (package-outputs bash)))
208
209 (arguments
210 (substitute-keyword-arguments (package-arguments bash)
211 ((#:modules _ '())
212 '((guix build gnu-build-system)
213 (guix build utils)
214 (srfi srfi-1)
215 (srfi srfi-26)))
216 ((#:configure-flags flags '())
217 `(list "--without-bash-malloc"
218 "--disable-readline"
219 "--disable-history"
220 "--disable-help-builtin"
221 "--disable-progcomp"
222 "--disable-net-redirections"
223 "--disable-nls"
224
225 ;; Pretend 'dlopen' is missing so we don't build loadable
226 ;; modules and related code.
227 "ac_cv_func_dlopen=no"
228
229 ,@(if (%current-target-system)
230 '("bash_cv_job_control_missing=no"
231 "bash_cv_getcwd_malloc=yes")
232 '())))
233 ((#:phases phases)
234 `(modify-phases ,phases
235 ;; No loadable modules.
236 (delete 'move-development-files)))))))
237
238 (define-public static-bash
239 ;; Statically-linked Bash that contains nothing but the 'bash' binary and
240 ;; 'sh' symlink, without any reference.
241 (let ((bash (static-package bash-minimal)))
242 (package
243 (inherit bash)
244 (name "bash-static")
245 (arguments
246 (substitute-keyword-arguments
247 `(#:allowed-references ("out") ,@(package-arguments bash))
248 ((#:phases phases)
249 `(modify-phases ,phases
250 (add-after 'strip 'remove-everything-but-the-binary
251 (lambda* (#:key outputs #:allow-other-keys)
252 (let* ((out (assoc-ref outputs "out"))
253 (bin (string-append out "/bin")))
254 (remove-store-references (string-append bin "/bash"))
255 (delete-file (string-append bin "/bashbug"))
256 (delete-file-recursively (string-append out "/share"))
257 #t))))))))))
258
259 (define-public bash-completion
260 (package
261 (name "bash-completion")
262 (version "2.8")
263 (source (origin
264 (method url-fetch)
265 (uri (string-append
266 "https://github.com/scop/" name "/releases/download/"
267 version "/" name "-" version ".tar.xz"))
268 (sha256
269 (base32
270 "0kgmflrr1ga9wfk770vmakna3nj46ylb5ky9ipd0v2k9ymq5a7y0"))
271 (patches
272 (search-patches "bash-completion-directories.patch"))))
273 (build-system gnu-build-system)
274 (native-inputs `(("util-linux" ,util-linux)))
275 (arguments
276 `(#:phases (modify-phases %standard-phases
277 (add-after
278 'install 'remove-redundant-completions
279 (lambda* (#:key
280 inputs native-inputs
281 outputs #:allow-other-keys)
282 ;; Util-linux comes with a bunch of completion files for
283 ;; its own commands which are more sophisticated and
284 ;; up-to-date than those of bash-completion. Remove those
285 ;; from bash-completion.
286 (let* ((out (assoc-ref outputs "out"))
287 (util-linux (assoc-ref (or native-inputs inputs)
288 "util-linux"))
289 (completions (string-append out
290 "/share/bash-completion"
291 "/completions"))
292 (already (find-files
293 (string-append
294 util-linux
295 "/etc/bash_completion.d"))))
296 (with-directory-excursion completions
297 (for-each (lambda (file)
298 (when (file-exists? file)
299 (delete-file file)))
300 (map basename already)))
301 #t))))))
302 (synopsis "Bash completions for common commands")
303 (description
304 "This package provides extensions that allow Bash to provide adapted
305 completion for many common commands.")
306 (home-page "https://github.com/scop/bash-completion")
307 (license gpl2+)))
308
309 (define-public bash-tap
310 (package
311 (name "bash-tap")
312 (version "1.0.2")
313 (source
314 (origin
315 (method git-fetch)
316 (uri (git-reference
317 (url "https://github.com/illusori/bash-tap.git")
318 (commit version)))
319 (file-name (git-file-name name version))
320 (sha256
321 (base32 "13zz9h6bhhnk3hiwhlpafrnf2isws249h3fz785dcgymk02arz9c"))))
322 ;; There is no compilation process to use this package, however, the bash
323 ;; scripts installed by this package start with "#!/bin/bash". To fix
324 ;; these lines, we use the patch-shebangs of the GNU build system. The
325 ;; project does not use a Makefile.
326 (build-system gnu-build-system)
327 (arguments
328 `(#:tests? #f ; There is no test suite.
329 #:phases
330 (modify-phases %standard-phases
331 ;; Because there are no configure scripts or Makefile, we can
332 ;; remove these phases.
333 (delete 'configure)
334 (delete 'build)
335 ;; The installation involves manually copying the files to a location.
336 ;; To make them easily accessible by setting PATH, we add the scripts
337 ;; to the "bin" folder.
338 (replace 'install
339 (lambda* (#:key outputs #:allow-other-keys)
340 (let ((bin (string-append (assoc-ref outputs "out") "/bin")))
341 (install-file "bash-tap" bin)
342 (install-file "bash-tap-bootstrap" bin)
343 (install-file "bash-tap-mock" bin)))))))
344 (home-page "http://www.illusori.co.uk/projects/bash-tap/")
345 (synopsis "Bash port of a Test::More/Test::Builder-style TAP-compliant
346 test library")
347 (description "Bash TAP is a TAP-compliant Test::More-style testing library
348 for Bash shell scripts and functions. Along with the Test::More-style testing
349 helpers it provides helper functions for mocking commands and in-process output
350 capturing.")
351 (license expat)))