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 | # |
Paul E. McKenney | 5bfd7d3 | 2018-04-23 14:03:00 -0700 | [diff] [blame] | 5 | # Usage: kvm-build.sh config-template build-dir resdir |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 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 |
Paul E. McKenney | 0e342a8 | 2013-12-03 09:54:18 -0800 | [diff] [blame] | 18 | # along with this program; if not, you can access it online at |
| 19 | # http://www.gnu.org/licenses/gpl-2.0.html. |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 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} |
Paul E. McKenney | 5bfd7d3 | 2018-04-23 14:03:00 -0700 | [diff] [blame] | 32 | resdir=${3} |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 33 | |
Paul E. McKenney | b038c58 | 2017-08-30 15:33:49 -0700 | [diff] [blame] | 34 | T=${TMPDIR-/tmp}/test-linux.sh.$$ |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 35 | trap 'rm -rf $T' 0 |
| 36 | mkdir $T |
| 37 | |
Paul E. McKenney | d62c983 | 2017-05-01 17:49:29 -0700 | [diff] [blame] | 38 | cp ${config_template} $T/config |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 39 | cat << ___EOF___ >> $T/config |
Paul E. McKenney | 2f66dbc | 2014-02-26 11:16:07 -0800 | [diff] [blame] | 40 | CONFIG_INITRAMFS_SOURCE="$TORTURE_INITRD" |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 41 | CONFIG_VIRTIO_PCI=y |
| 42 | CONFIG_VIRTIO_CONSOLE=y |
| 43 | ___EOF___ |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 44 | |
Paul E. McKenney | 5bfd7d3 | 2018-04-23 14:03:00 -0700 | [diff] [blame] | 45 | configinit.sh $T/config O=$builddir $resdir |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 46 | retval=$? |
| 47 | if test $retval -gt 1 |
| 48 | then |
| 49 | exit 2 |
| 50 | fi |
| 51 | ncpus=`cpus2use.sh` |
Paul E. McKenney | 5bfd7d3 | 2018-04-23 14:03:00 -0700 | [diff] [blame] | 52 | make O=$builddir -j$ncpus $TORTURE_KMAKE_ARG > $resdir/Make.out 2>&1 |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 53 | retval=$? |
Paul E. McKenney | 5bfd7d3 | 2018-04-23 14:03:00 -0700 | [diff] [blame] | 54 | if test $retval -ne 0 || grep "rcu[^/]*": < $resdir/Make.out | egrep -q "Stop|Error|error:|warning:" || egrep -q "Stop|Error|error:" < $resdir/Make.out |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 55 | then |
| 56 | echo Kernel build error |
Paul E. McKenney | 5bfd7d3 | 2018-04-23 14:03:00 -0700 | [diff] [blame] | 57 | egrep "Stop|Error|error:|warning:" < $resdir/Make.out |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 58 | echo Run aborted. |
| 59 | exit 3 |
| 60 | fi |