PKGBUILD 12 KB

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