gnu: fontconfig: Add replacement with font-dejavu instead of gs-fonts.
[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 (8 "1qyp19krjh8zxvb0jgwmyjz40djslwcf4xi7kc1ab0iaca44bipf")
74 (9 "00yrjjqd95s81b21qq3ba1y7h879q8jaajlkjggc6grhcwbs4g7d")
75 (10 "04ca5bjv456v538mkspzvn4xb2zdphh31r4fpvfm9p5my0jw7yyn")
76 (11 "1sklyixvsv8993kxzs0jigacpdchjrq7jv5xpdx7kbqyp4rf6k9c")
77 (12 "0cz21qg2gbr40lfgza7g02bqi2qknwqgxnq459pjj640d0cywhr9")
78 (13 "16h9nwz3yzwj7fnxvlidjymdc4yr30h818433gh9j1x3in6igmzm")
79 (14 "12gm5bvv2pd3m72z2ilj26pa08c61az253dsgfl24vpf2ijywvjx")
80 (15 "0pm0px758w4i23s55wajcv6lqfiym7zgxvq0pxf6vclkv8nxy5x5")
81 (16 "0vdha332km2iwx8g2ld15jy7d24cbplzgr1531dpzylr9ajxglgz")))
82
83 (define (download-patches store count)
84 "Download COUNT Bash patches into store. Return a list of
85 number/base32-hash tuples, directly usable in the 'patch-series' form."
86 (unfold (cut > <> count)
87 (lambda (number)
88 (let* ((patch (download-to-store store (patch-url number)))
89 (sig (download-to-store store
90 (string-append (patch-url number)
91 ".sig"))))
92 (unless (eq? 'valid-signature (gnupg-verify* sig patch))
93 (error "failed to verify signature" patch))
94
95 (list number
96 (bytevector->nix-base32-string
97 (call-with-input-file patch port-sha256)))))
98 1+
99 1))
100
101 (define-public bash
102 (let* ((cppflags (string-join '("-DDEFAULT_PATH_VALUE='\"/no-such-path\"'"
103 "-DSTANDARD_UTILS_PATH='\"/no-such-path\"'"
104 "-DNON_INTERACTIVE_LOGIN_SHELLS"
105 "-DSSH_SOURCE_BASHRC")
106 " "))
107 (configure-flags
108 ``("--with-installed-readline"
109 ,,(string-append "CPPFLAGS=" cppflags)
110 ,(string-append
111 "LDFLAGS=-Wl,-rpath -Wl,"
112 (assoc-ref %build-inputs "readline")
113 "/lib"
114 " -Wl,-rpath -Wl,"
115 (assoc-ref %build-inputs "ncurses")
116 "/lib")))
117 (version "5.0"))
118 (package
119 (name "bash")
120 (source (origin
121 (method url-fetch)
122 (uri (string-append
123 "mirror://gnu/bash/bash-" version ".tar.gz"))
124 (sha256
125 (base32
126 "0kgvfwqdcd90waczf4gx39xnrxzijhjrzyzv7s8v4w31qqm0za5l"))
127 (patch-flags '("-p0"))
128 (patches (cons (search-patch "bash-linux-pgrp-pipe.patch")
129 %patch-series-5.0))))
130 (version (string-append version "." (number->string (length %patch-series-5.0))))
131 (build-system gnu-build-system)
132
133 (outputs '("out"
134 "doc" ;1.7 MiB of HTML and extra files
135 "include")) ;headers used by extensions
136 (inputs `(("readline" ,readline)
137 ("ncurses" ,ncurses))) ;TODO: add texinfo
138 (arguments
139 `(;; When cross-compiling, `configure' incorrectly guesses that job
140 ;; control is missing.
141 #:configure-flags ,(if (%current-target-system)
142 `(cons* "bash_cv_job_control_missing=no"
143 ,configure-flags)
144 configure-flags)
145
146 ;; Bash is reportedly not parallel-safe. See, for instance,
147 ;; <http://patches.openembedded.org/patch/32745/> and
148 ;; <http://git.buildroot.net/buildroot/commit/?h=79e2d802a>.
149 #:parallel-build? #f
150 #:parallel-tests? #f
151
152 ;; XXX: The tests have a lot of hard-coded paths, so disable them
153 ;; for now.
154 #:tests? #f
155
156 #:modules ((srfi srfi-26)
157 (guix build utils)
158 (guix build gnu-build-system))
159
160 #:phases
161 (modify-phases %standard-phases
162 (add-after 'install 'install-sh-symlink
163 (lambda* (#:key outputs #:allow-other-keys)
164 ;; Add a `sh' -> `bash' link.
165 (let ((out (assoc-ref outputs "out")))
166 (with-directory-excursion (string-append out "/bin")
167 (symlink "bash" "sh")
168 #t))))
169
170 (add-after 'install 'move-development-files
171 (lambda* (#:key outputs #:allow-other-keys)
172 ;; Move 'Makefile.inc' and 'bash.pc' to "include" to avoid
173 ;; circular references among the outputs.
174 (let ((out (assoc-ref outputs "out"))
175 (include (assoc-ref outputs "include"))
176 (lib (cut string-append <> "/lib/bash")))
177 (mkdir-p (lib include))
178 (rename-file (string-append (lib out)
179 "/Makefile.inc")
180 (string-append (lib include)
181 "/Makefile.inc"))
182 (rename-file (string-append out "/lib/pkgconfig")
183 (string-append include
184 "/lib/pkgconfig"))
185
186 ;; Don't capture the absolute file name of 'install' to avoid
187 ;; retaining a dependency on Coreutils.
188 (substitute* (string-append (lib include)
189 "/Makefile.inc")
190 (("^INSTALL =.*")
191 "INSTALL = install -c\n"))
192 #t))))))
193
194 (native-search-paths
195 (list (search-path-specification ;new in 4.4
196 (variable "BASH_LOADABLES_PATH")
197 (files '("lib/bash")))))
198
199 (synopsis "The GNU Bourne-Again SHell")
200 (description
201 "Bash is the shell, or command-line interpreter, of the GNU system. It
202 is compatible with the Bourne Shell, but it also integrates useful features
203 from the Korn Shell and the C Shell and new improvements of its own. It
204 allows command-line editing, unlimited command history, shell functions and
205 aliases, and job control while still allowing most sh scripts to be run
206 without modification.")
207 (license gpl3+)
208 (home-page "https://www.gnu.org/software/bash/"))))
209
210 (define-public bash-minimal
211 ;; A stripped-down Bash for non-interactive use.
212 (package (inherit bash)
213 (name "bash-minimal")
214 (inputs '()) ; no readline, no curses
215
216 ;; No "include" output because there's no support for loadable modules.
217 (outputs (delete "include" (package-outputs bash)))
218
219 (arguments
220 (substitute-keyword-arguments (package-arguments bash)
221 ((#:modules _ '())
222 '((guix build gnu-build-system)
223 (guix build utils)
224 (srfi srfi-1)
225 (srfi srfi-26)))
226 ((#:configure-flags flags '())
227 `(list "--without-bash-malloc"
228 "--disable-readline"
229 "--disable-history"
230 "--disable-help-builtin"
231 "--disable-progcomp"
232 "--disable-net-redirections"
233 "--disable-nls"
234
235 ;; Pretend 'dlopen' is missing so we don't build loadable
236 ;; modules and related code.
237 "ac_cv_func_dlopen=no"
238
239 ,@(if (%current-target-system)
240 '("bash_cv_job_control_missing=no"
241 "bash_cv_getcwd_malloc=yes")
242 '())))
243 ((#:phases phases)
244 `(modify-phases ,phases
245 ;; No loadable modules.
246 (delete 'move-development-files)))))))
247
248 (define-public static-bash
249 ;; Statically-linked Bash that contains nothing but the 'bash' binary and
250 ;; 'sh' symlink, without any reference.
251 (let ((bash (static-package bash-minimal)))
252 (package
253 (inherit bash)
254 (name "bash-static")
255 (arguments
256 (substitute-keyword-arguments
257 `(#:allowed-references ("out") ,@(package-arguments bash))
258 ((#:phases phases)
259 `(modify-phases ,phases
260 (add-after 'strip 'remove-everything-but-the-binary
261 (lambda* (#:key outputs #:allow-other-keys)
262 (let* ((out (assoc-ref outputs "out"))
263 (bin (string-append out "/bin")))
264 (remove-store-references (string-append bin "/bash"))
265 (delete-file (string-append bin "/bashbug"))
266 (delete-file-recursively (string-append out "/share"))
267 #t))))))))))
268
269 (define-public bash-completion
270 (package
271 (name "bash-completion")
272 (version "2.8")
273 (source (origin
274 (method url-fetch)
275 (uri (string-append
276 "https://github.com/scop/" name "/releases/download/"
277 version "/" name "-" version ".tar.xz"))
278 (sha256
279 (base32
280 "0kgmflrr1ga9wfk770vmakna3nj46ylb5ky9ipd0v2k9ymq5a7y0"))
281 (patches
282 (search-patches "bash-completion-directories.patch"))))
283 (build-system gnu-build-system)
284 (native-inputs `(("util-linux" ,util-linux)))
285 (arguments
286 `(#:phases (modify-phases %standard-phases
287 (add-after
288 'install 'remove-redundant-completions
289 (lambda* (#:key
290 inputs native-inputs
291 outputs #:allow-other-keys)
292 ;; Util-linux comes with a bunch of completion files for
293 ;; its own commands which are more sophisticated and
294 ;; up-to-date than those of bash-completion. Remove those
295 ;; from bash-completion.
296 (let* ((out (assoc-ref outputs "out"))
297 (util-linux (assoc-ref (or native-inputs inputs)
298 "util-linux"))
299 (completions (string-append out
300 "/share/bash-completion"
301 "/completions"))
302 (already (find-files
303 (string-append
304 util-linux
305 "/etc/bash_completion.d"))))
306 (with-directory-excursion completions
307 (for-each (lambda (file)
308 (when (file-exists? file)
309 (delete-file file)))
310 (map basename already)))
311 #t))))))
312 (synopsis "Bash completions for common commands")
313 (description
314 "This package provides extensions that allow Bash to provide adapted
315 completion for many common commands.")
316 (home-page "https://github.com/scop/bash-completion")
317 (license gpl2+)))
318
319 (define-public bash-tap
320 (package
321 (name "bash-tap")
322 (version "1.0.2")
323 (source
324 (origin
325 (method git-fetch)
326 (uri (git-reference
327 (url "https://github.com/illusori/bash-tap.git")
328 (commit version)))
329 (file-name (git-file-name name version))
330 (sha256
331 (base32 "13zz9h6bhhnk3hiwhlpafrnf2isws249h3fz785dcgymk02arz9c"))))
332 ;; There is no compilation process to use this package, however, the bash
333 ;; scripts installed by this package start with "#!/bin/bash". To fix
334 ;; these lines, we use the patch-shebangs of the GNU build system. The
335 ;; project does not use a Makefile.
336 (build-system gnu-build-system)
337 (arguments
338 `(#:tests? #f ; There is no test suite.
339 #:phases
340 (modify-phases %standard-phases
341 ;; Because there are no configure scripts or Makefile, we can
342 ;; remove these phases.
343 (delete 'configure)
344 (delete 'build)
345 ;; The installation involves manually copying the files to a location.
346 ;; To make them easily accessible by setting PATH, we add the scripts
347 ;; to the "bin" folder.
348 (replace 'install
349 (lambda* (#:key outputs #:allow-other-keys)
350 (let ((bin (string-append (assoc-ref outputs "out") "/bin")))
351 (install-file "bash-tap" bin)
352 (install-file "bash-tap-bootstrap" bin)
353 (install-file "bash-tap-mock" bin)))))))
354 (home-page "https://www.illusori.co.uk/projects/bash-tap/")
355 (synopsis "Bash port of a Test::More/Test::Builder-style TAP-compliant
356 test library")
357 (description "Bash TAP is a TAP-compliant Test::More-style testing library
358 for Bash shell scripts and functions. Along with the Test::More-style testing
359 helpers it provides helper functions for mocking commands and in-process output
360 capturing.")
361 (license expat)))