buildNewKernelIntoFS.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/bin/sh -xe
  2. # This file is part of PrawnOS (http://www.prawnos.com)
  3. # Copyright (c) 2018 Hal Emmerich <hal@halemmerich.com>
  4. # PrawnOS is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License version 2
  6. # as published by the Free Software Foundation.
  7. # PrawnOS is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. # GNU General Public License for more details.
  11. # You should have received a copy of the GNU General Public License
  12. # along with PrawnOS. If not, see <https://www.gnu.org/licenses/>.
  13. KVER=4.17.2
  14. outmnt=$(mktemp -d -p `pwd`)
  15. outdev=/dev/loop7
  16. build_resources=resources/BuildResources
  17. #A hacky way to ensure the loops are properly unmounted and the temp files are properly deleted.
  18. #Without this, a reboot is sometimes required to properly clean the loop devices and ensure a clean build
  19. cleanup() {
  20. set +e
  21. umount -l $outmnt > /dev/null 2>&1
  22. rmdir $outmnt > /dev/null 2>&1
  23. losetup -d $outdev > /dev/null 2>&1
  24. set +e
  25. umount -l $outmnt > /dev/null 2>&1
  26. rmdir $outmnt > /dev/null 2>&1
  27. losetup -d $outdev > /dev/null 2>&1
  28. }
  29. trap cleanup INT TERM EXIT
  30. #Mount the build filesystem image
  31. losetup -P $outdev PrawnOS-*-c201-libre-2GB*
  32. mount -o noatime ${outdev}p2 $outmnt
  33. # put the kernel in the kernel partition, modules in /lib/modules and AR9271
  34. # firmware in /lib/firmware
  35. dd if=$build_resources/blank_kernel of=${outdev}p1 conv=notrunc
  36. dd if=build/linux-$KVER/vmlinux.kpart of=${outdev}p1 conv=notrunc
  37. make -C build/linux-$KVER ARCH=arm INSTALL_MOD_PATH=$outmnt modules_install
  38. rm -f $outmnt/lib/modules/3.14.0/{build,source}
  39. install -D -m 644 build/open-ath9k-htc-firmware/target_firmware/htc_9271.fw $outmnt/lib/firmware/ath9k_htc/htc_9271-1.4.0.fw
  40. umount -l $outmnt > /dev/null 2>&1
  41. rmdir $outmnt > /dev/null 2>&1
  42. losetup -d $outdev > /dev/null 2>&1
  43. echo "DONE!"
  44. trap - INT TERM EXIT