PKGBUILD 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. # Maintainer: David P. <megver83@parabola.nu>
  2. # Contributor: André Silva <emulatorman@hyperbola.info>
  3. # Contributor: Márcio Silva <coadde@hyperbola.info>
  4. # Contributor: fauno <fauno@parabola.nu>
  5. # Contributor: Sorin-Mihai Vârgolici <smv@yobicore.org>
  6. # Contributor: Michał Masłowski <mtjm@mtjm.eu>
  7. # Contributor: Luke R. <g4jc@openmailbox.org>
  8. # Contributor: Andreas Grapentin <andreas@grapentin.org>
  9. # Based on linux-lts package
  10. # NOTE: Don't build htmldocs due to an error in sphinx (armv7h only)
  11. _replacesarchkernel=('linux%') # '%' gets replaced with kernel suffix
  12. _replacesoldkernels=() # '%' gets replaced with kernel suffix
  13. _replacesoldmodules=() # '%' gets replaced with kernel suffix
  14. pkgbase=linux-libre-lts
  15. pkgver=5.10.56
  16. pkgrel=1
  17. pkgdesc='LTS Linux-libre'
  18. rcnver=5.10.56
  19. rcnrel=armv7-x45
  20. url='https://linux-libre.fsfla.org/'
  21. arch=(i686 x86_64 armv7h)
  22. license=(GPL2)
  23. makedepends=(
  24. bc kmod libelf pahole cpio perl tar xz
  25. xmlto python-sphinx python-sphinx_rtd_theme graphviz imagemagick
  26. )
  27. options=('!strip')
  28. _srcname=linux-5.10
  29. source=(
  30. "https://linux-libre.fsfla.org/pub/linux-libre/releases/${_srcname##*-}-gnu/linux-libre-${_srcname##*-}-gnu.tar.xz"{,.sign}
  31. "https://linux-libre.fsfla.org/pub/linux-libre/releases/$pkgver-gnu/patch-${_srcname##*-}-gnu-$pkgver-gnu.xz"{,.sign}
  32. "https://repo.parabola.nu/other/linux-libre/logos/logo_linux_"{clut224.ppm,vga16.ppm,mono.pbm}{,.sig}
  33. config.i686 config.x86_64 config.armv7h # the main kernel config files
  34. linux-armv7h.preset # armv7h preset file for mkinitcpio ramdisk
  35. # maintain the TTY over USB disconnects
  36. # http://www.coreboot.org/EHCI_Gadget_Debug
  37. 0001-usb-serial-gadget-no-TTY-hangup-on-USB-disconnect-WI.patch
  38. # fix Atmel maXTouch touchscreen support
  39. # https://labs.parabola.nu/issues/877
  40. # http://www.fsfla.org/pipermail/linux-libre/2015-November/003202.html
  41. 0002-fix-Atmel-maXTouch-touchscreen-support.patch
  42. # Arch Linux patches
  43. 0001-ZEN-Add-sysctl-and-CONFIG-to-disallow-unprivileged-C.patch
  44. )
  45. source_i686=(
  46. # avoid using zstd compression in ultra mode (exhausts virtual memory)
  47. no-ultra-zstd.patch
  48. )
  49. source_armv7h=(
  50. # RCN patch (CM3 firmware deblobbed and bloatware removed)
  51. "https://repo.parabola.nu/other/rcn-libre/patches/$rcnver/rcn-libre-$rcnver-$rcnrel.patch"{,.sig}
  52. )
  53. validpgpkeys=(
  54. '474402C8C582DAFBE389C427BCB7CF877E7D47A7' # Alexandre Oliva
  55. '6DB9C4B4F0D8C0DC432CF6E4227CA7C556B2BA78' # David P.
  56. )
  57. sha512sums=('ccc52db049a66ff146d9fc84fb00e783f2d04211156233a382f87589fec7631b8fbb3e76bfd94279607b883d25f9745e6c7d2bd62b13311dc6b425002bd42ec0'
  58. 'SKIP'
  59. '44f57270e8c973d03515ff8526865e5cecd7e7ae29c4c10468a2ee33b98baa20cdca07fe64910740a3b38c4a08eeb5727fb26d415cfd719403b976685d0e2b86'
  60. 'SKIP'
  61. '13cb5bc42542e7b8bb104d5f68253f6609e463b6799800418af33eb0272cc269aaa36163c3e6f0aacbdaaa1d05e2827a4a7c4a08a029238439ed08b89c564bb3'
  62. 'SKIP'
  63. '7a3716bfe3b9f546da309c7492f3e08f8f506813afeb1c737a474c83313d5c313cf4582b65215c2cfce3b74d9d1021c96e8badafe8f6e5b01fe28d2b5c61ae78'
  64. 'SKIP'
  65. '267295aa0cea65684968420c68b32f1a66a22d018b9d2b2c1ef14267bcf4cb68aaf7099d073cbfefe6c25c8608bdcbbd45f7ac8893fdcecbf1e621abdfe9ecc1'
  66. 'SKIP'
  67. '42e5e4913993650bb9bb22accbc1c272e8e0be4891e5bb82fb7c0f140d56bdc6f5282f353d53d49e4aa3a010d464c64001fb6d14d615c6778c10bec204435ea3'
  68. 'f7397cfec791ba8df9e342a850f4794acc5e69707a5c4e5f9c03b14c75f975317055a2be59ee51c3fd22bb8c534639454931bac79d9f3761453a62fc085d8801'
  69. '6012fa7b97c15ada82f0c205ea983bebac8b672ca498e22f524d219bdd8715784b24ce7d457803e8221a945c3daff95c4e467f70a420b9c2aa95d627f2d160a9'
  70. '53103bf55b957b657039510527df0df01279dec59cda115a4d6454e4135025d4546167fa30bdc99107f232561c1e096d8328609ab5a876cf7017176f92ad3e0b'
  71. '02af4dd2a007e41db0c63822c8ab3b80b5d25646af1906dc85d0ad9bb8bbf5236f8e381d7f91cf99ed4b0978c50aee37cb9567cdeef65b7ec3d91b882852b1af'
  72. 'b8fe56e14006ab866970ddbd501c054ae37186ddc065bb869cf7d18db8c0d455118d5bda3255fb66a0dde38b544655cfe9040ffe46e41d19830b47959b2fb168'
  73. 'aed7844c51ec705ef1ef5d9f1adf27939073c99d4fcc97051bed2fba1ec161fdde4c57cbe039209fb86c72918493bea55ed26189c1dda3dbea3a3a7019363818')
  74. sha512sums_i686=('3a346ff5e0fdefafd28bc3dd0e4b6cd68e3f0014e59d1611d99f2edb8d074fd32649eeb0894a7e340e4f907b5cfc0e08e0753e0427a68dc113bb22835a892968')
  75. sha512sums_armv7h=('8105ecb83dd3afa8b20f1a0846ff63ae5e6368a46e3e2f5a270d94e1ef5886b2b48eb9a8ff6ce9be2d0474abcc793c760984cd9df37b53914d0a8f68e010f20e'
  76. 'SKIP')
  77. _replacesarchkernel=("${_replacesarchkernel[@]/\%/${pkgbase#linux-libre}}")
  78. _replacesoldkernels=("${_replacesoldkernels[@]/\%/${pkgbase#linux-libre}}")
  79. _replacesoldmodules=("${_replacesoldmodules[@]/\%/${pkgbase#linux-libre}}")
  80. case "$CARCH" in
  81. i686|x86_64) KARCH=x86;;
  82. armv7h) KARCH=arm;;
  83. esac
  84. export KBUILD_BUILD_HOST=parabola
  85. export KBUILD_BUILD_USER=$pkgbase
  86. export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
  87. prepare() {
  88. cd $_srcname
  89. if [ "${_srcname##*-}" != "$pkgver" ]; then
  90. echo "Applying upstream patch..."
  91. patch -Np1 < "../patch-${_srcname##*-}-gnu-$pkgver-gnu"
  92. fi
  93. echo "Adding freedo as boot logo..."
  94. install -m644 -t drivers/video/logo \
  95. ../logo_linux_{clut224.ppm,vga16.ppm,mono.pbm}
  96. echo "Setting version..."
  97. scripts/setlocalversion --save-scmversion
  98. echo "-$pkgrel" > localversion.10-pkgrel
  99. echo "${pkgbase#linux-libre}" > localversion.20-pkgname
  100. if [ "$CARCH" = "armv7h" ]; then
  101. local src_armv7h
  102. for src_armv7h in "${source_armv7h[@]}"; do
  103. src_armv7h="${src_armv7h%%::*}"
  104. src_armv7h="${src_armv7h##*/}"
  105. [[ $src_armv7h = *.patch ]] || continue
  106. echo "Applying patch $src_armv7h..."
  107. patch -Np1 < "../$src_armv7h"
  108. done
  109. fi
  110. if [ "$CARCH" = "i686" ]; then
  111. local src_i686
  112. for src_i686 in "${source_i686[@]}"; do
  113. src_i686="${src_i686%%::*}"
  114. src_i686="${src_i686##*/}"
  115. [[ $src_i686 = *.patch ]] || continue
  116. echo "Applying patch $src_i686..."
  117. patch -Np1 < "../$src_i686"
  118. done
  119. fi
  120. local src
  121. for src in "${source[@]}"; do
  122. src="${src%%::*}"
  123. src="${src##*/}"
  124. [[ $src = *.patch ]] || continue
  125. echo "Applying patch $src..."
  126. patch -Np1 < "../$src"
  127. done
  128. echo "Setting config..."
  129. cp ../config.$CARCH .config
  130. make olddefconfig
  131. make -s kernelrelease > version
  132. echo "Prepared $pkgbase version $(<version)"
  133. }
  134. build() {
  135. cd $_srcname
  136. make all
  137. if ! [ "$CARCH" = armv7h ]; then
  138. make htmldocs
  139. fi
  140. }
  141. _package() {
  142. pkgdesc="The $pkgdesc kernel and modules"
  143. depends=(coreutils kmod initramfs)
  144. optdepends=('crda: to set the correct wireless channels of your country'
  145. 'linux-libre-firmware: firmware images needed for some devices')
  146. provides=(VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE)
  147. replaces=(wireguard-lts)
  148. provides+=("${_replacesarchkernel[@]/%/=$pkgver}" "LINUX-ABI_VERSION=$pkgver")
  149. conflicts+=("${_replacesarchkernel[@]}" "${_replacesoldkernels[@]}" "${_replacesoldmodules[@]}")
  150. replaces+=("${_replacesarchkernel[@]}" "${_replacesoldkernels[@]}" "${_replacesoldmodules[@]}")
  151. cd $_srcname
  152. local kernver="$(<version)"
  153. local modulesdir="$pkgdir/usr/lib/modules/$kernver"
  154. echo "Installing boot image..."
  155. # systemd expects to find the kernel here to allow hibernation
  156. # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
  157. install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"
  158. # Used by mkinitcpio to name the kernel
  159. echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
  160. echo "Installing modules..."
  161. make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 modules_install
  162. # remove build and source links
  163. rm "$modulesdir"/{source,build}
  164. if [ "$CARCH" = "armv7h" ]; then
  165. echo "Installing device tree binaries..."
  166. make INSTALL_DTBS_PATH="$pkgdir/boot/dtbs/$pkgbase" dtbs_install
  167. # armv7h presets only work with ALL_kver=$kernver
  168. backup=("etc/mkinitcpio.d/$pkgbase.preset")
  169. echo "Installing mkinitcpio preset..."
  170. sed "s|%PKGBASE%|$pkgbase|g;s|%KERNVER%|$kernver|g" ../linux-armv7h.preset \
  171. | install -Dm644 /dev/stdin "$pkgdir/etc/mkinitcpio.d/$pkgbase.preset"
  172. fi
  173. }
  174. _package-headers() {
  175. pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
  176. provides=("${_replacesarchkernel[@]/%/-headers=$pkgver}")
  177. conflicts=("${_replacesarchkernel[@]/%/-headers}" "${_replacesoldkernels[@]/%/-headers}")
  178. replaces=("${_replacesarchkernel[@]/%/-headers}" "${_replacesoldkernels[@]/%/-headers}")
  179. cd $_srcname
  180. local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
  181. echo "Installing build files..."
  182. install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
  183. localversion.* version vmlinux
  184. install -Dt "$builddir/kernel" -m644 kernel/Makefile
  185. install -Dt "$builddir/arch/$KARCH" -m644 arch/$KARCH/Makefile
  186. if [[ $CARCH = i686 ]]; then
  187. install -Dt "$builddir/arch/$KARCH" -m644 arch/$KARCH/Makefile_32.cpu
  188. fi
  189. cp -t "$builddir" -a scripts
  190. # add objtool for external module building and enabled VALIDATION_STACK option
  191. if [[ -e tools/objtool/objtool ]]; then
  192. install -Dt "$builddir/tools/objtool" tools/objtool/objtool
  193. fi
  194. # add xfs and shmem for aufs building
  195. mkdir -p "$builddir"/{fs/xfs,mm}
  196. echo "Installing headers..."
  197. cp -t "$builddir" -a include
  198. cp -t "$builddir/arch/$KARCH" -a arch/$KARCH/include
  199. install -Dt "$builddir/arch/$KARCH/kernel" -m644 arch/$KARCH/kernel/asm-offsets.s
  200. # from linux-armv7
  201. if [ "$CARCH" = "armv7h" ]; then
  202. for i in dove omap2; do
  203. mkdir -p "$builddir/arch/$KARCH/mach-$i"
  204. cp -t "$builddir/arch/$KARCH/mach-$i/" -a arch/$KARCH/mach-$i/include
  205. done
  206. for i in omap orion versatile; do
  207. mkdir -p "$builddir/arch/$KARCH/plat-$i"
  208. cp -t "$builddir/arch/$KARCH/plat-$i/" -a arch/$KARCH/plat-$i/include
  209. done
  210. fi
  211. install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
  212. install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
  213. # http://bugs.archlinux.org/task/13146
  214. install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
  215. # http://bugs.archlinux.org/task/20402
  216. install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
  217. install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
  218. install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
  219. echo "Installing KConfig files..."
  220. find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
  221. echo "Removing unneeded architectures..."
  222. local arch
  223. for arch in "$builddir"/arch/*/; do
  224. [[ $arch = */$KARCH/ ]] && continue
  225. echo "Removing $(basename "$arch")"
  226. rm -r "$arch"
  227. done
  228. echo "Removing documentation..."
  229. rm -r "$builddir/Documentation"
  230. echo "Removing broken symlinks..."
  231. find -L "$builddir" -type l -printf 'Removing %P\n' -delete
  232. echo "Removing loose objects..."
  233. find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
  234. echo "Stripping build tools..."
  235. local file
  236. while read -rd '' file; do
  237. case "$(file -bi "$file")" in
  238. application/x-sharedlib\;*) # Libraries (.so)
  239. strip -v $STRIP_SHARED "$file" ;;
  240. application/x-archive\;*) # Libraries (.a)
  241. strip -v $STRIP_STATIC "$file" ;;
  242. application/x-executable\;*) # Binaries
  243. strip -v $STRIP_BINARIES "$file" ;;
  244. application/x-pie-executable\;*) # Relocatable binaries
  245. strip -v $STRIP_SHARED "$file" ;;
  246. esac
  247. done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
  248. echo "Stripping vmlinux..."
  249. strip -v $STRIP_STATIC "$builddir/vmlinux"
  250. echo "Adding symlink..."
  251. mkdir -p "$pkgdir/usr/src"
  252. ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
  253. }
  254. _package-docs() {
  255. pkgdesc="Documentation for the $pkgdesc kernel"
  256. provides=("${_replacesarchkernel[@]/%/-docs=$pkgver}")
  257. conflicts=("${_replacesarchkernel[@]/%/-docs}" "${_replacesoldkernels[@]/%/-docs}")
  258. replaces=("${_replacesarchkernel[@]/%/-docs}" "${_replacesoldkernels[@]/%/-docs}")
  259. cd $_srcname
  260. local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
  261. echo "Installing documentation..."
  262. local src dst
  263. while read -rd '' src; do
  264. dst="${src#Documentation/}"
  265. dst="$builddir/Documentation/${dst#output/}"
  266. install -Dm644 "$src" "$dst"
  267. done < <(find Documentation -name '.*' -prune -o ! -type d -print0)
  268. echo "Adding symlink..."
  269. mkdir -p "$pkgdir/usr/share/doc"
  270. ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
  271. }
  272. pkgname=("$pkgbase" "$pkgbase-headers")
  273. [[ $CARCH = armv7h ]] || pkgname+=("$pkgbase-docs")
  274. for _p in "${pkgname[@]}"; do
  275. eval "package_$_p() {
  276. $(declare -f "_package${_p#$pkgbase}")
  277. _package${_p#$pkgbase}
  278. }"
  279. done
  280. # vim:set ts=8 sts=2 sw=2 et: