gnu: r-biocviews: Update to 1.64.1.
[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, 2020 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, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
7 ;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
8 ;;; Copyright © 2020 Zhu Zihao <all_but_last@163.com>
9 ;;; Copyright © 2021 Marius Bakke <marius@gnu.org>
10 ;;;
11 ;;; This file is part of GNU Guix.
12 ;;;
13 ;;; GNU Guix is free software; you can redistribute it and/or modify it
14 ;;; under the terms of the GNU General Public License as published by
15 ;;; the Free Software Foundation; either version 3 of the License, or (at
16 ;;; your option) any later version.
17 ;;;
18 ;;; GNU Guix is distributed in the hope that it will be useful, but
19 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;;; GNU General Public License for more details.
22 ;;;
23 ;;; You should have received a copy of the GNU General Public License
24 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25
26 (define-module (gnu packages bash)
27 #:use-module ((guix licenses) #:prefix license:)
28 #:use-module (gnu packages)
29 #:use-module (gnu packages base)
30 #:use-module (gnu packages bootstrap)
31 #:use-module (gnu packages compression)
32 #:use-module (gnu packages elf)
33 #:use-module (gnu packages ncurses)
34 #:use-module (gnu packages readline)
35 #:use-module (gnu packages bison)
36 #:use-module (gnu packages linux)
37 #:use-module (gnu packages libffi)
38 #:use-module (gnu packages pkg-config)
39 #:use-module (gnu packages guile)
40 #:use-module (gnu packages version-control)
41 #:use-module (gnu packages less)
42 #:use-module (guix packages)
43 #:use-module (guix download)
44 #:use-module (guix git-download)
45 #:use-module (guix utils)
46 #:use-module (guix gexp)
47 #:use-module (guix monads)
48 #:use-module (guix store)
49 #:use-module (guix build-system gnu)
50 #:use-module (guix build-system trivial)
51 #:autoload (guix gnupg) (gnupg-verify*)
52 #:autoload (guix base32) (bytevector->nix-base32-string)
53
54 ;; See <https://bugs.gnu.org/41457> for why not #:autoload here.
55 #:use-module ((gcrypt hash) #:select (port-sha256))
56
57 #:use-module (srfi srfi-1)
58 #:use-module (srfi srfi-26)
59 #:use-module (ice-9 format))
60
61 (define (patch-url seqno)
62 "Return the URL of Bash patch number SEQNO."
63 (format #f "mirror://gnu/bash/bash-5.1-patches/bash51-~3,'0d" seqno))
64
65 (define (bash-patch seqno sha256-bv)
66 "Return the origin of Bash patch SEQNO, with expected hash SHA256-BV."
67 (origin
68 (method url-fetch)
69 (uri (patch-url seqno))
70 (sha256 sha256-bv)))
71
72 (define-syntax-rule (patch-series (seqno hash) ...)
73 (list (bash-patch seqno (base32 hash))
74 ...))
75
76 (define %patch-series-5.1
77 ;; This is the current patches series for 5.0, generated using
78 ;; 'download-patches' below.
79 (patch-series
80 (1 "1ymm8ppss6gyh9ifznjwiabrb4k91npd09c10y7mk66xp8yppc7b")
81 (2 "1gjx9zqcm407am3n2sh44b8dxm48kgm15rzfiijqxr01m0hn3shm")
82 (3 "1cdnpbfc64yhvkjj4d12s9ywp11g195vzfl1cab24sq55wkcrwi2")
83 (4 "11iwhy6v562bv0kk7lwj7f5jj65ma9bblivy0v02h3ggcibbdbls")
84 (5 "19bdyigdr81824nxvqr6a7k0cax60wq7376j6b91afbnwvlvbjyc")
85 (6 "051x8wlwrqk0yr0zg378vh824iklfl5g9pkmcdf62qp8gn9pvqbm")
86 (7 "0fir80pp1gmlpadmqcgkrv4y119pc7xllchjzg05fd7px73viz5c")
87 (8 "1lfjgshk8i9vch92p5wgc9r90j3phw79aa7gbai89w183b2z6b7j")))
88
89 (define (download-patches store count)
90 "Download COUNT Bash patches into store. Return a list of
91 number/base32-hash tuples, directly usable in the 'patch-series' form."
92 (unfold (cut > <> count)
93 (lambda (number)
94 (let* ((patch (download-to-store store (patch-url number)))
95 (sig (download-to-store store
96 (string-append (patch-url number)
97 ".sig"))))
98 (unless (eq? 'valid-signature (gnupg-verify* sig patch))
99 (error "failed to verify signature" patch))
100
101 (list number
102 (bytevector->nix-base32-string
103 (call-with-input-file patch port-sha256)))))
104 1+
105 1))
106
107 (define-public bash
108 (let* ((cppflags (string-join '("-DDEFAULT_PATH_VALUE='\"/no-such-path\"'"
109 "-DSTANDARD_UTILS_PATH='\"/no-such-path\"'"
110 "-DNON_INTERACTIVE_LOGIN_SHELLS"
111 "-DSSH_SOURCE_BASHRC")
112 " "))
113 (configure-flags
114 ``("--with-installed-readline"
115 ,,(string-append "CPPFLAGS=" cppflags)
116 ,(string-append
117 "LDFLAGS=-Wl,-rpath -Wl,"
118 (assoc-ref %build-inputs "readline")
119 "/lib"
120 " -Wl,-rpath -Wl,"
121 (assoc-ref %build-inputs "ncurses")
122 "/lib")))
123 (version "5.1"))
124 (package
125 (name "bash")
126 (source (origin
127 (method url-fetch)
128 (uri (string-append
129 "mirror://gnu/bash/bash-" version ".tar.gz"))
130 (sha256
131 (base32
132 "1alv68wplnfdm6mh39hm57060xgssb9vqca4yr1cyva0c342n0fc"))
133 (patch-flags '("-p0"))
134 (patches (cons (search-patch "bash-linux-pgrp-pipe.patch")
135 %patch-series-5.1))))
136 (version (string-append version "." (number->string (length %patch-series-5.1))))
137 (build-system gnu-build-system)
138
139 (outputs '("out"
140 "doc" ;1.7 MiB of HTML and extra files
141 "include")) ;headers used by extensions
142 (inputs (list readline ncurses)) ;TODO: add texinfo
143 (arguments
144 `(;; When cross-compiling, `configure' incorrectly guesses that job
145 ;; control is missing.
146 #:configure-flags ,(if (%current-target-system)
147 `(cons* "bash_cv_job_control_missing=no"
148 ,configure-flags)
149 configure-flags)
150
151 ;; Bash is reportedly not parallel-safe. See, for instance,
152 ;; <http://patches.openembedded.org/patch/32745/> and
153 ;; <http://git.buildroot.net/buildroot/commit/?h=79e2d802a>.
154 #:parallel-build? #f
155 #:parallel-tests? #f
156
157 ;; XXX: The tests have a lot of hard-coded paths, so disable them
158 ;; for now.
159 #:tests? #f
160
161 #:modules ((srfi srfi-26)
162 (guix build utils)
163 (guix build gnu-build-system))
164
165 #:phases
166 (modify-phases %standard-phases
167 (add-after 'install 'install-sh-symlink
168 (lambda* (#:key outputs #:allow-other-keys)
169 ;; Add a `sh' -> `bash' link.
170 (let ((out (assoc-ref outputs "out")))
171 (with-directory-excursion (string-append out "/bin")
172 (symlink "bash" "sh")
173 #t))))
174
175 (add-after 'install 'move-development-files
176 (lambda* (#:key outputs #:allow-other-keys)
177 ;; Move 'Makefile.inc' and 'bash.pc' to "include" to avoid
178 ;; circular references among the outputs.
179 (let ((out (assoc-ref outputs "out"))
180 (include (assoc-ref outputs "include"))
181 (lib (cut string-append <> "/lib/bash")))
182 (mkdir-p (lib include))
183 (rename-file (string-append (lib out)
184 "/Makefile.inc")
185 (string-append (lib include)
186 "/Makefile.inc"))
187 (rename-file (string-append out "/lib/pkgconfig")
188 (string-append include
189 "/lib/pkgconfig"))
190
191 ;; Don't capture the absolute file name of 'install' to avoid
192 ;; retaining a dependency on Coreutils.
193 (substitute* (string-append (lib include)
194 "/Makefile.inc")
195 (("^INSTALL =.*")
196 "INSTALL = install -c\n"))
197 #t))))))
198
199 (native-search-paths
200 (list (search-path-specification ;new in 4.4
201 (variable "BASH_LOADABLES_PATH")
202 (files '("lib/bash")))))
203
204 (synopsis "The GNU Bourne-Again SHell")
205 (description
206 "Bash is the shell, or command-line interpreter, of the GNU system. It
207 is compatible with the Bourne Shell, but it also integrates useful features
208 from the Korn Shell and the C Shell and new improvements of its own. It
209 allows command-line editing, unlimited command history, shell functions and
210 aliases, and job control while still allowing most sh scripts to be run
211 without modification.")
212 (license license:gpl3+)
213 (home-page "https://www.gnu.org/software/bash/"))))
214
215 (define-public bash-minimal
216 ;; A stripped-down Bash for non-interactive use.
217 (package (inherit bash)
218 (name "bash-minimal")
219 (inputs '()) ; no readline, no curses
220
221 ;; No "include" output because there's no support for loadable modules.
222 (outputs (delete "include" (package-outputs bash)))
223
224 (arguments
225 (substitute-keyword-arguments (package-arguments bash)
226 ((#:modules _ '())
227 '((guix build gnu-build-system)
228 (guix build utils)
229 (srfi srfi-1)
230 (srfi srfi-26)))
231 ((#:configure-flags flags '())
232 `(list "--without-bash-malloc"
233 "--disable-readline"
234 "--disable-history"
235 "--disable-help-builtin"
236 "--disable-progcomp"
237 "--disable-net-redirections"
238 "--disable-nls"
239
240 ;; Pretend 'dlopen' is missing so we don't build loadable
241 ;; modules and related code.
242 "ac_cv_func_dlopen=no"
243
244 ,@(if (%current-target-system)
245 '("bash_cv_job_control_missing=no"
246 "bash_cv_getcwd_malloc=yes")
247 '())))
248 ((#:phases phases)
249 `(modify-phases ,phases
250 ;; No loadable modules.
251 (delete 'move-development-files)))))))
252
253 (define-public static-bash
254 ;; Statically-linked Bash that contains nothing but the 'bash' binary and
255 ;; 'sh' symlink, without any reference.
256 (let ((bash (static-package bash-minimal)))
257 (package
258 (inherit bash)
259 (name "bash-static")
260 (arguments
261 (substitute-keyword-arguments
262 `(#:allowed-references ("out") ,@(package-arguments bash))
263 ((#:phases phases)
264 `(modify-phases ,phases
265 (add-after 'strip 'remove-everything-but-the-binary
266 (lambda* (#:key outputs #:allow-other-keys)
267 (let* ((out (assoc-ref outputs "out"))
268 (bin (string-append out "/bin")))
269 (remove-store-references (string-append bin "/bash"))
270 (delete-file (string-append bin "/bashbug"))
271 (delete-file-recursively (string-append out "/share"))
272 #t))))))))))
273
274 (define-public bash-with-syslog
275 (package
276 (inherit bash)
277 (name "bash-with-syslog")
278 (arguments
279 (substitute-keyword-arguments (package-arguments bash)
280 ((#:phases phases '%standard-phases)
281 `(modify-phases ,phases
282 (add-after 'unpack 'enable-syslogging
283 (lambda _
284 (substitute* "config-top.h"
285 (("/\\* #define SYSLOG_HISTORY \\*/")
286 "#define SYSLOG_HISTORY"))))))))
287 (description
288 "Bash is the shell, or command-line interpreter, of the GNU system. This
289 variant logs the history to syslog.")))
290
291 (define-public bash-completion
292 (package
293 (name "bash-completion")
294 (version "2.8")
295 (source (origin
296 (method url-fetch)
297 (uri (string-append
298 "https://github.com/scop/" name "/releases/download/"
299 version "/" name "-" version ".tar.xz"))
300 (sha256
301 (base32
302 "0kgmflrr1ga9wfk770vmakna3nj46ylb5ky9ipd0v2k9ymq5a7y0"))
303 (patches
304 (search-patches "bash-completion-directories.patch"))))
305 (build-system gnu-build-system)
306 (native-inputs (list util-linux))
307 (arguments
308 `(#:phases (modify-phases %standard-phases
309 (add-after
310 'install 'remove-redundant-completions
311 (lambda* (#:key
312 inputs native-inputs
313 outputs #:allow-other-keys)
314 ;; Util-linux comes with a bunch of completion files for
315 ;; its own commands which are more sophisticated and
316 ;; up-to-date than those of bash-completion. Remove those
317 ;; from bash-completion.
318 (let* ((out (assoc-ref outputs "out"))
319 (util-linux (assoc-ref (or native-inputs inputs)
320 "util-linux"))
321 (completions (string-append out
322 "/share/bash-completion"
323 "/completions"))
324 (already (find-files
325 (string-append
326 util-linux
327 "/etc/bash_completion.d"))))
328 (with-directory-excursion completions
329 (for-each (lambda (file)
330 (when (file-exists? file)
331 (delete-file file)))
332 (map basename already)))
333 #t))))))
334 (synopsis "Bash completions for common commands")
335 (description
336 "This package provides extensions that allow Bash to provide adapted
337 completion for many common commands.")
338 (home-page "https://github.com/scop/bash-completion")
339 (license license:gpl2+)))
340
341 (define-public bash-tap
342 (package
343 (name "bash-tap")
344 (version "1.0.2")
345 (source
346 (origin
347 (method git-fetch)
348 (uri (git-reference
349 (url "https://github.com/illusori/bash-tap")
350 (commit version)))
351 (file-name (git-file-name name version))
352 (sha256
353 (base32 "13zz9h6bhhnk3hiwhlpafrnf2isws249h3fz785dcgymk02arz9c"))))
354 ;; There is no compilation process to use this package, however, the bash
355 ;; scripts installed by this package start with "#!/bin/bash". To fix
356 ;; these lines, we use the patch-shebangs of the GNU build system. The
357 ;; project does not use a Makefile.
358 (build-system gnu-build-system)
359 (arguments
360 `(#:tests? #f ; There is no test suite.
361 #:phases
362 (modify-phases %standard-phases
363 ;; Because there are no configure scripts or Makefile, we can
364 ;; remove these phases.
365 (delete 'configure)
366 (delete 'build)
367 ;; The installation involves manually copying the files to a location.
368 ;; To make them easily accessible by setting PATH, we add the scripts
369 ;; to the "bin" folder.
370 (replace 'install
371 (lambda* (#:key outputs #:allow-other-keys)
372 (let ((bin (string-append (assoc-ref outputs "out") "/bin")))
373 (install-file "bash-tap" bin)
374 (install-file "bash-tap-bootstrap" bin)
375 (install-file "bash-tap-mock" bin)))))))
376 (home-page "https://www.illusori.co.uk/projects/bash-tap/")
377 (synopsis "Bash port of a Test::More/Test::Builder-style TAP-compliant
378 test library")
379 (description "Bash TAP is a TAP-compliant Test::More-style testing library
380 for Bash shell scripts and functions. Along with the Test::More-style testing
381 helpers it provides helper functions for mocking commands and in-process output
382 capturing.")
383 (license license:expat)))
384
385 (define-public bats
386 (package
387 (name "bats")
388 (version "1.2.0")
389 (source (origin
390 (method git-fetch)
391 (uri (git-reference
392 (url "https://github.com/bats-core/bats-core")
393 (commit (string-append "v" version))))
394 (file-name (git-file-name name version))
395 (sha256
396 (base32
397 "0f59zh4d4pa1a7ybs5zl6h0csbqqv11lbnq0jl1dgwm1s6p49bsq"))))
398 (inputs
399 (list bash coreutils guile-3.0 ;for wrap-script
400 grep))
401 (arguments
402 `(#:modules ((guix build utils))
403 #:builder
404 (begin
405 (use-modules (guix build utils))
406 (copy-recursively (assoc-ref %build-inputs "source") ".")
407 (setenv "PATH"
408 (string-append (assoc-ref %build-inputs "bash") "/bin"
409 ":" (assoc-ref %build-inputs "coreutils") "/bin"
410 ":" (assoc-ref %build-inputs "grep") "/bin"
411 ":" (assoc-ref %build-inputs "guile") "/bin"
412 ":" (getenv "PATH")))
413 (for-each (lambda (file) (patch-shebang file)) (find-files "."))
414 (substitute* "bin/bats"
415 (("export BATS_ROOT" line)
416 (string-append "BATS_ROOT=\"${BATS_ROOT:-" %output "/libexec/bats-core}\"\n"
417 line)))
418 ;; Install phase
419 (invoke "./install.sh" %output)
420 (wrap-script (string-append %output "/bin/bats")
421 #:guile (search-input-file %build-inputs "bin/guile")
422 (list "PATH" 'prefix (string-split (getenv "PATH")
423 #\:))))))
424 (build-system trivial-build-system)
425 (home-page "https://github.com/bats-core/bats-core/")
426 (synopsis "Bash Automated Testing System")
427 (description
428 "Bats is a @acronym{TAP, Test Anything Protocol}-compliant testing
429 framework for Bash. It provides a simple way to verify that the UNIX programs
430 you write behave as expected. Bats is most useful when testing software written
431 in Bash, but you can use it to test any UNIX program.")
432 (license license:expat)))
433
434 (define-public bash-ctypes
435 (package
436 (name "bash-ctypes")
437 (version "1.2")
438 (source
439 (origin
440 (method url-fetch)
441 (uri (string-append "https://github.com/taviso/ctypes.sh/releases/download/v"
442 version "/ctypes-sh-" version ".tar.gz"))
443 (sha256
444 (base32 "0s1sifqzqmr0dnciv06yqrpzgj11d7n0gy5zaxh6b3x8bx7k75l8"))))
445 (build-system gnu-build-system)
446 (inputs
447 (list elfutils
448 libelf
449 libffi
450 zlib
451 ;; Require a bash with C plugin support to build.
452 bash))
453 (native-inputs
454 (list pkg-config))
455 (home-page "https://github.com/taviso/ctypes.sh")
456 (synopsis "Foreign function interface for Bash")
457 (description "Bash-ctypes is a Bash plugin that provides a foreign
458 function interface (FFI) directly in your shell. In other words, it allows
459 you to call routines in shared libraries from within Bash.")
460 (license license:expat)))
461
462 (define-public blesh
463 (package
464 (name "blesh")
465 (version "0.4.0-devel2")
466 (source (origin
467 (method git-fetch)
468 (uri (git-reference
469 (url "https://github.com/akinomyoga/ble.sh")
470 (commit (string-append "v" version))))
471 (file-name (git-file-name name version))
472 (sha256
473 (base32
474 "02fdjyh4x6wr5hg3i86nsxhz8ysgjrvvxdmk6pqr0lm8ngw9p3sh"))))
475 (arguments
476 (list #:make-flags #~(list (string-append "PREFIX="
477 #$output))
478 #:phases #~(modify-phases %standard-phases
479 (add-after 'unpack 'pretend-contrib-.git-exists
480 (lambda _
481 (mkdir-p "contrib/.git")))
482 (add-after 'unpack 'make-readlink-work
483 (lambda _
484 (substitute* "ble.pp"
485 (("PATH=/bin:/usr/bin readlink")
486 (search-input-file %build-inputs
487 "/bin/readlink")))))
488 (delete 'configure) ;no configure
489 (add-before 'check 'use-LANG-for-tests
490 (lambda _
491 (setenv "LANG"
492 (getenv "LC_ALL"))
493 (unsetenv "LC_ALL"))))))
494 (build-system gnu-build-system)
495 (native-inputs (list less))
496 (home-page "https://github.com/akinomyoga/ble.sh")
497 (synopsis "Bash Line Editor")
498 (description
499 "Bash Line Editor (ble.sh) is a command line editor written in pure Bash
500 which replaces the default GNU Readline. It adds syntax highlighting, auto
501 suggestions, vim modes, and more to Bash interactive sessions.")
502 (license license:bsd-3)))