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