jjb: lava: cleanup: clarify comments and fix coding style
[lttng-ci.git] / scripts / system-tests / check-build-needs.sh
1 #!/bin/bash -xeu
2 # Copyright (C) 2016 - Francis Deslauriers <francis.deslauriers@efficios.com>
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17 mkdir -p "$DEPLOYDIR"
18
19 NEED_MODULES_BUILD=0
20 NEED_KERNEL_BUILD=0
21
22 set +e
23 $SSH_COMMAND "$STORAGE_USER@$STORAGE_HOST" ls "$STORAGE_KERNEL_IMAGE"
24 if [ $? -ne 0 ]; then
25 NEED_KERNEL_BUILD=1
26 # We need to build the lttng modules if the kernel has changed.
27 NEED_MODULES_BUILD=1
28 fi
29
30 $SSH_COMMAND "$STORAGE_USER@$STORAGE_HOST" ls "$STORAGE_LTTNG_MODULES"
31 if [ $? -ne 0 ]; then
32 NEED_MODULES_BUILD=1
33 fi
34 set -e
35
36 # We need to fetch the kernel source and lttng-modules to build either the
37 # kernel or modules
38 if [ $NEED_MODULES_BUILD -eq 1 ] || [ $NEED_KERNEL_BUILD -eq 1 ] ; then
39
40 git clone "$KGITREPO" "$LINUX_PATH"
41 pushd "$LINUX_PATH"
42 git checkout "$KERNEL_COMMIT_ID"
43 popd
44 git clone "$LTTNG_MODULES_GIT" "$LTTNG_MODULES_PATH"
45 pushd "$LTTNG_MODULES_PATH"
46 git checkout "$LTTNG_MODULES_COMMIT_ID"
47 popd
48
49 git clone https://github.com/lttng/lttng-ci "$LTTNG_CI_PATH"
50 cp "$LTTNG_CI_PATH"/lava/kernel/vanilla/x86_64_server.config "$LINUX_PATH/.config"
51 make --directory="$LINUX_PATH" olddefconfig
52
53 if [ $BUILD_DEVICE = 'kvm' ] ; then
54 make --directory="$LINUX_PATH" kvmconfig
55 fi
56
57 make --directory="$LINUX_PATH" modules_prepare
58 fi
59
60 #We create files to specify what needs to be built for the subsequent build steps
61 if [ $NEED_MODULES_BUILD -eq 0 ] ; then
62 touch modules-built.txt
63 fi
64 if [ $NEED_KERNEL_BUILD -eq 0 ] ; then
65 touch kernel-built.txt
66 fi
This page took 0.0774 seconds and 4 git commands to generate.