aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-01-12 16:44:26 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-01-12 16:44:26 +0100
commit00903fa79961d7eb0fadeb9ed2d7cda7821dc293 (patch)
treef4fbc45817d58c6e8360d3645ac00ab5527c773f /src
parent0cad1f80492ecf9b4a3420c1436c79a0648de79b (diff)
--check: Keep the differing output if -K is given
This makes it easier to investigate the non-determinism, e.g. $ nix-build pkgs/stdenv/linux -A stage1.pkgs.zlib --check -K error: derivation ‘/nix/store/l54i8wlw22656i4pk05c52ngv9rpl39q-zlib-1.2.8.drv’ may not be deterministic: output ‘/nix/store/11a27shh6n2ivi4a7s964i65ql80cf27-zlib-1.2.8’ differs from ‘/nix/store/11a27shh6n2ivi4a7s964i65ql80cf27-zlib-1.2.8-check’ $ diffoscope /nix/store/11a27shh6n2ivi4a7s964i65ql80cf27-zlib-1.2.8 /nix/store/11a27shh6n2ivi4a7s964i65ql80cf27-zlib-1.2.8-check ... ├── lib/libz.a │ ├── metadata │ │ @@ -1,15 +1,15 @@ │ │ -rw-r--r-- 30001/30000 3096 Jan 12 15:20 2016 adler32.o ... │ │ +rw-r--r-- 30001/30000 3096 Jan 12 15:28 2016 adler32.o ...
Diffstat (limited to 'src')
-rw-r--r--src/libstore/build.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 0b6a214ef..27ba1c84a 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -2748,8 +2748,18 @@ void DerivationGoal::registerOutputs()
if (buildMode == bmCheck) {
if (!store->isValidPath(path)) continue;
ValidPathInfo info = worker.store.queryPathInfo(path);
- if (hash.first != info.hash)
- throw Error(format("derivation ‘%1%’ may not be deterministic: hash mismatch in output ‘%2%’") % drvPath % path);
+ if (hash.first != info.hash) {
+ if (settings.keepFailed) {
+ Path dst = path + "-check";
+ if (pathExists(dst)) deletePath(dst);
+ if (rename(actualPath.c_str(), dst.c_str()))
+ throw SysError(format("renaming ‘%1%’ to ‘%2%’") % actualPath % dst);
+ throw Error(format("derivation ‘%1%’ may not be deterministic: output ‘%2%’ differs from ‘%3%’")
+ % drvPath % path % dst);
+ } else
+ throw Error(format("derivation ‘%1%’ may not be deterministic: output ‘%2%’ differs")
+ % drvPath % path);
+ }
continue;
}