diff options
| author | Alexander_Kabui <alexanderkabua@gmail.com> | 2026-10-07 07:05:45 +0300 |
|---|---|---|
| committer | Alexander_Kabui <alexanderkabua@gmail.com> | 2026-10-07 07:30:24 +0300 |
| commit | 95e9e7e920be5ccd4bf037b51bef6ab077b59c9a (patch) | |
| tree | 2bab24b509e6bbfb3e9799a619191c8f644f203e | |
| parent | 13a7cb117deadd7a8253e218ede7d6cd430c9da7 (diff) | |
| download | genenetwork4-95e9e7e920be5ccd4bf037b51bef6ab077b59c9a.tar.gz | |
guix.scm (vendor phase): write real package checksums from the restored lock.
Guix build attempt 3 (logs/guix-c1-3.log) got past the git-source
resolution and failed on checksum verification: the restored
Cargo.lock records every registry package's crates-io checksum, but
the stock patch-cargo-checksums {"files":{}} stub provides none —
"unable to verify that hashbrown v0.12.3 is the same as when the
lockfile was generated".
The replaced patch-cargo-checksums now writes each vendored crate's
.cargo-checksum.json as {"files":{},"package":"<checksum>"} with the
checksum read straight out of the restored lock (each vendor
directory is named after its lock entry, both generated from the same
lock by guix import crate). The per-file map stays empty — the same
trust model as the stock stub; only the package-level checksum cargo
verifies against the lock is real. The awk program builds the JSON
quotes/backslashes via %c so it needs no escaped literals (a first
draft double-escaped them; caught by running the exact program
against the real lock before committing, not after a 40-minute guix
cycle). The git checkout keeps a plain {"files":{}} stub.
The exact guix-style flow was re-proven offline end to end before this
commit: cold cargo cache, files:{} + lock-sourced package checksums,
cargo build --offline EXIT 0 (full recompile, 1m25s).
| -rw-r--r-- | guix.scm | 61 |
1 files changed, 45 insertions, 16 deletions
diff --git a/guix.scm b/guix.scm index b493c14..5b8df1f 100644 --- a/guix.scm +++ b/guix.scm @@ -32,31 +32,41 @@ (not (string-contains file "/target/"))))) (build-system cargo-build-system) ;; The xapian-rs git dependency (the native search engine's - ;; bindings) is vendored like every other crate, but cargo needs - ;; three things beyond the registry crates: a source-replacement - ;; stanza mapping the git source onto the vendored directory - ;; (exactly what `cargo vendor` emits), the Cargo.lock that the - ;; build system's configure phase deletes -- cargo refuses to - ;; resolve a git dependency against vendored sources without one - ;; ("requires a lock file to be present first"; mechanism verified - ;; end-to-end offline outside guix: lock + vendor dir + stanza = - ;; cargo build --offline EXIT 0) -- and a .cargo-checksum.json stub - ;; in the copied git checkout (cargo verifies directory-source - ;; packages through it; registry crates carry one inside their - ;; .crate tarball). The stub is written explicitly here rather - ;; than relying on patch-cargo-checksums, which skips the - ;; alphabetically first vendor directory. + ;; bindings) needs the vendored-graph build to deviate from the + ;; stock registry flow in four coordinated ways, all verified + ;; offline end-to-end first (lock + vendor dir + replacement + ;; stanza + real package checksums = cargo build --offline EXIT 0): + ;; + ;; 1. A source-replacement stanza mapping the git source onto the + ;; vendored directory -- exactly what `cargo vendor` emits. + ;; 2. The committed Cargo.lock restored after configure deleted it: + ;; cargo refuses to resolve a git dependency against vendored + ;; sources without a lock file ("requires a lock file to be + ;; present first"), so the stock delete-then-resolve flow cannot + ;; work for a git dep. + ;; 3. Real `package` checksums in every vendored registry crate's + ;; .cargo-checksum.json (read back out of the restored lock), + ;; replacing the stock {"files":{}} stub, which cannot verify + ;; what the lock records ("unable to verify that <crate> is the + ;; same as when the lockfile was generated"). The per-`files` map + ;; stays empty (no per-file verification), the same trust model + ;; the stock stub had. + ;; 4. A {"files":{}} stub in the vendored git checkout (git + ;; packages carry no checksum in the lock). + ;; + ;; The phase replaces patch-cargo-checksums wholesale, running in + ;; its slot (after patch-generated-file-shebangs, before build). (arguments (list #:install-source? #f #:phases #~(modify-phases %standard-phases - (add-after 'patch-cargo-checksums 'vendor-vendored-git-dep + (replace 'patch-cargo-checksums (lambda* (#:key source #:allow-other-keys) (let* ((rev "97fd34373e8f32f747f29d981271d6ec47643481") (git-url "https://github.com/Alexanderlacuna/xapian-rs") (vendor-dir "guix-vendor") (port (open-file ".cargo/config" "a" - #:encoding "utf-8"))) + #:encoding "utf-8"))) (format port " [source.\"git+~a?rev=~a\"] git = \"~a\" @@ -68,6 +78,25 @@ replace-with = 'vendored-sources' ;; Restore the lock the configure phase deleted. (copy-file (string-append source "/Cargo.lock") "Cargo.lock") + ;; Real package checksums for the vendored registry + ;; crates, read straight out of that lock: each + ;; vendor directory is named after its lock entry + ;; (rust-<name>-<version>.tar.gz, both generated + ;; from the same lock by `guix import crate`), so + ;; the checksum line carries everything needed. + ;; The JSON quotes are built via %c so the awk + ;; program needs no escaped literals. + (invoke "gawk" ' +/^name = / { name = $0; sub(/^[^"]*"/, "", name); sub(/".*$/, "", name) } +/^version = / { ver = $0; sub(/^[^"]*"/, "", ver); sub(/".*$/, "", ver) } +/^checksum = / { chk = $0; sub(/^[^"]*"/, "", chk); sub(/".*$/, "", chk); + q = sprintf("%c", 34); + file = "guix-vendor/rust-" name "-" ver ".tar.gz/.cargo-checksum.json"; + print "{" q "files" q ":{}," q "package" q ":" q chk q "}" > file } +' "Cargo.lock") + ;; The git checkout carries no checksum in the + ;; lock; stub it (empty files map = no per-file + ;; verification, the same trust level as above). (let ((xapian-dir (car (find-files vendor-dir "^rust-xapian-rs" #:directories? #t)))) |
