diff mbox

gnu: password-store: Wrap PATH.

Message ID 1469752717.117537.679907329.010AA3BD@webmail.messagingengine.com
State New
Headers show

Commit Message

Alex Griffin July 29, 2016, 12:38 a.m. UTC
On Thu, Jul 28, 2016, at 07:20 PM, Alex Griffin wrote:
> This patch fixes password-store so that you no longer need to install
> its dependencies into your profile.

Forgot a copyright line. Here's an updated patch.

Comments

Mathieu Lirzin July 29, 2016, 9:07 a.m. UTC | #1
Hello,

Alex Griffin <a@ajgrf.com> writes:

> On Thu, Jul 28, 2016, at 07:20 PM, Alex Griffin wrote:
>
> From 74b838fea52293386169299881cdd7cfefff7f4d Mon Sep 17 00:00:00 2001
> From: Alex Griffin <a@ajgrf.com>
> Date: Thu, 28 Jul 2016 19:06:10 -0500
> Subject: [PATCH] gnu: password-store: Wrap PATH.
>
> * gnu/packages/password-utils.scm (password-store):
> [arguments]: Wrap PATH more thoroughly.
> [native-inputs]: Move getopt to inputs.
> [inputs]: Add sed & alphabetize packages.
                      ^^
Indentation and formatting changes can be omitted in commit log.

