From patchwork Fri Jul 1 18:13:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: david larsson X-Patchwork-Id: 3514 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 C91D427BBEA; Fri, 1 Jul 2022 19:16:22 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI,PDS_OTHER_BAD_TLD, SPF_HELO_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 4332727BBE9 for ; Fri, 1 Jul 2022 19:16:21 +0100 (BST) Received: from localhost ([::1]:34514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o7LBj-0008Jy-FQ for patchwork@mira.cbaines.net; Fri, 01 Jul 2022 14:16:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7L9W-0007js-KM for guix-patches@gnu.org; Fri, 01 Jul 2022 14:14:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:45248) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o7L9W-00044D-56 for guix-patches@gnu.org; Fri, 01 Jul 2022 14:14:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o7L9W-0002L4-1C for guix-patches@gnu.org; Fri, 01 Jul 2022 14:14:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#51512] [PATCH v 3]: gnu: Add bash-bcu. Resent-From: david larsson Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 01 Jul 2022 18:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51512 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51512@debbugs.gnu.org Cc: Guix-patches Received: via spool by 51512-submit@debbugs.gnu.org id=B51512.16566992298956 (code B ref 51512); Fri, 01 Jul 2022 18:14:01 +0000 Received: (at 51512) by debbugs.gnu.org; 1 Jul 2022 18:13:49 +0000 Received: from localhost ([127.0.0.1]:39144 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7L99-0002K9-5j for submit@debbugs.gnu.org; Fri, 01 Jul 2022 14:13:49 -0400 Received: from server0.selfhosted.xyz ([217.64.149.7]:52006) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7L95-0002Jv-WB for 51512@debbugs.gnu.org; Fri, 01 Jul 2022 14:13:37 -0400 Received: from server0.selfhosted.xyz (localhost [127.0.0.1]) by server0.selfhosted.xyz (Postfix) with ESMTP id 6496F2B1DADC; Fri, 1 Jul 2022 20:13:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=selfhosted.xyz; s=dkim; t=1656699210; bh=B9kUwOOkBrTZR1zE7aTIDZ8N2YwFZMcZkJoDpuSROVA=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=luUvJ1W9owOxoPOR1C4bqxcy39zf6+h07qzAcXbpM5WHcRVqIftrN78G7iWWj5Vij EvmdoWwNiW9pnzjm0jjOuUQBQh4M+u+SDHJOj6JJCS8l5GE0uAx0Qk0/dLvhTdHiPb TOs/gjAv+wUJZT6CKC7EEPqV7tW8f/JpnLlRS2dCx4QJMq6c34x7TctacHpGxJ1a+3 bBTc8Rg0haehuBbvKiwZCwkbRH/2vDFlv0dn2H8CxmTHznkarYWtXppLPaQG+wkagL zQQkA2GamcHxhinT+nhAjeVykQ0KjmQZH4xcSbjU3O2g/IiXszU0KZmKNzKptoenkF +Sll0DbW6gT+Q== X-Fuglu-Suspect: 88240862de7b4c2cb5dd2cb75fd0c804 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; Fri, 1 Jul 2022 20:13:22 +0200 (CEST) MIME-Version: 1.0 Date: Fri, 01 Jul 2022 20:13:22 +0200 From: david larsson In-Reply-To: <93d8232c104dc63f46f6b975073b56ca@selfhosted.xyz> References: <3add15b77522d6e9ebd715a19d966666@selfhosted.xyz> <87r1bsqdy8.fsf@nckx> <93d8232c104dc63f46f6b975073b56ca@selfhosted.xyz> Message-ID: <482320c017a2ab923b040cb83746e563@selfhosted.xyz> X-Sender: david.larsson@selfhosted.xyz X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Mailman-Approved-At: Fri, 01 Jul 2022 14:16:05 -0400 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 New version based on prior reviews and off-list (IRC) communication. Best regards, David L From afcf99849048cf31384d9efcce99f2a4815346d6 Mon Sep 17 00:00:00 2001 From: David Larsson Date: Wed, 29 Jun 2022 23:35:50 +0200 Subject: [PATCH] gnu: Add bash-coding-utils * gnu/packages/bash.scm (guile-bash-for-bash-coding-utils, org-html-themes/methuselah-0, pydaemon, bash-coding-utils): New variables. * gnu/packages/patches/guile-bash-args-from-stdin.patch: New file. * gnu/local.mk: Register patch. --- gnu/local.mk | 1 + gnu/packages/bash.scm | 466 +++++++++++++++++- .../patches/guile-bash-args-from-stdin.patch | 42 ++ 3 files changed, 504 insertions(+), 5 deletions(-) create mode 100644 gnu/packages/patches/guile-bash-args-from-stdin.patch diff --git a/gnu/local.mk b/gnu/local.mk index 353b91cfd2..b9ff9a3784 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1229,6 +1229,7 @@ dist_patch_DATA = \ %D%/packages/patches/guile-1.8-cpp-4.5.patch \ %D%/packages/patches/guile-2.2-skip-oom-test.patch \ %D%/packages/patches/guile-2.2-skip-so-test.patch \ + %D%/packages/patches/guile-bash-args-from-stdin.patch \ %D%/packages/patches/guile-default-utf8.patch \ %D%/packages/patches/guile-2.2-default-utf8.patch \ %D%/packages/patches/guile-relocatable.patch \ diff --git a/gnu/packages/bash.scm b/gnu/packages/bash.scm index 72758560cd..f058793160 100644 --- a/gnu/packages/bash.scm +++ b/gnu/packages/bash.scm @@ -26,17 +26,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 bison) #:use-module (gnu packages bootstrap) #:use-module (gnu packages compression) + #:use-module (gnu packages curl) + #:use-module (gnu packages dns) #:use-module (gnu packages elf) - #:use-module (gnu packages ncurses) - #:use-module (gnu packages readline) - #:use-module (gnu packages bison) + #:use-module (gnu packages file) + #:use-module (gnu packages freedesktop) + #:use-module (gnu packages gawk) + #:use-module (gnu packages gtk) + #:use-module (gnu packages guile) + #:use-module (gnu packages guile-xyz) #:use-module (gnu packages linux) #:use-module (gnu packages libffi) + #:use-module (gnu packages lsof) + #:use-module (gnu packages ncurses) + #:use-module (gnu packages networking) + #: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 guile) + #:use-module (gnu packages python) + #:use-module (gnu packages python-xyz) + #:use-module (gnu packages readline) + #:use-module (gnu packages web) + #:use-module (gnu packages xml) #:use-module (guix packages) #:use-module (guix download) #:use-module (guix git-download) @@ -45,7 +62,8 @@ (define-module (gnu packages bash) #:use-module (guix monads) #:use-module (guix store) #:use-module (guix build-system gnu) - #:use-module (guix build-system trivial) + #:use-module (guix build-system copy) + #:use-module (guix build-system trivial) #:autoload (guix gnupg) (gnupg-verify*) #:autoload (guix base32) (bytevector->nix-base32-string) @@ -456,3 +474,441 @@ (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 guile-bash-for-bash-coding-utils + (let ((commit "1eabc563ca5692b3e08d84f1f0e6fd2283284469") + (revision "0")) + (package + (inherit guile2.0-bash) + (version (string-append "0.1.6-" revision "." (string-take commit 7))) + (home-page (package-home-page guile2.0-bash)) + (name "guile-bash-for-bash-coding-utils") + (source (origin + (method git-fetch) + (uri (git-reference + (commit commit) + (url home-page))) + (sha256 + (base32 + "097vny990wp2qpjij6a5a5gwc6fxzg5wk56inhy18iki5v6pif1p")) + (file-name (string-append name "-" version "-checkout")) + (patches (search-patches "guile-bash-args-from-stdin.patch")))) + (inputs + `(("guile" ,guile-3.0-latest) + ,@(assoc-remove! (package-inputs guile2.0-bash) "guile"))) + (propagated-inputs (list bash)) + (arguments + `(#:tests? #f + #:phases (modify-phases %standard-phases + (add-after 'install 'install-guile + (lambda* (#:key inputs outputs #:allow-other-keys) + (copy-recursively + (string-append (assoc-ref outputs "out") + (assoc-ref inputs "guile") "/share") + (string-append (assoc-ref outputs "out") "/share")) + #t))) + ,@(package-arguments guile2.0-bash)))))) + +(define org-html-themes/methuselah-0 + ;; XXX Bundles jquery and several other .js ‘libraries’ — problem? + ;; XXX A form of https://github.com/fniessen/org-html-themes but not + ;; drop-in compatible (using that would break the BCU docs). + ;; ‘Ideally’ we'd re-render them but uugh. + (let ((commit "8fff1d4c0879537b81f94d157a8c36485c790ee5") + (revision "0")) + (package + (name "org-html-themes") + (version (git-version "0.0.0" revision commit)) + (source + (origin + (method git-fetch) + (uri (git-reference + (commit commit) + (url "https://gitlab.com/methuselah-0/org-html-themes.git"))) + (file-name (git-file-name name version)) + (sha256 + (base32 "1hddgfdry8r65a5zqm1pc0rgicv78ls6giavfr5g0rzx428i1j45")))) + (build-system copy-build-system) + (home-page "https://github.com/fniessen/org-html-themes") ; XXX + (synopsis "Export Org mode files to HTML") + (description + "The Org-HMTL framework provides cross-browser themes for exporting Org +documents to cross-browser HTML mark-up.") + (license license:cc-by-sa3.0)))) + +(define-public pydaemon + (let ((commit "dae2798a2c1caa56025c6da69c0d464f70d9c79a") + (revision "0")) + (package + (name "pydaemon") + (version (git-version "0.0.0" revision commit)) + (source + (origin + (method git-fetch) + (uri (git-reference + (commit commit) + (url "https://gitlab.com/methuselah-0/pydaemon.git"))) + (file-name (git-file-name name version)) + (sha256 + (base32 "1cbg48ljyjqw1vxcb0sqhg9cxx0vgs6ggsdg8yvj441s6gakp2sh")))) + (build-system trivial-build-system) + + (inputs (list coreutils netcat python socat util-linux)) + (arguments + (list #:modules '((guix build utils)) + #:builder + #~(begin + (use-modules (guix build utils)) + (with-directory-excursion #$(package-source this-package) + (mkdir-p (string-append (assoc-ref %outputs "out") "/bin")) + (copy-file "pydaemon.py" + (string-append (assoc-ref %outputs "out") "/bin/pydaemon.py")) + (copy-file "py-net-daemon.py" + (string-append (assoc-ref %outputs "out") "/bin/py-net-daemon.py")) + (copy-file "pydaemon.sh" + (string-append (assoc-ref %outputs "out") "/bin/pydaemon.sh")) + + (substitute* (find-files (string-append #$output "/bin") "\\.sh$") + (("(flock) " library _) + (string-append #$(this-package-input "util-linux") "/bin/" library)) + (("(socat) " library _) + (string-append #$(this-package-input "socat") "/bin/" library)) + (("(nc) " library _) + (string-append #$(this-package-input "netcat") "/bin/" library)) + (("( )(mkdir|cat|sleep|chown|id|kill|dirname) " all pre command _) + (string-append pre #$(this-package-input "coreutils") "/bin/" command " ")) + (("(\\()(mkdir|cat|sleep|chown|id|kill|dirname) " all pre command _) + (string-append pre #$(this-package-input "coreutils") "/bin/" command " ")) + (("(python3) " library _) + (string-append #$(file-append (this-package-input "python") + "/bin/python" + (version-major+minor + (package-version + (this-package-input + "python")))) + " "))))))) + (home-page "https://gitlab.com/methuselah-0/pydaemon") + (synopsis "Use python from bash") + (description "With pydaemon you can pipe strings of python code to one +or multiple persistent python processes that keeps state, and get the results +back as strings. Can be used over either of a unix or tcp socket.") + (license license:cc-by-sa3.0)))) + +(define-public bash-coding-utils + (let ((commit "ce9e7a8910d7debe29a07b48aa0770913b1ecdaf") + (revision "0")) + (package + (name "bash-coding-utils") + (version (git-version "0.3.0" revision commit)) + (source + (origin + (method git-fetch) + (uri + (git-reference + (commit commit) + (url "https://git.sr.ht/~methuselah-0/bash-coding-utils") + (recursive? #t)) ) + (sha256 + (base32 "0hgj0fy66bj5kbjs02fvjp5n9a5sz32fk45rc3id2bs0b2k9jrnx")) + (file-name (git-file-name name version)))) + (build-system trivial-build-system) + (arguments + (list #:modules '((guix build utils)) + #:builder + #~(begin + (use-modules (guix build utils) + (ice-9 ftw) + (ice-9 match) + (srfi srfi-26)) + (let* ((bash #$(this-package-input "bash")) + (bin (string-append #$output "/bin")) + (bcu.sh (string-append bin "/bcu.sh")) + (share (string-append #$output "/share")) + (doc (string-append share "/doc/" #$name)) + ;; Everything but bcu.sh itself is only ever accessed + ;; internally by bcu, so put it all in share/. + (bcu-root (string-append share "/bcu")) + ;; XXX We should honour the without-tests transformation! + (tests? (not #$(%current-target-system)))) + + ;; Copy the ‘source’ and submodules directly to the output. + (let ((source #$(package-source this-package))) + (with-directory-excursion source + (mkdir-p bcu-root) + (for-each (lambda (file) + (copy-recursively file + (string-append bcu-root + "/" file))) + (list "bcu.sh" + "dependency_paths.sh" + "bcu-test.sh" + "docs" + "src" + "submodules")) + ;; Moving docs/ out of bcu-root would break symlinks. + (mkdir-p (dirname doc)) + (symlink (string-append bcu-root "/docs") doc))) + + ;; Patch absolute file name references. + (let* ((original-path (getenv "PATH")) + (shebang-inputs '(#$@(map (lambda (name) + (this-package-input name)) + '("guile" + "python")))) + (shebang-path (string-join + (map (cut string-append <> "/bin") + (cons bash shebang-inputs)) + ":"))) + (setenv "PATH" shebang-path) + (for-each patch-shebang + (find-files #$output "\\.(sh|scm|py)$")) + (setenv "PATH" original-path)) + + ;; Add paths to dependencies - defined in + ;; dependency_paths.sh, except the libguile-bash.so + ;; file. + (substitute* (find-files #$output "\\.sh$") + (("[^ ]*(/lib/bash/libguile-bash\\.so)" _ library) + (string-append + #$(this-package-input "guile-bash-for-bash-coding-utils") + library))) + + ;; TODO: use a PCRE regex to substitute invocations of coreutils + ;; commands + ;; TODO: condense below substitutions? + (substitute* (find-files #$output "dependency_paths\\.sh$") + (("export BCUCTYPES=(ctypes.sh)" _ library) + (string-append "export BCUCTYPES=" + #$(this-package-input "bash-ctypes") + "/bin/" library)) + (("export BCUDIFF=(diff)" _ library) + (string-append "export BCUDIFF=" + #$(this-package-input "diffutils") + "/bin/" library)) + (("export BCUPING=(ping)" _ library) + (string-append "export BCUPING=/run/setuid-programs/ping")) + (("export BCUPS=(ps)" _ library) + (string-append "export BCUPS=" + #$(this-package-input "procps") + "/bin/" library)) + (("export BCUFILE=(file)" _ library) + (string-append "export BCUFILE=" + #$(this-package-input "findutils") + "/bin/" library)) + (("export BCUFIND=(find)" _ library) + (string-append "export BCUFIND=" + #$(this-package-input "findutils") + "/bin/" library)) + (("export BCUFLOCK=(flock)" _ library) + (string-append "export BCUFLOCK=" + #$(this-package-input "util-linux") + "/bin/" library)) + (("export BCUGAWK=(gawk)" _ library) + (string-append "export BCUGAWK=" + #$(this-package-input "gawk") + "/bin/" library)) + (("export BCUGREP=(grep)" _ library) + (string-append "export BCUGREP=" + #$(this-package-input "grep") + "/bin/" library)) + (("export GUILE_LOAD_PATH=(.*)$") + (string-append "export GUILE_LOAD_PATH=\"" + (string-join + '(#$@(map (lambda (name) + (file-append (this-package-input name) + "/share/guile/site/" + (version-major+minor + (package-version + (this-package-input + "guile"))))) + '("guile-bash-for-bash-coding-utils"))) + ":") + "${GUILE_LOAD_PATH:+:}${GUILE_LOAD_PATH}\"\n")) + (("export BCUJQ=(jq)" _ library) + (string-append "export BCUJQ=" + #$(this-package-input "jq") + "/bin/" library)) + (("export BCULSOF=(lsof)" _ library) + (string-append "export BCULSOF=" + #$(this-package-input "lsof") + "/bin/" library)) + (("export BCUNMAP=(nmap)" _ library) + (string-append "export BCUNMAP=" + #$(this-package-input "nmap") + "/bin/" library)) + (("export BCUPCREGREP=(pcregrep)" _ library) + (string-append "export BCUPCREGREP=" + (assoc-ref %build-inputs "pcre:bin") + "/bin/" library)) + (("export BCUPERL=(perl)" _ library) + (string-append "export BCUPERL=" + #$(this-package-input "perl") + "/bin/" library)) + (("export BCUPHP=(php)" _ library) + (string-append "export BCUPHP=" + #$(this-package-input "php") + "/bin/" library)) + (("export BCUPS=(ps)" _ library) + (string-append "export BCUPS=" + #$(this-package-input "procps") + "/bin/" library)) + (("export BCUPYDAEMON=(pydaemon.sh)" _ library) + (string-append "export BCUPYDAEMON=" + #$(this-package-input "pydaemon") + "/bin/" library)) + (("export BCUPYTHONVERSION=(.*)$" _) + (string-append "export BCUPYTHONVERSION=" + #$(version-major+minor + (package-version + (this-package-input + "python"))))) + (("export BCUPYTHON=python(.*)$" _) + (string-append "export BCUPYTHON=" + #$(file-append (this-package-input "python") + "/bin/python" + (version-major+minor + (package-version + (this-package-input + "python")))) + "\n")) + (("export PYTHONPATH=.*" all) + (string-append "export PYTHONPATH=\"" + (string-join + '(#$@(map (lambda (name) + (file-append (this-package-input name) + "/lib/python" + (version-major+minor + (package-version + (this-package-input + "python"))) + "/site-packages")) + '("python" + "python-elementpath" + "python-lxml" + "python-netaddr"))) + ":") + "${PYTHONPATH:+:}${PYTHONPATH}\"\n")) + (("export BCUSED=(sed)" _ library) + (string-append "export BCUSED=" + #$(this-package-input "sed") + "/bin/" library)) + (("export BCUSOCAT=(socat)" _ library) + (string-append "export BCUSOCAT=" + #$(this-package-input "socat") + "/bin/" library)) + (("export BCUTREE=(tree)" _ library) + (string-append "export BCUTREE=" + #$(this-package-input "tree") + "/bin/" library)) + (("export BCUWHICH=(which)" _ library) + (string-append "export BCUWHICH=" + #$(this-package-input "which") + "/bin/" library)) + (("export XDG_DATA_DIRS=(.*)$") + (string-append + "[[ -e /run/current-system/profile/share ]] && " + "export XDG_DATA_DIRS=" + "/run/current-system/profile/share" + "${XDG_DATA_DIRS:+:}${XDG_DATA_DIRS}\n")) + (("export BCUXARGS=(xargs)" _ library) + (string-append "export BCUXARGS=" + #$(this-package-input "findutils") + "/bin/" library)) + (("export BCUXDGOPEN=(xdg-open)" _ library) + (string-append "export BCUXDGOPEN=" + #$(this-package-input "xdg-utils") + "/bin/" library)) + (("export BCUXMLLINT=(xmllint)" _ library) + (string-append "export BCUXMLLINT=" + #$(this-package-input "libxml2-xpath0") + "/bin/" library))) + + ;; Symlink to bcu.sh from the output bin directory. + (mkdir-p bin) + (symlink (string-append bcu-root "/bcu.sh") bcu.sh) + (chmod bcu.sh #o555) + + ;; Disable network and gui tests, and one test for setopts which + ;; doesn't work inside the Guix build environment. + (with-output-to-file (string-append bcu-root "/disabled_tests.txt") + (lambda _ + (format #t "~{~a~%~}" + (list "ip_of_test_1" + "setopts_test_4" + "web_media_server_test_1" + "web_api_server_test_1" + "find_gui_test_1")))) + + ;; Set up a minimal test environment & run the tests. + (when tests? + (setenv "PATH" (string-append bin ":" + bash "/bin:" + (getenv "PATH"))) + (setenv "SHELL" + (string-append bash "/bin/bash")) + (for-each (lambda (test-input) + (setenv "PATH" + (string-append + (assoc-ref %build-inputs test-input) + "/bin:" (getenv "PATH")))) + (list "coreutils")) + (setenv "HOME" "/tmp") + (with-directory-excursion bcu-root + (invoke "./bcu-test.sh") + ;; No need to keep passed tests in the final output + (for-each delete-file + (list "bcu-test.sh" + "disabled_tests.txt")))))))) + (native-inputs + `( ;; org-html-themes is bundled upstream as a git submodule, + ;; but we package it separately and copy it manually above. + ("org-html-themes" ,(package-source org-html-themes/methuselah-0)) + ("coreutils" ,coreutils) ;; Needed for tests. + ;; TODO: unable to get the correct hash for pcre:bin output using + ;; the new notation (see inputs list below) + ("pcre:bin" ,pcre "bin"))) + (inputs (list bash + bash-ctypes + coreutils + diffutils + file + findutils + gawk + grep + guile-3.0 + guile-bash-for-bash-coding-utils + jq + libxml2-xpath0 + lsof + nmap + ;;`(,pcre "bin") ;; TODO doesn't work when calling + ;; #$(this-package-input pcre)! + perl + php + procps + pydaemon + python + python-elementpath + python-lxml + python-netaddr + python-yq + sed + socat + tree + which + xdg-utils + util-linux)) + (propagated-inputs + `(("bash" ,bash))) ;; the bash shell needs to be the same version + ;;as guile-bash is compiled against + (home-page "https://git.sr.ht/~methuselah-0/bash-coding-utils") + (synopsis "Functions and tools for software prototyping in Bash") + (description + "Bash-Coding-Utils is a library of Bash functions and wrappers that can +be useful when writing quick implementations of new programs. It helps you +work with JSON, XML, API's and parallelization, and installs some helper +programs commonly 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 documentation.") + (license license:gpl3)))) diff --git a/gnu/packages/patches/guile-bash-args-from-stdin.patch b/gnu/packages/patches/guile-bash-args-from-stdin.patch new file mode 100644 index 0000000000..ad42616c70 --- /dev/null +++ b/gnu/packages/patches/guile-bash-args-from-stdin.patch @@ -0,0 +1,42 @@ +From a124921666a16cb4e93f59a653f98b99c78eb2ca Mon Sep 17 00:00:00 2001 +From: David Larsson +Date: Thu, 11 Nov 2021 14:07:04 +0100 +Subject: [PATCH] Enable reading arguments from bash via stdin + +* lisp/gnu/bash.scm(define-bash-function): read from stdin +to SCM_ARGS array when it is open, and separate args by null +instead of newline if -z option is passed as $1. +--- + lisp/gnu/bash.scm | 16 ++++++++++++---- + 1 file changed, 12 insertions(+), 4 deletions(-) + +diff --git a/lisp/gnu/bash.scm b/lisp/gnu/bash.scm +index 199ebc0..e9dcea5 100644 +--- a/lisp/gnu/bash.scm ++++ b/lisp/gnu/bash.scm +@@ -326,10 +326,18 @@ + (hashq-set! *funcs* symbol thunk) + (unsafe-format/eval + "function ~a { +- SCM_ARGS=($@) ; +- local retval=$~a ; +- unset SCM_ARGS ; +- return $retval ; ++ local -a Input SCM_ARGS ; ++ [[ ! -t 0 ]] && mapfile -d '' Input ; ++ if [[ -n \"${Input[@]}\" ]]; then ++ if [[ \"$1\" == -z ]]; then ++ local -a SCM_ARGS=\"(${Input[*]@Q})\" ; ++ else ++ mapfile -t SCM_ARGS < <(printf '%s' \"${Input[@]}\"); fi ; ++ else ++ SCM_ARGS=(\"$@\"); fi ; ++ local retval=$~a ; ++ unset SCM_ARGS ; ++ return $retval ; + }" + symbol special-varname)))) + +-- +2.31.0 + -- 2.33.1 From patchwork Tue May 23 04:55:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: david larsson X-Patchwork-Id: 13245 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 EB44827BBEA; Tue, 23 May 2023 05:56:27 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI,PDS_OTHER_BAD_TLD, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 204E027BBE2 for ; Tue, 23 May 2023 05:56:26 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q1K46-0007AT-NW; Tue, 23 May 2023 00:56:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1K42-000784-96 for guix-patches@gnu.org; Tue, 23 May 2023 00:56:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q1K42-0005gf-1G for guix-patches@gnu.org; Tue, 23 May 2023 00:56:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q1K41-0006h3-TP for guix-patches@gnu.org; Tue, 23 May 2023 00:56:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#51512] [PATCH v6 2/3]: gnu: Add guile-bash-for-bash-coding-utils Resent-From: david larsson Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 23 May 2023 04:56:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51512 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51512@debbugs.gnu.org Cc: Guix-patches Received: via spool by 51512-submit@debbugs.gnu.org id=B51512.168481773725587 (code B ref 51512); Tue, 23 May 2023 04:56:01 +0000 Received: (at 51512) by debbugs.gnu.org; 23 May 2023 04:55:37 +0000 Received: from localhost ([127.0.0.1]:37859 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1K3c-0006eW-Ft for submit@debbugs.gnu.org; Tue, 23 May 2023 00:55:37 -0400 Received: from server0.selfhosted.xyz ([217.64.149.7]:57360) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1K3a-0006da-AH for 51512@debbugs.gnu.org; Tue, 23 May 2023 00:55:35 -0400 Received: from server0.selfhosted.xyz (localhost [127.0.0.1]) by server0.selfhosted.xyz (Postfix) with ESMTP id A07C830F86C8; Tue, 23 May 2023 06:55:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=selfhosted.xyz; s=dkim; t=1684817728; bh=TqaoM/wXK5PVSZghVaLfAwBJYDKNb+CxnGiowDbWRfE=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=A7lb0pg4zfLS9DI3DIVE1qM2xUiCnj37deaEbwD14NhXrvuzJzJLFSuwVQz0MKP48 50KaRaoiJxUqobxfjTvSP3ovXH2/DorsXhBUfQ5G1mEspzY1L0e6o/dIdbeRQrtd2Y s2ihbsCGwrCognmWuXZHZmRAKbTRqFu7Pz61+momLdxIk1WYxWOVYSQajDAWDe83DK 1dXHKAfKa6aRJBuvfINloQ88qb+ir2WmIEgTpCCnQufoOduXr+QpYkuBNWaNtxWw5J k/7W9tYlXaRf7n6tkfzX0k5aW2JoixxhPZW0BaOtqZDBgDHKn6nIr0lbvBjPLimnVp BV/fEEmYuEULg== X-Fuglu-Suspect: d4af105c0b03435dbedbbfbe74ffab31 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; Tue, 23 May 2023 06:55:22 +0200 (CEST) MIME-Version: 1.0 Date: Tue, 23 May 2023 06:55:22 +0200 From: david larsson In-Reply-To: <3add15b77522d6e9ebd715a19d966666@selfhosted.xyz> References: <3add15b77522d6e9ebd715a19d966666@selfhosted.xyz> Message-ID: X-Sender: david.larsson@selfhosted.xyz 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-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches From 7f2df5fd5b6ec44170b44ac74cae554405d939b6 Mon Sep 17 00:00:00 2001 From: David Larsson Date: Tue, 23 May 2023 05:38:36 +0200 Subject: [PATCH 2/3] gnu: Add guile-bash-for-bash-coding-utils * gnu/packages/bash.scm (guile-bash-for-bash-coding-utils): New variable. --- gnu/local.mk | 1 + gnu/packages/bash.scm | 34 +++++++++++++++ .../patches/guile-bash-args-from-stdin.patch | 42 +++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 gnu/packages/patches/guile-bash-args-from-stdin.patch ++ return $retval ; + }" + symbol special-varname)))) + +-- +2.31.0 + -- 2.39.1 From 7f2df5fd5b6ec44170b44ac74cae554405d939b6 Mon Sep 17 00:00:00 2001 From: David Larsson Date: Tue, 23 May 2023 05:38:36 +0200 Subject: [PATCH 2/3] gnu: Add guile-bash-for-bash-coding-utils * gnu/packages/bash.scm (guile-bash-for-bash-coding-utils): New variable. --- gnu/local.mk | 1 + gnu/packages/bash.scm | 34 +++++++++++++++ .../patches/guile-bash-args-from-stdin.patch | 42 +++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 gnu/packages/patches/guile-bash-args-from-stdin.patch diff --git a/gnu/local.mk b/gnu/local.mk index c10fb01bb3..1db38d093c 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1302,6 +1302,7 @@ dist_patch_DATA = \ %D%/packages/patches/guile-1.8-cpp-4.5.patch \ %D%/packages/patches/guile-2.2-skip-oom-test.patch \ %D%/packages/patches/guile-2.2-skip-so-test.patch \ + %D%/packages/patches/guile-bash-args-from-stdin.patch \ %D%/packages/patches/guile-default-utf8.patch \ %D%/packages/patches/guile-2.2-default-utf8.patch \ %D%/packages/patches/guile-relocatable.patch \ diff --git a/gnu/packages/bash.scm b/gnu/packages/bash.scm index 1650fdeb72..64d6e8d65e 100644 --- a/gnu/packages/bash.scm +++ b/gnu/packages/bash.scm @@ -40,6 +40,7 @@ (define-module (gnu packages bash) #:use-module (gnu packages pkg-config) #:use-module (gnu packages python) #:use-module (gnu packages guile) + #:use-module (gnu packages guile-xyz) #:use-module (gnu packages version-control) #:use-module (gnu packages less) #:use-module (guix packages) @@ -540,3 +541,36 @@ (define-public pydaemon back as strings. Can be used over either of a unix or tcp socket.") (home-page "https://gitlab.com/methuselah-0/pydaemon") (license license:gpl3)))) + +(define-public guile-bash-for-bash-coding-utils + (let ((commit "1eabc563ca5692b3e08d84f1f0e6fd2283284469") + (revision "0")) + (package + (inherit guile2.0-bash) + (version (string-append "0.1.6-" revision "." (string-take commit 7))) + (name "guile-bash-for-bash-coding-utils") + (home-page (package-home-page guile2.0-bash)) + (source (origin + (method git-fetch) + (uri (git-reference + (commit commit) + (url home-page))) + (sha256 + (base32 + "097vny990wp2qpjij6a5a5gwc6fxzg5wk56inhy18iki5v6pif1p")) + (file-name (string-append name "-" version "-checkout")) + (patches (search-patches "guile-bash-args-from-stdin.patch")))) + (arguments (substitute-keyword-arguments (package-arguments guile2.0-bash) + ((#:tests? _ #f) #f) + ((#:phases phases #~%standard-phases) + #~(modify-phases #$phases + (add-after 'install 'install-guile + (lambda* (#:key inputs outputs #:allow-other-keys) + (copy-recursively + (string-append (assoc-ref outputs "out") + (assoc-ref inputs "guile") "/share") + (string-append (assoc-ref outputs "out") "/share")) + #t)))))) + (inputs (modify-inputs (package-inputs guile2.0-bash) + (replace "guile" guile-3.0-latest))) + (propagated-inputs (list bash))))) diff --git a/gnu/packages/patches/guile-bash-args-from-stdin.patch b/gnu/packages/patches/guile-bash-args-from-stdin.patch new file mode 100644 index 0000000000..ad42616c70 --- /dev/null +++ b/gnu/packages/patches/guile-bash-args-from-stdin.patch @@ -0,0 +1,42 @@ +From a124921666a16cb4e93f59a653f98b99c78eb2ca Mon Sep 17 00:00:00 2001 +From: David Larsson +Date: Thu, 11 Nov 2021 14:07:04 +0100 +Subject: [PATCH] Enable reading arguments from bash via stdin + +* lisp/gnu/bash.scm(define-bash-function): read from stdin +to SCM_ARGS array when it is open, and separate args by null +instead of newline if -z option is passed as $1. +--- + lisp/gnu/bash.scm | 16 ++++++++++++---- + 1 file changed, 12 insertions(+), 4 deletions(-) + +diff --git a/lisp/gnu/bash.scm b/lisp/gnu/bash.scm +index 199ebc0..e9dcea5 100644 +--- a/lisp/gnu/bash.scm ++++ b/lisp/gnu/bash.scm +@@ -326,10 +326,18 @@ + (hashq-set! *funcs* symbol thunk) + (unsafe-format/eval + "function ~a { +- SCM_ARGS=($@) ; +- local retval=$~a ; +- unset SCM_ARGS ; +- return $retval ; ++ local -a Input SCM_ARGS ; ++ [[ ! -t 0 ]] && mapfile -d '' Input ; ++ if [[ -n \"${Input[@]}\" ]]; then ++ if [[ \"$1\" == -z ]]; then ++ local -a SCM_ARGS=\"(${Input[*]@Q})\" ; ++ else ++ mapfile -t SCM_ARGS < <(printf '%s' \"${Input[@]}\"); fi ; ++ else ++ SCM_ARGS=(\"$@\"); fi ; ++ local retval=$~a ; ++ unset SCM_ARGS ; ++ return $retval ; + }" + symbol special-varname)))) + +-- +2.31.0 + -- 2.39.1 From patchwork Tue May 23 04:56:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: david larsson X-Patchwork-Id: 13246 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 9DF7927BBE9; Tue, 23 May 2023 05:57:18 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI,PDS_OTHER_BAD_TLD, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id D43F227BBE2 for ; Tue, 23 May 2023 05:57:15 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q1K54-0007Hx-EW; Tue, 23 May 2023 00:57:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1K53-0007Hp-0A for guix-patches@gnu.org; Tue, 23 May 2023 00:57:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q1K50-0005tT-Aj for guix-patches@gnu.org; Tue, 23 May 2023 00:57:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q1K50-0006jG-7k for guix-patches@gnu.org; Tue, 23 May 2023 00:57:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#51512] [PATCH v6 3/3]: gnu: Add bash-coding-utils Resent-From: david larsson Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 23 May 2023 04:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51512 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51512@debbugs.gnu.org Cc: Guix-patches Received: via spool by 51512-submit@debbugs.gnu.org id=B51512.168481780425827 (code B ref 51512); Tue, 23 May 2023 04:57:02 +0000 Received: (at 51512) by debbugs.gnu.org; 23 May 2023 04:56:44 +0000 Received: from localhost ([127.0.0.1]:37870 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1K4g-0006iR-NV for submit@debbugs.gnu.org; Tue, 23 May 2023 00:56:44 -0400 Received: from server0.selfhosted.xyz ([217.64.149.7]:57640) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1K4c-0006i7-HO for 51512@debbugs.gnu.org; Tue, 23 May 2023 00:56:41 -0400 Received: from server0.selfhosted.xyz (localhost [127.0.0.1]) by server0.selfhosted.xyz (Postfix) with ESMTP id 0FBFF30F86DE; Tue, 23 May 2023 06:56:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=selfhosted.xyz; s=dkim; t=1684817792; bh=Lp1b9iIpv7NQ09lybMzkB6obGjH9ELpq/OG7FhTFPPs=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=jTGbzi7g4TR3m0qi4/1PbrA5VfV9VXollZHc92fRHACL4USFP4npvTcwycLHLaAhq 7vkUWx86avwE5ZSABVHXVMngb9lmijhnNb7aZLNy2XF8DcVSDwCHEDmUHJ/+EjUooy gv0Oqt+MNJkrwKeW11Y14zfgsWPm108+LpG8Ru/VpRvzCIeVjmmQ4lM0/h07K1RC0b +4eyLlveEwefJJaXu8rotdddzR4UzzjEKVznWbgSbTYQC9lWL9jA/16+0HCPUsnolv cZaXiacukwjQYjuVdXwbVjQyVxacUS+dlZ06mVY3KCO3mfzfm9HWUXPB8yzb0ujmau r5SbwKih7sEQw== X-Fuglu-Suspect: 415de0b5342a422a9ec5bd04b1a38baf 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; Tue, 23 May 2023 06:56:25 +0200 (CEST) MIME-Version: 1.0 Date: Tue, 23 May 2023 06:56:25 +0200 From: david larsson In-Reply-To: <3add15b77522d6e9ebd715a19d966666@selfhosted.xyz> References: <3add15b77522d6e9ebd715a19d966666@selfhosted.xyz> Message-ID: X-Sender: david.larsson@selfhosted.xyz 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-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches From bb7ab11b11058d609a89cad164308b5b52ebadca Mon Sep 17 00:00:00 2001 From: David Larsson Date: Tue, 23 May 2023 06:42:03 +0200 Subject: [PATCH 3/3] gnu: Add bash-coding-utils * gnu/packages/bash.scm (bash-coding-utils) (org-html-themes/methuselah-0): new variables. --- gnu/packages/bash.scm | 260 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 260 insertions(+) "/disabled_tests.txt") + (lambda _ + (format #t "~{~a~%~}" + (list "ip_of_test_1" + "setopts_test_4" + "web_media_server_test_1" + "web_api_server_test_1" + "find_gui_test_1")))) + + ;; Set up a minimal test environment & run the tests. + (when tests? + (setenv "PATH" (string-append bin ":" + bash "/bin:" + (getenv "PATH"))) + (setenv "SHELL" + (string-append bash "/bin/bash")) + (for-each (lambda (test-input) + (setenv "PATH" + (string-append + (assoc-ref %build-inputs test-input) + "/bin:" (getenv "PATH")))) + (list "coreutils")) + (setenv "HOME" "/tmp") + (with-directory-excursion bcu-root + (invoke "./bcu-test.sh") + ;; No need to keep passed tests in the final output + (for-each delete-file + (list "bcu-test.sh" + "disabled_tests.txt")))))))) + (inputs (list bash bash-ctypes coreutils + diffutils file findutils + gawk guile-3.0 guile-bash-for-bash-coding-utils + jq libxml2-xpath0 + lsof + nmap + ;; org-html-themes is bundled upstream as a git submodule, + ;; but we package it separately and copy it manually above. + org-html-themes/methuselah-0 + pcre2 perl php + procps + pydaemon python python-elementpath python-lxml + python-netaddr python-yq + sed + socat + tree ugrep util-linux which + xdg-utils )) + ;; the bash shell needs to be the same version + ;; as guile-bash is compiled against + (propagated-inputs (list bash)) + (home-page "https://git.sr.ht/~methuselah-0/bash-coding-utils") + (synopsis "Functions and tools for software prototyping in Bash") + (description + "Bash-Coding-Utils is a library of Bash functions and wrappers that can +be useful when writing quick implementations of new programs. It helps you +work with JSON, XML, API's and parallelization, and installs some helper +programs commonly 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 documentation.") + (license license:gpl3)))) -- 2.39.1 From bb7ab11b11058d609a89cad164308b5b52ebadca Mon Sep 17 00:00:00 2001 From: David Larsson Date: Tue, 23 May 2023 06:42:03 +0200 Subject: [PATCH 3/3] gnu: Add bash-coding-utils * gnu/packages/bash.scm (bash-coding-utils) (org-html-themes/methuselah-0): new variables. --- gnu/packages/bash.scm | 260 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 260 insertions(+) diff --git a/gnu/packages/bash.scm b/gnu/packages/bash.scm index 64d6e8d65e..986ec68b3f 100644 --- a/gnu/packages/bash.scm +++ b/gnu/packages/bash.scm @@ -31,17 +31,28 @@ (define-module (gnu packages bash) #:use-module (gnu packages bootstrap) #:use-module (gnu packages compression) #:use-module (gnu packages elf) + #:use-module (gnu packages file) + #:use-module (gnu packages freedesktop) + #:use-module (gnu packages gawk) #: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 lsof) + #: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 search) #:use-module (gnu packages version-control) + #:use-module (gnu packages web) + #:use-module (gnu packages xml) #:use-module (gnu packages less) #:use-module (guix packages) #:use-module (guix download) @@ -574,3 +585,252 @@ (define-public guile-bash-for-bash-coding-utils (inputs (modify-inputs (package-inputs guile2.0-bash) (replace "guile" guile-3.0-latest))) (propagated-inputs (list bash))))) + +(define org-html-themes/methuselah-0 + ;; A form of https://github.com/fniessen/org-html-themes but not + ;; drop-in compatible (using that would break the BCU docs). + (let ((commit "cce6e288649d6555cb74583f3c02a1e4e97fa1f8") + (revision "0")) + (package + (name "org-html-themes") + (version (git-version "0.0.0" revision commit)) + (source + (origin + (method git-fetch) + (uri (git-reference + (commit commit) + (url "https://gitlab.com/methuselah-0/org-html-themes.git"))) + (file-name (git-file-name name version)) + (sha256 + (base32 "1ka40r5a7xc522wc03v3rwfwq3abb8c1h8sr3hw5v1gsws9s18y9")))) + (build-system copy-build-system) + (home-page "https://gitlab.com/methuselah-0/org-html-themes") + (synopsis "Export Org mode files to HTML") + (description + "The Org-HMTL framework provides cross-browser themes for exporting Org +documents to cross-browser HTML mark-up.") + (license license:gpl3)))) + +(define-public bash-coding-utils + (let ((commit "f1f0ed8bc39db2d5a2b6d3c5aca3e5cbadebfb29") + (revision "0")) + (package + (name "bash-coding-utils") + (version (git-version "0.3.0" revision commit)) + (source + (origin + (method git-fetch) + (uri + (git-reference + (commit commit) + (url "https://git.sr.ht/~methuselah-0/bash-coding-utils") + (recursive? #t)) ) + (sha256 + (base32 "1vpp91nsp0gyp5n4kkq0cjsndry9wclxrcr5y41fi1g35vw3m3zz")) + (file-name (git-file-name name version)))) + (build-system trivial-build-system) + (arguments + (list #:modules '((guix build utils)) + #:builder + #~(begin + (use-modules (guix build utils) + (ice-9 ftw) + (ice-9 match) + (srfi srfi-26)) + (let* ((bash #$(this-package-input "bash")) + (bin (string-append #$output "/bin")) + (bcu.sh (string-append bin "/bcu.sh")) + (share (string-append #$output "/share")) + (doc (string-append share "/doc/" #$name)) + ;; Everything but bcu.sh itself is only ever accessed + ;; internally by bcu, so put it all in share/. + (bcu-root (string-append share "/bcu")) + ;; XXX We should honour the without-tests transformation! + (tests? (not #$(%current-target-system)))) + + ;; Copy the ‘source’ to the output and replace submodules. + (let ((source #$(package-source this-package))) + (with-directory-excursion source + (mkdir-p (string-append bcu-root "/submodules")) + (for-each (lambda (file) + (copy-recursively file + (string-append bcu-root + "/" file))) + (list "bcu.sh" + "dependency_paths.sh" + "bcu-test.sh" + "docs" + "src")) + (copy-recursively + #$(package-source (this-package-input + "org-html-themes")) + (string-append bcu-root + "/submodules/org-html-themes")))) + ;; Patch absolute file name references. + (let* ((original-path (getenv "PATH")) + (shebang-inputs '(#$@(map (lambda (name) + (this-package-input name)) + '("guile" + "python")))) + (shebang-path (string-join + (map (cut string-append <> "/bin") + (cons bash shebang-inputs)) + ":"))) + (setenv "PATH" shebang-path) + (for-each patch-shebang + (find-files #$output "\\.(sh|scm|py)$")) + (setenv "PATH" original-path)) + + ;; Add paths to dependencies - defined in + ;; dependency_paths.sh, except the libguile-bash.so + ;; file. + (substitute* (find-files #$output "\\.sh$") + (("[^ ]*(/lib/bash/libguile-bash\\.so)" _ library) + (string-append + #$(this-package-input "guile-bash-for-bash-coding-utils") + library))) + + (substitute* (find-files #$output "dependency_paths\\.sh$") + (("=ctypes.sh") (string-append "=" #$(this-package-input "bash-ctypes") "/bin/ctypes.sh")) + (("=diff") (string-append "=" #$(this-package-input "diffutils") "/bin/diff")) + (("=ping") (string-append "=" "/run/setuid-programs/ping")) + (("=ps") (string-append "=" #$(this-package-input "procps") "/bin/ps")) + (("=file") (string-append "=" #$(this-package-input "findutils") "/bin/file")) + (("=find") (string-append "=" #$(this-package-input "findutils") "/bin/find")) + (("=flock") (string-append "=" #$(this-package-input "util-linux") "/bin/flock")) + (("=gawk") (string-append "=" #$(this-package-input "gawk") "/bin/gawk")) + (("=ugrep") (string-append "=" #$(this-package-input "ugrep") "/bin/ugrep")) + (("=jq") (string-append "=" #$(this-package-input "jq") "/bin/jq")) + (("=lsof") (string-append "=" #$(this-package-input "lsof") "/bin/lsof")) + (("=nmap") (string-append "=" #$(this-package-input "nmap") "/bin/nmap")) + (("=perl") (string-append "=" #$(this-package-input "perl") "/bin/perl")) + (("=php") (string-append "=" #$(this-package-input "php") "/bin/php")) + (("=ps") (string-append "=" #$(this-package-input "procps") "/bin/ps")) + (("=pydaemon.sh") (string-append "=" #$(this-package-input "pydaemon") "/bin/pydaemon.sh")) + (("=sed") (string-append "=" #$(this-package-input "sed") "/bin/sed")) + (("=socat") (string-append "=" #$(this-package-input "socat") "/bin/socat")) + (("=tree") (string-append "=" #$(this-package-input "tree") "/bin/tree")) + (("=pcre2grep") (string-append "=" #$(this-package-input "pcre2") "/bin/pcre2grep")) + (("=which") (string-append "=" #$(this-package-input "which") "/bin/which")) + (("=xargs") (string-append "=" #$(this-package-input "findutils") "/bin/xargs")) + (("=xdg-open") (string-append "=" #$(this-package-input "xdg-utils") "/bin/xdg-open")) + (("=xmllint") (string-append "=" #$(this-package-input "libxml2-xpath0") "/bin/xmllint")) + (("export GUILE_LOAD_PATH=(.*)$") + (string-append "export GUILE_LOAD_PATH=\"" + (string-join + '(#$@(map (lambda (name) + (file-append (this-package-input name) + "/share/guile/site/" + (version-major+minor + (package-version + (this-package-input + "guile"))))) + '("guile-bash-for-bash-coding-utils"))) + ":") + "${GUILE_LOAD_PATH:+:}${GUILE_LOAD_PATH}\"\n")) + (("export BCUPYTHONVERSION=(.*)$" _) + (string-append "export BCUPYTHONVERSION=" + #$(version-major+minor + (package-version + (this-package-input + "python"))))) + (("export BCUPYTHON=python(.*)$" _) + (string-append "export BCUPYTHON=" + #$(file-append (this-package-input "python") + "/bin/python" + (version-major+minor + (package-version + (this-package-input + "python")))) + "\n")) + (("export PYTHONPATH=.*" all) + (string-append "export PYTHONPATH=\"" + (string-join + '(#$@(map (lambda (name) + (file-append (this-package-input name) + "/lib/python" + (version-major+minor + (package-version + (this-package-input + "python"))) + "/site-packages")) + '("python" + "python-elementpath" + "python-lxml" + "python-netaddr"))) + ":") + "${PYTHONPATH:+:}${PYTHONPATH}\"\n")) + (("export XDG_DATA_DIRS=(.*)$") + (string-append + "[[ -e /run/current-system/profile/share ]] && " + "export XDG_DATA_DIRS=" + "/run/current-system/profile/share" + "${XDG_DATA_DIRS:+:}${XDG_DATA_DIRS}\n"))) + + ;; Symlink to bcu.sh from the output bin directory. + (mkdir-p bin) + (symlink (string-append bcu-root "/bcu.sh") bcu.sh) + (chmod bcu.sh #o555) + + ;; Disable network and gui tests, and one test for setopts which + ;; doesn't work inside the Guix build environment. + (with-output-to-file (string-append bcu-root "/disabled_tests.txt") + (lambda _ + (format #t "~{~a~%~}" + (list "ip_of_test_1" + "setopts_test_4" + "web_media_server_test_1" + "web_api_server_test_1" + "find_gui_test_1")))) + + ;; Set up a minimal test environment & run the tests. + (when tests? + (setenv "PATH" (string-append bin ":" + bash "/bin:" + (getenv "PATH"))) + (setenv "SHELL" + (string-append bash "/bin/bash")) + (for-each (lambda (test-input) + (setenv "PATH" + (string-append + (assoc-ref %build-inputs test-input) + "/bin:" (getenv "PATH")))) + (list "coreutils")) + (setenv "HOME" "/tmp") + (with-directory-excursion bcu-root + (invoke "./bcu-test.sh") + ;; No need to keep passed tests in the final output + (for-each delete-file + (list "bcu-test.sh" + "disabled_tests.txt")))))))) + (inputs (list bash bash-ctypes coreutils + diffutils file findutils + gawk guile-3.0 guile-bash-for-bash-coding-utils + jq libxml2-xpath0 + lsof + nmap + ;; org-html-themes is bundled upstream as a git submodule, + ;; but we package it separately and copy it manually above. + org-html-themes/methuselah-0 + pcre2 perl php + procps + pydaemon python python-elementpath python-lxml + python-netaddr python-yq + sed + socat + tree ugrep util-linux which + xdg-utils )) + ;; the bash shell needs to be the same version + ;; as guile-bash is compiled against + (propagated-inputs (list bash)) + (home-page "https://git.sr.ht/~methuselah-0/bash-coding-utils") + (synopsis "Functions and tools for software prototyping in Bash") + (description + "Bash-Coding-Utils is a library of Bash functions and wrappers that can +be useful when writing quick implementations of new programs. It helps you +work with JSON, XML, API's and parallelization, and installs some helper +programs commonly 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 documentation.") + (license license:gpl3)))) -- 2.39.1