2023-07-18 14:30:33 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -eu -o pipefail
|
|
|
|
|
|
|
|
set -x
|
|
|
|
|
|
|
|
source common.sh
|
|
|
|
|
|
|
|
# Avoid store dir being inside sandbox build-dir
|
|
|
|
unset NIX_STORE_DIR
|
|
|
|
unset NIX_STATE_DIR
|
|
|
|
|
|
|
|
storeDirs
|
|
|
|
|
|
|
|
initLowerStore
|
|
|
|
|
|
|
|
mountOverlayfs
|
|
|
|
|
2023-07-18 15:10:34 +03:00
|
|
|
# Realise a derivation from the lower store to propagate paths to overlay DB
|
|
|
|
nix-store --store "$storeB" --realise $drvPath
|
2023-07-18 14:30:33 +03:00
|
|
|
|
2023-07-18 15:10:34 +03:00
|
|
|
# Also ensure dummy file exists in overlay DB
|
|
|
|
dummyPath=$(nix-store --store "$storeB" --add ../dummy)
|
2023-07-18 14:30:33 +03:00
|
|
|
|
2023-07-18 15:10:34 +03:00
|
|
|
# Verify should be successful at this point
|
|
|
|
nix-store --store "$storeB" --verify --check-contents
|
2023-07-18 14:30:33 +03:00
|
|
|
|
2023-07-18 15:10:34 +03:00
|
|
|
# Now delete one of the derivation inputs in the lower store
|
|
|
|
inputDrvFullPath=$(find "$storeA" -name "*-hermetic-input-1.drv")
|
|
|
|
inputDrvPath=${inputDrvFullPath/*\/nix\/store\///nix/store/}
|
|
|
|
rm -v "$inputDrvFullPath"
|
2023-07-18 14:30:33 +03:00
|
|
|
|
2023-07-18 15:10:34 +03:00
|
|
|
# And truncate the contents of dummy file in lower store
|
|
|
|
find "$storeA" -name "*-dummy" -exec truncate -s 0 {} \;
|
2023-07-18 14:30:33 +03:00
|
|
|
|
2023-07-18 15:10:34 +03:00
|
|
|
# Verify should fail with the messages about missing input and modified dummy file
|
2023-07-18 15:49:13 +03:00
|
|
|
verifyOutput=$(expectStderr 1 nix-store --store "$storeB" --verify --check-contents --repair)
|
2023-07-18 15:10:34 +03:00
|
|
|
<<<"$verifyOutput" grepQuiet "path '$inputDrvPath' disappeared, but it still has valid referrers!"
|
|
|
|
<<<"$verifyOutput" grepQuiet "path '$dummyPath' was modified! expected hash"
|
2023-07-18 15:49:13 +03:00
|
|
|
<<<"$verifyOutput" grepQuiet "store does not support --verify --repair"
|