Subject: Re: [bug#66704] [PATCH v2] gnu: patman: Wrap program with git.

From: Maxim Cournoyer <[email-masked]>
Date: Sat, 14 Sep 2024 22:01:33 +0900

Hi Simon,

Simon Tournier <[email-masked]> writes:

> * gnu/packages/bootloaders.scm (patman): Replace by 'package/inherit'.

I don't think package/inherit is appropriate here; patman is not a
variant of u-boot (doesn't share any of its inputs) -- it jut happens to
have its source part of the u-boot sources.

I've dropped it.

> [arguments]: Add 'wrap-program' that uses git dependency.
> [inputs]: Add git and git:send-email.
>
> Change-Id: Id4ebadd518f271baa087161b10455ec03d6f959b
> ---
>  gnu/packages/bootloaders.scm | 22 ++++++++++++++++++----
>  1 file changed, 18 insertions(+), 4 deletions(-)
>
> Hi,
>
> On Mon, 23 Oct 2023 at 21:05, Maxim Cournoyer <[email-masked]> wrote:
>
>> I see 'git send-email' in the above
>
> Good catch!  Added.  However, I am not happy with the mix of “styles”.  And I
> suspect a “bug” or something lacking for packages with multiple outputs; I am
> going to open a report about that.  Another story and not blocking, IMHO.
>
>
>>                        Did you test that this suffices to get a fully
>> self-contained working patman?  Maybe you can send a v2 with patman.

[...]

>                (substitute* "pyproject.toml"
>                  (("patman.__main__:run_patman")
> -                 "patman.__main__")))))))
> -    (inputs (list python-pygit2 python-requests python-u-boot-pylib))
> +                 "patman.__main__"))))
> +          (add-after 'install 'wrap-program
> +            (lambda* (#:key inputs #:allow-other-keys)
> +              (let ((git:send-email (assoc-ref inputs "git:send-email")))
> +                (wrap-program (string-append #$output "/bin/patman")
> +                  `("PATH" ":" prefix
> +                    (,(string-append #$(this-package-input "git") "/bin")))
> +                  `("GIT_EXEC_PATH" ":" prefix
> +                    (,(string-append #$(this-package-input "git") "/libexec/git-core")
> +                     ,(string-append git:send-email "/libexec/git-core"))))))))))

I think 'search-input-file' would be better here. It should be preferred
to gexps in general, as it is more lazy and works better with
inheritance.

> +    (inputs `(("git" ,git)
> +              ("git:send-email" ,git "send-email")
> +              ("python-pygit2" ,python-pygit2)
> +              ("python-requests" ,python-requests)
> +              ("python-u-boot-pylib" ,python-u-boot-pylib)))
>      (synopsis "Patch automation tool")
>      (description "Patman is a patch automation script which:
>  @itemize

I modified this to avoid adding labels, which was not necessary.  I've
also used wrap-script, which inserts the wrapping in the Python script
directly instead of creating a .patman-real wrapper, which uglifies the
process name in top, for example.

You'll find the result in commit 4c99ef43f0.

Thanks for kicking the ball.

-- 
Thanks,
Maxim