1if [ -e .attrs.sh ]; then source .attrs.sh; fi
2source $stdenv/setup
3
4set -x
5
6if ! [ -f "$cacheDB" ]; then
7 echo "Creating cache DB $cacheDB"
8 mtn --db "$cacheDB" db init
9fi
10
11echo "getting revision $selector";
12
13done=;
14for source in $dbs; do
15 if mtn pull --db "$cacheDB" "$source" "${branch}"; then
16 revision="$(mtn --db "$cacheDB" au toposort $(mtn --db "$cacheDB" au select "$selector") | tail -1)";
17 if [ -n "$revision" ]; then
18 if mtn --db "$cacheDB" au get_revision "$revision"; then
19 echo "found revision $revision"
20 done=1;
21 else
22 echo "revision $revision does not exist";
23 fi
24 else
25 echo "selector $selector does not match any revision";
26 fi
27 else
28 echo "pulling branch $branch wasn't successful";
29 fi;
30 if test -n "$done"; then
31 break;
32 fi;
33done;
34
35echo "checking out the revision $revision";
36
37if test -n "$done"; then
38 mtn checkout --db "$cacheDB" -r "$revision" "$out" -b "${branch}"
39else
40 echo "Needed revision still not found. Exiting";
41 exit 1;
42fi;
43
44echo "clearing _MTN in the output"
45
46rm -rf "$out/_MTN"