GNU bug report logs - #47754
[PATCH] gnu: transformations: fix with-latest option for git source package.

Previous Next

Package: guix-patches;

Reported by: Z572 <873216071 <at> qq.com>

Date: Tue, 13 Apr 2021 16:33:01 UTC

Severity: normal

Tags: patch

To reply to this bug, email your comments to 47754 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#47754; Package guix-patches. (Tue, 13 Apr 2021 16:33:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Z572 <873216071 <at> qq.com>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Tue, 13 Apr 2021 16:33:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Z572 <873216071 <at> qq.com>
To: guix-patches <at> gnu.org
Subject: [PATCH] gnu: transformations: fix with-latest option for git source
 package.
Date: Wed, 14 Apr 2021 00:28:57 +0800
[0001-gnu-transformations-fix-with-latest-option-for-git-s.patch (text/x-patch, inline)]
From 52bd30a6ac967375aa9a178345f1bdea8388457a Mon Sep 17 00:00:00 2001
From: Zheng Junjie <873216071 <at> qq.com>
Date: Tue, 13 Apr 2021 23:00:10 +0800
Subject: [PATCH] gnu: transformations: fix with-latest option for git source
 package.

gnu/transformations.scm: (transform-package-latest): (package-with-latest-upstream):
use git-checkout if p is a git source package.
---
 guix/transformations.scm | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/guix/transformations.scm b/guix/transformations.scm
index 4e9260350c..559e408c37 100644
--- a/guix/transformations.scm
+++ b/guix/transformations.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo <at> gnu.org>
+;;; Copyright @ 2021 Zheng Junjie <873216071 <at> qq.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -26,6 +27,7 @@
   #:autoload   (guix git-download) (git-reference? git-reference-url)
   #:autoload   (guix git) (git-checkout git-checkout? git-checkout-url)
   #:autoload   (guix upstream) (package-latest-release*
+                                upstream-source-urls
                                 upstream-source-version
                                 upstream-source-signature-urls)
   #:use-module (guix utils)
@@ -537,7 +539,11 @@ are replaced by their latest upstream version."
              (package
                (inherit p)
                (version (upstream-source-version source))
-               (source source))))))
+               (source (cond ((false-if-exception (package-git-url p))
+                              (git-checkout
+                               (url (car (upstream-source-urls source)))
+                               (recursive? #t)))
+                             (else source))))))))
 
   (define rewrite
     (package-input-rewriting/spec
-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#47754; Package guix-patches. (Wed, 03 Nov 2021 11:04:01 GMT) Full text and rfc822 format available.

Message #8 received at 47754 <at> debbugs.gnu.org (full text, mbox):

From: zimoun <zimon.toutoune <at> gmail.com>
To: Z572 <873216071 <at> qq.com>
Cc: 47754 <at> debbugs.gnu.org
Subject: Re: bug#47754: [PATCH] gnu: transformations: fix with-latest option
 for git source package.
Date: Wed, 03 Nov 2021 11:18:44 +0100
Hi,

Thanks for the patch.

On Wed, 14 Apr 2021 at 00:28, Z572 <873216071 <at> qq.com> wrote:

>>From 52bd30a6ac967375aa9a178345f1bdea8388457a Mon Sep 17 00:00:00 2001
> From: Zheng Junjie <873216071 <at> qq.com>
> Date: Tue, 13 Apr 2021 23:00:10 +0800
> Subject: [PATCH] gnu: transformations: fix with-latest option for git source
>  package.
>
> gnu/transformations.scm: (transform-package-latest): (package-with-latest-upstream):
> use git-checkout if p is a git source package.
> ---
>  guix/transformations.scm | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)

[...]

>    #:autoload   (guix upstream) (package-latest-release*
> +                                upstream-source-urls
>                                  upstream-source-version
>                                  upstream-source-signature-urls)
>    #:use-module (guix utils)
> @@ -537,7 +539,11 @@ are replaced by their latest upstream version."
>               (package
>                 (inherit p)
>                 (version (upstream-source-version source))
> -               (source source))))))
> +               (source (cond ((false-if-exception (package-git-url p))
> +                              (git-checkout
> +                               (url (car (upstream-source-urls source)))
> +                               (recursive? #t)))
> +                             (else source))))))))

Could you provide an example for an use-case?

Cheers,
simon




Information forwarded to guix-patches <at> gnu.org:
bug#47754; Package guix-patches. (Wed, 03 Nov 2021 15:35:01 GMT) Full text and rfc822 format available.

Message #11 received at 47754 <at> debbugs.gnu.org (full text, mbox):

From: Z572 <873216071 <at> qq.com>
To: zimoun <zimon.toutoune <at> gmail.com>
Cc: 47754 <at> debbugs.gnu.org
Subject: Re: bug#47754: [PATCH] gnu: transformations: fix with-latest option
 for git source package.
