diff options
author | Christopher Baines <mail@cbaines.net> | 2020-04-25 15:05:00 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2020-04-25 15:05:00 +0100 |
commit | ea30c6d8d263ffaf65e4297a49af92536cd7445d (patch) | |
tree | f2dffc5094d67332f053a9ca6fc50d51dee56f8a /guix-build-coordinator | |
parent | fc4d44ab84fb080c04f849cdc73b1c8a839d7814 (diff) | |
download | build-coordinator-ea30c6d8d263ffaf65e4297a49af92536cd7445d.tar build-coordinator-ea30c6d8d263ffaf65e4297a49af92536cd7445d.tar.gz |
Add datastore-list-related-derivations-with-no-build
Useful for finding out what derivations need to be built to ensure all related
derivations have been built by the build coordinator.
Diffstat (limited to 'guix-build-coordinator')
-rw-r--r-- | guix-build-coordinator/datastore.scm | 1 | ||||
-rw-r--r-- | guix-build-coordinator/datastore/sqlite.scm | 38 |
2 files changed, 39 insertions, 0 deletions
diff --git a/guix-build-coordinator/datastore.scm b/guix-build-coordinator/datastore.scm index 14dbe73..47275c8 100644 --- a/guix-build-coordinator/datastore.scm +++ b/guix-build-coordinator/datastore.scm @@ -16,6 +16,7 @@ (re-export datastore-store-build-result) (re-export datastore-fetch-setup-failures) (re-export datastore-list-build-outputs) +(re-export datastore-list-related-derivations-with-no-build) (re-export datastore-store-setup-failure) (re-export datastore-store-setup-failure/missing-inputs) (re-export datastore-list-setup-failure-missing-inputs) diff --git a/guix-build-coordinator/datastore/sqlite.scm b/guix-build-coordinator/datastore/sqlite.scm index ed2bbe8..6743e3c 100644 --- a/guix-build-coordinator/datastore/sqlite.scm +++ b/guix-build-coordinator/datastore/sqlite.scm @@ -11,6 +11,7 @@ #:export (sqlite-datastore datastore-update datastore-store-derivation + datastore-list-related-derivations-with-no-build datastore-store-build datastore-find-build datastore-list-builds-for-derivation @@ -182,6 +183,43 @@ WHERE agent_id = :agent_id AND password = :password"))) (sqlite-exec db "COMMIT TRANSACTION;"))))) #t) +(define-method (datastore-list-related-derivations-with-no-build + (datastore <sqlite-datastore>) + derivation) + (call-with-worker-thread + (slot-ref datastore 'worker-thread-channel) + (lambda (db) + (let ((statement + (sqlite-prepare + db + " +WITH RECURSIVE related_derivations(name) AS ( + VALUES(:derivation) +UNION + SELECT derivation_outputs.derivation_name + FROM derivation_outputs + INNER JOIN derivation_inputs + ON derivation_outputs.id = derivation_inputs.derivation_output_id + INNER JOIN related_derivations + ON related_derivations.name = derivation_inputs.derivation_name +) +SELECT name +FROM related_derivations +WHERE name != :derivation + AND name NOT IN (SELECT derivation_name FROM builds)"))) + + (sqlite-bind-arguments + statement + #:derivation derivation) + + (let ((result (sqlite-map + (match-lambda + (#(derivation) derivation)) + statement))) + (sqlite-reset statement) + + result))))) + (define-method (datastore-store-build (datastore <sqlite-datastore>) derivation-name |