summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Buddelmeijer <hugo@buddelmeijer.nl>2026-06-30 17:42:10 +0200
committerLudovic Courtès <ludo@gnu.org>2026-07-01 09:08:53 +0200
commit85571d27d2e830fd7f6e96dc4df7f92a30ff3c2e (patch)
treedf97f972f2342e387b0f7ae738f13ed92d1bf7ff
parent636a104836fe00fca5844e15e3c40c9cf5cd1427 (diff)
daemon: Don't delete files from the store with guix build -K --rounds=3 --check.
Specifying all three of -K, --check, --rounds=3 caused valid packages to be deleted from the store. When `buildMode == bmCheck`, the built package is not renamed from `actualPath` to `i.second.path. Then later, when `settings.keepFailed` and `curRound < nrRounds`, `i.second.path` was renamed to `i.second.path + "-check"` anyway. * nix/libstore/build.cc (DerivationGoal::registerOutputs): Add check for bmCheck before renaming store path. * tests/store.scm ("build-things, check mode"): Ensure file is a valid path. ("build-things, check mode + keep-failed"): New test. Fixes: #9631. Change-Id: I31d24b2349f563867b8101a1b5ce3c10896ce165 Co-authored-by: Ludovic Courtès <ludo@gnu.org> Signed-off-by: Ludovic Courtès <ludo@gnu.org> Merges: #9632
-rw-r--r--nix/libstore/build.cc5
-rw-r--r--tests/store.scm31
2 files changed, 34 insertions, 2 deletions
diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc
index 85be95d557f..b94bca5359a 100644
--- a/nix/libstore/build.cc
+++ b/nix/libstore/build.cc
@@ -3370,7 +3370,10 @@ void DerivationGoal::registerOutputs()
3370 assert(false); // shouldn't happen 3370 assert(false); // shouldn't happen
3371 } 3371 }
3372 3372
3373 if (settings.keepFailed) { 3373 /* Rename the built package when doing multiple rounds, but
3374 don't move the package when running in check mode, since
3375 that would remove the valid package from the store. */
3376 if (settings.keepFailed && buildMode != bmCheck) {
3374 for (auto & i : drv.outputs) { 3377 for (auto & i : drv.outputs) {
3375 Path prev = i.second.path + checkSuffix; 3378 Path prev = i.second.path + checkSuffix;
3376 if (pathExists(prev)) deletePath(prev); 3379 if (pathExists(prev)) deletePath(prev);
diff --git a/tests/store.scm b/tests/store.scm
index a3e67ac7ea4..87773bf0c36 100644
--- a/tests/store.scm
+++ b/tests/store.scm
@@ -1702,7 +1702,8 @@ System: x86_64-linux~%"
1702 (begin 1702 (begin
1703 (guard (c ((store-protocol-error? c) 1703 (guard (c ((store-protocol-error? c)
1704 (pk 'determinism-exception c) 1704 (pk 'determinism-exception c)
1705 (and (not (zero? (store-protocol-error-status c))) 1705 (and (valid-path? store file) ;must still be valid
1706 (not (zero? (store-protocol-error-status c)))
1706 (string-contains (store-protocol-error-message c) 1707 (string-contains (store-protocol-error-message c)
1707 "deterministic")))) 1708 "deterministic"))))
1708 ;; This one will produce a different result. Since we're in 1709 ;; This one will produce a different result. Since we're in
@@ -1711,6 +1712,34 @@ System: x86_64-linux~%"
1711 (build-mode check)) 1712 (build-mode check))
1712 #f)))))) 1713 #f))))))
1713 1714
1715(test-equal "build-things, check mode + keep-failed"
1716 '(#t #t)
1717 (with-store store
1718 (let* ((drv (build-expression->derivation
1719 store "deterministic-thing-to-check"
1720 `(let ((out (assoc-ref %outputs "out")))
1721 (call-with-output-file out
1722 (lambda (port)
1723 (display ,(let ((now (gettimeofday)))
1724 (+ (car now) (cdr now)))
1725 port))))
1726 #:guile-for-build
1727 (package-derivation
1728 store %bootstrap-guile (%current-system))))
1729 (file (derivation->output-path drv)))
1730 (and (build-things store (list (derivation-file-name drv)))
1731 (valid-path? store file)
1732 (begin
1733 ;; This would trigger accidental deletion of FILE.
1734 (set-build-options store
1735 #:keep-failed? #t
1736 #:keep-going? #t
1737 #:rounds 3)
1738 (build-things store (list (derivation-file-name drv))
1739 (build-mode check))
1740 (list (valid-path? store file)
1741 (file-exists? file)))))))
1742
1714(test-assert "build-succeeded trace in check mode" 1743(test-assert "build-succeeded trace in check mode"
1715 (string-contains 1744 (string-contains
1716 (call-with-output-string 1745 (call-with-output-string