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