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