forked from DanielG/travis-run
-
Notifications
You must be signed in to change notification settings - Fork 0
/
travis-run-create.sh
51 lines (42 loc) · 1.74 KB
/
travis-run-create.sh
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Copyright (C) 2014 Daniel Gröber <dxld ÄT darkboxed DOT org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This script will be sourced by travis-run
## Create travis build VM on the current machine
if [ ! -e .travis.yml ]; then
echo "Error: .travis.yml does not exist.">&2
echo "You probably don't want to create the VM here, some backends store">&2
echo "per-project state needed to run the build in the current directory."
exit 1
fi
LANGUAGE=""
perl -e 'use YAML::Tiny;' >/dev/null 2>&1
PERL_YAML=$?
ruby -e 'require "yaml"' >/dev/null 2>&1
RUBY_YAML=$?
if [ $PERL_YAML -ne 0 ] && [ $RUBY_YAML -ne 0 ]; then
echo "You need to have perl's YAML::Tiny module or ruby's 'yaml' gem installed.">&2
exit 1
elif [ $PERL_YAML -eq 0 ]; then
LANGUAGE=$(perl -e 'use YAML::Tiny; print YAML::Tiny->read(".travis.yml")->[0]->{"language"};')
else
LANGUAGE=$(ruby -e 'require "yaml"; puts YAML.load_file(".travis.yml")["language"]')
fi
if [ ! "$LANGUAGE" ]; then
echo "Could not detect language, please add a \`language:' declaration">&2
echo "to your \`.travis.yml'."
exit 1
fi
backend_clean "$OPT_VM_NAME"
backend_create "$OPT_VM_NAME" "$LANGUAGE"