build-guestkernel 1.1 KB

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