From: david larsson <david.larsson@selfhosted.xyz>
To: 51512@debbugs.gnu.org
Subject: [bug#51512] [PATCH v 2]: gnu: Add bash-bcu.
Date: Tue, 09 Nov 2021 13:32:28 +0100 [thread overview]
Message-ID: <93d8232c104dc63f46f6b975073b56ca@selfhosted.xyz> (raw)
In-Reply-To: <87r1bsqdy8.fsf@nckx>
[-- Attachment #1: Type: text/plain, Size: 2858 bytes --]
On 2021-11-07 13:40, Tobias Geerinckx-Rice wrote:
> David,
>
> Thank you!
>
> (One fire's out, you'll be glad to hear, so in return here's most of a
> review. I still reserve the right to tinker with the hunk below —
> you'll see which — later today.)
>
Thanks for the review, it feels like I learn a lot from this :-)
Not sure if u intended to attach ur modified version of the patch when
you replied or not. I have however made the changes you suggested in a
version2 and attached.
[...]
>> + (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)
>
> [So this is the part I was waiting to finish :-) I still don't have
> time now.]
>
> I really want to rewrite this whole block, but for now I just have 1
> question: why not simply append /run/setuid-programs to the start of
> $PATH here? What's the difference, if any, and do we care?
Basically just to make minimal disruption of the the current environment
when you source bcu.sh. Almost certainly a non-issue 99.9% of cases,
i.e. I think that just prepending /run/setuid-programs to PATH would be
fine as well.
>> + (license license:gpl3))))
>
> Why not lgpl3+? I can't find the gpl3-only file(s).
I really don't know enough about licensing to answer this very well
unfortunately.. bash-coding-utils is to a large extent a remix of
stackoverflow contributions (CC-BY-SA-4.0) and other small libraries,
some of which have GPLv3+ stated at the top (e.g. src/csv/csv/csv.scm).
I want to apply whatever license must be applied based on the included
software and SO snippets. If it needs to be lgpl3+ or GPLv3 in the end
does not matter much to me (Im the author of bash-coding-utils).
Best regards,
David
[-- Attachment #2: 0001-gnu-Add-bash-bcu.patch --]
[-- Type: text/x-diff, Size: 11548 bytes --]
From d3ee10521b981fb4b97b2020bf9e3cd8373c3d5b Mon Sep 17 00:00:00 2001
From: David Larsson <david.larsson@selfhosted.xyz>
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 | 195 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 195 insertions(+)
diff --git a/gnu/packages/bash.scm b/gnu/packages/bash.scm
index ed2931fd97..95294ef5ed 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,181 @@ 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-coding-utils
+ (package
+ (name "bash-coding-utils")
+ (version "0.2.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (commit "608a4c2a615e0d6e35bbb28d3a42864ee013975")
+ (url "https://gitlab.com/methuselah-0/bash-coding-utils.sh.git")
+ ;; TODO: unbundle submodules some day.
+ (recursive? #t)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "1hfcxfv2i7rara96nk4w9babg8bm8khr2m9nlh09hxjhn22l0jga"))))
+ (build-system trivial-build-system)
+ (arguments
+ `(#:modules ((guix build utils))
+ #:builder
+ (begin
+ (use-modules (guix build utils))
+ (let* ((python-version ,(version-major+minor (package-version python)))
+ (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 "/share/guile/site/"
+ ,(version-major+minor (package-version guile-3.0))))
+ ;; Some python libraries needs added to PYTHONPATH
+ (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"))
+ (p-lib (string-append
+ (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")))
+ (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* ((wrapper (string-append bin "/bcu.sh"))
+ (bcu-port (open-file wrapper "a"))
+ (path (string-append
+ bash "/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 "#!" bash "/bin/bash\n") bcu-port)
+ (display
+ (string-append
+ "[[ \"$_BCU_SH_LOADED\" == YES ]] || { \nexport PATH=\""
+ path "${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 wrapper #o555)
+ (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)
+ (patch-shebang file))
+ (find-files out "\\.(sh|scm|awk|php|py)$"))
+
+;;; Now that everything's installed, prepare & run the tests.
+ ;; 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
+ (with-output-to-file (string-append libexec "/disabled_tests.txt")
+ (lambda _
+ (format #t "~{~a~%~}"
+ (list "ip_of_test_1"
+ "setopts_test_1"
+ "setopts_test_2"
+ "setopts_test_3"
+ "setopts_test_4"
+ "setopts_test_5"
+ "setopts_test_6"))))
+ (invoke (string-append libexec "/bcu-test.sh"))))))
+ (inputs `(("bash" ,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)))
+ (synopsis "Functions and tools for software prototyping in Bash")
+ (home-page "https://gitlab.com/methuselah-0/bash-coding-utils.sh")
+ (description
+ "Bash-coding-utils 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},
+ and type @command{bcu__docs} for the full html documentation.")
+ (license license:gpl3)))
--
2.31.0
next prev parent reply other threads:[~2021-11-09 12:33 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-30 14:59 [bug#51512] [PATCH]: gnu: Add bash-bcu david larsson
2021-11-07 12:40 ` Tobias Geerinckx-Rice via Guix-patches via
2021-11-09 12:32 ` david larsson [this message]
2021-11-20 14:11 ` [bug#51512] [PATCH v 2]: " Tobias Geerinckx-Rice via Guix-patches via
2021-11-23 12:44 ` david larsson
2022-07-01 18:13 ` [bug#51512] [PATCH v 3]: " david larsson
2022-08-02 20:21 ` david larsson
2022-08-27 18:29 ` david larsson
2023-05-20 19:23 ` david larsson
2023-05-20 19:28 ` david larsson
2023-05-20 20:16 ` [bug#51512] [PATCH v 4]: " david larsson
2022-07-04 21:11 ` [bug#51512] [PATCH]: " ( via Guix-patches via
2022-07-04 21:21 ` ( via Guix-patches via
2023-05-21 6:58 ` [bug#51512] [PATCH v5]: " david larsson
2023-05-23 4:51 ` [bug#51512] [PATCH v6 0/3]: " david larsson
2023-05-23 4:53 ` [bug#51512] [PATCH v6 1/3]: " david larsson
2023-05-23 4:55 ` [bug#51512] [PATCH v6 2/3]: gnu: Add guile-bash-for-bash-coding-utils david larsson
2023-05-23 4:56 ` [bug#51512] [PATCH v6 3/3]: gnu: Add bash-coding-utils david larsson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=93d8232c104dc63f46f6b975073b56ca@selfhosted.xyz \
--to=david.larsson@selfhosted.xyz \
--cc=51512@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).