Date: Wed, 03 Nov 2021 22:54:40 +0800
Hi,

zimoun <zimon.toutoune <at> gmail.com> writes:

> Hi,
>
> Thanks for the patch.
>
> On Wed, 14 Apr 2021 at 00:28, Z572 <873216071 <at> qq.com> wrote:
>
>>>From 52bd30a6ac967375aa9a178345f1bdea8388457a Mon Sep 17 00:00:00 2001
>> From: Zheng Junjie <873216071 <at> qq.com>
>> Date: Tue, 13 Apr 2021 23:00:10 +0800
>> Subject: [PATCH] gnu: transformations: fix with-latest option for git source
>>  package.
>>
>> gnu/transformations.scm: (transform-package-latest): (package-with-latest-upstream):
>> use git-checkout if p is a git source package.
>> ---
>>  guix/transformations.scm | 8 +++++++-
>>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> [...]
>
>>    #:autoload   (guix upstream) (package-latest-release*
>> +                                upstream-source-urls
>>                                  upstream-source-version
>>                                  upstream-source-signature-urls)
>>    #:use-module (guix utils)
>> @@ -537,7 +539,11 @@ are replaced by their latest upstream version."
>>               (package
>>                 (inherit p)
>>                 (version (upstream-source-version source))
>> -               (source source))))))
>> +               (source (cond ((false-if-exception (package-git-url p))
>> +                              (git-checkout
>> +                               (url (car (upstream-source-urls source)))
>> +                               (recursive? #t)))
>> +                             (else source))))))))
>
> Could you provide an example for an use-case?

Just try this:

``` bash
$ file `guix build fbreader --with-latest=fbreader -S`
/gnu/store/rdqkmjpiig9gddzsxj4mdyw8lvn944xg-FBReader: HTML document, UTF-8 Unicode text, with very long lines

```

If a package is a git source package, after use "with-latest" option, it's url
will become to it's source. and build will fail.

This patch just fix this.

But i think this patch not good, maybe need a new patch(use latest version
not latest commit).  But i'm not familiar with this part.


>
> Cheers,
> simon


-- 
over




Information forwarded to guix-patches <at> gnu.org:
bug#47754; Package guix-patches. (Wed, 03 Nov 2021 16:20:02 GMT) Full text and rfc822 format available.

Message #14 received at 47754 <at> debbugs.gnu.org (full text, mbox):

From: zimoun <zimon.toutoune <at> gmail.com>
To: Z572 <873216071 <at> qq.com>
Cc: 47754 <at> debbugs.gnu.org
Subject: Re: bug#47754: [PATCH] gnu: transformations: fix with-latest option
 for git source package.
Date: Wed, 3 Nov 2021 17:18:40 +0100
Hi,

On Wed, 3 Nov 2021 at 16:34, Z572 <873216071 <at> qq.com> wrote:

> $ file `guix build fbreader --with-latest=fbreader -S`
> /gnu/store/rdqkmjpiig9gddzsxj4mdyw8lvn944xg-FBReader: HTML document, UTF-8 Unicode text, with very long lines

> If a package is a git source package, after use "with-latest" option, it's url
> will become to it's source. and build will fail.
>
> This patch just fix this.

I see.  However, I am not convinced your example is correct, because
for instance,

--8<---------------cut here---------------start------------->8---
$ file $(guix build r-soupx -S)
/gnu/store/1z0j6i4a9xwwd8d3955m7vq3f1x4p3aq-r-soupx-0.3.1-1.a3354be-checkout:
directory
--8<---------------cut here---------------end--------------->8---

What you are seeing is: Git upstream source is modified by Guix (for
instance, patches are applied or files are removed; in the field
'origin') and "guix build -S" returns what Guix actually builds, not
what upstream provides.  Therefore, in this case, the modified source
is returned as compressed archive.  However, when using the
transformation 'with-latest', in this case, "guix build -S
--with-latest" returns what upstream provides, thus a directory (or
something else as a file).

Maybe I miss something, but from me, the inconsistency comes from the
behavior of "guix build -S", not about the behaviour of 'with-latest'
transformation.  And I also miss why the build would fail.


Cheers,
simon




Information forwarded to guix-patches <at> gnu.org:
bug#47754; Package guix-patches. (Thu, 04 Nov 2021 11:58:01 GMT) Full text and rfc822 format available.

Message #17 received at 47754 <at> debbugs.gnu.org (full text, mbox):

From: Z572 <873216071 <at> qq.com>
To: zimoun <zimon.toutoune <at> gmail.com>
Cc: 47754 <at> debbugs.gnu.org
Subject: Re: bug#47754: [PATCH] gnu: transformations: fix with-latest option
 for git source package.
Date: Thu, 04 Nov 2021 19:17:38 +0800

zimoun <zimon.toutoune <at> gmail.com> writes:

