Subject: bug#57722: closed (Re: bug#57722: [PATCH] gnu: ipfs: Install bash completion.)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 14 Sep 2022 21:30:02 +0000

Your bug report

#57722: [PATCH] gnu: ipfs: Install bash completion.

which was filed against the guix-patches package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
57722: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=57722
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#57722: [PATCH] gnu: ipfs: Install bash completion.
From: Ludovic Courtès <[email-masked]>
To: Michael Rohleder <[email-masked]>
Cc: [email-masked], Maxime Devos <[email-masked]>
Date: Wed, 14 Sep 2022 23:29:25 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Michael Rohleder <[email-masked]> skribis:

> From bbf32c53a2402f6f123d00d2e5ece9efdbf10504 Mon Sep 17 00:00:00 2001
> From: Michael Rohleder <[email-masked]>
> Date: Tue, 13 Sep 2022 11:29:23 +0200
> Subject: [PATCH] gnu: go-ipfs: Install bash completion.
>
> * gnu/packages/ipfs.scm (go-ipfs)[arguments]: Use gexp.
> Add 'install-bashcompletion phase to install bash completion.

Applied, thanks!

Great that Maxime found a bug as a side effect.  :-)

Subject: [PATCH] gnu: ipfs: Install bash completion.
From: Michael Rohleder <[email-masked]>
To: [email-masked]
Cc: Michael Rohleder <[email-masked]>
Date: Sat, 10 Sep 2022 23:47:21 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

* gnu/packages/ipfs.scm (ipfs)[arguments]: Add 'install-bashcompletion
phase to install bash completion.
---
 gnu/packages/ipfs.scm | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/ipfs.scm b/gnu/packages/ipfs.scm
index ccc36007b4..faa209bf2a 100644
--- a/gnu/packages/ipfs.scm
+++ b/gnu/packages/ipfs.scm
@@ -2,7 +2,7 @@
 ;;; Copyright © 2018 Pierre Neidhardt <[email-masked]>
 ;;; Copyright © 2019, 2020 Tobias Geerinckx-Rice <[email-masked]>
 ;;; Copyright © 2019, 2020 Martin Becze <[email-masked]>
-;;; Copyright © 2020, 2021 Michael Rohleder <[email-masked]>
+;;; Copyright © 2020, 2021, 2022 Michael Rohleder <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -230,7 +230,26 @@ (define-public go-ipfs
     (build-system go-build-system)
     (arguments
      `(#:unpack-path "github.com/ipfs/go-ipfs"
-       #:import-path "github.com/ipfs/go-ipfs/cmd/ipfs"))
+       #:import-path "github.com/ipfs/go-ipfs/cmd/ipfs"
+       #:modules ((guix build utils)
+                  (guix build go-build-system)
+                  (ice-9 popen)
+                  (ice-9 textual-ports))
+       #:phases
+       (modify-phases %standard-phases
+         ;; https://github.com/ipfs/kubo/blob/master/docs/command-completion.md
+         (add-after 'install 'install-bashcompletion
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (completiondir (string-append out "/etc/bash_completion.d")))
+               (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))))))))))
     (native-inputs
      (list python-minimal-wrapper zsh))
     (home-page "https://ipfs.io")
-- 
2.37.3