Commit | Line | Data |
---|---|---|
233e7676 | 1 | ;;; GNU Guix --- Functional package management for GNU |
928d62f2 | 2 | ;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org> |
c93d7edd | 3 | ;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org> |
c44899a2 | 4 | ;;; |
233e7676 | 5 | ;;; This file is part of GNU Guix. |
c44899a2 | 6 | ;;; |
233e7676 | 7 | ;;; GNU Guix is free software; you can redistribute it and/or modify it |
c44899a2 LC |
8 | ;;; under the terms of the GNU General Public License as published by |
9 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
10 | ;;; your option) any later version. | |
11 | ;;; | |
233e7676 | 12 | ;;; GNU Guix is distributed in the hope that it will be useful, but |
c44899a2 LC |
13 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | ;;; GNU General Public License for more details. | |
16 | ;;; | |
17 | ;;; You should have received a copy of the GNU General Public License | |
233e7676 | 18 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. |
c44899a2 | 19 | |
1ffa7090 | 20 | (define-module (gnu packages bash) |
4a44e743 | 21 | #:use-module (guix licenses) |
1ffa7090 LC |
22 | #:use-module (gnu packages ncurses) |
23 | #:use-module (gnu packages readline) | |
2d5d63d7 | 24 | #:use-module (gnu packages bison) |
c44899a2 | 25 | #:use-module (guix packages) |
87f5d366 | 26 | #:use-module (guix download) |
c44899a2 | 27 | #:use-module (guix utils) |
c1fe82d5 LC |
28 | #:use-module (guix build-system gnu) |
29 | #:autoload (guix gnupg) (gnupg-verify*) | |
30 | #:autoload (guix hash) (port-sha256) | |
31 | #:autoload (guix base32) (bytevector->nix-base32-string) | |
32 | #:use-module (srfi srfi-1) | |
33 | #:use-module (srfi srfi-26) | |
34 | #:use-module (ice-9 format)) | |
35 | ||
36 | (define (patch-url seqno) | |
37 | "Return the URL of Bash patch number SEQNO." | |
38 | (format #f "mirror://gnu/bash/bash-4.3-patches/bash43-~3,'0d" seqno)) | |
39 | ||
40 | (define (bash-patch seqno sha256) | |
41 | "Return the origin of Bash patch SEQNO, with expected hash SHA256" | |
42 | (origin | |
43 | (method url-fetch) | |
44 | (uri (patch-url seqno)) | |
45 | (sha256 sha256))) | |
46 | ||
47 | (define-syntax-rule (patch-series (seqno hash) ...) | |
48 | (list (bash-patch seqno (base32 hash)) | |
49 | ...)) | |
50 | ||
51 | (define %patch-series-4.3 | |
52 | ;; This is the current patches series for 4.3, generated using | |
53 | ;; 'download-patches' below. | |
54 | (patch-series | |
55 | (1 "0hip2n2s5hws8p4nfcz37379zn6cak83ljsm64z52rw6ckrdzczc") | |
56 | (2 "0ashj5d1g3zbyr7zf0r72s5wnk96cz1xj919y3jajadbc9qcvrzf") | |
57 | (3 "0z88q4daq7dmw93iqd9c5i5d1sndklih3nrh0v75746da2n6w3h0") | |
58 | (4 "0f0kh9j5k4ym6knshscx31przm50x5cc7ifkwqk0swh6clna982y") | |
59 | (5 "1ym3b8b7lgmdp3dklp8qaqhyq965wd5392namq8mz7rb0d231j0s") | |
60 | (6 "04q20igq49py49ynb0f83f6f52cdkyqwd9bpic6akr0m5pkqwr50") | |
61 | (7 "18zkz23d9myshrwfcwcdjk7qmkqp8az5n91ni9jaixlwqlhy64qi") | |
62 | (8 "0pprcwvh7ngdli0x95pc1cpssg4qg7layi9xrv2jq6c7965ajhcr") | |
63 | (9 "19a0pf0alp30d1bjj0zf3zq2f5n0s6y91w7brm9jyswl51kns8n0") | |
64 | (10 "1dzhr5ammyijisz48cqi5vaw26hfr5vh9smnqxq4qc9p06f7j1ff") | |
65 | (11 "0fvzdzzi142a8rf3v965r6gbpn0k7fv2gif1yq8a4160vcn40qvw") | |
66 | (12 "04lcgfcyz7p3zagb4hkia3hkpd7lii9m8ycy9qqwzyrm1c1pj4ry") | |
67 | (13 "0y9cqi378z6flapkd5k5lfl4lq3ivzg4njj3i3wmw7xb6r9wma5z") | |
68 | (14 "04xcb0k9fxxq4vashgzb98567xzdnm4655nlm4jvfvjv6si6ykas") | |
69 | (15 "13ay6lldy1p00xj41nfjpq8lai3vw2qwca79gx6s80z04j53wa8k") | |
70 | (16 "0wq7bvx3pfw90pnfb86yg5nr9jgjsvm2nq5rrkqxf6zn977hpmlj") | |
71 | (17 "103p7sibihv6cshqj12k546zsbz0dnd5cv5vlx1719avddfc4rqj") | |
72 | (18 "0n1x3812y1brb9xbabaj3fvr4cpvm2225iwckmqk2fcpkq5b9a3s") | |
73 | (19 "08rd1p7zpzgbpmmmnj2im8wj2pcwmbbx51psr9vdc5c049si9ad7") | |
74 | (20 "163c6g05qpag2plx5q795pmw3f3m904jy7z93xj2i08pgzc8cpna") | |
75 | (21 "1a90cl3h10dh8k9f2ddrsjmw5ywaw2d5x78xb4fd2sryi039yhs1") | |
76 | (22 "120s0s4qcqd0q12j1iv0hkpf9fp3w5jnqw646kv66n66jnxlfkgx") | |
77 | (23 "1m00sfi88p2akgiyrg4hw0gvz3s1586pkzjdr3dm73vs773m1hls") | |
78 | (24 "0v0gjqzjsqjfgj5x17fq7g649k94jn8zq92qsxkhc2d6l215hl1v") | |
2d5d63d7 MW |
79 | (25 "0lcj96i659q35f1jcmwwbnw3p7w7vvlxjxqi989vn6d6qksqcl8y") ;CVE-2014-6271 |
80 | (26 "0k919ir0inwn4wai2vdzpbwqq5h54fnrlkmgccxjg91v3ch15k1f") ;CVE-2014-7169 | |
459cad23 MW |
81 | (27 "1gnsfvq6bhb3srlbh0cannj2hackdsipcg7z0ds7zlk1hp96mdqy") |
82 | (28 "17a65c4fn4c5rgsiw9gqqnzhznh3gwnd2xzzv2dppyi48znxpc78") ;CVE-2014-7186 | |
83 | (29 "14k27p28r5l2fz3r03kd0x72vvsq8bja8c6hjz5kxikbzsbs7i2c") ;CVE-2014-6277 | |
c93d7edd MW |
84 | (30 "0nrqb0m7s89qsrbfaffpilc5gcf82bx9yvgzld4hr79p5y54yhw5") ;CVE-2014-6278 |
85 | (31 "07d62bl3z7qa8v6kgk47vzzazw563mlk9zhrsr4xsbqgvmcrylnd") | |
86 | (32 "0jjgapfq4qhmndfrw8c3q3lva8xjdhlbd9cc631v41b0kb95g4w8") | |
87 | (33 "05ma5rlxiadnfh925p4y7s0vvk917kmsdb1mfdx05gizl63pfapv"))) | |
c1fe82d5 LC |
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)) | |
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 | |
9a97b814 LC |
107 | (let* ((cppflags (string-join '("-DSYS_BASHRC='\"/etc/bashrc\"'" |
108 | "-DSYS_BASH_LOGOUT='\"/etc/bash_logout\"'" | |
109 | "-DDEFAULT_PATH_VALUE='\"/no-such-path\"'" | |
110 | "-DSTANDARD_UTILS_PATH='\"/no-such-path\"'" | |
111 | "-DNON_INTERACTIVE_LOGIN_SHELLS" | |
112 | "-DSSH_SOURCE_BASHRC") | |
113 | " ")) | |
114 | (configure-flags | |
115 | ``("--with-installed-readline" | |
116 | ,,(string-append "CPPFLAGS=" cppflags) | |
117 | ,(string-append | |
118 | "LDFLAGS=-Wl,-rpath -Wl," | |
119 | (assoc-ref %build-inputs "readline") | |
120 | "/lib" | |
121 | " -Wl,-rpath -Wl," | |
122 | (assoc-ref %build-inputs "ncurses") | |
123 | "/lib"))) | |
124 | (post-install-phase | |
125 | '(lambda* (#:key outputs #:allow-other-keys) | |
126 | ;; Add a `bash' -> `sh' link. | |
127 | (let ((out (assoc-ref outputs "out"))) | |
128 | (with-directory-excursion (string-append out "/bin") | |
c1fe82d5 LC |
129 | (symlink "bash" "sh"))))) |
130 | (version "4.3")) | |
c44899a2 LC |
131 | (package |
132 | (name "bash") | |
c44899a2 | 133 | (source (origin |
87f5d366 | 134 | (method url-fetch) |
c44899a2 | 135 | (uri (string-append |
0db342a5 | 136 | "mirror://gnu/bash/bash-" version ".tar.gz")) |
c44899a2 LC |
137 | (sha256 |
138 | (base32 | |
c1fe82d5 LC |
139 | "1m14s1f61mf6bijfibcjm9y6pkyvz6gibyl8p4hxq90fisi8gimg")) |
140 | (patch-flags '("-p0")) | |
459cad23 | 141 | (patches %patch-series-4.3) |
2d5d63d7 MW |
142 | |
143 | ;; The patches above modify 'parse.y', so force a rebuild of the | |
144 | ;; parser. | |
145 | (snippet '(for-each delete-file | |
146 | '("y.tab.c" "y.tab.h" "parser-built"))))) | |
c1fe82d5 LC |
147 | (version (string-append version "." |
148 | (number->string (length %patch-series-4.3)))) | |
c44899a2 | 149 | (build-system gnu-build-system) |
2d5d63d7 | 150 | (native-inputs `(("bison" ,bison))) ;to rebuild the parser |
c44899a2 | 151 | (inputs `(("readline" ,readline) |
2d5d63d7 | 152 | ("ncurses" ,ncurses))) ;TODO: add texinfo |
c44899a2 | 153 | (arguments |
9a97b814 LC |
154 | `(;; When cross-compiling, `configure' incorrectly guesses that job |
155 | ;; control is missing. | |
156 | #:configure-flags ,(if (%current-target-system) | |
157 | `(cons* "bash_cv_job_control_missing=no" | |
158 | ,configure-flags) | |
159 | configure-flags) | |
c44899a2 LC |
160 | |
161 | ;; Bash is reportedly not parallel-safe. See, for instance, | |
162 | ;; <http://patches.openembedded.org/patch/32745/> and | |
163 | ;; <http://git.buildroot.net/buildroot/commit/?h=79e2d802ae7e376a413c02097790493e1f65c3a4>. | |
164 | #:parallel-build? #f | |
165 | #:parallel-tests? #f | |
166 | ||
167 | ;; XXX: The tests have a lot of hard-coded paths, so disable them | |
168 | ;; for now. | |
169 | #:tests? #f | |
170 | ||
c0895112 LC |
171 | #:phases (alist-cons-after 'install 'post-install |
172 | ,post-install-phase | |
56c092ce | 173 | %standard-phases))) |
f50d2669 | 174 | (synopsis "The GNU Bourne-Again SHell") |
c44899a2 | 175 | (description |
79c311b8 | 176 | "Bash is the shell, or command-line interpreter, of the GNU system. It |
a22dc0c4 LC |
177 | is compatible with the Bourne Shell, but it also integrates useful features |
178 | from the Korn Shell and the C Shell and new improvements of its own. It | |
79c311b8 | 179 | allows command-line editing, unlimited command history, shell functions and |
a22dc0c4 LC |
180 | aliases, and job control while still allowing most sh scripts to be run |
181 | without modification.") | |
4a44e743 | 182 | (license gpl3+) |
c44899a2 | 183 | (home-page "http://www.gnu.org/software/bash/")))) |
450fb5a6 LC |
184 | |
185 | (define-public bash-light | |
186 | ;; A stripped-down Bash for non-interactive use. | |
187 | (package (inherit bash) | |
188 | (name "bash-light") | |
189 | (inputs '()) ; no readline, no curses | |
190 | (arguments | |
191 | (let ((args `(#:modules ((guix build gnu-build-system) | |
192 | (guix build utils) | |
193 | (srfi srfi-1) | |
56c092ce | 194 | (srfi srfi-26)) |
0e999137 | 195 | ,@(package-arguments bash)))) |
450fb5a6 LC |
196 | (substitute-keyword-arguments args |
197 | ((#:configure-flags flags) | |
198 | `(list "--without-bash-malloc" | |
199 | "--disable-readline" | |
200 | "--disable-history" | |
201 | "--disable-help-builtin" | |
202 | "--disable-progcomp" | |
203 | "--disable-net-redirections" | |
0e999137 LC |
204 | "--disable-nls" |
205 | ||
206 | ,@(if (%current-target-system) | |
207 | '("bash_cv_job_control_missing=no") | |
208 | '())))))))) | |
928d62f2 LC |
209 | |
210 | (define-public bash-completion | |
211 | (package | |
212 | (name "bash-completion") | |
213 | (version "2.1") | |
214 | (source (origin | |
215 | (method url-fetch) | |
216 | (uri (string-append | |
217 | "http://bash-completion.alioth.debian.org/files/" | |
218 | "bash-completion-" version ".tar.bz2")) | |
219 | (sha256 | |
220 | (base32 | |
221 | "0kxf8s5bw7y50x0ksb77d3kv0dwadixhybl818w27y6mlw26hq1b")))) | |
222 | (build-system gnu-build-system) | |
223 | (synopsis "Bash completions for common commands") | |
224 | (description | |
225 | "This package provides extensions that allow Bash to provide adapted | |
226 | completion for many common commands.") | |
227 | (home-page "http://bash-completion.alioth.debian.org/") | |
228 | (license gpl2+))) |