Subject: bug#61684: can't compose 'with-patch' with 'with-source'

From: Ludovic Courtès <[email-masked]>
Date: Thu, 23 Feb 2023 15:08:48 +0100

Hi Maxim,

Maxim Cournoyer <[email-masked]> skribis:

> Given 'with-source' discards any patch from the original source, I thought
> I could at least add them back via 'with-patch', but it appears this
> does not work:
>
> scheme@(gnu packages jami)> (options->transformation 
>                              `((with-source . "[email-masked]=/home/maxim/src/jami/jami-20230220.0.tar.gz")
>                                (with-patch . ,(string-append 
>                                                "libjami=" (search-patch 
>                                                            "jami-disable-integration-tests.patch")))))
> $6 = #<procedure 7f2cd01a97e0 at guix/transformations.scm:1010:2 (obj)>
> scheme@(gnu packages jami)> ($6 libjami)
> $7 = #<package [email-masked] guix/transformations.scm:1002 7f2ccc8386e0>
> scheme@(gnu packages jami)> (package-source $7)
> $8 = #<<downloaded-file> uri: "/home/maxim/src/jami/jami-20230220.0.tar.gz" recursive?: #t>
> scheme@(gnu packages jami)>
>
> The downloaded-file resulting package source has lost the patch, and no
> error got produced, leaving the user to discover this limitation by
> themselves.

The order of options matters; in this case, you need to do it the other
way around:

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> (options->transformation '((with-patch . "jami=/tmp/t.patch")
						(with-source . "jami=http://example.org/foo.tar.gz")))
$18 = #<procedure 7f7e6b1fd0c0 at guix/transformations.scm:1010:2 (obj)>
scheme@(guile-user)> ($18 jami)
$19 = #<package [email-masked] guix/transformations.scm:1002 7f7e6b1602c0>
scheme@(guile-user)> (package-source $19)
$20 = #<<computed-file> name: "jami-20230206.0-source" gexp: #<gexp  guix/transformations.scm:688:19 7f7e6b6c8d50> guile: #f options: (#:local-build? #t)>
--8<---------------cut here---------------end--------------->8---

The <computed-file> bit comes from the ‘with-patch’ transformation, to
apply the patch to the <downloaded-file>.

If you do it the other way around, the effect of ‘with-patch’ is
canceled by that of ‘with-source’, which does not preserve patches.  So
strictly speaking, both options had an effect, but they were
contradictory.

Note that ordering is “specified”, notably with the test added in
0f024554e63a49e20c2a7a67e928073c266bf5c5 (this is crucial for our HPC
users, who routinely combine a whole bunch of options; you have no idea
how far they go once you give them the tool :-)).  I don’t think the
manual explicitly states it though.

HTH,
Ludo’.