From patchwork Sat Oct 30 14:59:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: david larsson X-Patchwork-Id: 34167 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 9F1AC27BBE3; Sat, 30 Oct 2021 16:00:45 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id D846F27BBE1 for ; Sat, 30 Oct 2021 16:00:44 +0100 (BST) Received: from localhost ([::1]:35318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mgpqd-0002SA-W3 for patchwork@mira.cbaines.net; Sat, 30 Oct 2021 11:00:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mgppy-0002Rn-Bt for guix-patches@gnu.org; Sat, 30 Oct 2021 11:00:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:46601) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mgppx-0000bp-VY for guix-patches@gnu.org; Sat, 30 Oct 2021 11:00:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mgppx-0004DQ-St for guix-patches@gnu.org; Sat, 30 Oct 2021 11:00:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#51512] [PATCH]: gnu: Add bash-bcu. Resent-From: david larsson Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 30 Oct 2021 15:00:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 51512 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51512@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.163560599716167 (code B ref -1); Sat, 30 Oct 2021 15:00:01 +0000 Received: (at submit) by debbugs.gnu.org; 30 Oct 2021 14:59:57 +0000 Received: from localhost ([127.0.0.1]:58147 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mgpps-0004Ch-Go for submit@debbugs.gnu.org; Sat, 30 Oct 2021 10:59:57 -0400 Received: from lists.gnu.org ([209.51.188.17]:38720) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mgppk-0004CR-KR for submit@debbugs.gnu.org; Sat, 30 Oct 2021 10:59:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mgppk-0002RL-BO for guix-patches@gnu.org; Sat, 30 Oct 2021 10:59:48 -0400 Received: from server0.selfhosted.xyz ([217.64.149.7]:48460) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mgppg-0000b3-2Y for guix-patches@gnu.org; Sat, 30 Oct 2021 10:59:47 -0400 Received: from server0.selfhosted.xyz (localhost [127.0.0.1]) by server0.selfhosted.xyz (Postfix) with ESMTP id 5EB72270C008 for ; Sat, 30 Oct 2021 16:59:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=selfhosted.xyz; s=dkim; t=1635605979; bh=Cx/twYtDLpeeT1vFOEudWkc054Cts8zYsMtq4bW8DMo=; h=Date:From:To:Subject; b=gvATYh5bJnZJt0VM5CixY6yG9mMQxBvFynUiUmxLe8/NkCrv/OKtRmwXnNS0GqarO BsztYkRVQvqDLhPJmtOPdZH3MkwzytVBrAldfdN7wRwh0FEK7Ok9/Aop2smiz5qUOx 1uXY5IY9RmBchhbBHholNkRf46REfEazSETQA9E9QpuU0upk32zrVMQF7iZrLatoY4 iYAj7Ji96FrT4ayOWhm5JBWk3b9+VXGd0P1BPSRVhaI9BOFviOfbYHeYgezxfceBo8 75O8NsCAGo/7u221LuiZRpHELRN2voSP+9dMAD8O+Mp0pxcY6m/UtzVKnFUD/h0CSP 0X/D2HIhZmdpw== X-Fuglu-Suspect: 84f1f5cc27fa4f34a40b53638ee78fe0 X-Fuglu-Spamstatus: NO Received: from webmail.selfhosted.xyz (office.selfhosted.xyz [192.168.1.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: mail@selfhosted.xyz) by server0.selfhosted.xyz (Postfix) with ESMTPSA for ; Sat, 30 Oct 2021 16:59:33 +0200 (CEST) MIME-Version: 1.0 Date: Sat, 30 Oct 2021 16:59:33 +0200 From: david larsson Message-ID: <3add15b77522d6e9ebd715a19d966666@selfhosted.xyz> X-Sender: david.larsson@selfhosted.xyz Received-SPF: pass client-ip=217.64.149.7; envelope-from=david.larsson@selfhosted.xyz; helo=server0.selfhosted.xyz X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.499, FROM_SUSPICIOUS_NTLD_FP=1.999, PDS_OTHER_BAD_TLD=0.076, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Hi, This patch adds "bash-coding-utils" as the bash-bcu package. Best regards, David From b79e6173263acb8d77946a08e03d5b01a9f5f86c Mon Sep 17 00:00:00 2001 From: David Larsson Date: Fri, 29 Oct 2021 13:58:41 +0200 Subject: [PATCH] gnu: Add bash-bcu. * gnu/packages/bash.scm (bash-bcu): New variable. --- gnu/packages/bash.scm | 193 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 193 insertions(+) diff --git a/gnu/packages/bash.scm b/gnu/packages/bash.scm index ed2931fd97..f89dcf5341 100644 --- a/gnu/packages/bash.scm +++ b/gnu/packages/bash.scm @@ -25,17 +25,34 @@ (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,179 @@ in Bash, but you can use it to test any UNIX program.") 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-bcu + (let ((pyver (version-major+minor (package-version python))) + (guilever (version-major+minor (package-version guile-3.0)))) + (package + (name "bash-bcu") + (version "v0.2.0") + (home-page "https://gitlab.com/methuselah-0/bash-coding-utils.sh") + (source + (origin + (method git-fetch) + (uri (git-reference + (commit "40d6527a9effb4e18778c37bebaa9f3a58de12d6") + (url "https://gitlab.com/methuselah-0/bash-coding-utils.sh.git") + (recursive? #t))) + (sha256 + (base32 + "007g6wfybjr0ms32qikb545r11lgm3p98cd7dbzpfyh0grgn9vj1")))) + (inputs `(("bash-full" ,bash) + ("bindutils" ,isc-bind "utils") + ("coreutils" ,coreutils) + ("ctypes.sh" ,bash-ctypes) + ("curl" ,curl) + ("diffutils" ,diffutils) + ("ed" ,ed) + ("expect" ,expect) + ("find" ,findutils) + ("gawk" ,gawk) + ("grep" ,grep) + ("guile" ,guile-3.0) + ("guile-bash" ,guile-bash) + ("guile-daemon" ,guile-daemon) + ("inetutils" ,inetutils) + ("jq" ,jq) + ("libxml2-xpath0" ,libxml2-xpath0) + ("netcat" ,netcat) + ("nmap" ,nmap) + ("pcre/bin" ,pcre "bin") + ("perl" ,perl) + ("php" ,php) + ("prips" ,prips) + ("python" ,python) + ("python-elementpath" ,python-elementpath) + ("python-lxml" ,python-lxml) + ("python-netaddr" ,python-netaddr) + ("python-yq" ,python-yq) + ("sed" ,sed) + ("socat" ,socat) + ("util-linux" ,util-linux) + ("which" ,which) + ("xdg-utils" ,xdg-utils) + ("yad" ,yad))) + (arguments + `(#:modules ((guix build utils)) + #:builder + (begin + (use-modules (guix build utils)) + (let* ((bashfull (assoc-ref %build-inputs "bash-full")) + ;; 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 + "/share/guile/site/" ,guilever)) + ;; Some python libraries needs added to PYTHONPATH + (p-elementpath-lib (string-append + (assoc-ref %build-inputs "python-elementpath") + "/lib/python" ,pyver "/site-packages")) + (p-lxml-lib (string-append + (assoc-ref %build-inputs "python-lxml") + "/lib/python" ,pyver "/site-packages")) + (p-netaddr-lib (string-append + (assoc-ref %build-inputs "python-netaddr") + "/lib/python" ,pyver "/site-packages")) + (p-lib (string-append + (assoc-ref %build-inputs "python") + "/lib/python" ,pyver "/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"))) + (mkdir-p libexec) + (copy-recursively (assoc-ref %build-inputs "source") libexec) + ;; Create a bcu.sh wrapping script manually that ensures + ;; we prepend necessary PATHs. + (mkdir-p bin) + (let* ((binfile (string-append bin "/bcu.sh")) + (bcu-port (open-file binfile "a")) + (pathline (string-append + bashfull "/bin" + ":" (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"))) + (display (string-append "#!" bashfull "/bin/bash\n") bcu-port) + (display + (string-append + "[[ \"$_BCU_SH_LOADED\" == YES ]] || { \nexport PATH=\"" + pathline "${PATH:+:}${PATH}\"\nexport PYTHONPATH=\"" + pylibsline "${PYTHONPATH:+:}${PYTHONPATH}\"\nexport GUILE_LOAD_PATH=\"" + g-bash-lib "${GUILE_LOAD_PATH:+:}${GUILE_LOAD_PATH}\"\n" + ;; XDG_DATA_DIRS needs set for yad to load icons properly + "[[ -e /run/current-system/profile/share ]] && export XDG_DATA_DIRS=" + "/run/current-system/profile/share${XDG_DATA_DIRS:+:}${XDG_DATA_DIRS}\n" + ;; Ensure that the setuid version of ping is used + "[[ -e /run/setuid-programs/ping ]] && " + "ping(){ /run/setuid-programs/ping \"$@\" ; } && export -f ping\n" + "[[ -e /run/setuid-programs/ping6 ]] && " + "ping6(){ /run/setuid-programs/ping6 \"$@\" ; } && export -f ping6\n}\n") + bcu-port) + (display (string-append "source " libexec "/bcu.sh\n") bcu-port) + (close-port bcu-port) + (chmod binfile #o555) + (setenv "PATH" (string-append pathline ":" (getenv "PATH")))) + (for-each (lambda (file) + (substitute* file + (("~/\\.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")))) + (find-files out ".*\\.sh")) + (for-each (lambda (file) + (patch-shebang file)) + (find-files out ".*\\.(sh|scm|awk|php|py)$")) + ;; Setup PATH for tests + (setenv "PATH" (string-append bin ":" (getenv "PATH"))) + ;; Some tests need a HOME-directory + (setenv "HOME" "/tmp") + ;; Disable network tests, and all tests for setopts which + ;; don't work inside the Guix build environment + (call-with-output-file (string-append libexec "/disabled_tests.txt") + (lambda (port) + (display (string-append + "ip_of_test_1\nsetopts_test_1\nsetopts_test_2\nsetopts_test_3" + "\nsetopts_test_4\nsetopts_test_5\nsetopts_test_6\n") + port))) + (invoke (string-append libexec "/bcu-test.sh")))))) + (build-system trivial-build-system) + (synopsis "Bash functions and tools for software prototyping in Bash") + (description + (string-append + "Bash-bcu contains bash functions and wrappers that can be useful when" + " writing quick implementations of new programs. It helps you work with" + " JSON, XML, parallelization and installs some commonly used \"helper\"" + " programs used in Bash scripting. Just run @command{. bcu.sh}, type " + "@command{bcu__}, hit @command{TAB} to see available functions and give" + " any of them the @command{ --help} flag to see how to use it, or run " + "@command{bcu__docs} for the full html documentation.")) + (license license:gpl3)))) -- 2.31.0