gnu: Add cl-ana.statistical-learning.
[jackhill/guix/guix.git] / gnu / packages / bash.scm
CommitLineData
233e7676 1;;; GNU Guix --- Functional package management for GNU
f94f9d67 2;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2019 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*)
ca719424 41 #:autoload (gcrypt hash) (port-sha256)
c1fe82d5
LC
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."
847ffe88 49 (format #f "mirror://gnu/bash/bash-5.0-patches/bash50-~3,'0d" seqno))
c1fe82d5
LC
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
847ffe88
EF
62(define %patch-series-5.0
63 ;; This is the current patches series for 5.0, generated using
c1fe82d5 64 ;; 'download-patches' below.
feefbb09 65 (patch-series
4aeb42b9 66 (1 "12bjfdy6bg8nhyw27bdgxn7h4paylx8d927skfmi9pxd1wgrxzpj")
13f3893b
EF
67 (2 "01w7yrzmz10mw06ys0546vhl7isv2v402ziyvfd7k67588spvs47")
68 (3 "0ny81ridp5n0j69hb8ixrc7dmxybby54jbsz5hikly8kgg1wvssf")
69 (4 "021gqqvgydixkrmqss64b6srfdlkvnx88lyfzpxfrn5d6bc7li0l")
70 (5 "0xl2kyzm84nlyklrqzkn73ixabhzfhn9x91lzcmis89cppclvxav")
71 (6 "0844749ixk1z60437nkznzms1f0nzh9an62kj7sny6r0zyk2k1fn")
72 (7 "16xg37gp1b8zlj5969w8mcrparwqlcbj9695vn3qhgb7wdz1xd0p")))
a2a9bba4 73
c1fe82d5
LC
74(define (download-patches store count)
75 "Download COUNT Bash patches into store. Return a list of
76number/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"))))
f94f9d67 83 (unless (eq? 'valid-signature (gnupg-verify* sig patch))
c1fe82d5
LC
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))
c44899a2
LC
91
92(define-public bash
1382bde9 93 (let* ((cppflags (string-join '("-DDEFAULT_PATH_VALUE='\"/no-such-path\"'"
9a97b814
LC
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")))
847ffe88 108 (version "5.0"))
c44899a2
LC
109 (package
110 (name "bash")
c44899a2 111 (source (origin
87f5d366 112 (method url-fetch)
c44899a2 113 (uri (string-append
0db342a5 114 "mirror://gnu/bash/bash-" version ".tar.gz"))
c44899a2
LC
115 (sha256
116 (base32
4aeb42b9
EF
117 "0kgvfwqdcd90waczf4gx39xnrxzijhjrzyzv7s8v4w31qqm0za5l"))
118 (patch-flags '("-p0"))
119 (patches %patch-series-5.0)))
120 (version (string-append version "." (number->string (length %patch-series-5.0))))
c44899a2 121 (build-system gnu-build-system)
2b34b4b4
LC
122
123 (outputs '("out"
4d28b97c
LC
124 "doc" ;1.7 MiB of HTML and extra files
125 "include")) ;headers used by extensions
c44899a2 126 (inputs `(("readline" ,readline)
2d5d63d7 127 ("ncurses" ,ncurses))) ;TODO: add texinfo
c44899a2 128 (arguments
9a97b814
LC
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)
c44899a2
LC
135
136 ;; Bash is reportedly not parallel-safe. See, for instance,
137 ;; <http://patches.openembedded.org/patch/32745/> and
a124bbd2 138 ;; <http://git.buildroot.net/buildroot/commit/?h=79e2d802a>.
c44899a2
LC
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
c573f5a5 146 #:modules ((srfi srfi-26)
3dcbb75f
LF
147 (guix build utils)
148 (guix build gnu-build-system))
149
c573f5a5
LC
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")
8809a153
MW
157 (symlink "bash" "sh")
158 #t))))
c573f5a5
LC
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"))
d9b4cbc2
LC
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"))
c573f5a5
LC
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
f50d2669 189 (synopsis "The GNU Bourne-Again SHell")
c44899a2 190 (description
79c311b8 191 "Bash is the shell, or command-line interpreter, of the GNU system. It
a22dc0c4
LC
192is compatible with the Bourne Shell, but it also integrates useful features
193from the Korn Shell and the C Shell and new improvements of its own. It
79c311b8 194allows command-line editing, unlimited command history, shell functions and
a22dc0c4
LC
195aliases, and job control while still allowing most sh scripts to be run
196without modification.")
4a44e743 197 (license gpl3+)
6fd52309 198 (home-page "https://www.gnu.org/software/bash/"))))
450fb5a6 199
f24931d8 200(define-public bash-minimal
450fb5a6
LC
201 ;; A stripped-down Bash for non-interactive use.
202 (package (inherit bash)
f24931d8 203 (name "bash-minimal")
450fb5a6 204 (inputs '()) ; no readline, no curses
c86447f4
LC
205
206 ;; No "include" output because there's no support for loadable modules.
207 (outputs (delete "include" (package-outputs bash)))
208
450fb5a6 209 (arguments
4cc80c94
LC
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)))))))
928d62f2 237
6c7f44ef
LC
238(define-public static-bash
239 ;; Statically-linked Bash that contains nothing but the 'bash' binary and
240 ;; 'sh' symlink, without any reference.
f24931d8 241 (let ((bash (static-package bash-minimal)))
6c7f44ef
LC
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)
a7a1cf29
LC
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"))
e543c8a2 257 #t))))))))))
6c7f44ef 258
928d62f2
LC
259(define-public bash-completion
260 (package
261 (name "bash-completion")
504be7db 262 (version "2.8")
928d62f2
LC
263 (source (origin
264 (method url-fetch)
265 (uri (string-append
ba6d25f3
266 "https://github.com/scop/" name "/releases/download/"
267 version "/" name "-" version ".tar.xz"))
928d62f2
LC
268 (sha256
269 (base32
504be7db 270 "0kgmflrr1ga9wfk770vmakna3nj46ylb5ky9ipd0v2k9ymq5a7y0"))
16629c8a 271 (patches
fc1adab1 272 (search-patches "bash-completion-directories.patch"))))
928d62f2 273 (build-system gnu-build-system)
b16b7790
LC
274 (native-inputs `(("util-linux" ,util-linux)))
275 (arguments
aa67d3c5
276 `(#:phases (modify-phases %standard-phases
277 (add-after
278 'install 'remove-redundant-completions
d8dbfbce
MO
279 (lambda* (#:key
280 inputs native-inputs
281 outputs #:allow-other-keys)
aa67d3c5
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"))
d8dbfbce
MO
287 (util-linux (assoc-ref (or native-inputs inputs)
288 "util-linux"))
aa67d3c5
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))))))
928d62f2
LC
302 (synopsis "Bash completions for common commands")
303 (description
304 "This package provides extensions that allow Bash to provide adapted
305completion for many common commands.")
b07e0863 306 (home-page "https://github.com/scop/bash-completion")
928d62f2 307 (license gpl2+)))
2d4422d5
RJ
308
309(define-public bash-tap
310 (package
311 (name "bash-tap")
312 (version "1.0.2")
38e10e08
TGR
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"))))
2d4422d5
RJ
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
346test library")
347 (description "Bash TAP is a TAP-compliant Test::More-style testing library
348for Bash shell scripts and functions. Along with the Test::More-style testing
349helpers it provides helper functions for mocking commands and in-process output
350capturing.")
351 (license expat)))