Toggle diff (224 lines)
diff --git a/gnu/packages/bash.scm b/gnu/packages/bash.scm
index ed2931fd97..114ea1dcac 100644
--- a/gnu/packages/bash.scm
+++ b/gnu/packages/bash.scm
(define-module (gnu packages bash)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (gnu packages)
+ #:use-module (gnu packages admin)
#:use-module (gnu packages base)
#:use-module (gnu packages bootstrap)
#:use-module (gnu packages compression)
+ #:use-module (gnu packages curl)
+ #:use-module (gnu packages dns)
+ #:use-module (gnu packages ed)
#:use-module (gnu packages elf)
+ #:use-module (gnu packages freedesktop)
+ #:use-module (gnu packages gawk)
+ #:use-module (gnu packages gtk)
#:use-module (gnu packages ncurses)
+ #:use-module (gnu packages networking)
#:use-module (gnu packages readline)
#:use-module (gnu packages bison)
#:use-module (gnu packages linux)
#:use-module (gnu packages libffi)
+ #:use-module (gnu packages pcre)
+ #:use-module (gnu packages perl)
+ #:use-module (gnu packages php)
#:use-module (gnu packages pkg-config)
+ #:use-module (gnu packages python)
+ #:use-module (gnu packages python-xyz)
#:use-module (gnu packages guile)
+ #:use-module (gnu packages guile-xyz)
+ #:use-module (gnu packages tcl)
+ #:use-module (gnu packages web)
+ #:use-module (gnu packages xml)
#:use-module (guix packages)
#:use-module (guix download)
#:use-module (guix git-download)
@@ -448,3 +465,182 @@ (define-public bash-ctypes
function interface (FFI) directly in your shell. In other words, it allows
you to call routines in shared libraries from within Bash.")
(license license:expat)))
+(define-public bash-coding-utils
+ (name "bash-coding-utils")
+ (commit "40d6527a9effb4e18778c37bebaa9f3a58de12d6")
+ (url "https://gitlab.com/methuselah-0/bash-coding-utils.sh.git")
+ ;; Include submodules/. TODO: These seem to be worth packaging?
+ (base32 "007g6wfybjr0ms32qikb545r11lgm3p98cd7dbzpfyh0grgn9vj1"))))
+ (inputs `(("bash" ,bash)
+ ("bindutils" ,isc-bind "utils")
+ ("coreutils" ,coreutils)
+ ("ctypes.sh" ,bash-ctypes)
+ ("diffutils" ,diffutils)
+ ("guile-bash" ,guile-bash)
+ ("guile-daemon" ,guile-daemon)
+ ("inetutils" ,inetutils)
+ ("libxml2-xpath0" ,libxml2-xpath0)
+ ("pcre/bin" ,pcre "bin")
+ ("python-elementpath" ,python-elementpath)
+ ("python-lxml" ,python-lxml)
+ ("python-netaddr" ,python-netaddr)
+ ("python-yq" ,python-yq)
+ ("util-linux" ,util-linux)
+ ("xdg-utils" ,xdg-utils)
+ (build-system trivial-build-system)
+ `(#:modules ((guix build utils))
+ (use-modules (guix build utils))
+ (let* ((bash (assoc-ref %build-inputs "bash"))
+ ;; Some Guile libraries such as GNU Bash will need
+ ;; to be added to GUILE_LOAD_PATH.
+ (guile-bash (assoc-ref %build-inputs "guile-bash"))
+ (g-bash-lib (string-append guile-bash
+ ,(version-major+minor (package-version guile-3.0))))
+ ;; Some Python libraries needs added to PYTHONPATH.
+ (python-version ,(version-major+minor (package-version python)))
+ (p-elementpath-lib (string-append
+ (assoc-ref %build-inputs "python-elementpath")
+ "/lib/python" python-version "/site-packages"))
+ (p-lxml-lib (string-append
+ (assoc-ref %build-inputs "python-lxml")
+ "/lib/python" python-version "/site-packages"))
+ (p-netaddr-lib (string-append
+ (assoc-ref %build-inputs "python-netaddr")
+ "/lib/python" python-version "/site-packages"))
+ (assoc-ref %build-inputs "python")
+ "/lib/python" python-version "/site-packages"))
+ (pylibsline (string-append
+ p-elementpath-lib ":" p-lxml-lib
+ ":" p-netaddr-lib ":" p-lib))
+ (out (assoc-ref %outputs "out"))
+ (bin (string-append out "/bin"))
+ ;; Everything but bcu.sh itself is only accessed
+ ;; internally by bcu so we put it in libexec.
+ (libexec (string-append out "/libexec/bcu")))
+ (copy-recursively (assoc-ref %build-inputs "source") libexec)
+ ;; Create a bcu.sh wrapping script manually that ensures
+ ;; we prepend necessary PATHs.
+ (let* ((bcu.sh (string-append bin "/bcu.sh"))
+ ":" (assoc-ref %build-inputs "bindutils") "/bin"
+ ":" (assoc-ref %build-inputs "coreutils") "/bin"
+ ":" (assoc-ref %build-inputs "ctypes.sh") "/bin"
+ ":" (assoc-ref %build-inputs "curl") "/bin"
+ ":" (assoc-ref %build-inputs "diffutils") "/bin"
+ ":" (assoc-ref %build-inputs "ed") "/bin"
+ ":" (assoc-ref %build-inputs "expect") "/bin"
+ ":" (assoc-ref %build-inputs "find") "/bin"
+ ":" (assoc-ref %build-inputs "gawk") "/bin"
+ ":" (assoc-ref %build-inputs "grep") "/bin"
+ ":" (assoc-ref %build-inputs "guile") "/bin"
+ ":" (assoc-ref %build-inputs "inetutils") "/bin"
+ ":" (assoc-ref %build-inputs "jq") "/bin"
+ ":" (assoc-ref %build-inputs "libxml2-xpath0") "/bin"
+ ":" (assoc-ref %build-inputs "netcat") "/bin"
+ ":" (assoc-ref %build-inputs "nmap") "/bin"
+ ":" (assoc-ref %build-inputs "pcre/bin") "/bin"
+ ":" (assoc-ref %build-inputs "perl") "/bin"
+ ":" (assoc-ref %build-inputs "php") "/bin"
+ ":" (assoc-ref %build-inputs "prips") "/bin"
+ ":" (assoc-ref %build-inputs "python") "/bin"
+ ":" (assoc-ref %build-inputs "python-yq") "/bin"
+ ":" (assoc-ref %build-inputs "sed") "/bin"
+ ":" (assoc-ref %build-inputs "socat") "/bin"
+ ":" (assoc-ref %build-inputs "util-linux") "/bin"
+ ":" (assoc-ref %build-inputs "which") "/bin"
+ ":" (assoc-ref %build-inputs "xdg-utils") "/bin"
+ ":" (assoc-ref %build-inputs "yad") "/bin")))
+ (with-output-to-file bcu.sh
+ (display (string-append "#!" bash "/bin/bash\n"))
+ (display "[[ \"$_BCU_SH_LOADED\" == YES ]] || { \n")
+ (display (string-append "export PATH=\"" path
+ "${PATH:+:}${PATH}\"\n"))
+ (display (string-append "export PYTHONPATH=\"" pylibsline
+ "${PYTHONPATH:+:}${PYTHONPATH}\"\n"))
+ (string-append "export GUILE_LOAD_PATH=\"" g-bash-lib
+ "${GUILE_LOAD_PATH:+:}${GUILE_LOAD_PATH}\"\n"))
+ ;; XDG_DATA_DIRS needs set for yad to load icons properly.
+ (display (string-append
+ "[[ -e /run/current-system/profile/share ]] && "
+ "export XDG_DATA_DIRS="
+ "/run/current-system/profile/share"
+ "${XDG_DATA_DIRS:+:}${XDG_DATA_DIRS}\n"))
+ (display (string-append "source " libexec "/bcu.sh\n"))
+ (setenv "PATH" (string-append path ":" (getenv "PATH"))))
+ (substitute* (find-files out ".*\\.sh")
+ (("~/\\.guix-profile/lib/bash/libguile-bash\\.so")
+ (string-append guile-bash "/lib/bash/libguile-bash.so"))
+ (("\"\\$GUIX_PROFILE\"/lib/bash/libguile-bash\\.so")
+ (string-append guile-bash "/lib/bash/libguile-bash.so")))
+ (for-each (lambda (file)
+ (find-files out ".*\\.(sh|scm|awk|php|py)$") )
+ ;; Set up PATH for tests.
+ (setenv "PATH" (string-append bin ":" (getenv "PATH")))
+ ;; Some tests need a HOME directory.
+ ;; Disable network tests, and all tests for setopts which
+ ;; don't work inside the Guix build environment.
+ (with-output-to-file (string-append libexec "/disabled_tests.txt")
+ (invoke (string-append libexec "/bcu-test.sh"))))))
+ (home-page "https://gitlab.com/methuselah-0/bash-coding-utils.sh")
+ (synopsis "Functions and tools for software prototyping in Bash")
+ "This package contains Bash functions and wrappers that can be useful
+when writing quick implementations of new programs. It helps you work with
+JSON, XML, and parallelization, and installs some commonly used helper programs
+used in Bash scripting. Just run @command{. bcu.sh}, type @command{bcu__}, hit
+@key{TAB} to see available functions and give any of them the @code{--help}
+flag to see how to use it, or run @command{bcu__docs} for the full HTML
+ (license license:gpl3))))