1
0
mirror of https://git.savannah.gnu.org/git/guix.git synced 2026-05-23 09:35:56 +02:00

import: crate: Add Cargo.lock parser.

* guix/import/crate/cargo-lock.scm: New file.
* Makefile.am (MODULES): Regisiter it.
* etc/teams.scm (rust)[#:scope]: Add it.
* CODEOWNERS: Add it.
* guix/import/crate.scm (cargo-lock->expressions): New procedure.
* tests/crate.scm (temp-file): New variable.
("crate-lockfile-import"): New test.

Co-authored-by: Murilo <murilo@disroot.org>
Co-authored-by: Luis Guilherme Coelho <lgcoelho@disroot.org>
Change-Id: I95421e9e2ba11a671b4bc4e1323c6d31a1b012c5
This commit is contained in:
Hilton Chain
2025-02-24 12:50:26 +08:00
parent 4e8eab6fe4
commit f27fb840c2
6 changed files with 273 additions and 0 deletions
+87
View File
@@ -34,6 +34,7 @@
#:use-module (gnu packages)
#:use-module (ice-9 iconv)
#:use-module (ice-9 match)
#:use-module (srfi srfi-11)
#:use-module (srfi srfi-64))
@@ -476,6 +477,9 @@
(description #f)
(license #f)))
(define temp-file
(string-append "t-crate-" (number->string (getpid))))
(test-begin "crate")
@@ -1178,4 +1182,87 @@
(x
(pk 'fail (pretty-print-with-comments (current-output-port) x) #f)))))
(test-assert "crate-lockfile-import"
(begin
(call-with-output-file temp-file
(lambda (port)
(display "\
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = \"adler2\"
version = \"2.0.0\"
source = \"registry+https://github.com/rust-lang/crates.io-index\"
checksum = \"512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627\"
[[package]]
name = \"aho-corasick\"
version = \"1.1.3\"
source = \"registry+https://github.com/rust-lang/crates.io-index\"
checksum = \"8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916\"
dependencies = [
\"memchr\",
]
[[package]]
name = \"smithay\"
version = \"0.4.0\"
source = \"git+https://github.com/Smithay/smithay.git?rev=\
0cd3345c59f7cb139521f267956a1a4e33248393#\
0cd3345c59f7cb139521f267956a1a4e33248393\"
dependencies = [
\"appendlist\",
]
[[package]]
name = \"test\"
version = \"25.2.0\"\n" port)))
(mock
((guix scripts download) guix-download
(lambda _
(format #t "~a~%~a~%"
"/gnu/store/in056fyrz6nvy3jpxrxglgj30g0lwniv-smithay-0cd3345"
"191h87bpzg0l1ihfb4hmx00b86pfb5mwwc6s8i49al0vigc14l37")))
(let-values
(((source-expressions cargo-inputs-entry)
(cargo-lock->expressions temp-file "test")))
(and
(match source-expressions
(`((define rust-adler2-2.0.0
(crate-source
"adler2" "2.0.0"
"09r6drylvgy8vv8k20lnbvwq8gp09h7smfn6h1rxsy15pgh629si"))
(define rust-aho-corasick-1.1.3
(crate-source
"aho-corasick" "1.1.3"
"05mrpkvdgp5d20y2p989f187ry9diliijgwrs254fs9s1m1x6q4f"))
(define rust-smithay-0.4.0.0cd3345
,($ <comment>
";; TODO: Define standalone package if this is a workspace.\n"
#f)
(origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/Smithay/smithay.git")
(commit "0cd3345c59f7cb139521f267956a1a4e33248393")))
(file-name (git-file-name "rust-smithay" "0.4.0.0cd3345"))
(sha256
(base32
"191h87bpzg0l1ihfb4hmx00b86pfb5mwwc6s8i49al0vigc14l37")))))
#t)
(x
(pk 'fail (pretty-print-with-comments (current-output-port) x) #f)))
(match cargo-inputs-entry
(`(test => (list rust-adler2-2.0.0
rust-aho-corasick-1.1.3
rust-smithay-0.4.0.0cd3345))
#t)
(x
(pk 'fail x #f))))))))
(test-end "crate")
(false-if-exception (delete-file temp-file))