GNU bug report logs - #41752
[PATCH] gnu: Add bash-hosts.

Previous Next

Package: guix-patches;

Reported by: Oleg Pykhalov <go.wigust <at> gmail.com>

Date: Sun, 7 Jun 2020 18:25:02 UTC

Severity: normal

Tags: patch

Done: Oleg Pykhalov <go.wigust <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 41752 in the body.
You can then email your comments to 41752 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#41752; Package guix-patches. (Sun, 07 Jun 2020 18:25:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Oleg Pykhalov <go.wigust <at> gmail.com>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Sun, 07 Jun 2020 18:25:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Oleg Pykhalov <go.wigust <at> gmail.com>
To: guix-patches <at> gnu.org
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>
Subject: [PATCH] gnu: Add bash-hosts.
Date: Sun,  7 Jun 2020 21:24:10 +0300
* gnu/packages/admin.scm (bash-hosts): New variable.
---
 gnu/packages/admin.scm | 43 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index bb93f7efb1..dd0ada0422 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -3841,3 +3841,46 @@ It supports mounting local filesystems of any kind the normal mount utility
 supports.  It can also mount encrypted LUKS volumes using the password
 supplied by the user when logging in.")
     (license (list license:gpl2+ license:lgpl2.1+))))
+
+(define-public bash-hosts
+  (package
+    (name "bash-hosts")
+    (version "3.5.1")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/xwmx/hosts.git")
+                    (commit version)))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0q02n28sng0757cgkkc7r45krs07j993k6sgyyp27n8v0l8q6fv4"))))
+    (build-system trivial-build-system)
+    (inputs
+     `(("bash" ,bash)))
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder
+       (begin
+         (use-modules (guix build utils))
+         (copy-recursively (assoc-ref %build-inputs "source") ".")
+         (substitute* "hosts"
+           (("/usr/bin/env bash")
+            (string-append (assoc-ref %build-inputs "bash")
+                           "/bin/bash")))
+         (install-file "hosts" (string-append %output "/bin"))
+         (let ((bash-completion (string-append %output
+                                               "/etc/bash_completion.d")))
+           (mkdir-p bash-completion)
+           (copy-file "etc/hosts-completion.bash"
+                      (string-append bash-completion "/hosts")))
+         #t)))
+    (home-page "https://github.com/xwmx/hosts/")
+    (synopsis "Command line hosts file editor in a single portable script")
+    (description "@code{hosts} is a command line program for managing hosts
+file entries.  @code{hosts} works with existing hosts files and entries,
+making it easier to add, remove, comment, and search hosts file entries using
+simple, memorable commands.  @code{hosts} is designed to be lightweight, easy
+to use, and contained in a single, portable script that can be curled into any
+environment.")
+    (license license:expat)))
-- 
2.26.2





Information forwarded to guix-patches <at> gnu.org:
bug#41752; Package guix-patches. (Sun, 07 Jun 2020 19:26:03 GMT) Full text and rfc822 format available.

Message #8 received at 41752 <at> debbugs.gnu.org (full text, mbox):

From: Tobias Geerinckx-Rice <me <at> tobias.gr>
To: Oleg Pykhalov <go.wigust <at> gmail.com>
Cc: 41752 <at> debbugs.gnu.org
Subject: Re: [bug#41752] [PATCH] gnu: Add bash-hosts.
Date: Sun, 07 Jun 2020 21:25:18 +0200
[Message part 1 (text/plain, inline)]
Oleg,

Oleg Pykhalov 写道:
> * gnu/packages/admin.scm (bash-hosts): New variable.

Thanks!  The package should be called just ‘hosts’.

> +(define-public bash-hosts
> +  (package
> +    (name "bash-hosts")
> +    (version "3.5.1")
> +    (source (origin
> +              (method git-fetch)
> +              (uri (git-reference
> +                    (url "https://github.com/xwmx/hosts.git")
> +                    (commit version)))
> +              (file-name (git-file-name name version))
> +              (sha256
> +               (base32
> + 
> "0q02n28sng0757cgkkc7r45krs07j993k6sgyyp27n8v0l8q6fv4"))))
> +    (build-system trivial-build-system)
> +    (inputs
> +     `(("bash" ,bash)))

Like all non-trivial shell scripts it assumes coreutils are 
present.  It also hard-depends on ncurses (for tput), gawk, sed, & 
grep.  You can substitute* these as well, or use wrap-script 
(which requires adding guile-3.0) since ‘performance’ probably 
doesn't matter here.  But read on.

Keeping optional dependencies (like sudo) up to the user is good.

