gnu: python-babel: Update to 2.7.0.
[guix.git] / gnu / packages / bash.scm
blobfb4e3f4be3ff45cd919b22c05a9a8b21191cdf9e
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017 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 Efraim Flashner <efraim@flashner.co.il>
6 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
7 ;;;
8 ;;; This file is part of GNU Guix.
9 ;;;
10 ;;; GNU Guix is free software; you can redistribute it and/or modify it
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 ;;;
15 ;;; GNU Guix is distributed in the hope that it will be useful, but
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
21 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
23 (define-module (gnu packages bash)
24   #:use-module (guix licenses)
25   #:use-module (gnu packages)
26   #:use-module (gnu packages bootstrap)
27   #:use-module (gnu packages ncurses)
28   #:use-module (gnu packages readline)
29   #:use-module (gnu packages bison)
30   #:use-module (gnu packages linux)
31   #:use-module (guix packages)
32   #:use-module (guix download)
33   #:use-module (guix utils)
34   #:use-module (guix gexp)
35   #:use-module (guix monads)
36   #:use-module (guix store)
37   #:use-module (guix build-system gnu)
38   #:autoload   (guix gnupg) (gnupg-verify*)
39   #:autoload   (gcrypt hash) (port-sha256)
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))
45 (define (patch-url seqno)
46   "Return the URL of Bash patch number SEQNO."
47   (format #f "mirror://gnu/bash/bash-4.4-patches/bash44-~3,'0d" seqno))
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)))
56 (define-syntax-rule (patch-series (seqno hash) ...)
57   (list (bash-patch seqno (base32 hash))
58         ...))
60 (define %patch-series-4.4
61   ;; This is the current patches series for 4.4, generated using
62   ;; 'download-patches' below.
63   (patch-series
64    (1 "03vzy7qwjdd5qvl3ydg99naazas2qmyd0yhnrflgjbbm64axja1y")
65    (2 "0lrwq6vyqism3yqv9s7kzaf3dsl4q5w9r5svcqz279qp7qca083h")
66    (3 "1chqww2rj6g42b8s60q5zlzy0jzp684jkpsbrbfy1vzxja8mmpsi")
67    (4 "1cy8abf96hkrjhw921ndr0shlcnc52bg45rn6xri4v5clhq0l25d")
68    (5 "0a8515kyk4zsgmvlqvlganjfr7pq0j6kzpr4d6xx02kpbdr4n7i2")
69    (6 "1f24wgqngmj2mrj9yibwvc2zvlmn5xi53mnw777g3l40c4m2x3ka")
70    (7 "1bzdsnqaf05gdbqpsixhan8vygjxpcxlz1dd8d9f5jdznw3wq76y") ;CVE-2017-5932
71    (8 "1firw915mjm03hbbw9a70ch3cpgrgnvqjpllgdnn6csr8q04f546")
72    (9 "0g1l56kvw61rpw7dqa9fcl9llkl693h73g631hrhxlm030ddssqb")
73    (10 "01lfhrkdsdkdz8ypzapr614ras23x7ckjnr60aa5bzkaqprccrc4")
74    (11 "038p7mhnq9m65g505hi3827jkf9f35nd1cy00w8mwafpyxp44mnx")
75    (12 "0gh6lbb1rwpk44pvbamm6vzdfi50xnwkqd9v7s8cjwk3pz973hps")
76    (13 "1djkx0w9v62q78gz3jsvamj1jq53i6hbfrfhhsw86ihwpjnfy98v")
77    (14 "0z5ikcq9zyxw79d0z36r5p0mspnb5piavbv03jmlan1wnknmrxx7")
78    (15 "09n307fi1j257abhm295k6ksmnzw47ka2zhnr0i5lbdnpvn04xnk")
79    (16 "1cgi1y6mifm8hsgv4avj5ih76535js3qba1sqwbfvp7si76927sh")
80    (17 "0w6jpj2giakji1ir83rpkx1y7n7xqppah3j748m6dm38hywr0gvp")
81    (18 "1k58h4wxbsg7r4rwhrvzx5hfbapba2nxjysbhh6qp6ki5ys99i2v")
82    (19 "07n1i5610lbs672x1s8g82qn3qfj06s0ip3z80sri0g8vxp0s5r7")
83    (20 "0b2jk5n1af1vh590qfc52hv65mafb4vl1xv26s8j5a3byb5y4h0q")
84    (21 "1hblcd2xmqqlp0idnavw66570n7m0yv5rbbr873c2gkn982mk3xx")
85    (22 "0yfbjzr79vzjs2hyi5m8iy2b38fq7vikdfa4zqdvjsp36q4iycs5")
86    (23 "1dlism6qdx60nvzj0v7ndr7lfahl4a8zmzckp13hqgdx7xpj7v2g")))
88 (define (download-patches store count)
89   "Download COUNT Bash patches into store.  Return a list of
90 number/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))
100               (list number
101                     (bytevector->nix-base32-string
102                      (call-with-input-file patch port-sha256)))))
103           1+
104           1))
106 (define-public bash
107   (let* ((cppflags (string-join '("-DDEFAULT_PATH_VALUE='\"/no-such-path\"'"
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")))
122          (version "4.4"))
123     (package
124      (name "bash")
125      (source (origin
126               (method url-fetch)
127               (uri (string-append
128                     "mirror://gnu/bash/bash-" version ".tar.gz"))
129               (sha256
130                (base32
131                 "1jyz6snd63xjn6skk7za6psgidsd53k05cr3lksqybi0q6936syq"))
132               (patch-flags '("-p0"))
133               (patches %patch-series-4.4)))
134      (version (string-append version "."
135                              (number->string (length %patch-series-4.4))))
136      (build-system gnu-build-system)
138      (outputs '("out"
139                 "doc"                         ;1.7 MiB of HTML and extra files
140                 "include"))                   ;headers used by extensions
141      (inputs `(("readline" ,readline)
142                ("ncurses" ,ncurses)))             ;TODO: add texinfo
143      (arguments
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)
151         ;; Bash is reportedly not parallel-safe.  See, for instance,
152         ;; <http://patches.openembedded.org/patch/32745/> and
153         ;; <http://git.buildroot.net/buildroot/commit/?h=79e2d802a>.
154         #:parallel-build? #f
155         #:parallel-tests? #f
157         ;; XXX: The tests have a lot of hard-coded paths, so disable them
158         ;; for now.
159         #:tests? #f
161         #:modules ((srfi srfi-26)
162                    (guix build utils)
163                    (guix build gnu-build-system))
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")
172                   (symlink "bash" "sh")
173                   #t))))
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"))
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"))
197                 #t))))))
199      (native-search-paths
200       (list (search-path-specification            ;new in 4.4
201              (variable "BASH_LOADABLES_PATH")
202              (files '("lib/bash")))))
204      (synopsis "The GNU Bourne-Again SHell")
205      (description
206       "Bash is the shell, or command-line interpreter, of the GNU system.  It
207 is compatible with the Bourne Shell, but it also integrates useful features
208 from the Korn Shell and the C Shell and new improvements of its own.  It
209 allows command-line editing, unlimited command history, shell functions and
210 aliases, and job control while still allowing most sh scripts to be run
211 without modification.")
212      (license gpl3+)
213      (home-page "https://www.gnu.org/software/bash/"))))
215 (define-public bash-minimal
216   ;; A stripped-down Bash for non-interactive use.
217   (package (inherit bash)
218     (name "bash-minimal")
219     (inputs '())                                ; no readline, no curses
221     ;; No "include" output because there's no support for loadable modules.
222     (outputs (delete "include" (package-outputs bash)))
224     (arguments
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"
240                ;; Pretend 'dlopen' is missing so we don't build loadable
241                ;; modules and related code.
242                "ac_cv_func_dlopen=no"
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)))))))
253 (define-public static-bash
254   ;; Statically-linked Bash that contains nothing but the 'bash' binary and
255   ;; 'sh' symlink, without any reference.
256   (let ((bash (static-package bash-minimal)))
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)
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"))
272                    #t))))))))))
274 (define-public bash-completion
275   (package
276     (name "bash-completion")
277     (version "2.8")
278     (source (origin
279               (method url-fetch)
280               (uri (string-append
281                     "https://github.com/scop/" name "/releases/download/"
282                     version "/" name "-" version ".tar.xz"))
283               (sha256
284                (base32
285                 "0kgmflrr1ga9wfk770vmakna3nj46ylb5ky9ipd0v2k9ymq5a7y0"))
286               (patches
287                (search-patches "bash-completion-directories.patch"))))
288     (build-system gnu-build-system)
289     (native-inputs `(("util-linux" ,util-linux)))
290     (arguments
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))))))
314     (synopsis "Bash completions for common commands")
315     (description
316      "This package provides extensions that allow Bash to provide adapted
317 completion for many common commands.")
318     (home-page "https://github.com/scop/bash-completion")
319     (license gpl2+)))
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
357 test library")
358     (description "Bash TAP is a TAP-compliant Test::More-style testing library
359 for Bash shell scripts and functions.  Along with the Test::More-style testing
360 helpers it provides helper functions for mocking commands and in-process output
361 capturing.")
362     (license expat)))