PKGBUILD 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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.7.6.19.g340b1df92d20
  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/dev/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. boot_dir="${pkgdir}/boot"
  46. dtb_dir="${boot_dir}/dtbs"
  47. usr_dir="${pkgdir}/usr"
  48. firmware_dir="${usr_dir}/lib/firmware"
  49. preset_dir=${pkgdir}/etc/mkinitcpio.d
  50. cd $_kernel_src_dir
  51. INSTALL_MOD_PATH=${usr_dir} ${_make_cmd} modules_install
  52. if [ -n "${LOCAL_PI_VER}" ]; then
  53. INSTALL_DTBS_PATH=${dtb_dir} ${_make_cmd} dtbs_install
  54. fi
  55. mkdir -p ${boot_dir}
  56. if [ "${LOCAL_PI_VER}" = "3" ]; then
  57. cp arch/arm64/boot/Image ${boot_dir}/Image${postfix}
  58. elif [ "${LOCAL_PI_VER}" = "2" ]; then
  59. cp arch/arm/boot/zImage ${boot_dir}/vmlinuz-${postfix}
  60. else
  61. cp arch/x86/boot/bzImage ${boot_dir}/vmlinuz-${postfix}
  62. fi
  63. mkdir -p ${preset_dir}
  64. cp ${startdir}/spudd.preset ${preset_dir}/${postfix}.preset
  65. sed -i "s/spudd/${postfix}/g" ${preset_dir}/${postfix}.preset
  66. rm -Rf ${startdir}/firmware
  67. if [[ -d ${firmware_dir} ]]; then
  68. mv ${firmware_dir} ${startdir}
  69. fi
  70. }
  71. if [ -n "${LOCAL_PI_VER}" ]; then
  72. case ${LOCAL_PI_VER} in
  73. 2)
  74. echo "Compiling for the RPi 2 aarch32"
  75. _config_file="${startdir}/rpi2"
  76. _xcompile_args="ARCH=arm CROSS_COMPILE=/opt/armv7-rpi2-linux-gnueabihf/bin/armv7-rpi2-linux-gnueabihf-"
  77. ;;
  78. 3)
  79. #symbols omitted by default wtf!
  80. #DTC_FLAGS=\"-@ -H epapr\"
  81. echo "Compiling for the RPi 3 aarch64"
  82. _config_file="${startdir}/rpi3"
  83. _xcompile_args="ARCH=arm64 CROSS_COMPILE=/opt/x-tools/aarch64-rpi3-linux-gnu/bin/aarch64-rpi3-linux-gnu-"
  84. ;;
  85. *)
  86. echo "Only supports the rpi3 at this point in time"
  87. exit 1
  88. ;;
  89. esac
  90. else
  91. echo "Compiling for desktop"
  92. #_xcompile_args="CC=clang HOSTCC=clang"
  93. #_xcompile_args=""
  94. _config_file="${startdir}/desktop"
  95. #_config_file="${_kernel_src_dir}/configs/desktop"
  96. fi
  97. _make_cmd="eval time make VERBOSE=1 ${_xcompile_args}"