Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Build a kvm-ready Linux kernel from the tree in the current directory. |
| 4 | # |
| 5 | # Usage: sh kvm-build.sh config-template build-dir more-configs |
| 6 | # |
| 7 | # This program is free software; you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by |
| 9 | # the Free Software Foundation; either version 2 of the License, or |
| 10 | # (at your option) any later version. |
| 11 | # |
| 12 | # This program is distributed in the hope that it will be useful, |
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | # GNU General Public License for more details. |
| 16 | # |
| 17 | # You should have received a copy of the GNU General Public License |
| 18 | # along with this program; if not, write to the Free Software |
| 19 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 20 | # |
| 21 | # Copyright (C) IBM Corporation, 2011 |
| 22 | # |
| 23 | # Authors: Paul E. McKenney <paulmck@linux.vnet.ibm.com> |
| 24 | |
| 25 | config_template=${1} |
| 26 | if test -z "$config_template" -o ! -f "$config_template" -o ! -r "$config_template" |
| 27 | then |
| 28 | echo "kvm-build.sh :$config_template: Not a readable file" |
| 29 | exit 1 |
| 30 | fi |
| 31 | builddir=${2} |
| 32 | if test -z "$builddir" -o ! -d "$builddir" -o ! -w "$builddir" |
| 33 | then |
| 34 | echo "kvm-build.sh :$builddir: Not a writable directory, cannot build into it" |
| 35 | exit 1 |
| 36 | fi |
| 37 | moreconfigs=${3} |
| 38 | if test -z "$moreconfigs" -o ! -r "$moreconfigs" |
| 39 | then |
| 40 | echo "kvm-build.sh :$moreconfigs: Not a readable file" |
| 41 | exit 1 |
| 42 | fi |
| 43 | |
| 44 | T=/tmp/test-linux.sh.$$ |
| 45 | trap 'rm -rf $T' 0 |
| 46 | mkdir $T |
| 47 | |
| 48 | cat ${config_template} | grep -v CONFIG_RCU_TORTURE_TEST > $T/config |
| 49 | cat << ___EOF___ >> $T/config |
| 50 | CONFIG_INITRAMFS_SOURCE="$KVM/initrd" |
| 51 | CONFIG_VIRTIO_PCI=y |
| 52 | CONFIG_VIRTIO_CONSOLE=y |
| 53 | ___EOF___ |
| 54 | cat $moreconfigs >> $T/config |
| 55 | |
| 56 | configinit.sh $T/config O=$builddir |
| 57 | retval=$? |
| 58 | if test $retval -gt 1 |
| 59 | then |
| 60 | exit 2 |
| 61 | fi |
| 62 | ncpus=`cpus2use.sh` |
| 63 | make O=$builddir -j$ncpus > $builddir/Make.out 2>&1 |
| 64 | retval=$? |
| 65 | if test $retval -ne 0 || grep "rcu[^/]*": < $builddir/Make.out | egrep -q "Stop|Error|error:|warning:" || egrep -q "Stop|Error|error:" < $builddir/Make.out |
| 66 | then |
| 67 | echo Kernel build error |
| 68 | egrep "Stop|Error|error:|warning:" < $builddir/Make.out |
| 69 | echo Run aborted. |
| 70 | exit 3 |
| 71 | fi |