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