From: Efraim Flashner <efraim@flashner.co.il>
To: 66421@debbugs.gnu.org
Cc: Efraim Flashner <efraim@flashner.co.il>,
Efraim Flashner <efraim@flashner.co.il>
Subject: [bug#66421] [PATCH] guix: import: Don't import yanked rust crates.
Date: Mon, 9 Oct 2023 15:28:01 +0300 [thread overview]
Message-ID: <7e6cbc6b1b853dcc951ba85efc5f90a7443ff800.1696854438.git.efraim@flashner.co.il> (raw)
* 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@0.8` would
give 0.8.5 (which was yanked but was higher than 0.8.4). Similarly,
before `guix import core-foundation-sys@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@nicolasgoaziou.fr>
;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
;;; Copyright © 2023 Simon Tournier <zimon.toutoune@gmail.com>
+;;; Copyright © 2023 Efraim Flashner <efraim@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@craven.ch>
;;; Copyright © 2019, 2020, 2022 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
+;;; Copyright © 2023 Efraim Flashner <efraim@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@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
next reply other threads:[~2023-10-09 12:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-09 12:28 Efraim Flashner [this message]
2023-10-19 2:24 ` [bug#66421] [PATCH] guix: import: Don't import yanked rust crates Maxim Cournoyer
2023-10-22 13:57 ` bug#66421: " Efraim Flashner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7e6cbc6b1b853dcc951ba85efc5f90a7443ff800.1696854438.git.efraim@flashner.co.il \
--to=efraim@flashner.co.il \
--cc=66421@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).