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