buildKernel.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. set -x
  3. set -e
  4. # build Linux-libre, with ath9k_htc firmware and initramfs built in
  5. # This file is part of PrawnOS (https://www.prawnos.com)
  6. # Copyright (c) 2018-2020 Hal Emmerich <hal@halemmerich.com>
  7. # PrawnOS is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License version 2
  9. # as published by the Free Software Foundation.
  10. # PrawnOS is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. # You should have received a copy of the GNU General Public License
  15. # along with PrawnOS. If not, see <https://www.gnu.org/licenses/>.
  16. if [ -z "$1" ]
  17. then
  18. echo "No kernel version supplied"
  19. exit 1
  20. fi
  21. if [ -z "$2" ]
  22. then
  23. echo "No resources directory"
  24. exit 1
  25. fi
  26. if [ -z "$3" ]
  27. then
  28. echo "No build directory supplied"
  29. exit 1
  30. fi
  31. if [ -z "$4" ]
  32. then
  33. echo "No PrawnOS initramfs supplied"
  34. exit 1
  35. fi
  36. KVER=$1
  37. RESOURCES=$2
  38. BUILD_DIR=$3
  39. INITRAMFS=$4
  40. cd $BUILD_DIR
  41. make mrproper
  42. #copy in the resources, initramfs
  43. cp $INITRAMFS .
  44. cp $RESOURCES/config .config
  45. cp $RESOURCES/kernel.its .
  46. make -j $(($(nproc) +1)) CROSS_COMPILE=arm-none-eabi- ARCH=arm zImage modules dtbs
  47. mkimage -D "-I dts -O dtb -p 2048" -f kernel.its vmlinux.uimg
  48. dd if=/dev/zero of=bootloader.bin bs=512 count=1
  49. vbutil_kernel --pack vmlinux.kpart \
  50. --version 1 \
  51. --vmlinuz vmlinux.uimg \
  52. --arch arm \
  53. --keyblock /usr/share/vboot/devkeys/kernel.keyblock \
  54. --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
  55. --config $RESOURCES/cmdline \
  56. --bootloader bootloader.bin
  57. RESULT=$?
  58. if [ ! $RESULT -eq 0 ]; then
  59. rm -f vmlinux.kpart
  60. fi