summaryrefslogtreecommitdiff
path: root/guix/scripts
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-11-17 23:10:34 +0100
committerLudovic Courtès <ludo@gnu.org>2019-11-17 23:14:54 +0100
commit9c9982dc0c8c38ce3821b154b7e92509c1564317 (patch)
treec1e11b91d1bd5e6f5adb836262c871b618daedd7 /guix/scripts
parent16ac74033ae9f01e8be81c4f7f1857e13545bc2f (diff)
guix build: Handle "guix build /….drv" correctly for non-existent derivations.
This lets the daemon substitute missing derivations, as in the example at <https://bugs.gnu.org/38226>, instead of failing with ENOENT. * guix/scripts/build.scm (options->things-to-build): In the 'derivation-path?' case, don't fail when 'read-derivation-from-file' raises to ENOENT; return the empty list in that case. (guix-build): Add non-existent '.drv' files to ITEMS. Pass ITEMS in addition to DRV to 'build-derivations'. * tests/guix-build.sh: Add test.
Diffstat (limited to 'guix/scripts')
-rw-r--r--guix/scripts/build.scm19
1 files changed, 16 insertions, 3 deletions
diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm
index 9ad7379bbe..ae78df9c5c 100644
--- a/guix/scripts/build.scm
+++ b/guix/scripts/build.scm
@@ -802,7 +802,15 @@ build---packages, gexps, derivations, and so on."
(append-map (match-lambda
(('argument . (? string? spec))
(cond ((derivation-path? spec)
- (list (read-derivation-from-file spec)))
+ (catch 'system-error
+ (lambda ()
+ (list (read-derivation-from-file spec)))
+ (lambda args
+ ;; Non-existent .drv files can be substituted down
+ ;; the road, so don't error out.
+ (if (= ENOENT (system-error-errno args))
+ '()
+ (apply throw args)))))
((store-path? spec)
;; Nothing to do; maybe for --log-file.
'())
@@ -934,7 +942,11 @@ needed."
'())))
(items (filter-map (match-lambda
(('argument . (? store-path? file))
- (and (not (derivation-path? file))
+ ;; If FILE is a .drv that's not in
+ ;; store, keep it so that it can be
+ ;; substituted.
+ (and (or (not (derivation-path? file))
+ (not (file-exists? file)))
file))
(_ #f))
opts))
@@ -965,7 +977,8 @@ needed."
(map (compose list derivation-file-name) drv)
roots))
((not (assoc-ref opts 'dry-run?))
- (and (build-derivations store drv mode)
+ (and (build-derivations store (append drv items)
+ mode)
(for-each show-derivation-outputs drv)
(for-each (cut register-root store <> <>)
(map (lambda (drv)