GNU bug report logs - #57722
[PATCH] gnu: ipfs: Install bash completion.

Previous Next

Package: guix-patches;

Reported by: Michael Rohleder <mike <at> rohleder.de>

Date: Sat, 10 Sep 2022 21:49:01 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


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

From: Maxime Devos <maximedevos <at> telenet.be>
To: Michael Rohleder <mike <at> rohleder.de>, 57722 <at> debbugs.gnu.org
Subject: Re: [bug#57722] [PATCH] gnu: ipfs: Install bash completion.
Date: Sun, 11 Sep 2022 13:47:58 +0200
[Message part 1 (text/plain, inline)]

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.
[OpenPGP_0x49E3EE22191725EE.asc (application/pgp-keys, attachment)]
[OpenPGP_signature (application/pgp-signature, attachment)]

This bug report was last modified 2 years and 249 days ago.

Previous Next


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