[PATCH] gnu: Add bash-hosts.

  • Done
  • quality assurance status badge
Details
2 participants
  • Oleg Pykhalov
  • Tobias Geerinckx-Rice
Owner
unassigned
Submitted by
Oleg Pykhalov
Severity
normal
O
O
Oleg Pykhalov wrote on 7 Jun 2020 20:24
(address . guix-patches@gnu.org)(name . Oleg Pykhalov)(address . go.wigust@gmail.com)
20200607182410.4594-1-go.wigust@gmail.com
* gnu/packages/admin.scm (bash-hosts): New variable.
---
gnu/packages/admin.scm | 43 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)

Toggle diff (53 lines)
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
T
T
Tobias Geerinckx-Rice wrote on 7 Jun 2020 21:25
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)(address . 41752@debbugs.gnu.org)
87d06a8yqp.fsf@nckx
Oleg,

Oleg Pykhalov ???
Toggle quote (2 lines)
> * gnu/packages/admin.scm (bash-hosts): New variable.

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

Toggle quote (18 lines)
> +(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.

Toggle quote (13 lines)
> + (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.

Toggle quote (12 lines)
> + (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.

Toggle quote (2 lines)
> + (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.

Toggle quote (2 lines)
> for managing hosts file entries.

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

Toggle quote (2 lines)
> @code{hosts} works with existing hosts files and entries,

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

Toggle quote (8 lines)
> +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?

Toggle quote (2 lines)
> + (license license:expat)))

I've opened a bug report about the unclear licencing:

Kind regards,

T G-R
-----BEGIN PGP SIGNATURE-----

iHUEARYKAB0WIQT12iAyS4c9C3o4dnINsP+IT1VteQUCXt0/HgAKCRANsP+IT1Vt
eYOxAPwK4G1Bn7K0qA5dvaoReEuj/pmhSwizpnGzToFx+unzwQEAlzPfO03h2rhg
yiHjRPSyA8q9EZ2qbqZ+8eVIdUen0gM=
=VGJw
-----END PGP SIGNATURE-----

T
T
Tobias Geerinckx-Rice wrote on 8 Jun 2020 01:45
877dwi8mp9.fsf@nckx
Oleg Pykhalov ???
Toggle quote (3 lines)
> + (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
-----BEGIN PGP SIGNATURE-----

iHUEARYKAB0WIQT12iAyS4c9C3o4dnINsP+IT1VteQUCXt18EwAKCRANsP+IT1Vt
ebcSAP42ioVJvAbJAnV2oQyMsF+SkuEx/RW6IXMjjh9wGtMTzQD+JDKV+nRg/IQy
ZmzcWJAI1ozFX0OSQMz/fC9GWjOVAgU=
=Cg9e
-----END PGP SIGNATURE-----

O
O
Oleg Pykhalov wrote on 30 Jun 2020 19:48
(name . Tobias Geerinckx-Rice)(address . me@tobias.gr)(address . 41752-done@debbugs.gnu.org)
87366cwikr.fsf@gmail.com
Hello,

Thank you for review!

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

Pushed as ceb233bb7642b2a7efec57073bf205b62ebd8f97.

Oleg.
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEcjhxI46s62NFSFhXFn+OpQAa+pwFAl77evQACgkQFn+OpQAa
+pyQiw//R97OrohvVxSeH48CtDwPuqueAfD+UG0KEIclyWu1gv9YMu0RKcjuhix1
c6ajwPPdQ2TjFrpfaSkuv/UTGJMqXZCNCeOTVrIjWUH/tWZl8BJEixiwGgq0c7Rt
W+b5H/31sUhELsuxArstfdpdfLRu0ckm5isu4mjCkcUUPLh1PFYzpITPpyZTQenp
8XggcqE3Z0FeDGyR5IZ1WPm2zFPlmHqInHivXpoNslohj9nz9SPjNNesm8UVkpC7
YtUTkDi6Z0b66HDiGWLbQ3utd6PL6FQ3AiWfKsjGnM+RGRG75yzXvy1VQfBP1hGF
PJsR/OceN6PbpsfjwO1Ffc6S6kxhCgdxfoHyKB1X+5QYICEKUG8LekAp+ty4kSok
lHSce9YGz7NhqKuVdaELMMRaNBabTB6+o+r2TNe/msj32rsMR/WfDw9DJg1Up2/8
NRrxYEreICY8oAewQuuaAVJY+PJWKVXqlnj0lw8lF9wYZCPXwXzufC69vNlSC+m4
b6Q5JN+EcoC3nLIUkfRy1a1B1tQMGKJSk0+gChqOltbFzVl0iFYJwL4zQnRRp6dG
l4CZSE87Fz/js/U09nTy01hKHCVJuwcRR0jQ6F/WKtt1oLXnT0xbmtjv2Cu23zEY
rE+uu78xzuz3tfod3kBGeYG5z7R6pi3nlM7qjhfvHqHDTrvT75o=
=St33
-----END PGP SIGNATURE-----

Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 41752@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 41752
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch