GNU bug report logs - #66421
[PATCH] guix: import: Don't import yanked rust crates.

Previous Next

Package: guix-patches;

Reported by: Efraim Flashner <efraim <at> flashner.co.il>

Date: Mon, 9 Oct 2023 12:32:02 UTC

Severity: normal

Tags: patch

Done: Efraim Flashner <efraim <at> flashner.co.il>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 66421 in the body.
You can then email your comments to 66421 AT debbugs.gnu.org in the normal way.

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

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


Report forwarded to efraim <at> flashner.co.il, guix-patches <at> gnu.org:
bug#66421; Package guix-patches. (Mon, 09 Oct 2023 12:32:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Efraim Flashner <efraim <at> flashner.co.il>:
New bug report received and forwarded. Copy sent to efraim <at> flashner.co.il, guix-patches <at> gnu.org. (Mon, 09 Oct 2023 12:32:02 GMT) Full text and rfc822 format available.

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

From: Efraim Flashner <efraim <at> flashner.co.il>
To: guix-patches <at> gnu.org
Cc: Efraim Flashner <efraim <at> flashner.co.il>
Subject: [PATCH] guix: import: Don't import yanked rust crates.
Date: Mon,  9 Oct 2023 15:28:01 +0300
* guix/import/crate.scm (<crate-version>): Add yanked? field.
(crate->guix-package)[find-crate-version]: Remove versions which have
been yanked.
* tests/crate.scm: Adjust tests for new yanked? field.
---

Before this patch `guix import core-foundation-sys` would give 0.8.4
(the listed max version), `guix import core-foundation-sys <at> 0.8` would
give 0.8.5 (which was yanked but was higher than 0.8.4). Similarly,
before `guix import core-foundation-sys <at> 0.7` gave 0.7.2 and after 0.7.0.

 guix/import/crate.scm |  7 ++++++-
 tests/crate.scm       | 40 +++++++++++++++++++++++++++-------------
 2 files changed, 33 insertions(+), 14 deletions(-)

diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index 6e10ebb5d4..a7eafb023e 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -5,6 +5,7 @@
 ;;; Copyright © 2021 Nicolas Goaziou <mail <at> nicolasgoaziou.fr>
 ;;; Copyright © 2022 Hartmut Goebel <h.goebel <at> crazy-compilers.com>
 ;;; Copyright © 2023 Simon Tournier <zimon.toutoune <at> gmail.com>
+;;; Copyright © 2023 Efraim Flashner <efraim <at> flashner.co.il>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -82,6 +83,7 @@ (define-json-mapping <crate-version> make-crate-version crate-version?
                  (match-lambda
                    ('null #f)
                    ((? string? str) str)))
+  (yanked?       crate-version-yanked? "yanked")  ;boolean
   (links         crate-version-links))            ;alist
 
 ;; Crate dependency.  Each dependency (each edge in the graph) is annotated as
@@ -256,12 +258,15 @@ (define* (crate->guix-package crate-name #:key version include-dev-deps?
            (semver->string (last versions)))))
 
   ;; find the highest version of a crate that fulfills the semver <range>
+  ;; and hasn't been yanked
   (define (find-crate-version crate range)
     (let* ((semver-range (string->semver-range range))
            (versions
             (sort
              (filter (lambda (entry)
-                       (semver-range-contains? semver-range (first entry)))
+                       (and
+                         (not (crate-version-yanked? (second entry)))
+                         (semver-range-contains? semver-range (first entry))))
                      (map (lambda (ver)
                             (list (string->semver (crate-version-number ver))
                                   ver))
diff --git a/tests/crate.scm b/tests/crate.scm
index 720fcb212c..5aea5efaf3 100644
--- a/tests/crate.scm
+++ b/tests/crate.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2016 David Craven <david <at> craven.ch>
 ;;; Copyright © 2019, 2020, 2022 Ludovic Courtès <ludo <at> gnu.org>
 ;;; Copyright © 2020 Martin Becze <mjbecze <at> riseup.net>
+;;; Copyright © 2023 Efraim Flashner <efraim <at> flashner.co.il>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -76,21 +77,24 @@ (define test-foo-crate
         \"license\": \"MIT OR Apache-2.0\",
         \"links\": {
           \"dependencies\": \"/api/v1/crates/foo/0.8.1/dependencies\"
-        }
+        },
+        \"yanked\": false
       },
       { \"id\": 234212,
         \"num\": \"1.0.0\",
         \"license\": \"MIT OR Apache-2.0\",
         \"links\": {
           \"dependencies\": \"/api/v1/crates/foo/1.0.0/dependencies\"
-        }
+        },
+        \"yanked\": false
       },
       { \"id\": 234214,
         \"num\": \"1.0.3\",
         \"license\": \"MIT OR Apache-2.0\",
         \"links\": {
           \"dependencies\": \"/api/v1/crates/foo/1.0.3/dependencies\"
-        }
+        },
+        \"yanked\": false
       }
     ]
   }
@@ -123,14 +127,16 @@ (define test-root-crate
         \"license\": \"MIT OR Apache-2.0\",
         \"links\": {
           \"dependencies\": \"/api/v1/crates/root/1.0.0/dependencies\"
-        }
+        },
+        \"yanked\": false
       },
       { \"id\": 234242,
         \"num\": \"1.0.4\",
         \"license\": \"MIT OR Apache-2.0\",
         \"links\": {
           \"dependencies\": \"/api/v1/crates/root/1.0.4/dependencies\"
-        }
+        },
+        \"yanked\": false
       }
     ]
   }
@@ -178,21 +184,24 @@ (define test-intermediate-a-crate
         \"license\": \"MIT OR Apache-2.0\",
         \"links\": {
           \"dependencies\": \"/api/v1/crates/intermediate-a/1.0.40/dependencies\"
-        }
+        },
+        \"yanked\": false
       },
       { \"id\": 234250,
         \"num\": \"1.0.42\",
         \"license\": \"MIT OR Apache-2.0\",
         \"links\": {
           \"dependencies\": \"/api/v1/crates/intermediate-a/1.0.42/dependencies\"
-        }
+        },
+        \"yanked\": false
       },
       { \"id\": 234252,
         \"num\": \"1.1.0-alpha.1\",
         \"license\": \"MIT OR Apache-2.0\",
         \"links\": {
           \"dependencies\": \"/api/v1/crates/intermediate-a/1.1.0-alpha.1/dependencies\"
-        }
+        },
+        \"yanked\": false
       }
     ]
   }
@@ -235,7 +244,8 @@ (define test-intermediate-b-crate
         \"license\": \"MIT OR Apache-2.0\",
         \"links\": {
           \"dependencies\": \"/api/v1/crates/intermediate-b/1.2.3/dependencies\"
-        }
+        },
+        \"yanked\": false
       }
     ]
   }
@@ -268,14 +278,16 @@ (define test-leaf-alice-crate
         \"license\": \"MIT OR Apache-2.0\",
         \"links\": {
           \"dependencies\": \"/api/v1/crates/leaf-alice/0.7.3/dependencies\"
-        }
+        },
+        \"yanked\": false
       },
       { \"id\": 234272,
         \"num\": \"0.7.5\",
         \"license\": \"MIT OR Apache-2.0\",
         \"links\": {
           \"dependencies\": \"/api/v1/crates/leaf-alice/0.7.5/dependencies\"
-        }
+        },
+        \"yanked\": false
       }
     ]
   }
@@ -302,7 +314,8 @@ (define test-leaf-bob-crate
         \"license\": \"MIT OR Apache-2.0\",
         \"links\": {
           \"dependencies\": \"/api/v1/crates/leaf-bob/3.0.1/dependencies\"
-        }
+        },
+        \"yanked\": false
       }
     ]
   }
@@ -597,7 +610,8 @@ (define test-doctool-crate
         \"license\": \"MIT OR Apache-2.0\",
         \"links\": {
           \"dependencies\": \"/api/v1/crates/doctool/2.2.2/dependencies\"
-        }
+        },
+        \"yanked\": false
       }
     ]
   }

