-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·59 lines (45 loc) · 1.14 KB
/
build.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
52
53
54
55
56
57
58
59
#!/bin/bash -x
AVR_CONTAINER_VERSION="latest"
function init() {
DEPENDENCY_LABEL=`env | grep GO_DEPENDENCY_LABEL_ | cut -d= -f2 | sed 's/\s//g' | tr -d '\n'`
if [ -z ${DEPENDENCY_LABEL} ]; then
AVR_CONTAINER_VERSION="latest"
else
AVR_CONTAINER_VERSION="v${DEPENDENCY_LABEL}"
fi
}
function fix_git_user() {
git config --system user.name Docker && git config --system user.email docker@localhost
ERROR_CODE=$?
if [ ${ERROR_CODE} -ne 0 ]; then
echo "Setting Git user failed"
exit ${ERROR_CODE}
fi
}
function compile() {
# this files helps bundling the build commands
# fix_git_user
mkdir -p build && cd build && cmake .. && make
ERROR_CODE=$?
if [ ${ERROR_CODE} -ne 0 ]; then
echo "Compilation failed"
exit ${ERROR_CODE}
fi
}
function build_software() {
mkdir -p build;
docker run --rm --user `id -u`:`id -g` -v $PWD:/build --entrypoint /build/build.sh ubirch/avr-build:${AVR_CONTAINER_VERSION}
if [ $? -ne 0 ]; then
echo "Docker build failed"
exit 1
fi
}
case "$1" in
build)
init
build_software
;;
*)
compile
esac
exit 0