buildNewKernelIntoFS.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/sh -xe
  2. KVER=4.17.2
  3. outmnt=$(mktemp -d -p `pwd`)
  4. outdev=/dev/loop7
  5. #A hacky way to ensure the loops are properly unmounted and the temp files are properly deleted.
  6. #Without this, a reboot is required to properly clean the loop devices and ensure a clean build
  7. cleanuptwice() {
  8. cleanup
  9. cleanup
  10. }
  11. cleanup() {
  12. set +e
  13. #umount -l $inmnt > /dev/null 2>&1
  14. #rmdir $inmnt > /dev/null 2>&1
  15. #losetup -d $indev > /dev/null 2>&1
  16. umount -l $outmnt > /dev/null 2>&1
  17. rmdir $outmnt > /dev/null 2>&1
  18. losetup -d $outdev > /dev/null 2>&1
  19. }
  20. trap cleanuptwice INT TERM EXIT
  21. #Mount the build filesystem image
  22. losetup -P $outdev debian-stretch-c201-libre-2GB*
  23. mount -o noatime ${outdev}p2 $outmnt
  24. # put the kernel in the kernel partition, modules in /lib/modules and AR9271
  25. # firmware in /lib/firmware
  26. dd if=blank_kernel of=${outdev}p1 conv=notrunc
  27. dd if=linux-$KVER/vmlinux.kpart of=${outdev}p1 conv=notrunc
  28. make -C linux-$KVER ARCH=arm INSTALL_MOD_PATH=$outmnt modules_install
  29. rm -f $outmnt/lib/modules/3.14.0/{build,source}
  30. install -D -m 644 open-ath9k-htc-firmware/target_firmware/htc_9271.fw $outmnt/lib/firmware/ath9k_htc/htc_9271-1.4.0.fw
  31. echo "DONE!"
  32. cleanup