PKGBUILD 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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.10.rc7.15.g74c50e07d8ef
  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. if [[ -n ${_config_preset} ]]; then
  39. echo ${_make_cmd} ${_config_preset}
  40. ${_make_cmd} ${_config_preset}
  41. elif [[ -n ${_config_file} ]]; then
  42. cp ${_config_file} ${_kernel_src_dir}/.config
  43. else
  44. echo "Kernel not configured; bailing"
  45. exit 1
  46. fi
  47. ${_make_cmd} all 2>&1 | tee ${log_path}
  48. if [ -n "${LOCAL_PI_VER}" ]; then
  49. ${_make_cmd} dtbs 2>&1 | tee -a ${log_path}
  50. fi
  51. }
  52. package() {
  53. prepare
  54. boot_dir="${pkgdir}/boot"
  55. dtb_dir="${boot_dir}/dtbs"
  56. usr_dir="${pkgdir}/usr"
  57. firmware_dir="${usr_dir}/lib/firmware"
  58. preset_dir=${pkgdir}/etc/mkinitcpio.d
  59. cd $_kernel_src_dir
  60. INSTALL_MOD_PATH=${usr_dir} INSTALL_MOD_STRIP=1 ${_make_cmd} modules_install
  61. if [ -n "${LOCAL_PI_VER}" ]; then
  62. INSTALL_DTBS_PATH=${dtb_dir} ${_make_cmd} dtbs_install
  63. fi
  64. mkdir -p ${boot_dir}
  65. if [ "${LOCAL_PI_VER}" = "3" ] || [ "${LOCAL_PI_VER}" = "4" ]; then
  66. cp arch/arm64/boot/Image ${boot_dir}/Image
  67. cp arch/arm64/boot/Image.gz ${boot_dir}/Image.gz
  68. elif [ "${LOCAL_PI_VER}" = "2" ]; then
  69. cp arch/arm/boot/zImage ${boot_dir}/vmlinuz-${postfix}
  70. else
  71. cp arch/x86/boot/bzImage ${boot_dir}/vmlinuz-${postfix}
  72. fi
  73. mkdir -p ${preset_dir}
  74. cp ${startdir}/spudd.preset ${preset_dir}/${postfix}.preset
  75. sed -i "s/spudd/${postfix}/g" ${preset_dir}/${postfix}.preset
  76. rm -Rf ${startdir}/firmware
  77. if [[ -d ${firmware_dir} ]]; then
  78. mv ${firmware_dir} ${startdir}
  79. fi
  80. }
  81. if [ -n "${LOCAL_PI_VER}" ]; then
  82. case ${LOCAL_PI_VER} in
  83. 2)
  84. echo "Compiling for the RPi 2 aarch32"
  85. _config_file="${startdir}/rpi2"
  86. _xcompile_args="ARCH=arm CROSS_COMPILE=/opt/armv7-rpi2-linux-gnueabihf/bin/armv7-rpi2-linux-gnueabihf-"
  87. ;;
  88. 3)
  89. #symbols omitted by default wtf!
  90. #DTC_FLAGS=\"-@ -H epapr\"
  91. echo "Compiling for the RPi 3 aarch64"
  92. _config_file="${startdir}/rpi3"
  93. _xcompile_args="ARCH=arm64 CROSS_COMPILE=/opt/x-tools/aarch64-rpi3-linux-gnu/bin/aarch64-rpi3-linux-gnu-"
  94. ;;
  95. 4)
  96. #symbols omitted by default wtf!
  97. #DTC_FLAGS=\"-@ -H epapr\"
  98. echo "Compiling for the RPi 4 aarch64"
  99. _config_preset="bcm2711_defconfig"
  100. _xcompile_args="ARCH=arm64 CROSS_COMPILE=${HOME}/x-tools/aarch64-spudd-linux-gnu/bin/aarch64-spudd-linux-gnu-"
  101. ;;
  102. *)
  103. echo "Only supports the rpi 4 at this point in time"
  104. exit 1
  105. ;;
  106. esac
  107. else
  108. echo "Compiling for desktop"
  109. #_xcompile_args="CC=clang HOSTCC=clang"
  110. #_xcompile_args=""
  111. _config_file="${startdir}/desktop"
  112. #_config_file="${_kernel_src_dir}/configs/desktop"
  113. fi
  114. _make_cmd="eval time make VERBOSE=1 ${_xcompile_args}"