From abacaf6db0f165740117d421b9957a8663d6bb02 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sat, 24 Oct 2020 17:43:19 +0100 Subject: WIP --- guix-build-coordinator/agent.scm | 1 + guix-build-coordinator/utils.scm | 54 +++++++++++++++++++++------------------- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/guix-build-coordinator/agent.scm b/guix-build-coordinator/agent.scm index 850d378..9fbd882 100644 --- a/guix-build-coordinator/agent.scm +++ b/guix-build-coordinator/agent.scm @@ -202,6 +202,7 @@ (append-map (lambda (missing-output) (find-missing-substitutes-for-output + store non-derivation-substitute-urls missing-output)) missing-files)))) diff --git a/guix-build-coordinator/utils.scm b/guix-build-coordinator/utils.scm index 3fbb349..d9ce9d1 100644 --- a/guix-build-coordinator/utils.scm +++ b/guix-build-coordinator/utils.scm @@ -257,13 +257,13 @@ upcoming chunk." (values response body)))))))) -(define (find-missing-substitutes-for-output substitute-urls output) - (define %narinfo-cache-directory - (if (zero? (getuid)) - (or (and=> (getenv "XDG_CACHE_HOME") - (cut string-append <> "/guix/substitute")) - (string-append %state-directory "/substitute/cache")) - (string-append (cache-directory #:ensure? #f) "/substitute"))) +(define (find-missing-substitutes-for-output store substitute-urls output) + ;; (define %narinfo-cache-directory + ;; (if (zero? (getuid)) + ;; (or (and=> (getenv "XDG_CACHE_HOME") + ;; (cut string-append <> "/guix/substitute")) + ;; (string-append %state-directory "/substitute/cache")) + ;; (string-append (cache-directory #:ensure? #f) "/substitute"))) ;; Because there's no control over the caching of 404 lookups, and I'd ;; rather not reach inside and monkey patch the Guix code, just delete any @@ -290,25 +290,27 @@ upcoming chunk." ;; #:unwind? #t)))) ;; (or directories '()))) - (let ((narinfo - (any (lambda (substitute-url) - (let ((result (lookup-narinfos substitute-url (list output)))) - (if (null? result) - #f - (first result)))) - substitute-urls))) - (if narinfo - (append-map - (lambda (reference) - (let ((referenced-output - (string-append (%store-prefix) "/" reference))) - (peek "REF" referenced-output) - (if (string=? referenced-output output) - '() - (find-missing-substitutes-for-output substitute-urls - referenced-output)))) - (narinfo-references narinfo)) - (list output)))) + (if (valid-path? store output) + '() + (let ((narinfo + (any (lambda (substitute-url) + (let ((result (lookup-narinfos substitute-url (list output)))) + (if (null? result) + #f + (first result)))) + substitute-urls))) + (if narinfo + (append-map + (lambda (reference) + (let ((referenced-output + (string-append (%store-prefix) "/" reference))) + (peek "REF" referenced-output) + (if (string=? referenced-output output) + '() + (find-missing-substitutes-for-output substitute-urls + referenced-output)))) + (narinfo-references narinfo)) + (list output))))) (define (has-substiutes-no-cache? substitute-urls file) (define %narinfo-cache-directory -- cgit v1.2.3