unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Maxime Devos <maximedevos@telenet.be>
To: Michael Rohleder <mike@rohleder.de>, 57722@debbugs.gnu.org
Subject: [bug#57722] [PATCH] gnu: ipfs: Install bash completion.
Date: Sun, 11 Sep 2022 13:47:58 +0200	[thread overview]
Message-ID: <5d80a74a-fb2f-2236-a722-62e9d20b8487@telenet.be> (raw)
In-Reply-To: <20220910214721.9993-1-mike@rohleder.de>


[-- Attachment #1.1.1: Type: text/plain, Size: 1950 bytes --]



On 10-09-2022 23:47, Michael Rohleder wrote:
> +           (lambda* (#:key inputs outputs #:allow-other-keys)

'inputs' is unused.

> +             (let* ((out (assoc-ref outputs "out"))
> +                    (completiondir (string-append out "/etc/bash_completion.d")))

#$output can be used nowadays instead of (assoc-ref outputs "out"). 
Then 'outputs' would be unused as well and the lambda can be simplified 
to (lambda _ [...]).

> +               (mkdir-p completiondir)
> +               (call-with-output-file (string-append completiondir "/ipfs")
> +                 (lambda (port)
> +                   (let ((input-pipe (open-pipe* OPEN_READ
> +                                                 (string-append out "/bin/ipfs")
> +                                                 "commands" "completion" "bash")))
> +                     (display (get-string-all input-pipe) port)
> +                     (close-pipe input-pipe))))))))))

Can be simplified to

   (with-output-to-file (string-append completiondir "/ipfs")
     (invoke (string-append out "/bin/ipfs")
             "commands" "completion" "bash"))

(untested)

When cross-compiling, the cross-compiled bin/ipfs cannot be run.  To 
solve this, you can add 'this-package' to the native-inputs conditional 
upon (%current-target-system):

  (native-inputs
     (append
       (if (%current-target-system)
           (list this-package)
           '())
       (list python-minimal-wrapper zsh))).

and in the build phase, do two separate cases: when compiling natively, 
use the ipfs from #$output as you're doing, when cross-compiling, use 
the ipfs from $PATH:

   (with-output-to-file (string-append completiondir "/ipfs")
     (invoke #$(if (%current-target-system)
                   "ipfs"
                   #~(string-append #$output "/bin/ipfs"))
             "commands" "completion" "bash"))

Greetings,
Maxime.

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 929 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

  reply	other threads:[~2022-09-11 11:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-10 21:47 [bug#57722] [PATCH] gnu: ipfs: Install bash completion Michael Rohleder
2022-09-11 11:47 ` Maxime Devos [this message]
2022-09-12 11:21   ` Maxime Devos
2022-09-13  9:49   ` Michael Rohleder
2022-09-13 10:48     ` Maxime Devos
2022-09-13 11:02       ` Maxime Devos
2022-09-14 21:29     ` bug#57722: " Ludovic Courtès

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=5d80a74a-fb2f-2236-a722-62e9d20b8487@telenet.be \
    --to=maximedevos@telenet.be \
    --cc=57722@debbugs.gnu.org \
    --cc=mike@rohleder.de \
    /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).