[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#57722] [PATCH] gnu: ipfs: Install bash completion.
From: |
Maxime Devos |
Subject: |
[bug#57722] [PATCH] gnu: ipfs: Install bash completion. |
Date: |
Sun, 11 Sep 2022 13:47:58 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 |
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
Description: OpenPGP public key
OpenPGP_signature
Description: OpenPGP digital signature