GNU bug report logs - #61684
can't compose 'with-patch' with 'with-source'

Previous Next

Package: guix;

Reported by: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Date: Tue, 21 Feb 2023 18:09:02 UTC

Severity: normal

Full log


View this message in rfc822 format

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 61684 <at> debbugs.gnu.org
Subject: bug#61684: can't compose 'with-patch' with 'with-source'
Date: Fri, 24 Feb 2023 08:59:19 -0500
Hi Ludovic,

Ludovic Courtès <ludo <at> gnu.org> writes:

> Hi Maxim,
>
> Maxim Cournoyer <maxim.cournoyer <at> gmail.com> 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 . "libjami <at> 20230220.0=/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 libjami <at> 20230220.0 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:
>
> 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 jami <at> 20230206.0 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)>
>
> The <computed-file> bit comes from the ‘with-patch’ transformation, to
> apply the patch to the <downloaded-file>.

I tried to do that, like so:

--8<---------------cut here---------------start------------->8---
(define (with-latest-sources name)
  (options->transformation
   ;; XXX: The ordering is important; with-patch must appear before
   ;; with-source, otherwise it is silently discarded.
   `(,@(if (string=? name "libjami")
           `((with-patch . ,(string-append
                             name "="
                             (search-patch
                              "jami-disable-integration-tests.patch")))
             (with-patch . ,(string-append
                             name "="
                             (search-patch
                              "jami-libjami-headers-search.patch"))))
           '())
     (with-source . ,(format #f "~a@~a=~a" name
                             %release-version %release-file-name)))))

(define libjami/latest
  ((with-latest-sources "libjami") libjami))
--8<---------------cut here---------------end--------------->8---

Unfortunately the source derivation fails because it attempts to apply a
patch (a single one?) to a tarball:

--8<---------------cut here---------------start------------->8---
(begin
  (use-modules
   (guix build utils))
  (setenv "PATH" "/gnu/store/mp0syh29rjknflaiv0hkpdlb2mjk0rlx-patch-2.7.6/bin")
  (copy-recursively "/gnu/store/ig8awlxbzrasp9p4f9vq8fqcidrma5qj-jami-20230224.0.tar.gz"
                    ((@
                      (guile)
                      getenv)
                     "out"))
  (chdir
   ((@
     (guile)
     getenv)
    "out"))
  (for-each
   (lambda
       (patch)
     (invoke "patch" "-p1" "--batch" "-i" patch))
   (quote
    ("/gnu/store/iq7hd3f9kr2kvz7lvnygq51yxp85gxbn-jami-libjami-headers-search.patch"))))
--8<---------------cut here---------------end--------------->8---

My expectation of the source rewriting options is that it should end up
with something like what I'd write manually, e.g. an origin with an
appropriate fetch method and its patches field populated, etc., so that
it'd work the same.

-- 
Thanks,
Maxim




This bug report was last modified 2 years and 103 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.