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