> +    (arguments
> +     `(#:modules ((guix build utils))
> +       #:builder
> +       (begin
> +         (use-modules (guix build utils))
> +         (copy-recursively (assoc-ref %build-inputs "source") 
> ".")
> +         (substitute* "hosts"
> +           (("/usr/bin/env bash")
> +            (string-append (assoc-ref %build-inputs "bash")
> +                           "/bin/bash")))
> +         (install-file "hosts" (string-append %output "/bin"))

We should copy LICENSE and README to /share/doc/,name-,version 
too.

> +         (let ((bash-completion (string-append %output
> + 
> "/etc/bash_completion.d")))
> +           (mkdir-p bash-completion)
> +           (copy-file "etc/hosts-completion.bash"
> +                      (string-append bash-completion 
> "/hosts")))
> +         #t)))
> +    (home-page "https://github.com/xwmx/hosts/")
> +    (synopsis "Command line hosts file editor in a single 
> portable script")

I don't think ‘in a single portable script’ (like ‘Free’ or 
‘cross-platform’ or ‘now contains Rust!’) adds value here.  Write 
@file{hosts} for clarity.

> +    (description "@code{hosts} is a command line program

@code{hosts} should be either @command{hosts} or simply ‘Hosts’. 
I favour the latter, at least for this occurrence.

> for managing hosts file entries.

You can use @file{/etc/hosts} mark-up here too to make up for it.

> @code{hosts} works with existing hosts files and entries,

Nitpick: every sentence starting with ‘Hosts’ sounds odd to me. 
This could start with ‘It’.

> +making it easier to add, remove, comment, and search hosts file 
> entries using
> +simple, memorable commands.  @code{hosts} is designed to be 
> lightweight, easy
> +to use, and contained in a single, portable script that can be 
> curled into any
> +environment.")

Users will have to invoke it as ‘sh ./hosts’ to skip the patched 
shebang, but it would work.  If we patch or wrap it to include 
store patch for all dependencies it won't be true at all.

If this feature matters to you, I think you could do something 
like

   (substitute* "hosts"
     (("#!/usr/bin/env bash")
      (string-append "#! "(assoc-ref %build-inputs "bash")
                     "/bin/bash\n"
                     ;; Just a rough example.
                     "PATH=\"" (getenv "PATH") ":$PATH\"")))

To avoid a separate .hosts-real file and keep the script working 
both in pure environments and when scp'd to random hosts.

But Guix packages in general don't care about being self-contained 
like this.  Maybe it's not worth supporting; one can always curl 
the unguixed original instead?

> +    (license license:expat)))

I've opened a bug report about the unclear licencing: 
<https://github.com/xwmx/hosts/issues/10>.

Kind regards,

T G-R
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#41752; Package guix-patches. (Sun, 07 Jun 2020 23:46:01 GMT) Full text and rfc822 format available.

Message #11 received at 41752 <at> debbugs.gnu.org (full text, mbox):

From: Tobias Geerinckx-Rice <me <at> tobias.gr>
To: Oleg Pykhalov <go.wigust <at> gmail.com>, 41752 <at> debbugs.gnu.org
Subject: Re: [bug#41752] [PATCH] gnu: Add bash-hosts.
Date: Mon, 08 Jun 2020 01:45:22 +0200
[Message part 1 (text/plain, inline)]
Oleg Pykhalov 写道:
> +    (name "bash-hosts")
> +    (version "3.5.1")

There's now a 3.6.1 release that includes a licence header in the 
script.

Kind regards,

T G-R
[signature.asc (application/pgp-signature, inline)]

Reply sent to Oleg Pykhalov <go.wigust <at> gmail.com>:
You have taken responsibility. (Tue, 30 Jun 2020 17:49:02 GMT) Full text and rfc822 format available.

Notification sent to Oleg Pykhalov <go.wigust <at> gmail.com>:
bug acknowledged by developer. (Tue, 30 Jun 2020 17:49:02 GMT) Full text and rfc822 format available.

Message #16 received at 41752-done <at> debbugs.gnu.org (full text, mbox):

From: Oleg Pykhalov <go.wigust <at> gmail.com>
To: Tobias Geerinckx-Rice <me <at> tobias.gr>
Cc: 41752-done <at> debbugs.gnu.org
Subject: Re: [bug#41752] [PATCH] gnu: Add bash-hosts.
Date: Tue, 30 Jun 2020 20:48:36 +0300
[Message part 1 (text/plain, inline)]
Hello,

Thank you for review!

I applied all your suggestions, added ZSH completion and tests.

Pushed as ceb233bb7642b2a7efec57073bf205b62ebd8f97.

Oleg.
[signature.asc (application/pgp-signature, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 29 Jul 2020 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 269 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.