base-commit: 9b77bd0b9b4f3de69390da0ba7db5b9dbc01e554
-- 
Efraim Flashner   <efraim <at> flashner.co.il>   רנשלפ םירפא
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted





Information forwarded to guix-patches <at> gnu.org:
bug#66421; Package guix-patches. (Thu, 19 Oct 2023 02:26:01 GMT) Full text and rfc822 format available.

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

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: Efraim Flashner <efraim <at> flashner.co.il>
Cc: 66421 <at> debbugs.gnu.org
Subject: Re: [bug#66421] [PATCH] guix: import: Don't import yanked rust crates.
Date: Wed, 18 Oct 2023 22:24:57 -0400
Hi Efraim,

Efraim Flashner <efraim <at> flashner.co.il> writes:

> * guix/import/crate.scm (<crate-version>): Add yanked? field.
> (crate->guix-package)[find-crate-version]: Remove versions which have
> been yanked.
> * tests/crate.scm: Adjust tests for new yanked? field.
> ---
>
> Before this patch `guix import core-foundation-sys` would give 0.8.4
> (the listed max version), `guix import core-foundation-sys <at> 0.8` would
> give 0.8.5 (which was yanked but was higher than 0.8.4). Similarly,
> before `guix import core-foundation-sys <at> 0.7` gave 0.7.2 and after 0.7.0.
>
>  guix/import/crate.scm |  7 ++++++-
>  tests/crate.scm       | 40 +++++++++++++++++++++++++++-------------
>  2 files changed, 33 insertions(+), 14 deletions(-)
>
> diff --git a/guix/import/crate.scm b/guix/import/crate.scm
> index 6e10ebb5d4..a7eafb023e 100644
> --- a/guix/import/crate.scm
> +++ b/guix/import/crate.scm
> @@ -5,6 +5,7 @@
>  ;;; Copyright © 2021 Nicolas Goaziou <mail <at> nicolasgoaziou.fr>
>  ;;; Copyright © 2022 Hartmut Goebel <h.goebel <at> crazy-compilers.com>
>  ;;; Copyright © 2023 Simon Tournier <zimon.toutoune <at> gmail.com>
> +;;; Copyright © 2023 Efraim Flashner <efraim <at> flashner.co.il>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -82,6 +83,7 @@ (define-json-mapping <crate-version> make-crate-version crate-version?
>                   (match-lambda
>                     ('null #f)
>                     ((? string? str) str)))
> +  (yanked?       crate-version-yanked? "yanked")  ;boolean
>    (links         crate-version-links))            ;alist
>  
>  ;; Crate dependency.  Each dependency (each edge in the graph) is annotated as
> @@ -256,12 +258,15 @@ (define* (crate->guix-package crate-name #:key version include-dev-deps?
>             (semver->string (last versions)))))
>  
>    ;; find the highest version of a crate that fulfills the semver <range>
> +  ;; and hasn't been yanked

While touching this comment, it'd be nice to turn add punctuation
(capitalize the first letter and add a period).

