unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Tobias Geerinckx-Rice via Guix-patches via <guix-patches@gnu.org>
To: Oleg Pykhalov <go.wigust@gmail.com>
Cc: 41752@debbugs.gnu.org
Subject: [bug#41752] [PATCH] gnu: Add bash-hosts.
Date: Sun, 07 Jun 2020 21:25:18 +0200	[thread overview]
Message-ID: <87d06a8yqp.fsf@nckx> (raw)
In-Reply-To: <20200607182410.4594-1-go.wigust@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3982 bytes --]

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]

  reply	other threads:[~2020-06-07 19:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-07 18:24 [bug#41752] [PATCH] gnu: Add bash-hosts Oleg Pykhalov
2020-06-07 19:25 ` Tobias Geerinckx-Rice via Guix-patches via [this message]
2020-06-07 23:45   ` Tobias Geerinckx-Rice via Guix-patches via
2020-06-30 17:48     ` bug#41752: " Oleg Pykhalov

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=87d06a8yqp.fsf@nckx \
    --to=guix-patches@gnu.org \
    --cc=41752@debbugs.gnu.org \
    --cc=go.wigust@gmail.com \
    --cc=me@tobias.gr \
    /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).