2010-11-17 17:30:07 +02:00
|
|
|
source common.sh
|
|
|
|
|
2010-11-17 19:32:25 +02:00
|
|
|
clearManifests
|
|
|
|
|
2010-11-17 17:30:07 +02:00
|
|
|
mkdir -p $TEST_ROOT/cache2 $TEST_ROOT/patches
|
|
|
|
|
|
|
|
RESULT=$TEST_ROOT/result
|
|
|
|
|
|
|
|
# Build version 1 and 2 of the "foo" package.
|
2011-10-11 00:11:08 +03:00
|
|
|
nix-push --copy $TEST_ROOT/cache2 $TEST_ROOT/manifest1 \
|
2011-10-11 00:32:34 +03:00
|
|
|
$(nix-build -o $RESULT binary-patching.nix --arg version 1)
|
2010-11-17 17:30:07 +02:00
|
|
|
|
2011-10-11 00:32:34 +03:00
|
|
|
out2=$(nix-build -o $RESULT binary-patching.nix --arg version 2)
|
2011-10-11 00:11:08 +03:00
|
|
|
nix-push --copy $TEST_ROOT/cache2 $TEST_ROOT/manifest2 $out2
|
2010-11-17 20:01:37 +02:00
|
|
|
|
2011-10-11 00:32:34 +03:00
|
|
|
out3=$(nix-build -o $RESULT binary-patching.nix --arg version 3)
|
2011-10-11 00:11:08 +03:00
|
|
|
nix-push --copy $TEST_ROOT/cache2 $TEST_ROOT/manifest3 $out3
|
2010-11-17 20:01:37 +02:00
|
|
|
|
2010-11-17 17:30:07 +02:00
|
|
|
rm $RESULT
|
|
|
|
|
2010-11-17 20:01:37 +02:00
|
|
|
# Generate binary patches.
|
2011-10-11 00:11:08 +03:00
|
|
|
nix-generate-patches $TEST_ROOT/cache2 $TEST_ROOT/patches \
|
2010-11-17 17:30:07 +02:00
|
|
|
file://$TEST_ROOT/patches $TEST_ROOT/manifest1 $TEST_ROOT/manifest2
|
|
|
|
|
2011-10-11 00:11:08 +03:00
|
|
|
nix-generate-patches $TEST_ROOT/cache2 $TEST_ROOT/patches \
|
2010-11-17 20:01:37 +02:00
|
|
|
file://$TEST_ROOT/patches $TEST_ROOT/manifest2 $TEST_ROOT/manifest3
|
2010-11-17 17:30:07 +02:00
|
|
|
|
2010-11-17 20:01:37 +02:00
|
|
|
grep -q "patch {" $TEST_ROOT/manifest3
|
2010-11-17 17:30:07 +02:00
|
|
|
|
2010-11-17 20:01:37 +02:00
|
|
|
# Get rid of versions 2 and 3.
|
2011-10-11 00:32:34 +03:00
|
|
|
nix-store --delete $out2 $out3
|
2010-11-17 17:30:07 +02:00
|
|
|
|
2010-11-17 20:01:37 +02:00
|
|
|
# Pull the manifest containing the patches.
|
|
|
|
clearManifests
|
2011-10-11 00:32:34 +03:00
|
|
|
nix-pull file://$TEST_ROOT/manifest3
|
2010-11-17 17:30:07 +02:00
|
|
|
|
2010-11-17 20:01:37 +02:00
|
|
|
# Make sure that the download size prediction uses the patches rather
|
2010-11-17 19:32:25 +02:00
|
|
|
# than the full download.
|
2011-10-11 00:32:34 +03:00
|
|
|
nix-build -o $RESULT binary-patching.nix --arg version 3 --dry-run 2>&1 | grep -q "0.01 MiB"
|
2010-11-17 19:32:25 +02:00
|
|
|
|
2010-11-17 20:01:37 +02:00
|
|
|
# Now rebuild it. This should use the two patches generated above.
|
|
|
|
rm -f $TEST_ROOT/var/log/nix/downloads
|
2011-10-11 00:32:34 +03:00
|
|
|
nix-build -o $RESULT binary-patching.nix --arg version 3
|
2010-11-17 20:01:37 +02:00
|
|
|
rm $RESULT
|
|
|
|
[ "$(grep ' patch ' $TEST_ROOT/var/log/nix/downloads | wc -l)" -eq 2 ]
|
|
|
|
|
|
|
|
# Add a patch from version 1 directly to version 3.
|
2011-10-11 00:11:08 +03:00
|
|
|
nix-generate-patches $TEST_ROOT/cache2 $TEST_ROOT/patches \
|
2010-11-17 20:01:37 +02:00
|
|
|
file://$TEST_ROOT/patches $TEST_ROOT/manifest1 $TEST_ROOT/manifest3
|
|
|
|
|
|
|
|
# Rebuild version 3. This should use the direct patch rather than the
|
|
|
|
# sequence of two patches.
|
2011-10-11 00:32:34 +03:00
|
|
|
nix-store --delete $out2 $out3
|
2010-11-17 20:01:37 +02:00
|
|
|
clearManifests
|
|
|
|
rm $TEST_ROOT/var/log/nix/downloads
|
2011-10-11 00:32:34 +03:00
|
|
|
nix-pull file://$TEST_ROOT/manifest3
|
|
|
|
nix-build -o $RESULT binary-patching.nix --arg version 3
|
2010-11-17 20:01:37 +02:00
|
|
|
[ "$(grep ' patch ' $TEST_ROOT/var/log/nix/downloads | wc -l)" -eq 1 ]
|