aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2020-04-30 20:07:53 +0100
committerChristopher Baines <mail@cbaines.net>2020-04-30 20:07:53 +0100
commite72892ee26d1d755f3289e5c8c3a187ecd6a9230 (patch)
tree706364ef458e98f46394c034833b789da7d2c89f /scripts
parent3087c9e6fa7d42ffb34132eb3b78d6815be13ac5 (diff)
downloadbuild-coordinator-e72892ee26d1d755f3289e5c8c3a187ecd6a9230.tar
build-coordinator-e72892ee26d1d755f3289e5c8c3a187ecd6a9230.tar.gz
Add --ignore-if-build-for-outputs-exists
Diffstat (limited to 'scripts')
-rw-r--r--scripts/guix-build-coordinator.in46
1 files changed, 37 insertions, 9 deletions
diff --git a/scripts/guix-build-coordinator.in b/scripts/guix-build-coordinator.in
index 38fdea9..04c52e2 100644
--- a/scripts/guix-build-coordinator.in
+++ b/scripts/guix-build-coordinator.in
@@ -26,7 +26,9 @@
(srfi srfi-37)
(ice-9 match)
((guix ui) #:select (read/eval))
+ (guix derivations)
(guix-build-coordinator hooks)
+ (guix-build-coordinator utils)
(guix-build-coordinator config)
(guix-build-coordinator datastore)
(guix-build-coordinator coordinator)
@@ -73,6 +75,9 @@
(option '("ignore-if-build-for-derivation-exists") #f #f
(lambda (opt name _ result)
(alist-cons 'ignore-if-build-for-derivation-exists #t result)))
+ (option '("ignore-if-build-for-outputs-exists") #f #f
+ (lambda (opt name _ result)
+ (alist-cons 'ignore-if-build-for-outputs-exists #t result)))
(option '("ensure-all-related-derivations-have-builds") #f #f
(lambda (opt name _ result)
(alist-cons 'ensure-all-related-derivations-have-builds
@@ -86,6 +91,7 @@
(define %build-option-defaults
`((priority . 0)
(ignore-if-build-for-derivation-exists . #f)
+ (ignore-if-build-for-outputs-exists . #f)
(ensure-all-related-derivations-have-builds . #f)
(defer-allocation . #f)))
@@ -182,15 +188,37 @@
derivation-file)
(exit 0))))
- (let ((uuid (submit-build
- datastore
- derivation-file
- #:priority (assq-ref opts 'priority)
- #:defer-allocation? (assq-ref opts 'defer-allocation)
- #:ensure-all-related-derivations-have-builds?
- (assq-ref
- opts 'ensure-all-related-derivations-have-builds))))
- (simple-format #t "build submitted as ~A\n" uuid)))))))
+ (unless (file-exists? derivation-file)
+ (substitute-derivation derivation-file))
+
+ (let ((derivation (read-derivation-from-file derivation-file)))
+
+ (when (assq-ref opts 'ignore-if-build-for-outputs-exists)
+ (for-each
+ (match-lambda
+ ((name . derivation-output)
+ (let ((builds-for-output
+ (datastore-list-builds-for-output
+ datastore
+ (derivation-output-path derivation-output))))
+
+ (unless (null? builds-for-output)
+ (simple-format
+ #t "there are already ~A builds for ~A, skipping\n"
+ (length builds-for-output)
+ (derivation-output-path derivation-output))
+ (exit 0)))))
+ (derivation-outputs derivation)))
+
+ (let ((uuid (submit-build
+ datastore
+ derivation
+ #:priority (assq-ref opts 'priority)
+ #:defer-allocation? (assq-ref opts 'defer-allocation)
+ #:ensure-all-related-derivations-have-builds?
+ (assq-ref
+ opts 'ensure-all-related-derivations-have-builds))))
+ (simple-format #t "build submitted as ~A\n" uuid))))))))
(("agent" "new" rest ...)
(let ((opts (parse-options (append %agent-options
%base-options)