summaryrefslogtreecommitdiff
path: root/src/cuirass/database.scm
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2020-01-04 09:43:04 +0000
committerChristopher Baines <mail@cbaines.net>2020-01-04 09:43:04 +0000
commit4195cc3f7200527ae98d182babb266e97ea1bf8c (patch)
treec58386f5fd894fb28c164664f69ac1d9ccd55ec7 /src/cuirass/database.scm
parent5c5790ad21d88599bb07dd9669708d8b58a47124 (diff)
downloadcuirass-4195cc3f7200527ae98d182babb266e97ea1bf8c.tar
cuirass-4195cc3f7200527ae98d182babb266e97ea1bf8c.tar.gz
Support returning build information by output.support-returning-build-information-by-output
Being able to take a derivation and query the build information is useful, but in cases where there are multiple derivations that produce the same outputs, the probability of getting the data back from Cuirass is reduced. This is because Cuirass might not have build the exact derivation you have, but a different derivation that produces the same outputs (this can commonly happen when a related fixed output derivation changes). Cuirass doesn't store derivations if they produce the same outputs as a derivation it already knows about, so it can't determine if this is the case. Therefore, provide a way of querying build results by output, rather than derivation. The motivation behind this is to make it easier to import build information in to the Guix Data Service. * src/cuirass/database.scm (db-get-output): New procedure. * src/cuirass/http.scm (respond-output-not-found): New procedure. (request-path-components): Handle /output/… requests. * doc/cuirass.texi (Build information): Mention that you can get build information by output.
Diffstat (limited to 'src/cuirass/database.scm')
-rw-r--r--src/cuirass/database.scm15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/cuirass/database.scm b/src/cuirass/database.scm
index 523165d..66e93e2 100644
--- a/src/cuirass/database.scm
+++ b/src/cuirass/database.scm
@@ -47,6 +47,7 @@
build-status
db-add-build
db-update-build-status!
+ db-get-output
db-get-build
db-get-builds
db-get-builds-by-search
@@ -539,6 +540,20 @@ log file for DRV."
"WHERE derivation=" drv " AND status != " status
";")))))
+(define (db-get-output path)
+ "Retrieve the OUTPUT for PATH."
+ (with-db-critical-section db
+ ;; There isn't a unique index on path, but because Cuirass avoids adding
+ ;; derivations which introduce the same outputs, there should only be one
+ ;; result.
+ (match (sqlite-exec db "SELECT derivation, name FROM Outputs
+WHERE path =" path "
+LIMIT 1;")
+ (() #f)
+ ((#(derivation name))
+ `((#:derivation . ,derivation)
+ (#:name . ,name))))))
+
(define (db-get-outputs derivation)
"Retrieve the OUTPUTS of the build identified by DERIVATION in the
database."