>    (define (find-crate-version crate range)
>      (let* ((semver-range (string->semver-range range))
>             (versions
>              (sort
>               (filter (lambda (entry)
> -                       (semver-range-contains? semver-range (first entry)))
> +                       (and
> +                         (not (crate-version-yanked? (second entry)))
> +                         (semver-range-contains? semver-range (first entry))))
>                       (map (lambda (ver)
>                              (list (string->semver (crate-version-number ver))
>                                    ver))

LGTM.  Related, but not in scope, could be to rewrite the above using a
match-lambda instead of accessing the entry items via first second.

-- 
Thanks,
Maxim




Reply sent to Efraim Flashner <efraim <at> flashner.co.il>:
You have taken responsibility. (Sun, 22 Oct 2023 13:59:02 GMT) Full text and rfc822 format available.

Notification sent to Efraim Flashner <efraim <at> flashner.co.il>:
bug acknowledged by developer. (Sun, 22 Oct 2023 13:59:02 GMT) Full text and rfc822 format available.

Message #13 received at 66421-done <at> debbugs.gnu.org (full text, mbox):

From: Efraim Flashner <efraim <at> flashner.co.il>
To: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Cc: 66421-done <at> debbugs.gnu.org
Subject: Re: [bug#66421] [PATCH] guix: import: Don't import yanked rust crates.
Date: Sun, 22 Oct 2023 16:57:54 +0300
[Message part 1 (text/plain, inline)]
On Wed, Oct 18, 2023 at 10:24:57PM -0400, Maxim Cournoyer wrote:
> Hi Efraim,
> 
> Efraim Flashner <efraim <at> flashner.co.il> writes:
> 
> > * guix/import/crate.scm (<crate-version>): Add yanked? field.
> > (crate->guix-package)[find-crate-version]: Remove versions which have
> > been yanked.
> > * tests/crate.scm: Adjust tests for new yanked? field.
> > ---
> >
> > Before this patch `guix import core-foundation-sys` would give 0.8.4
> > (the listed max version), `guix import core-foundation-sys <at> 0.8` would
> > give 0.8.5 (which was yanked but was higher than 0.8.4). Similarly,
> > before `guix import core-foundation-sys <at> 0.7` gave 0.7.2 and after 0.7.0.
> >
> >  guix/import/crate.scm |  7 ++++++-
> >  tests/crate.scm       | 40 +++++++++++++++++++++++++++-------------
> >  2 files changed, 33 insertions(+), 14 deletions(-)
> >
> > diff --git a/guix/import/crate.scm b/guix/import/crate.scm
> > index 6e10ebb5d4..a7eafb023e 100644
> > --- a/guix/import/crate.scm
> > +++ b/guix/import/crate.scm
> > @@ -5,6 +5,7 @@
> >  ;;; Copyright © 2021 Nicolas Goaziou <mail <at> nicolasgoaziou.fr>
> >  ;;; Copyright © 2022 Hartmut Goebel <h.goebel <at> crazy-compilers.com>
> >  ;;; Copyright © 2023 Simon Tournier <zimon.toutoune <at> gmail.com>
> > +;;; Copyright © 2023 Efraim Flashner <efraim <at> flashner.co.il>
> >  ;;;
> >  ;;; This file is part of GNU Guix.
> >  ;;;
> > @@ -82,6 +83,7 @@ (define-json-mapping <crate-version> make-crate-version crate-version?
> >                   (match-lambda
> >                     ('null #f)
> >                     ((? string? str) str)))
> > +  (yanked?       crate-version-yanked? "yanked")  ;boolean
> >    (links         crate-version-links))            ;alist
> >  
> >  ;; Crate dependency.  Each dependency (each edge in the graph) is annotated as
> > @@ -256,12 +258,15 @@ (define* (crate->guix-package crate-name #:key version include-dev-deps?
> >             (semver->string (last versions)))))
> >  
> >    ;; find the highest version of a crate that fulfills the semver <range>
> > +  ;; and hasn't been yanked
> 
> While touching this comment, it'd be nice to turn add punctuation
> (capitalize the first letter and add a period).

Done

> >    (define (find-crate-version crate range)
> >      (let* ((semver-range (string->semver-range range))
> >             (versions
> >              (sort
> >               (filter (lambda (entry)
> > -                       (semver-range-contains? semver-range (first entry)))
> > +                       (and
> > +                         (not (crate-version-yanked? (second entry)))
> > +                         (semver-range-contains? semver-range (first entry))))
> >                       (map (lambda (ver)
> >                              (list (string->semver (crate-version-number ver))
> >                                    ver))
> 
> LGTM.  Related, but not in scope, could be to rewrite the above using a
> match-lambda instead of accessing the entry items via first second.

This I'm going to have to spend some more time on, I haven't used
match-lambda much.

-- 
Efraim Flashner   <efraim <at> flashner.co.il>   רנשלפ םירפא
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted
[signature.asc (application/pgp-signature, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 20 Nov 2023 12:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 209 days ago.

Previous Next


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