2006-03-01 14:15:33 +02:00
|
|
|
source common.sh
|
|
|
|
|
2006-09-21 21:54:08 +03:00
|
|
|
clearProfiles
|
2006-02-08 16:32:06 +02:00
|
|
|
|
2007-11-29 18:18:24 +02:00
|
|
|
set -x
|
|
|
|
|
2006-02-08 16:32:06 +02:00
|
|
|
# Query installed: should be empty.
|
2011-10-11 00:32:34 +03:00
|
|
|
test "$(nix-env -p $profiles/test -q '*' | wc -l)" -eq 0
|
2006-02-08 16:32:06 +02:00
|
|
|
|
|
|
|
# Query available: should contain several.
|
2011-10-11 00:32:34 +03:00
|
|
|
test "$(nix-env -p $profiles/test -f ./user-envs.nix -qa '*' | wc -l)" -eq 5
|
2006-02-08 16:32:06 +02:00
|
|
|
|
2006-03-10 18:20:42 +02:00
|
|
|
# Query descriptions.
|
2011-10-11 00:32:34 +03:00
|
|
|
nix-env -p $profiles/test -f ./user-envs.nix -qa '*' --description | grep silly
|
2006-03-10 18:20:42 +02:00
|
|
|
|
2006-02-08 16:32:06 +02:00
|
|
|
# Install "foo-1.0".
|
2011-10-11 00:32:34 +03:00
|
|
|
nix-env -p $profiles/test -f ./user-envs.nix -i foo-1.0
|
2006-02-08 16:32:06 +02:00
|
|
|
|
|
|
|
# Query installed: should contain foo-1.0 now (which should be
|
|
|
|
# executable).
|
2011-10-11 00:32:34 +03:00
|
|
|
test "$(nix-env -p $profiles/test -q '*' | wc -l)" -eq 1
|
|
|
|
nix-env -p $profiles/test -q '*' | grep -q foo-1.0
|
2006-02-08 16:32:06 +02:00
|
|
|
test "$($profiles/test/bin/foo)" = "foo-1.0"
|
|
|
|
|
|
|
|
# Store the path of foo-1.0.
|
2011-10-11 00:32:34 +03:00
|
|
|
outPath10=$(nix-env -p $profiles/test -q --out-path --no-name '*' | grep foo-1.0)
|
2006-02-08 16:32:06 +02:00
|
|
|
echo "foo-1.0 = $outPath10"
|
|
|
|
test -n "$outPath10"
|
|
|
|
|
|
|
|
# Install "foo-2.0pre1": should remove foo-1.0.
|
2011-10-11 00:32:34 +03:00
|
|
|
nix-env -p $profiles/test -f ./user-envs.nix -i foo-2.0pre1
|
2006-02-08 16:32:06 +02:00
|
|
|
|
|
|
|
# Query installed: should contain foo-2.0pre1 now.
|
2011-10-11 00:32:34 +03:00
|
|
|
test "$(nix-env -p $profiles/test -q '*' | wc -l)" -eq 1
|
|
|
|
nix-env -p $profiles/test -q '*' | grep -q foo-2.0pre1
|
2006-02-08 16:32:06 +02:00
|
|
|
test "$($profiles/test/bin/foo)" = "foo-2.0pre1"
|
|
|
|
|
|
|
|
# Upgrade "foo": should install foo-2.0.
|
2011-12-01 18:41:43 +02:00
|
|
|
NIX_PATH=nixpkgs=./user-envs.nix nix-env -p $profiles/test -f '<nixpkgs>' -u foo
|
2006-02-08 16:32:06 +02:00
|
|
|
|
|
|
|
# Query installed: should contain foo-2.0 now.
|
2011-10-11 00:32:34 +03:00
|
|
|
test "$(nix-env -p $profiles/test -q '*' | wc -l)" -eq 1
|
|
|
|
nix-env -p $profiles/test -q '*' | grep -q foo-2.0
|
2006-02-08 16:32:06 +02:00
|
|
|
test "$($profiles/test/bin/foo)" = "foo-2.0"
|
|
|
|
|
|
|
|
# Store the path of foo-2.0.
|
2011-10-11 00:32:34 +03:00
|
|
|
outPath20=$(nix-env -p $profiles/test -q --out-path --no-name '*' | grep foo-2.0)
|
2006-02-08 16:32:06 +02:00
|
|
|
test -n "$outPath20"
|
|
|
|
|
|
|
|
# Install bar-0.1, uninstall foo.
|
2011-10-11 00:32:34 +03:00
|
|
|
nix-env -p $profiles/test -f ./user-envs.nix -i bar-0.1
|
|
|
|
nix-env -p $profiles/test -f ./user-envs.nix -e foo
|
2006-02-08 16:32:06 +02:00
|
|
|
|
|
|
|
# Query installed: should only contain bar-0.1 now.
|
2011-10-11 00:32:34 +03:00
|
|
|
if nix-env -p $profiles/test -q '*' | grep -q foo; then false; fi
|
|
|
|
nix-env -p $profiles/test -q '*' | grep -q bar
|
2006-02-08 16:32:06 +02:00
|
|
|
|
|
|
|
# Rollback: should bring "foo" back.
|
2011-10-11 00:32:34 +03:00
|
|
|
nix-env -p $profiles/test --rollback
|
|
|
|
nix-env -p $profiles/test -q '*' | grep -q foo-2.0
|
|
|
|
nix-env -p $profiles/test -q '*' | grep -q bar
|
2006-02-08 16:32:06 +02:00
|
|
|
|
|
|
|
# Rollback again: should remove "bar".
|
2011-10-11 00:32:34 +03:00
|
|
|
nix-env -p $profiles/test --rollback
|
|
|
|
nix-env -p $profiles/test -q '*' | grep -q foo-2.0
|
|
|
|
if nix-env -p $profiles/test -q '*' | grep -q bar; then false; fi
|
2006-02-08 16:32:06 +02:00
|
|
|
|
|
|
|
# Count generations.
|
2011-10-11 00:32:34 +03:00
|
|
|
nix-env -p $profiles/test --list-generations
|
|
|
|
test "$(nix-env -p $profiles/test --list-generations | wc -l)" -eq 5
|
2006-02-08 16:32:06 +02:00
|
|
|
|
|
|
|
# Install foo-1.0, now using its store path.
|
|
|
|
echo $outPath10
|
2011-10-11 00:32:34 +03:00
|
|
|
nix-env -p $profiles/test -i "$outPath10"
|
|
|
|
nix-env -p $profiles/test -q '*' | grep -q foo-1.0
|
2006-02-08 16:32:06 +02:00
|
|
|
|
2007-11-29 18:18:24 +02:00
|
|
|
# Uninstall foo-1.0, using a symlink to its store path.
|
|
|
|
ln -sfn $outPath10/bin/foo $TEST_ROOT/symlink
|
2011-10-11 00:32:34 +03:00
|
|
|
nix-env -p $profiles/test -e $TEST_ROOT/symlink
|
|
|
|
if nix-env -p $profiles/test -q '*' | grep -q foo; then false; fi
|
2007-11-29 18:18:24 +02:00
|
|
|
|
|
|
|
# Install foo-1.0, now using a symlink to its store path.
|
2011-10-11 00:32:34 +03:00
|
|
|
nix-env -p $profiles/test -i $TEST_ROOT/symlink
|
|
|
|
nix-env -p $profiles/test -q '*' | grep -q foo
|
2007-11-29 18:18:24 +02:00
|
|
|
|
2006-02-08 16:32:06 +02:00
|
|
|
# Delete all old generations.
|
2011-10-11 00:32:34 +03:00
|
|
|
nix-env -p $profiles/test --delete-generations old
|
2006-02-08 16:32:06 +02:00
|
|
|
|
|
|
|
# Run the garbage collector. This should get rid of foo-2.0 but not
|
|
|
|
# foo-1.0.
|
2011-10-11 00:32:34 +03:00
|
|
|
nix-collect-garbage
|
2006-02-08 16:32:06 +02:00
|
|
|
test -e "$outPath10"
|
|
|
|
if test -e "$outPath20"; then false; fi
|
2006-02-17 19:03:19 +02:00
|
|
|
|
|
|
|
# Uninstall everything
|
2011-10-11 00:32:34 +03:00
|
|
|
nix-env -p $profiles/test -f ./user-envs.nix -e '*'
|
|
|
|
test "$(nix-env -p $profiles/test -q '*' | wc -l)" -eq 0
|
2006-02-17 19:03:19 +02:00
|
|
|
|
|
|
|
# Installing "foo" should only install the newest foo.
|
2011-10-11 00:32:34 +03:00
|
|
|
nix-env -p $profiles/test -f ./user-envs.nix -i foo
|
|
|
|
test "$(nix-env -p $profiles/test -q '*' | grep foo- | wc -l)" -eq 1
|
|
|
|
nix-env -p $profiles/test -q '*' | grep -q foo-2.0
|
2006-02-17 19:03:19 +02:00
|
|
|
|
2006-02-17 19:05:34 +02:00
|
|
|
# On the other hand, this should install both (and should fail due to
|
|
|
|
# a collision).
|
2011-10-11 00:32:34 +03:00
|
|
|
nix-env -p $profiles/test -f ./user-envs.nix -e '*'
|
|
|
|
if nix-env -p $profiles/test -f ./user-envs.nix -i foo-1.0 foo-2.0; then false; fi
|
2006-02-17 19:05:34 +02:00
|
|
|
|
2006-02-17 19:03:19 +02:00
|
|
|
# Installing "*" should install one foo and one bar.
|
2011-10-11 00:32:34 +03:00
|
|
|
nix-env -p $profiles/test -f ./user-envs.nix -e '*'
|
|
|
|
nix-env -p $profiles/test -f ./user-envs.nix -i '*'
|
|
|
|
test "$(nix-env -p $profiles/test -q '*' | wc -l)" -eq 2
|
|
|
|
nix-env -p $profiles/test -q '*' | grep -q foo-2.0
|
|
|
|
nix-env -p $profiles/test -q '*' | grep -q bar-0.1.1
|