PKGBUILD 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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=6.6.14
  15. pkgrel=2
  16. pkgdesc='LTS Linux-libre'
  17. url='https://linux-libre.fsfla.org/'
  18. arch=(i686 x86_64 armv7h)
  19. license=(GPL2)
  20. makedepends=(
  21. bc
  22. cpio
  23. gettext
  24. libelf
  25. pahole
  26. perl
  27. python
  28. tar
  29. xz
  30. # htmldocs
  31. graphviz
  32. imagemagick
  33. python-sphinx
  34. texlive-latexextra
  35. )
  36. options=('!strip')
  37. _srcname=linux-6.6
  38. source=(
  39. "https://linux-libre.fsfla.org/pub/linux-libre/releases/${_srcname##*-}-gnu/linux-libre-${_srcname##*-}-gnu.tar.xz"{,.sign}
  40. "https://linux-libre.fsfla.org/pub/linux-libre/releases/$pkgver-gnu/patch-${_srcname##*-}-gnu-$pkgver-gnu.xz"{,.sign}
  41. "https://repo.parabola.nu/other/linux-libre/logos/logo_linux_"{clut224.ppm,vga16.ppm,mono.pbm}{,.sig}
  42. config.i686 config.x86_64 config.armv7h # the main kernel config files
  43. linux-armv7h.preset # armv7h preset file for mkinitcpio ramdisk
  44. # maintain the TTY over USB disconnects
  45. # http://www.coreboot.org/EHCI_Gadget_Debug
  46. 0001-usb-serial-gadget-no-TTY-hangup-on-USB-disconnect-WI.patch
  47. # fix Atmel maXTouch touchscreen support
  48. # https://labs.parabola.nu/issues/877
  49. # http://www.fsfla.org/pipermail/linux-libre/2015-November/003202.html
  50. 0002-fix-Atmel-maXTouch-touchscreen-support.patch
  51. # Arch Linux patches
  52. # https://gitlab.archlinux.org/archlinux/packaging/packages/linux-lts
  53. 0001-ZEN-Add-sysctl-and-CONFIG-to-disallow-unprivileged-C.patch
  54. 0002-skip-simpledrm-if-nvidia-drm.modeset=1-is.patch
  55. 0003-Default-to-maximum-amount-of-ASLR-bits.patch
  56. )
  57. source_i686=(
  58. # avoid using zstd compression in ultra mode (exhausts virtual memory)
  59. no-ultra-zstd.patch
  60. )
  61. validpgpkeys=(
  62. 474402C8C582DAFBE389C427BCB7CF877E7D47A7 # Alexandre Oliva
  63. 6DB9C4B4F0D8C0DC432CF6E4227CA7C556B2BA78 # David P.
  64. )
  65. sha256sums=('d71785bdb694fefaa4f183e5dd2ffc453c179db6f9427cc37e1ed046f0073ccf'
  66. 'SKIP'
  67. 'fce0be10daa22b9019538c9809726b787f5edf5b1a9a0d22844cce5233a31210'
  68. 'SKIP'
  69. 'bfd4a7f61febe63c880534dcb7c31c5b932dde6acf991810b41a939a93535494'
  70. 'SKIP'
  71. '6de8a8319271809ffdb072b68d53d155eef12438e6d04ff06a5a4db82c34fa8a'
  72. 'SKIP'
  73. '13bd7a8d9ed6b6bc971e4cd162262c5a20448a83796af39ce394d827b0e5de74'
  74. 'SKIP'
  75. 'e2ac4c8c597b5493685dec86894d16efe901ea3ca9d4672d7ce748553549bf1c'
  76. '74b6aad76e0a087038731dc4bc775ec1cc768a55032d5a25e8477b8eb70f0955'
  77. '2e2d59869253b2a1b3feb4b5dcdccb4a3385e9ae53fc94604492b8298bc2c0ad'
  78. 'ca1708abbd2f8960c278722dc81a7c635973d92872386ad9e2fff10b86836e98'
  79. '0376bd5efa31d4e2a9d52558777cebd9f0941df8e1adab916c868bf0c05f2fc3'
  80. '351fd96be8cd5ebd0435c0a8a978673fc023e3b1026085e67f86d815b2285e25'
  81. '21195509fded29d0256abfce947b5a8ce336d0d3e192f3f8ea90bde9dd95a889'
  82. '2f23be91455e529d16aa2bbf5f2c7fe3d10812749828fc752240c21b2b845849'
  83. '6400a06e6eb3a24b650bc3b1bba9626622f132697987f718e7ed6a5b8c0317bc')
  84. sha256sums_i686=('a044d2ed2ac13f0435e94e567f6fd5d8380b694f74e344857ca64ef0c9424a07')
  85. b2sums=('e3e753fed07258f34e2e44e1acd4be0c22a3c58a3ae4856b518a4f99358f5bf6e8f38e41f422d9a434b33b0d7ee972e93ac7d37c9734949d6db263afe4c4f47c'
  86. 'SKIP'
  87. '00b6f532d3dd8c6cda6c315b9b980411f33dc7e50c4dafe8247a1f023591da21d8b84b415fc4d9277e370ad94b635baa4c90c507e173326fc5ae0369143d4c0a'
  88. 'SKIP'
  89. '73fee2ae5cb1ffd3e6584e56da86a8b1ff6c713aae54d77c0dab113890fc673dc5f300eb9ed93fb367b045ece8fa80304ff277fe61665eccf7b7ce24f0c045eb'
  90. 'SKIP'
  91. 'd02a1153a4285b32c774dca4560fe37907ccf30b8e487a681b717ed95ae9bed5988875c0a118938e5885ae9d2857e53a6f216b732b6fa3368e3c5fe08c86382c'
  92. 'SKIP'
  93. '580911af9431c066bbc072fd22d5e2ef65f12d8358cec5ff5a4f1b7deebb86cef6b5c1ad631f42350af72c51d44d2093c71f761234fb224a8b9dbb3b64b8201d'
  94. 'SKIP'
  95. '79316cdbf03bb4d91e5ebff3229433ee422232a3eb59bca819b8f8a2cada3410aaa630859a63d7cadfb00777425eab90e1054f3f37d32914caf32c8ec668839e'
  96. '3be29e751d1fe76caeb2474e31ee2df9b119dd6ba0002ca197bce2d66a5554465f839080fe470608a957324ded2a977c3f1635bf905db6cd352beb8ad939fe57'
  97. '912493240dbcf506cf2cc02b8fd7e7b22de3e369a5bfd87ce5a7faf592e54f112f64422fc0f4fab1ff2c8cd530502b23d24b3a6d5e00f8f95d98f0eb25f8776a'
  98. 'af69176b1117b94e56b043e97b0bd5873a2974a6a2fd52b102d0ffdca440ff68cfb241d6c4d4ef453cc8c220c236b739bad232e53fd500ce7672fa6e5ba87383'
  99. 'c2214154c36900e311531bfe68184f31639f5c50fed23bc3803a7f18439b7ff258552a39f02fed0ea92f10744e17a6c55cef0ef1a98187f978fe480fb3dddc14'
  100. '0c7ceba7cd90087db3296610a07886f337910bad265a32c052d3a703e6eb8e53f355ab9948d72d366408d968d8ee7435084dd89bef5ed0b69355fd884c2cd468'
  101. '02a10396c92ab93124139fc3e37b1d4d8654227556d0d11486390da35dfc401ff5784ad86d0d2aa7eacac12bc451aa2ff138749748c7e24deadd040d5404734c'
  102. '5dc21a7a6f0b840e6a671dcf09a865e42f0e2c000d5e45d3f3202c02946a8ab2207858d0b2ef1004648b8c2963efb428298b263c8494be806dfc9b6af66d5413'
  103. 'ba6ebe349b3757411364a9ba2deaa30a8d71a247d518c159385977c2b4782771bda4edfc96bd954808617c9ba984d832471b63c11f5bd6003369bfe4051df31f')
  104. b2sums_i686=('e7915714b504b92155c983a30df6d97966c14520dc9eb004671003dbdecf454b061138a6d237cabe86be32ae2ea4c598cdb821cb1dd52f6a9bfe5e280bffa321')
  105. _replacesarchkernel=("${_replacesarchkernel[@]/\%/${pkgbase#linux-libre}}")
  106. _replacesoldkernels=("${_replacesoldkernels[@]/\%/${pkgbase#linux-libre}}")
  107. _replacesoldmodules=("${_replacesoldmodules[@]/\%/${pkgbase#linux-libre}}")
  108. case "$CARCH" in
  109. i686|x86_64) KARCH=x86;;
  110. armv7h) KARCH=arm;;
  111. esac
  112. export KBUILD_BUILD_HOST=parabola
  113. export KBUILD_BUILD_USER=$pkgbase
  114. export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
  115. prepare() {
  116. cd $_srcname
  117. if [ "${_srcname##*-}" != "$pkgver" ]; then
  118. echo "Applying upstream patch..."
  119. patch -Np1 < "../patch-${_srcname##*-}-gnu-$pkgver-gnu"
  120. fi
  121. echo "Adding freedo as boot logo..."
  122. install -m644 -t drivers/video/logo \
  123. ../logo_linux_{clut224.ppm,vga16.ppm,mono.pbm}
  124. echo "Setting version..."
  125. echo "-$pkgrel" > localversion.10-pkgrel
  126. echo "${pkgbase#linux-libre}" > localversion.20-pkgname
  127. local source=("${source[@]}")
  128. case "$CARCH" in
  129. "armv7h")
  130. source+=("${source_armv7h[@]}") ;;
  131. "i686")
  132. source+=("${source_i686[@]}") ;;
  133. esac
  134. local src
  135. for src in "${source[@]}"; do
  136. src="${src%%::*}"
  137. src="${src##*/}"
  138. src="${src%.zst}"
  139. [[ $src = *.patch ]] || continue
  140. echo "Applying patch $src..."
  141. patch -Np1 < "../$src"
  142. done
  143. echo "Setting config..."
  144. cp ../config.$CARCH .config
  145. make olddefconfig
  146. diff -u ../config.$CARCH .config || :
  147. make -s kernelrelease > version
  148. echo "Prepared $pkgbase version $(<version)"
  149. }
  150. build() {
  151. cd $_srcname
  152. make all
  153. # temporarily disabled documentation due to sphinx_rtd_theme (FS32#163)
  154. if [ "$CARCH" != "i686" ]; then
  155. make htmldocs
  156. fi
  157. }
  158. _package() {
  159. pkgdesc="The $pkgdesc kernel and modules"
  160. depends=(
  161. coreutils
  162. initramfs
  163. kmod
  164. )
  165. optdepends=(
  166. 'wireless-regdb: to set the correct wireless channels of your country'
  167. 'linux-libre-firmware: firmware images needed for some devices'
  168. )
  169. provides=(
  170. KSMBD-MODULE
  171. VIRTUALBOX-GUEST-MODULES
  172. WIREGUARD-MODULE
  173. )
  174. replaces=(
  175. wireguard-lts
  176. )
  177. provides+=("${_replacesarchkernel[@]/%/=$pkgver}" "LINUX-ABI_VERSION=$pkgver")
  178. conflicts+=("${_replacesarchkernel[@]}" "${_replacesoldkernels[@]}" "${_replacesoldmodules[@]}")
  179. replaces+=("${_replacesarchkernel[@]}" "${_replacesoldkernels[@]}" "${_replacesoldmodules[@]}")
  180. cd $_srcname
  181. local modulesdir="$pkgdir/usr/lib/modules/$(<version)"
  182. echo "Installing boot image..."
  183. # systemd expects to find the kernel here to allow hibernation
  184. # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
  185. install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"
  186. # On armv7h, the uboot4extlinux-* packages provide and use a extlinux.conf
  187. # file in /boot/extlinux/. This file is needed for the bootloader to find the
  188. # kernel, initramfs and devicetree. Because of that we need the kernel image
  189. # to also be installed in /boot for several reasons:
  190. #
  191. # - First the $modulesdir name contains the kernel version, and extlinux.conf
  192. # is supposed to be edited by hand by users. Users can't be expected to do
  193. # that at each kernel updates beause at some point they will forget and get
  194. # a mismatch between the kernel image and modules which often breaks boot.
  195. # In addition people know that the kernel image is in /boot. Having it in
  196. # $moduledir instead is not documented anywhere. And we don't have code that
  197. # can automatically generate an extlinux.conf.
  198. #
  199. # - Then we also need the kernel image in /boot to be able to use LVM rootfs
  200. # as this requires a separate /boot partition and u-boot can't read LVM.
  201. #
  202. # - Finally, doing the copy manually might be straigtforward in some cases,
  203. # as computers like the Lime 2 A20 are well supported, boot on a microSD or
  204. # other removable storage that can be read by a laptop/desktop computer and
  205. # even has a display that works at boot. But some of the supported ARM
  206. # computers have an internal eMMC and no display that works at boot (like
  207. # the TBS2910 or beaglebone black) and no way to export the internal storage
  208. # as an usb mass storage (because the ums command is not compiled in u-boot)
  209. # and sometimes even no way to connect a display at all (like the BegaleBone
  210. # green). So that makes the simple way of copying a file way more complex.
  211. # So it is a good idea not to break the boot if possible.
  212. if [ "$CARCH" = "armv7h" ]; then
  213. install -Dm644 "$(make -s image_name)" "$pkgdir/boot/vmlinuz-${pkgbase}"
  214. fi
  215. # Used by mkinitcpio to name the kernel
  216. echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
  217. echo "Installing modules..."
  218. ZSTD_CLEVEL=19 make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 \
  219. DEPMOD=/doesnt/exist modules_install # Suppress depmod
  220. # remove build link
  221. rm "$modulesdir"/build
  222. if [ "$CARCH" = "armv7h" ]; then
  223. echo "Installing device tree binaries..."
  224. make INSTALL_DTBS_PATH="$pkgdir/boot/dtbs/$pkgbase" dtbs_install
  225. # armv7h presets only work with ALL_kver=$(<version)
  226. backup+=("etc/mkinitcpio.d/$pkgbase.preset")
  227. echo "Installing mkinitcpio preset..."
  228. sed "s|%PKGBASE%|$pkgbase|g;s|%KERNVER%|$(<version)|g" ../linux-armv7h.preset \
  229. | install -Dm644 /dev/stdin "$pkgdir/etc/mkinitcpio.d/$pkgbase.preset"
  230. fi
  231. }
  232. _package-headers() {
  233. pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
  234. depends=(pahole)
  235. provides=("${_replacesarchkernel[@]/%/-headers=$pkgver}")
  236. conflicts=("${_replacesarchkernel[@]/%/-headers}" "${_replacesoldkernels[@]/%/-headers}")
  237. replaces=("${_replacesarchkernel[@]/%/-headers}" "${_replacesoldkernels[@]/%/-headers}")
  238. cd $_srcname
  239. local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
  240. echo "Installing build files..."
  241. install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
  242. localversion.* version vmlinux
  243. install -Dt "$builddir/kernel" -m644 kernel/Makefile
  244. install -Dt "$builddir/arch/$KARCH" -m644 arch/$KARCH/Makefile
  245. if [[ $CARCH = i686 ]]; then
  246. install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile_32.cpu
  247. fi
  248. cp -t "$builddir" -a scripts
  249. # required when STACK_VALIDATION is enabled
  250. if [[ -e tools/objtool/objtool ]]; then
  251. install -Dt "$builddir/tools/objtool" tools/objtool/objtool
  252. fi
  253. # required when DEBUG_INFO_BTF_MODULES is enabled
  254. if [[ -e tools/bpf/resolve_btfids/resolve_btfids ]]; then
  255. install -Dt "$builddir/tools/bpf/resolve_btfids" tools/bpf/resolve_btfids/resolve_btfids
  256. fi
  257. echo "Installing headers..."
  258. cp -t "$builddir" -a include
  259. cp -t "$builddir/arch/$KARCH" -a arch/$KARCH/include
  260. install -Dt "$builddir/arch/$KARCH/kernel" -m644 arch/$KARCH/kernel/asm-offsets.s
  261. install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
  262. install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
  263. # https://bugs.archlinux.org/task/13146
  264. install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
  265. # https://bugs.archlinux.org/task/20402
  266. install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
  267. install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
  268. install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
  269. # https://bugs.archlinux.org/task/71392
  270. install -Dt "$builddir/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h
  271. echo "Installing KConfig files..."
  272. find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
  273. echo "Removing unneeded architectures..."
  274. local arch
  275. for arch in "$builddir"/arch/*/; do
  276. [[ $arch = */$KARCH/ ]] && continue
  277. echo "Removing $(basename "$arch")"
  278. rm -r "$arch"
  279. done
  280. echo "Removing documentation..."
  281. rm -r "$builddir/Documentation"
  282. echo "Removing broken symlinks..."
  283. find -L "$builddir" -type l -printf 'Removing %P\n' -delete
  284. echo "Removing loose objects..."
  285. find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
  286. echo "Stripping build tools..."
  287. local file
  288. while read -rd '' file; do
  289. case "$(file -Sib "$file")" in
  290. application/x-sharedlib\;*) # Libraries (.so)
  291. strip -v $STRIP_SHARED "$file" ;;
  292. application/x-archive\;*) # Libraries (.a)
  293. strip -v $STRIP_STATIC "$file" ;;
  294. application/x-executable\;*) # Binaries
  295. strip -v $STRIP_BINARIES "$file" ;;
  296. application/x-pie-executable\;*) # Relocatable binaries
  297. strip -v $STRIP_SHARED "$file" ;;
  298. esac
  299. done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
  300. echo "Stripping vmlinux..."
  301. strip -v $STRIP_STATIC "$builddir/vmlinux"
  302. echo "Adding symlink..."
  303. mkdir -p "$pkgdir/usr/src"
  304. ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
  305. }
  306. _package-docs() {
  307. pkgdesc="Documentation for the $pkgdesc kernel"
  308. provides=("${_replacesarchkernel[@]/%/-docs=$pkgver}")
  309. conflicts=("${_replacesarchkernel[@]/%/-docs}" "${_replacesoldkernels[@]/%/-docs}")
  310. replaces=("${_replacesarchkernel[@]/%/-docs}" "${_replacesoldkernels[@]/%/-docs}")
  311. cd $_srcname
  312. local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
  313. echo "Installing documentation..."
  314. local src dst
  315. while read -rd '' src; do
  316. dst="${src#Documentation/}"
  317. dst="$builddir/Documentation/${dst#output/}"
  318. install -Dm644 "$src" "$dst"
  319. done < <(find Documentation -name '.*' -prune -o ! -type d -print0)
  320. echo "Adding symlink..."
  321. mkdir -p "$pkgdir/usr/share/doc"
  322. ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
  323. }
  324. pkgname=(
  325. "$pkgbase"
  326. "$pkgbase-headers"
  327. "$pkgbase-docs"
  328. )
  329. for _p in "${pkgname[@]}"; do
  330. eval "package_$_p() {
  331. $(declare -f "_package${_p#$pkgbase}")
  332. _package${_p#$pkgbase}
  333. }"
  334. done
  335. # vim:set ts=8 sts=2 sw=2 et: