gnu: facter: Update to 4.0.33.
[jackhill/guix/guix.git] / gnu / packages / bash.scm
index 84268e0..47ca625 100644 (file)
@@ -1,9 +1,9 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2015, 2017 Leo Famulari <leo@famulari.name>
 ;;; Copyright © 2016, 2017, 2018, 2019 Efraim Flashner <efraim@flashner.co.il>
-;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
+;;; Copyright © 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 (define-module (gnu packages bash)
   #:use-module (guix licenses)
   #:use-module (gnu packages)
+  #:use-module (gnu packages base)
   #:use-module (gnu packages bootstrap)
   #:use-module (gnu packages ncurses)
   #:use-module (gnu packages readline)
   #:use-module (gnu packages bison)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages guile)
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module (guix monads)
   #:use-module (guix store)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system trivial)
   #:autoload   (guix gnupg) (gnupg-verify*)
-  #:autoload   (gcrypt hash) (port-sha256)
   #:autoload   (guix base32) (bytevector->nix-base32-string)
+
+  ;; See <https://bugs.gnu.org/41457> for why not #:autoload here.
+  #:use-module ((gcrypt hash) #:select (port-sha256))
+
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
   #:use-module (ice-9 format))
   "Return the URL of Bash patch number SEQNO."
   (format #f "mirror://gnu/bash/bash-5.0-patches/bash50-~3,'0d" seqno))
 
-(define (bash-patch seqno sha256)
-  "Return the origin of Bash patch SEQNO, with expected hash SHA256"
+(define (bash-patch seqno sha256-bv)
+  "Return the origin of Bash patch SEQNO, with expected hash SHA256-BV."
   (origin
     (method url-fetch)
     (uri (patch-url seqno))
-    (sha256 sha256)))
+    (sha256 sha256-bv)))
 
 (define-syntax-rule (patch-series (seqno hash) ...)
   (list (bash-patch seqno (base32 hash))
@@ -324,7 +330,7 @@ completion for many common commands.")
      (origin
        (method git-fetch)
        (uri (git-reference
-             (url "https://github.com/illusori/bash-tap.git")
+             (url "https://github.com/illusori/bash-tap")
              (commit version)))
        (file-name (git-file-name name version))
        (sha256
@@ -351,7 +357,7 @@ completion for many common commands.")
                (install-file "bash-tap" bin)
                (install-file "bash-tap-bootstrap" bin)
                (install-file "bash-tap-mock" bin)))))))
-    (home-page "http://www.illusori.co.uk/projects/bash-tap/")
+    (home-page "https://www.illusori.co.uk/projects/bash-tap/")
     (synopsis "Bash port of a Test::More/Test::Builder-style TAP-compliant
 test library")
     (description "Bash TAP is a TAP-compliant Test::More-style testing library
@@ -359,3 +365,53 @@ for Bash shell scripts and functions.  Along with the Test::More-style testing
 helpers it provides helper functions for mocking commands and in-process output
 capturing.")
     (license expat)))
+
+(define-public bats
+  (package
+    (name "bats")
+    (version "1.2.0")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/bats-core/bats-core")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0f59zh4d4pa1a7ybs5zl6h0csbqqv11lbnq0jl1dgwm1s6p49bsq"))))
+    (inputs
+     `(("bash" ,bash)
+       ("coreutils" ,coreutils)
+       ("guile" ,guile-3.0) ;for wrap-script
+       ("grep" ,grep)))
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder
+       (begin
+         (use-modules (guix build utils))
+         (copy-recursively (assoc-ref %build-inputs "source") ".")
+         (setenv "PATH"
+                 (string-append (assoc-ref %build-inputs "bash") "/bin"
+                                ":" (assoc-ref %build-inputs "coreutils") "/bin"
+                                ":" (assoc-ref %build-inputs "grep") "/bin"
+                                ":" (assoc-ref %build-inputs "guile") "/bin"
+                                ":" (getenv "PATH")))
+         (for-each (lambda (file) (patch-shebang file)) (find-files "."))
+         (substitute* "bin/bats"
+           (("export BATS_ROOT" line)
+            (string-append "BATS_ROOT=\"${BATS_ROOT:-" %output "/libexec/bats-core}\"\n"
+                           line)))
+         ;; Install phase
+         (invoke "./install.sh" %output)
+         (wrap-script (string-append %output "/bin/bats")
+                      (list "PATH" 'prefix (string-split (getenv "PATH")
+                                                         #\:))))))
+    (build-system trivial-build-system)
+    (home-page "https://github.com/bats-core/bats-core/")
+    (synopsis "Bash Automated Testing System")
+    (description
+     "Bats is a @acronym{TAP, Test Anything Protocol}-compliant testing
+framework for Bash.  It provides a simple way to verify that the UNIX programs
+you write behave as expected.  Bats is most useful when testing software written
+in Bash, but you can use it to test any UNIX program.")
+    (license expat)))