PKGBUILD 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. # AArch64 multi-platform
  2. # Maintainer: Kevin Mihelich <kevin@archlinuxarm.org>
  3. pkgbase=linux-pinebook
  4. _srcname=linux-5.16
  5. _kernelname=${pkgbase#linux}
  6. _desc="pinebook kernel"
  7. pkgver=5.16.2
  8. pkgrel=1
  9. arch=('aarch64')
  10. url="http://www.kernel.org/"
  11. license=('GPL2')
  12. makedepends=('xmlto' 'docbook-xsl' 'kmod' 'inetutils' 'bc' 'git' 'uboot-tools' 'vboot-utils' 'dtc')
  13. options=('!strip')
  14. source=("http://www.kernel.org/pub/linux/kernel/v5.x/${_srcname}.tar.xz"
  15. "http://www.kernel.org/pub/linux/kernel/v5.x/patch-${pkgver}.xz"
  16. "0001-Bluetooth-Add-new-quirk-for-broken-local-ext-features.patch"
  17. "0002-Bluetooth-btrtl-add-support-for-the-RTL8723CS.patch"
  18. "0003-arm64-allwinner-a64-enable-Bluetooth-On-Pinebook.patch"
  19. 'config'
  20. 'linux.preset'
  21. '60-linux.hook'
  22. '90-linux.hook')
  23. md5sums=('e6680ce7c989a3efe58b51e3f3f0bf93'
  24. '3ce3933c25c9a589fb072b81894a8f7b'
  25. 'cf64831f27bb47da29e708b7243bb340'
  26. 'a100d32aa6c345290061d2a773bf1232'
  27. '9510821113c122f91f47b9d0f7ca7264'
  28. 'c44955625a37f9e01dc4658049554884'
  29. '41cb5fef62715ead2dd109dbea8413d6'
  30. 'ce6c81ad1ad1f8b333fd6077d47abdaf'
  31. '3dc88030a8f2f5a5f97266d99b149f77')
  32. prepare() {
  33. cd ${_srcname}
  34. # add upstream patch
  35. git apply --whitespace=nowarn ../patch-${pkgver}
  36. # ALARM patches
  37. git apply ../0001-Bluetooth-Add-new-quirk-for-broken-local-ext-features.patch
  38. git apply ../0002-Bluetooth-btrtl-add-support-for-the-RTL8723CS.patch
  39. git apply ../0003-arm64-allwinner-a64-enable-Bluetooth-On-Pinebook.patch
  40. cat "${srcdir}/config" > ./.config
  41. # add pkgrel to extraversion
  42. sed -ri "s|^(EXTRAVERSION =)(.*)|\1 \2-${pkgrel}|" Makefile
  43. # don't run depmod on 'make install'. We'll do this ourselves in packaging
  44. sed -i '2iexit 0' scripts/depmod.sh
  45. }
  46. build() {
  47. cd ${_srcname}
  48. # get kernel version
  49. make prepare
  50. # load configuration
  51. # Configure the kernel. Replace the line below with one of your choice.
  52. #make menuconfig # CLI menu for configuration
  53. #make nconfig # new CLI menu for configuration
  54. #make xconfig # X-based configuration
  55. #make oldconfig # using old config from previous kernel version
  56. # ... or manually edit .config
  57. # Copy back our configuration (use with new kernel version)
  58. #cp ./.config ../${pkgbase}.config
  59. ####################
  60. # stop here
  61. # this is useful to configure the kernel
  62. #msg "Stopping build"
  63. #return 1
  64. ####################
  65. #yes "" | make config
  66. # build!
  67. unset LDFLAGS
  68. make ${MAKEFLAGS} Image Image.gz modules
  69. # Generate device tree blobs with symbols to support applying device tree overlays in U-Boot
  70. #make ${MAKEFLAGS} DTC_FLAGS="-@" allwinner/sun50i-a64-pinebook.dtb
  71. make ${MAKEFLAGS} DTC_FLAGS="-@" dtbs
  72. }
  73. _package() {
  74. pkgdesc="The Linux Kernel and modules - ${_desc}"
  75. depends=('coreutils' 'linux-firmware' 'kmod' 'mkinitcpio>=0.7')
  76. optdepends=('crda: to set the correct wireless channels of your country')
  77. provides=("linux=${pkgver}" "WIREGUARD-MODULE")
  78. replaces=('linux-armv8')
  79. conflicts=('linux')
  80. backup=("etc/mkinitcpio.d/${pkgbase}.preset")
  81. install=${pkgname}.install
  82. cd ${_srcname}
  83. KARCH=arm64
  84. # get kernel version
  85. _kernver="$(make kernelrelease)"
  86. _basekernel=${_kernver%%-*}
  87. _basekernel=${_basekernel%.*}
  88. mkdir -p "${pkgdir}"/{boot,usr/lib/modules}
  89. make INSTALL_MOD_PATH="${pkgdir}/usr" modules_install
  90. make INSTALL_DTBS_PATH="${pkgdir}/boot/dtbs" dtbs_install
  91. cp arch/$KARCH/boot/Image{,.gz} "${pkgdir}/boot"
  92. # make room for external modules
  93. local _extramodules="extramodules-${_basekernel}${_kernelname}"
  94. ln -s "../${_extramodules}" "${pkgdir}/usr/lib/modules/${_kernver}/extramodules"
  95. # add real version for building modules and running depmod from hook
  96. echo "${_kernver}" |
  97. install -Dm644 /dev/stdin "${pkgdir}/usr/lib/modules/${_extramodules}/version"
  98. # remove build and source links
  99. rm "${pkgdir}"/usr/lib/modules/${_kernver}/{source,build}
  100. # now we call depmod...
  101. depmod -b "${pkgdir}/usr" -F System.map "${_kernver}"
  102. # sed expression for following substitutions
  103. local _subst="
  104. s|%PKGBASE%|${pkgbase}|g
  105. s|%KERNVER%|${_kernver}|g
  106. s|%EXTRAMODULES%|${_extramodules}|g
  107. "
  108. # install mkinitcpio preset file
  109. sed "${_subst}" ../linux.preset |
  110. install -Dm644 /dev/stdin "${pkgdir}/etc/mkinitcpio.d/${pkgbase}.preset"
  111. # install pacman hooks
  112. sed "${_subst}" ../60-linux.hook |
  113. install -Dm644 /dev/stdin "${pkgdir}/usr/share/libalpm/hooks/60-${pkgbase}.hook"
  114. sed "${_subst}" ../90-linux.hook |
  115. install -Dm644 /dev/stdin "${pkgdir}/usr/share/libalpm/hooks/90-${pkgbase}.hook"
  116. }
  117. _package-headers() {
  118. pkgdesc="Header files and scripts for building modules for linux kernel - ${_desc}"
  119. provides=("linux-headers=${pkgver}")
  120. conflicts=('linux-headers')
  121. cd ${_srcname}
  122. local builddir="${pkgdir}/usr/lib/modules/${_kernver}/build"
  123. echo "Installing build files..."
  124. install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map vmlinux
  125. install -Dt "$builddir/kernel" -m644 kernel/Makefile
  126. install -Dt "$builddir/arch/${KARCH}" -m644 arch/${KARCH}/Makefile
  127. cp -t "$builddir" -a scripts
  128. # add xfs and shmem for aufs building
  129. mkdir -p "$builddir"/{fs/xfs,mm}
  130. echo "Installing headers..."
  131. cp -t "$builddir" -a include
  132. cp -t "$builddir/arch/${KARCH}" -a arch/${KARCH}/include
  133. install -Dt "$builddir/arch/${KARCH}/kernel" -m644 arch/${KARCH}/kernel/asm-offsets.s
  134. mkdir -p "$builddir/arch/arm"
  135. cp -t "$builddir/arch/arm" -a arch/arm/include
  136. install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
  137. install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
  138. # https://bugs.archlinux.org/task/13146
  139. install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
  140. # https://bugs.archlinux.org/task/20402
  141. install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
  142. install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
  143. install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
  144. # https://bugs.archlinux.org/task/71392
  145. install -Dt "$builddir/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h
  146. echo "Installing KConfig files..."
  147. find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
  148. echo "Removing unneeded architectures..."
  149. local arch
  150. for arch in "$builddir"/arch/*/; do
  151. [[ $arch = */${KARCH}/ || $arch == */arm/ ]] && continue
  152. echo "Removing $(basename "$arch")"
  153. rm -r "$arch"
  154. done
  155. echo "Removing documentation..."
  156. rm -r "$builddir/Documentation"
  157. echo "Removing broken symlinks..."
  158. find -L "$builddir" -type l -printf 'Removing %P\n' -delete
  159. echo "Removing loose objects..."
  160. find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
  161. echo "Stripping build tools..."
  162. local file
  163. while read -rd '' file; do
  164. case "$(file -bi "$file")" in
  165. application/x-sharedlib\;*) # Libraries (.so)
  166. strip -v $STRIP_SHARED "$file" ;;
  167. application/x-archive\;*) # Libraries (.a)
  168. strip -v $STRIP_STATIC "$file" ;;
  169. application/x-executable\;*) # Binaries
  170. strip -v $STRIP_BINARIES "$file" ;;
  171. application/x-pie-executable\;*) # Relocatable binaries
  172. strip -v $STRIP_SHARED "$file" ;;
  173. esac
  174. done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
  175. echo "Adding symlink..."
  176. mkdir -p "$pkgdir/usr/src"
  177. ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
  178. }
  179. pkgname=("${pkgbase}" "${pkgbase}-headers")
  180. for _p in ${pkgname[@]}; do
  181. eval "package_${_p}() {
  182. _package${_p#${pkgbase}}
  183. }"
  184. done