testing: Do not overwrite kernel configuration if it already exists
[strongswan.git] / testing / scripts / build-guestkernel
1 #!/bin/bash
2
3 DIR=$(dirname `readlink -f $0`)
4 . $DIR/../testing.conf
5 . $DIR/function.sh
6
7 echo "Building guest kernel version $KERNELVERSION"
8
9 [ -f "$KERNELCONFIG" ] || die "Kernel config $KERNELCONFIG not found"
10
11 check_commands bunzip2 bzcat make wget
12
13 cd $BUILDDIR
14
15 if [ ! -f "$KERNELTARBALL" ]
16 then
17         url=ftp://ftp.kernel.org/pub/linux/kernel/v${KERNELVERSION:0:1}.x/$KERNELTARBALL
18         log_action "Downloading $url"
19         execute "wget -q $url"
20 fi
21
22 if [[ $KERNELPATCH && ! -f "$KERNELPATCH" ]]
23 then
24         url=http://download.strongswan.org/uml/$KERNELPATCH
25         log_action "Downloading $url"
26         execute "wget -q $url"
27 fi
28
29 KERNELDIR=$BUILDDIR/$KERNEL
30 cd $KERNELDIR
31
32 if [ ! -d "$KERNELDIR" ]
33 then
34         log_action "Unpacking kernel"
35         execute "tar xJf $KERNELTARBALL"
36
37         if [ $KERNELPATCH ]
38         then
39                 log_action "Applying kernel patch"
40                 bzcat ../$KERNELPATCH | patch -p1 >>$LOGFILE 2>&1
41                 log_status $?
42                 [ $? -eq 0 ] || exit 1
43         fi
44 fi
45
46 if [ ! -f .config ]
47 then
48         execute "cp $KERNELCONFIG .config" 0
49 fi
50
51 echo "Creating kernel configuration, you might get prompted for new parameters"
52 make oldconfig 2>&1 | tee -a $LOGFILE
53
54 log_action "Compiling the kernel"
55 execute "make -j5"