> ---
>  gnu/packages/password-utils.scm | 33 ++++++++++++++++-----------------
>  1 file changed, 16 insertions(+), 17 deletions(-)
>
> diff --git a/gnu/packages/password-utils.scm b/gnu/packages/password-utils.scm
> index a03214a..497717f 100644
> --- a/gnu/packages/password-utils.scm
> +++ b/gnu/packages/password-utils.scm
> @@ -6,6 +6,7 @@
>  ;;; Copyright © 2016 Jessica Tallon <tsyesika@tsyesika.se>
>  ;;; Copyright © 2016 Andreas Enge <andreas@enge.fr>
>  ;;; Copyright © 2016 Lukas Gradl <lgradl@openmailbox.org>
> +;;; Copyright © 2016 Alex Griffin <a@ajgrf.com>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -266,27 +267,25 @@ any X11 window.")
>       '(#:phases
>         (modify-phases %standard-phases
>           (delete 'configure)
> -         (add-after
> -          ;; The script requires 'getopt' at run-time, and this allows
> -          ;; the user to not install the providing package 'util-linux'
> -          ;; in their profile.
> -          'unpack 'patch-path
> -          (lambda* (#:key inputs outputs #:allow-other-keys)
> -            (let ((getopt (string-append (assoc-ref inputs "getopt")
> -                                         "/bin/getopt")))
> -              (substitute* "src/password-store.sh"
> -                (("GETOPT=\"getopt\"")
> -                 (string-append "GETOPT=\"" getopt "\"")))
> -              #t))))
> +         (add-after 'install 'wrap-path
> +           (lambda* (#:key inputs outputs #:allow-other-keys)
> +             (let* ((out (assoc-ref outputs "out"))
> +                    (path (map (lambda (pkg)
> +                                 (string-append (assoc-ref inputs pkg) "/bin"))
> +                               '("coreutils" "getopt" "git" "gnupg" "pwgen"
> +                                 "sed" "tree" "which" "xclip"))))
> +               (wrap-program (string-append out "/bin/pass")
> +                 `("PATH" ":" prefix (,(string-join path ":"))))))))

'let*' can safely be replaced by 'let' here.

>         #:make-flags (list "CC=gcc" (string-append "PREFIX=" %output))
>         #:test-target "test"))
> -    (native-inputs `(("getopt" ,util-linux))) ; getopt for the tests
> -    (inputs `(("gnupg" ,gnupg)
> -              ("pwgen" ,pwgen)
> -              ("xclip" ,xclip)
> +    (inputs `(("getopt" ,util-linux)
>                ("git" ,git)
> +              ("gnupg" ,gnupg)
> +              ("pwgen" ,pwgen)
> +              ("sed" ,sed)
>                ("tree" ,tree)
> -              ("which" ,which)))
> +              ("which" ,which)
> +              ("xclip" ,xclip)))
>      (home-page "http://www.passwordstore.org/")
>      (synopsis "Encrypted password manager")
>      (description "Password-store is a password manager which uses GnuPG to

Pushed in commit 61201e46a72b715e1a38ce56932c3f4f2d3885b4.

Thanks.
David Thompson July 29, 2016, 2:02 p.m. UTC | #2
On Fri, Jul 29, 2016 at 5:07 AM, Mathieu Lirzin <mthl@gnu.org> wrote:
> Hello,
>
> Alex Griffin <a@ajgrf.com> writes:
>
>> On Thu, Jul 28, 2016, at 07:20 PM, Alex Griffin wrote:
>>
>> From 74b838fea52293386169299881cdd7cfefff7f4d Mon Sep 17 00:00:00 2001
>> From: Alex Griffin <a@ajgrf.com>
>> Date: Thu, 28 Jul 2016 19:06:10 -0500
>> Subject: [PATCH] gnu: password-store: Wrap PATH.
>>
>> * gnu/packages/password-utils.scm (password-store):
>> [arguments]: Wrap PATH more thoroughly.
>> [native-inputs]: Move getopt to inputs.
>> [inputs]: Add sed & alphabetize packages.
>                       ^^
> Indentation and formatting changes can be omitted in commit log.
>
>> ---
>>  gnu/packages/password-utils.scm | 33 ++++++++++++++++-----------------
>>  1 file changed, 16 insertions(+), 17 deletions(-)
>>
>> diff --git a/gnu/packages/password-utils.scm b/gnu/packages/password-utils.scm
>> index a03214a..497717f 100644
>> --- a/gnu/packages/password-utils.scm
>> +++ b/gnu/packages/password-utils.scm
>> @@ -6,6 +6,7 @@
>>  ;;; Copyright © 2016 Jessica Tallon <tsyesika@tsyesika.se>
>>  ;;; Copyright © 2016 Andreas Enge <andreas@enge.fr>
>>  ;;; Copyright © 2016 Lukas Gradl <lgradl@openmailbox.org>
>> +;;; Copyright © 2016 Alex Griffin <a@ajgrf.com>
>>  ;;;
>>  ;;; This file is part of GNU Guix.
>>  ;;;
>> @@ -266,27 +267,25 @@ any X11 window.")
>>       '(#:phases
>>         (modify-phases %standard-phases
>>           (delete 'configure)
>> -         (add-after
>> -          ;; The script requires 'getopt' at run-time, and this allows
>> -          ;; the user to not install the providing package 'util-linux'
>> -          ;; in their profile.
>> -          'unpack 'patch-path
>> -          (lambda* (#:key inputs outputs #:allow-other-keys)
>> -            (let ((getopt (string-append (assoc-ref inputs "getopt")
>> -                                         "/bin/getopt")))
>> -              (substitute* "src/password-store.sh"
>> -                (("GETOPT=\"getopt\"")
>> -                 (string-append "GETOPT=\"" getopt "\"")))
>> -              #t))))
>> +         (add-after 'install 'wrap-path
>> +           (lambda* (#:key inputs outputs #:allow-other-keys)
>> +             (let* ((out (assoc-ref outputs "out"))
>> +                    (path (map (lambda (pkg)
>> +                                 (string-append (assoc-ref inputs pkg) "/bin"))
>> +                               '("coreutils" "getopt" "git" "gnupg" "pwgen"
>> +                                 "sed" "tree" "which" "xclip"))))
>> +               (wrap-program (string-append out "/bin/pass")
>> +                 `("PATH" ":" prefix (,(string-join path ":"))))))))
>
> 'let*' can safely be replaced by 'let' here.
>
>>         #:make-flags (list "CC=gcc" (string-append "PREFIX=" %output))
>>         #:test-target "test"))
>> -    (native-inputs `(("getopt" ,util-linux))) ; getopt for the tests
>> -    (inputs `(("gnupg" ,gnupg)
>> -              ("pwgen" ,pwgen)
>> -              ("xclip" ,xclip)
>> +    (inputs `(("getopt" ,util-linux)
>>                ("git" ,git)
>> +              ("gnupg" ,gnupg)
>> +              ("pwgen" ,pwgen)
>> +              ("sed" ,sed)
>>                ("tree" ,tree)
>> -              ("which" ,which)))
>> +              ("which" ,which)
>> +              ("xclip" ,xclip)))
>>      (home-page "http://www.passwordstore.org/")
>>      (synopsis "Encrypted password manager")
>>      (description "Password-store is a password manager which uses GnuPG to
>
> Pushed in commit 61201e46a72b715e1a38ce56932c3f4f2d3885b4.

Sorry I'm late, but I don't think this is the right fix.  Wrapping
programs should only be considered after other options are exhausted.
The correct fix is to patch the source directly to refer to
executables by their absolute path.  Why wasn't it done this way?

- Dave
Alex Griffin July 29, 2016, 2:27 p.m. UTC | #3
On Fri, Jul 29, 2016, at 09:02 AM, Thompson, David wrote:
> Sorry I'm late, but I don't think this is the right fix.  Wrapping
> programs should only be considered after other options are exhausted.
> The correct fix is to patch the source directly to refer to
> executables by their absolute path.  Why wasn't it done this way?

Mostly because it would be a lot of on-going work every time the package
is updated. As a shell script, it invokes an external tool nearly every
other line. If you look at the discussion that happened in February when
the package was first added [1], Jessica (the original packager) was
really discouraged by the prospect of patching every invocation of an
external tool. She also tried to submit changes upstream so that kind of
work wouldn't be necessary, but upstream wasn't very receptive to the
idea. In the end, the package was just committed to Guix in a broken
state.

Another approach I considered was adding a bunch of shell aliases to the
top of the script pointing to the Guix store. That makes the problem a
lot more tractable than replacing every external invocation, but it's
still kinda complicated and it still requires finding every single
program that gets called and keeping it up to date with new releases. So
even if all upstream does is use another program from coreutils, the fix
would be out-of-date again.

[1]: https://lists.gnu.org/archive/html/guix-devel/2016-02/msg01310.html
Mathieu Lirzin July 29, 2016, 4:57 p.m. UTC | #4
Alex Griffin <a@ajgrf.com> writes:

> On Fri, Jul 29, 2016, at 09:02 AM, Thompson, David wrote:
>> Sorry I'm late, but I don't think this is the right fix.  

Sorry for not letting you the time to respond.

>> Wrapping programs should only be considered after other options are
>> exhausted.  The correct fix is to patch the source directly to refer
>> to executables by their absolute path.  Why wasn't it done this way?
>
> Mostly because it would be a lot of on-going work every time the package
> is updated. As a shell script, it invokes an external tool nearly every
> other line. If you look at the discussion that happened in February when
> the package was first added [1], Jessica (the original packager) was
> really discouraged by the prospect of patching every invocation of an
> external tool. She also tried to submit changes upstream so that kind of
> work wouldn't be necessary, but upstream wasn't very receptive to the
> idea. In the end, the package was just committed to Guix in a broken
> state.
>
> Another approach I considered was adding a bunch of shell aliases to the
> top of the script pointing to the Guix store. That makes the problem a
> lot more tractable than replacing every external invocation, but it's
> still kinda complicated and it still requires finding every single
> program that gets called and keeping it up to date with new releases. So
> even if all upstream does is use another program from coreutils, the fix
> would be out-of-date again.
>
> [1]: https://lists.gnu.org/archive/html/guix-devel/2016-02/msg01310.html

This makes sense to me.
diff mbox

Patch

From 74b838fea52293386169299881cdd7cfefff7f4d Mon Sep 17 00:00:00 2001
From: Alex Griffin <a@ajgrf.com>
Date: Thu, 28 Jul 2016 19:06:10 -0500
Subject: [PATCH] gnu: password-store: Wrap PATH.

* gnu/packages/password-utils.scm (password-store):
[arguments]: Wrap PATH more thoroughly.
[native-inputs]: Move getopt to inputs.
[inputs]: Add sed & alphabetize packages.
---
 gnu/packages/password-utils.scm | 33 ++++++++++++++++-----------------
 1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/gnu/packages/password-utils.scm b/gnu/packages/password-utils.scm
index a03214a..497717f 100644
--- a/gnu/packages/password-utils.scm
+++ b/gnu/packages/password-utils.scm
@@ -6,6 +6,7 @@ 
 ;;; Copyright © 2016 Jessica Tallon <tsyesika@tsyesika.se>
 ;;; Copyright © 2016 Andreas Enge <andreas@enge.fr>
 ;;; Copyright © 2016 Lukas Gradl <lgradl@openmailbox.org>
+;;; Copyright © 2016 Alex Griffin <a@ajgrf.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -266,27 +267,25 @@  any X11 window.")
      '(#:phases
        (modify-phases %standard-phases
          (delete 'configure)
-         (add-after
-          ;; The script requires 'getopt' at run-time, and this allows
-          ;; the user to not install the providing package 'util-linux'
-          ;; in their profile.
-          'unpack 'patch-path
-          (lambda* (#:key inputs outputs #:allow-other-keys)
-            (let ((getopt (string-append (assoc-ref inputs "getopt")
-                                         "/bin/getopt")))
-              (substitute* "src/password-store.sh"
-                (("GETOPT=\"getopt\"")
-                 (string-append "GETOPT=\"" getopt "\"")))
-              #t))))
+         (add-after 'install 'wrap-path
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (path (map (lambda (pkg)
+                                 (string-append (assoc-ref inputs pkg) "/bin"))
+                               '("coreutils" "getopt" "git" "gnupg" "pwgen"
+                                 "sed" "tree" "which" "xclip"))))
+               (wrap-program (string-append out "/bin/pass")
+                 `("PATH" ":" prefix (,(string-join path ":"))))))))
        #:make-flags (list "CC=gcc" (string-append "PREFIX=" %output))
        #:test-target "test"))
-    (native-inputs `(("getopt" ,util-linux))) ; getopt for the tests
-    (inputs `(("gnupg" ,gnupg)
-              ("pwgen" ,pwgen)
-              ("xclip" ,xclip)
+    (inputs `(("getopt" ,util-linux)
               ("git" ,git)
+              ("gnupg" ,gnupg)
+              ("pwgen" ,pwgen)
+              ("sed" ,sed)
               ("tree" ,tree)
-              ("which" ,which)))
+              ("which" ,which)
+              ("xclip" ,xclip)))
     (home-page "http://www.passwordstore.org/")
     (synopsis "Encrypted password manager")
     (description "Password-store is a password manager which uses GnuPG to
-- 
2.9.2