> Hi,
>
> On Wed, 3 Nov 2021 at 16:34, Z572 <873216071 <at> qq.com> wrote:
>
>> $ file `guix build fbreader --with-latest=fbreader -S`
>> /gnu/store/rdqkmjpiig9gddzsxj4mdyw8lvn944xg-FBReader: HTML document,
>> UTF-8 Unicode text, with very long lines
>
>> If a package is a git source package, after use "with-latest"
>> option, it's url
>> will become to it's source. and build will fail.
>>
>> This patch just fix this.
>
> I see.  However, I am not convinced your example is correct, because
> for instance,
>
> $ file $(guix build r-soupx -S)
> /gnu/store/1z0j6i4a9xwwd8d3955m7vq3f1x4p3aq-r-soupx-0.3.1-1.a3354be-checkout:
> directory
>
> What you are seeing is: Git upstream source is modified by Guix (for
> instance, patches are applied or files are removed; in the field
> 'origin') and "guix build -S" returns what Guix actually builds, not
> what upstream provides.  Therefore, in this case, the modified source
> is returned as compressed archive.  However, when using the
> transformation 'with-latest', in this case, "guix build -S
> --with-latest" returns what upstream provides, thus a directory (or
> something else as a file).

I looked source again, just because of "upstream-source-compiler" don't support
git source package, all will become to use url-fetch.

See (guix upstream) module:

``` scheme
(define-gexp-compiler (upstream-source-compiler (source <upstream-source>)
                                                system target)
  "Download SOURCE from its first URL and lower it as a fixed-output
derivation that would fetch it."
  (mlet* %store-monad ((url -> (first (upstream-source-urls source)))
                       (signature
                        -> (and=> (upstream-source-signature-urls source)
                                  first))
                       (tarball ((store-lift download-tarball) url signature)))
    (unless tarball
      (raise (formatted-message (G_ "failed to fetch source from '~a'")
                                url)))

    ;; Instead of returning TARBALL, return a fixed-output derivation that
    ;; would be able to re-download it.  In practice, since TARBALL is already
    ;; in the store, no extra download will happen, but having the derivation
    ;; in store improves provenance tracking.
    (let ((hash (call-with-input-file tarball port-sha256)))
      (url-fetch url 'sha256 hash (store-path-package-name tarball)
                 #:system system))))

```

I'm have no idea how to change it, so i just check if package is
git-source, use "git-checkout" instead of "upstream-source".

>
> Maybe I miss something, but from me, the inconsistency comes from the
> behavior of "guix build -S", not about the behaviour of 'with-latest'
> transformation.  And I also miss why the build would fail.
>
>
> Cheers,
> simon


-- 
over




Information forwarded to guix-patches <at> gnu.org:
bug#47754; Package guix-patches. (Sat, 06 Nov 2021 19:07:02 GMT) Full text and rfc822 format available.

Message #20 received at 47754 <at> debbugs.gnu.org (full text, mbox):

From: zimoun <zimon.toutoune <at> gmail.com>
To: Z572 <873216071 <at> qq.com>
Cc: 47754 <at> debbugs.gnu.org
Subject: Re: bug#47754: [PATCH] gnu: transformations: fix with-latest option
 for git source package.
Date: Sat, 06 Nov 2021 19:17:05 +0100
Hi,

On Thu, 04 Nov 2021 at 19:17, Z572 <873216071 <at> qq.com> wrote:

>>> If a package is a git source package, after use "with-latest"
>>> option, it's url
>>> will become to it's source. and build will fail.
>>>
>>> This patch just fix this.
>>
>> I see.  However, I am not convinced your example is correct, because
>> for instance,
>>
>> $ file $(guix build r-soupx -S)
>> /gnu/store/1z0j6i4a9xwwd8d3955m7vq3f1x4p3aq-r-soupx-0.3.1-1.a3354be-checkout:
>> directory
>>
>> What you are seeing is: Git upstream source is modified by Guix (for
>> instance, patches are applied or files are removed; in the field
>> 'origin') and "guix build -S" returns what Guix actually builds, not
>> what upstream provides.  Therefore, in this case, the modified source
>> is returned as compressed archive.  However, when using the
>> transformation 'with-latest', in this case, "guix build -S
>> --with-latest" returns what upstream provides, thus a directory (or
>> something else as a file).
>
> I looked source again, just because of "upstream-source-compiler" don't support
> git source package, all will become to use url-fetch.

[...]

> I'm have no idea how to change it, so i just check if package is
> git-source, use "git-checkout" instead of "upstream-source".

>> Maybe I miss something, but from me, the inconsistency comes from the
>> behavior of "guix build -S", not about the behaviour of 'with-latest'
>> transformation.  And I also miss why the build would fail.

I am sorry if I misread you.  What are you trying to solve?


Cheers,
simon




This bug report was last modified 3 years and 317 days ago.

Previous Next


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