From 0df7fce1f2746fadfe3f9aa82826b48c84b3eab2 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sat, 24 Oct 2020 17:33:10 +0100 Subject: Improve missing inputs behaviour When a substitute is found for a direct input, but it can't be fetched, this is probably because something it referenced isn't available. Therefore, look through the references recursively and collect up the store items that aren't available locally or via a substitute. Send this list to the coordinator so that it can schedule builds. --- guix-build-coordinator/utils.scm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'guix-build-coordinator/utils.scm') diff --git a/guix-build-coordinator/utils.scm b/guix-build-coordinator/utils.scm index ef26d3a..c6f1b44 100644 --- a/guix-build-coordinator/utils.scm +++ b/guix-build-coordinator/utils.scm @@ -36,6 +36,7 @@ call-with-streaming-http-request make-chunked-input-port* + find-missing-substitutes-for-output has-substiutes-no-cache? substitute-derivation @@ -256,6 +257,30 @@ upcoming chunk." (values response body)))))))) +(define (find-missing-substitutes-for-output store substitute-urls 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 store + substitute-urls + referenced-output)))) + (narinfo-references narinfo)) + (list output))))) + (define (has-substiutes-no-cache? substitute-urls file) (define %narinfo-cache-directory (if (zero? (getuid)) -- cgit v1.2.3