about summary refs log tree commit diff
path: root/tests/substituter.sh
blob: 885655760e05a10af897cbc1dc9938d7d1c76760 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#! /bin/sh -e
echo substituter args: $* >&2

if test $1 = "--query"; then
    while read cmd args; do
        echo "CMD = $cmd, ARGS = $args" >&2
        if test "$cmd" = "have"; then
            for path in $args; do 
                read path
                if grep -q "$path" $TEST_ROOT/sub-paths; then
                    echo $path
                fi
            done
            echo
        elif test "$cmd" = "info"; then
            for path in $args; do
                echo $path
                echo "" # deriver
                echo 0 # nr of refs
                echo $((1 * 1024 * 1024)) # download size
                echo $((2 * 1024 * 1024)) # nar size
            done
            echo
        else
            echo "bad command $cmd"
            exit 1
        fi
    done
elif test $1 = "--substitute"; then
    mkdir $2
    echo "Hallo Wereld" > $2/hello
    echo # no expected hash
else
    echo "unknown substituter operation"
    exit 1
fi