mirror of
https://github.com/NixOS/nix
synced 2025-07-08 06:53:54 +02:00
* `nix-install-package --url': install from a URL (NIX-12).
* `nix-install-package --help' (NIX-9). * `nix-install-package --non-interactive': don't prompt or pause. * Tests for nix-install-package. * Security fixes: filter the values obtained from the nixpkg.
This commit is contained in:
parent
4e91d8621f
commit
0bd5eb71a0
10 changed files with 152 additions and 37 deletions
|
@ -3,7 +3,7 @@ TESTS_ENVIRONMENT = $(SHELL) -e
|
|||
extra1 = $(shell pwd)/test-tmp/shared
|
||||
|
||||
simple.sh: simple.nix
|
||||
dependencies.sh gc.sh nix-push.sh nix-pull.in logging.sh nix-build.sh: dependencies.nix
|
||||
dependencies.sh gc.sh nix-push.sh nix-pull.in logging.sh nix-build.sh install-package.sh: dependencies.nix
|
||||
locking.sh: locking.nix
|
||||
parallel.sh: parallel.nix
|
||||
build-hook.sh: build-hook.nix
|
||||
|
@ -19,7 +19,7 @@ TESTS = init.sh hash.sh lang.sh add.sh simple.sh dependencies.sh \
|
|||
locking.sh parallel.sh build-hook.sh substitutes.sh substitutes2.sh \
|
||||
fallback.sh nix-push.sh gc.sh gc-concurrent.sh verify.sh nix-pull.sh \
|
||||
referrers.sh user-envs.sh logging.sh nix-build.sh misc.sh fixed.sh \
|
||||
gc-runtime.sh
|
||||
gc-runtime.sh install-package.sh
|
||||
|
||||
XFAIL_TESTS =
|
||||
|
||||
|
|
|
@ -47,3 +47,18 @@ export nixhash=$TOP/src/nix-hash/nix-hash
|
|||
readLink() {
|
||||
ls -l "$1" | sed 's/.*->\ //'
|
||||
}
|
||||
|
||||
clearStore() {
|
||||
echo "clearing store..."
|
||||
chmod -R +w "$NIX_STORE_DIR"
|
||||
rm -rf "$NIX_STORE_DIR"
|
||||
mkdir "$NIX_STORE_DIR"
|
||||
rm -rf "$NIX_DB_DIR"
|
||||
mkdir "$NIX_DB_DIR"
|
||||
$nixstore --init
|
||||
}
|
||||
|
||||
clearProfiles() {
|
||||
profiles="$NIX_STATE_DIR"/profiles
|
||||
rm -f $profiles/*
|
||||
}
|
||||
|
|
|
@ -21,9 +21,12 @@ mkdir $NIX_BIN_DIR
|
|||
ln -s $nixstore $NIX_BIN_DIR/
|
||||
ln -s $nixinstantiate $NIX_BIN_DIR/
|
||||
ln -s $nixhash $NIX_BIN_DIR/
|
||||
ln -s $nixenv $NIX_BIN_DIR/
|
||||
ln -s $TOP/scripts/nix-prefetch-url $NIX_BIN_DIR/
|
||||
ln -s $TOP/scripts/nix-collect-garbage $NIX_BIN_DIR/
|
||||
ln -s $TOP/scripts/nix-build $NIX_BIN_DIR/
|
||||
ln -s $TOP/scripts/nix-install-package $NIX_BIN_DIR/
|
||||
ln -s $TOP/scripts/nix-pull $NIX_BIN_DIR/
|
||||
ln -s $bzip2_bin_test/bzip2 $NIX_BIN_DIR/
|
||||
ln -s $bzip2_bin_test/bunzip2 $NIX_BIN_DIR/
|
||||
mkdir $NIX_BIN_DIR/nix
|
||||
|
@ -52,8 +55,9 @@ for i in \
|
|||
$NIX_BIN_DIR/nix-prefetch-url \
|
||||
$NIX_BIN_DIR/nix-collect-garbage \
|
||||
$NIX_BIN_DIR/nix-build \
|
||||
$NIX_BIN_DIR/nix-install-package \
|
||||
$NIX_BIN_DIR/nix-pull \
|
||||
; do
|
||||
echo "$REAL_BIN_DIR"
|
||||
sed < $i > $i.tmp \
|
||||
-e "s^$REAL_BIN_DIR^$NIX_BIN_DIR^" \
|
||||
-e "s^$REAL_LIBEXEC_DIR^$NIX_LIBEXEC_DIR^" \
|
||||
|
|
21
tests/install-package.sh
Normal file
21
tests/install-package.sh
Normal file
|
@ -0,0 +1,21 @@
|
|||
source common.sh
|
||||
|
||||
# Note: this test expects to be run *after* nix-push.sh.
|
||||
|
||||
drvPath=$($nixinstantiate ./dependencies.nix)
|
||||
outPath=$($nixstore -q $drvPath)
|
||||
|
||||
clearStore
|
||||
clearProfiles
|
||||
|
||||
cat > $TEST_ROOT/foo.nixpkg <<EOF
|
||||
NIXPKG1 file://$TEST_ROOT/manifest simple $system $drvPath $outPath
|
||||
EOF
|
||||
|
||||
$NIX_BIN_DIR/nix-install-package --non-interactive -p $profiles/test $TEST_ROOT/foo.nixpkg
|
||||
test "$($nixenv -p $profiles/test -q '*' | wc -l)" -eq 1
|
||||
|
||||
clearProfiles
|
||||
|
||||
$NIX_BIN_DIR/nix-install-package --non-interactive -p $profiles/test --url file://$TEST_ROOT/foo.nixpkg
|
||||
test "$($nixenv -p $profiles/test -q '*' | wc -l)" -eq 1
|
|
@ -1,15 +1,5 @@
|
|||
source common.sh
|
||||
|
||||
clearStore () {
|
||||
echo "clearing store..."
|
||||
chmod -R +w "$NIX_STORE_DIR"
|
||||
rm -rf "$NIX_STORE_DIR"
|
||||
mkdir "$NIX_STORE_DIR"
|
||||
rm -rf "$NIX_DB_DIR"
|
||||
mkdir "$NIX_DB_DIR"
|
||||
$nixstore --init
|
||||
}
|
||||
|
||||
pullCache () {
|
||||
echo "pulling cache..."
|
||||
$PERL -w -I$TOP/scripts $TOP/scripts/nix-pull file://$TEST_ROOT/manifest
|
||||
|
|
|
@ -3,7 +3,7 @@ source common.sh
|
|||
# This takes way to long on Cygwin (because process creation is so slow...).
|
||||
if test "$system" = i686-cygwin; then exit 0; fi
|
||||
|
||||
max=5000
|
||||
max=2500
|
||||
|
||||
reference=$NIX_STORE_DIR/abcdef
|
||||
touch $reference
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
source common.sh
|
||||
|
||||
profiles="$NIX_STATE_DIR"/profiles
|
||||
rm -f $profiles/*
|
||||
clearProfiles
|
||||
|
||||
# Query installed: should be empty.
|
||||
test "$($nixenv -p $profiles/test -q '*' | wc -l)" -eq 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue