2020-11-17 15:33:09 +02:00
|
|
|
# Test that we can successfully migrate from an older db schema
|
|
|
|
|
2023-03-16 22:00:20 +02:00
|
|
|
source common.sh
|
|
|
|
|
2020-11-17 15:33:09 +02:00
|
|
|
# Only run this if we have an older Nix available
|
2021-03-16 15:20:10 +02:00
|
|
|
# XXX: This assumes that the `daemon` package is older than the `client` one
|
2021-12-09 17:26:46 +02:00
|
|
|
if [[ -z "${NIX_DAEMON_PACKAGE-}" ]]; then
|
2023-03-16 22:00:20 +02:00
|
|
|
skipTest "not using the Nix daemon"
|
2020-11-17 15:33:09 +02:00
|
|
|
fi
|
|
|
|
|
2021-07-26 07:54:55 +03:00
|
|
|
killDaemon
|
|
|
|
|
2020-11-17 15:33:09 +02:00
|
|
|
# Fill the db using the older Nix
|
|
|
|
PATH_WITH_NEW_NIX="$PATH"
|
2021-12-09 17:26:46 +02:00
|
|
|
export PATH="${NIX_DAEMON_PACKAGE}/bin:$PATH"
|
2020-11-17 15:33:09 +02:00
|
|
|
clearStore
|
|
|
|
nix-build simple.nix --no-out-link
|
|
|
|
nix-store --generate-binary-cache-key cache1.example.org $TEST_ROOT/sk1 $TEST_ROOT/pk1
|
|
|
|
dependenciesOutPath=$(nix-build dependencies.nix --no-out-link --secret-key-files "$TEST_ROOT/sk1")
|
|
|
|
fixedOutPath=$(IMPURE_VAR1=foo IMPURE_VAR2=bar nix-build fixed.nix -A good.0 --no-out-link)
|
|
|
|
|
|
|
|
# Migrate to the new schema and ensure that everything's there
|
|
|
|
export PATH="$PATH_WITH_NEW_NIX"
|
|
|
|
info=$(nix path-info --json $dependenciesOutPath)
|
|
|
|
[[ $info =~ '"ultimate":true' ]]
|
|
|
|
[[ $info =~ 'cache1.example.org' ]]
|
|
|
|
nix verify -r "$fixedOutPath"
|
|
|
|
nix verify -r "$dependenciesOutPath" --sigs-needed 1 --trusted-public-keys $(cat $TEST_ROOT/pk1)
|