Fix checkout string; bail on error.
[cdist.git] / vmbuild
1 #!/bin/bash
2 set -e
3
4 if [ "$1" == "" -o "$2" == "" ]; then
5     echo "Syntax: $0 <target> <version> [<output-dir>]"
6 fi
7
8 IFS='-' read distro version bits <<< $1
9
10 bits=$1
11 checkout=$2
12 output=$3
13
14 if [ "$bits" == "32" ]; then
15     port=2000
16 elif [ "$bits" == "64" ]; then
17     port=2001
18 else
19     echo "Unrecognised bit depth $bits"
20     exit 1
21 fi
22
23 nohup vboxheadless --startvm fedora-22-$bits &
24 sleep 10
25 ssh -p $port carl@localhost "rm -rf fedora-*"
26 ssh -p $port carl@localhost cdist -p dcpomatic -c v$checkout -t host package
27 if [ "$output" != "" ]; then
28     scp -P $port carl@localhost:fedora-22-$bits/* $output/
29 fi
30 ssh -p $port carl@localhost "sudo /sbin/poweroff"