gnu: packages: Use 'search-patches' everywhere.
[jackhill/guix/guix.git] / gnu / packages / bash.scm
index 6b2d0b8..cad66da 100644 (file)
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
+;;; Copyright © 2015 Leo Famulari <leo@famulari.name>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
    (36 "0z6jbyy70lfdm6d3x0sbazbqdxb3xnpn9bmz7madpvrnbd284pxc")
    (37 "04sqr8zkl6s5fccfvb775ppn3ldij5imria9swc39aq0fkfp1w9k")
    (38 "0rv3g14mpgv8br267bf7rmgqlgwnc4v6g3g8y0sjba571i8amgmd")
-   (39 "1v3l3vkc3g2b6fjycqwlakr8xhiw6bmw6q0zd6bi0m0m4bnxr55b")))
+   (39 "1v3l3vkc3g2b6fjycqwlakr8xhiw6bmw6q0zd6bi0m0m4bnxr55b")
+   (40 "0sypv66vsldmc95gwvf7ylz1k7y37vnvdsjg8ajjr6b2j9mkkfw4")
+   (41 "06ic2gdpbi1afik3wqf9d4vh95if4bz8bmhcgr555621dsb35i2f")
+   (42 "06a90k0p6bqc4wk2dsmapna69124an76xvlnlj3xm497vci968dc")))
+
 (define (download-patches store count)
   "Download COUNT Bash patches into store.  Return a list of
 number/base32-hash tuples, directly usable in the 'patch-series' form."
@@ -143,17 +148,18 @@ number/base32-hash tuples, directly usable in the 'patch-series' form."
              ;; guile-bash expect.
              (let ((include (string-append (assoc-ref outputs "include")
                                             "/include/bash"))
+                   (includes "^\\./include/[^/]+\\.h$")
                    (headers "^\\./(builtins/|lib/glob/|lib/tilde/|)[^/]+\\.h$"))
                (mkdir-p include)
                (for-each (lambda (file)
-                           (when ((@ (ice-9 regex) string-match) headers file)
-                             (let ((directory (string-append include "/"
-                                                             (dirname file))))
-                               (mkdir-p directory)
-                               (copy-file file
-                                          (string-append directory "/"
-                                                         (basename file))))))
+                           (when (string-match includes file)
+                             (install-file file include))
+                           (when (string-match headers file)
+                             (install-file file
+                                           (string-append include "/"
+                                                          (dirname file)))))
                          (find-files "." "\\.h$"))
+               (delete-file (string-append include "/" "y.tab.h"))
                #t)))
          (version "4.3"))
     (package
@@ -177,8 +183,9 @@ number/base32-hash tuples, directly usable in the 'patch-series' form."
      (build-system gnu-build-system)
 
      (outputs '("out"
-                "include"))                       ;headers used by extensions
-     (native-inputs `(("bison" ,bison)))          ;to rebuild the parser
+                "doc"                         ;1.7 MiB of HTML and extra files
+                "include"))                   ;headers used by extensions
+     (native-inputs `(("bison" ,bison)))      ;to rebuild the parser
      (inputs `(("readline" ,readline)
                ("ncurses" ,ncurses)))             ;TODO: add texinfo
      (arguments
@@ -191,7 +198,7 @@ number/base32-hash tuples, directly usable in the 'patch-series' form."
 
         ;; Bash is reportedly not parallel-safe.  See, for instance,
         ;; <http://patches.openembedded.org/patch/32745/> and
-        ;; <http://git.buildroot.net/buildroot/commit/?h=79e2d802ae7e376a413c02097790493e1f65c3a4>.
+        ;; <http://git.buildroot.net/buildroot/commit/?h=79e2d802a>.
         #:parallel-build? #f
         #:parallel-tests? #f
 
@@ -199,10 +206,14 @@ number/base32-hash tuples, directly usable in the 'patch-series' form."
         ;; for now.
         #:tests? #f
 
+        #:modules ((ice-9 regex)
+                   (guix build utils)
+                   (guix build gnu-build-system))
+
         #:phases (modify-phases %standard-phases
                    (add-after 'install 'post-install ,post-install-phase)
                    (add-after 'install 'install-headers
-                              ,install-headers-phase))))
+                     ,install-headers-phase))))
      (synopsis "The GNU Bourne-Again SHell")
      (description
       "Bash is the shell, or command-line interpreter, of the GNU system.  It
@@ -214,10 +225,10 @@ without modification.")
      (license gpl3+)
      (home-page "http://www.gnu.org/software/bash/"))))
 
-(define-public bash-light
+(define-public bash-minimal
   ;; A stripped-down Bash for non-interactive use.
   (package (inherit bash)
-    (name "bash-light")
+    (name "bash-minimal")
     (inputs '())                                ; no readline, no curses
     (arguments
      (let ((args `(#:modules ((guix build gnu-build-system)
@@ -239,6 +250,28 @@ without modification.")
                        '("bash_cv_job_control_missing=no")
                        '()))))))))
 
+(define-public static-bash
+  ;; Statically-linked Bash that contains nothing but the 'bash' binary and
+  ;; 'sh' symlink, without any reference.
+  (let ((bash (static-package bash-minimal)))
+    (package
+      (inherit bash)
+      (name "bash-static")
+      (arguments
+       (substitute-keyword-arguments
+           `(#:allowed-references ("out") ,@(package-arguments bash))
+         ((#:phases phases)
+          `(alist-cons-after
+            'strip 'remove-everything-but-the-binary
+            (lambda* (#:key outputs #:allow-other-keys)
+              (let* ((out (assoc-ref outputs "out"))
+                     (bin (string-append out "/bin")))
+                (remove-store-references (string-append bin "/bash"))
+                (delete-file (string-append bin "/bashbug"))
+                (delete-file-recursively (string-append out "/share"))
+                #t))
+            ,phases)))))))
+
 (define-public bash-completion
   (package
     (name "bash-completion")
@@ -252,7 +285,7 @@ without modification.")
                (base32
                 "0kxf8s5bw7y50x0ksb77d3kv0dwadixhybl818w27y6mlw26hq1b"))
               (patches
-               (list (search-patch "bash-completion-directories.patch")))))
+               (search-patches "bash-completion-directories.patch"))))
     (build-system gnu-build-system)
     (native-inputs `(("util-linux" ,util-linux)))
     (arguments
@@ -268,8 +301,10 @@ without modification.")
                           (completions (string-append out
                                                       "/share/bash-completion"
                                                       "/completions"))
-                          (already     (find-files (string-append util-linux
-                                                                  "/etc/bash_completion.d"))))
+                          (already     (find-files
+                                        (string-append
+                                         util-linux
+                                         "/etc/bash_completion.d"))))
                      (with-directory-excursion completions
                        (for-each (lambda (file)
                                    (when (file-exists? file)