PKGBUILD 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. # Maintainer: Donald Carr <sirspudd at gmail dot com>
  2. #set -x
  3. options=('!strip')
  4. # The firmware the kernel produces blows: don't falsify this lightly
  5. # "linux-firmware=20170309.695f2d6-1"
  6. pkgrel=1
  7. pkgver=5.9.13.g060b07e759b9
  8. pkgdesc="Kernel build from head"
  9. arch=("x86_64" "aarch64" "armv7h")
  10. license=("GPL2.1")
  11. log_path="${PWD}/$(date +"%Y-%m-%d-%H%M").log"
  12. _kernel_src_dir=/opt/src/OSS/linux
  13. pkgname() {
  14. oldpath=${PWD}
  15. cd $_kernel_src_dir
  16. postfix="spudd-$(git rev-parse --abbrev-ref HEAD)"
  17. if [[ -f testing ]]; then
  18. postfix=${postfix}-testing
  19. fi
  20. pkgname=linux-${postfix}
  21. cd ${oldpath}
  22. }
  23. pkgname
  24. if [ -z "${LOCAL_PI_VER}" ]; then
  25. install=spudd.install
  26. fi
  27. _make_cmd="make ${_xcompile_args}"
  28. prepare() {
  29. cp ${startdir}/_spudd.install ${startdir}/spudd.install
  30. sed -i "s/spudd/${postfix}/g" ${startdir}/spudd.install
  31. }
  32. pkgver() {
  33. cd $_kernel_src_dir
  34. git describe --tags | sed -e "s/^v//" | tr '-' '.'
  35. }
  36. build() {
  37. cd $_kernel_src_dir && git clean -xdf
  38. cp ${_config_file} ${_kernel_src_dir}/.config
  39. ${_make_cmd} all 2>&1 | tee ${log_path}
  40. if [ -n "${LOCAL_PI_VER}" ]; then
  41. ${_make_cmd} dtbs 2>&1 | tee -a ${log_path}
  42. fi
  43. }
  44. package() {
  45. prepare
  46. boot_dir="${pkgdir}/boot"
  47. dtb_dir="${boot_dir}/dtbs"
  48. usr_dir="${pkgdir}/usr"
  49. firmware_dir="${usr_dir}/lib/firmware"
  50. preset_dir=${pkgdir}/etc/mkinitcpio.d
  51. cd $_kernel_src_dir
  52. INSTALL_MOD_PATH=${usr_dir} INSTALL_MOD_STRIP=1 ${_make_cmd} modules_install
  53. if [ -n "${LOCAL_PI_VER}" ]; then
  54. INSTALL_DTBS_PATH=${dtb_dir} ${_make_cmd} dtbs_install
  55. fi
  56. mkdir -p ${boot_dir}
  57. if [ "${LOCAL_PI_VER}" = "3" ]; then
  58. cp arch/arm64/boot/Image ${boot_dir}/Image${postfix}
  59. elif [ "${LOCAL_PI_VER}" = "2" ]; then
  60. cp arch/arm/boot/zImage ${boot_dir}/vmlinuz-${postfix}
  61. else
  62. cp arch/x86/boot/bzImage ${boot_dir}/vmlinuz-${postfix}
  63. fi
  64. mkdir -p ${preset_dir}
  65. cp ${startdir}/spudd.preset ${preset_dir}/${postfix}.preset
  66. sed -i "s/spudd/${postfix}/g" ${preset_dir}/${postfix}.preset
  67. rm -Rf ${startdir}/firmware
  68. if [[ -d ${firmware_dir} ]]; then
  69. mv ${firmware_dir} ${startdir}
  70. fi
  71. }
  72. if [ -n "${LOCAL_PI_VER}" ]; then
  73. case ${LOCAL_PI_VER} in
  74. 2)
  75. echo "Compiling for the RPi 2 aarch32"
  76. _config_file="${startdir}/rpi2"
  77. _xcompile_args="ARCH=arm CROSS_COMPILE=/opt/armv7-rpi2-linux-gnueabihf/bin/armv7-rpi2-linux-gnueabihf-"
  78. ;;
  79. 3)
  80. #symbols omitted by default wtf!
  81. #DTC_FLAGS=\"-@ -H epapr\"
  82. echo "Compiling for the RPi 3 aarch64"
  83. _config_file="${startdir}/rpi3"
  84. _xcompile_args="ARCH=arm64 CROSS_COMPILE=/opt/x-tools/aarch64-rpi3-linux-gnu/bin/aarch64-rpi3-linux-gnu-"
  85. ;;
  86. *)
  87. echo "Only supports the rpi3 at this point in time"
  88. exit 1
  89. ;;
  90. esac
  91. else
  92. echo "Compiling for desktop"
  93. _xcompile_args="CC=clang HOSTCC=clang"
  94. #_xcompile_args=""
  95. _config_file="${startdir}/desktop"
  96. #_config_file="${_kernel_src_dir}/configs/desktop"
  97. fi
  98. _make_cmd="eval time make VERBOSE=1 ${_xcompile_args}"