PKGBUILD 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. # Maintainer: David P. <megver83@parabola.nu>
  2. # Based on linux-rt-lts package
  3. _replacesarchkernel=('linux%') # '%' gets replaced with kernel suffix
  4. _replacesoldkernels=() # '%' gets replaced with kernel suffix
  5. _replacesoldmodules=() # '%' gets replaced with kernel suffix
  6. pkgbase=linux-libre-rt-lts
  7. _kver=6.1.69
  8. _rtver=21
  9. pkgver=$_kver.$_rtver.realtime1
  10. pkgrel=2
  11. pkgdesc='Linux-libre RT LTS'
  12. url='https://linux-libre.fsfla.org/'
  13. arch=(i686 x86_64 armv7h)
  14. makedepends=(
  15. bc
  16. cpio
  17. gettext
  18. libelf
  19. pahole
  20. perl
  21. python
  22. tar
  23. xz
  24. # htmldocs
  25. graphviz
  26. imagemagick
  27. python-sphinx
  28. texlive-latexextra
  29. )
  30. options=('!strip')
  31. _srcname=linux-6.1
  32. source=(
  33. "https://cdn.kernel.org/pub/linux/kernel/projects/rt/${_srcname##*-}/older/patch-$_kver-rt$_rtver.patch"{.xz,.sign}
  34. "https://linux-libre.fsfla.org/pub/linux-libre/releases/${_srcname##*-}-gnu/linux-libre-${_srcname##*-}-gnu.tar.xz"{,.sign}
  35. "https://linux-libre.fsfla.org/pub/linux-libre/releases/$_kver-gnu/patch-${_srcname##*-}-gnu-$_kver-gnu.xz"{,.sign}
  36. "https://repo.parabola.nu/other/linux-libre/logos/logo_linux_"{clut224.ppm,vga16.ppm,mono.pbm}{,.sig}
  37. config.i686 config.x86_64 config.armv7h # the main kernel config files
  38. linux-armv7h.preset # armv7h preset file for mkinitcpio ramdisk
  39. # maintain the TTY over USB disconnects
  40. # http://www.coreboot.org/EHCI_Gadget_Debug
  41. 0001-usb-serial-gadget-no-TTY-hangup-on-USB-disconnect-WI.patch
  42. # fix Atmel maXTouch touchscreen support
  43. # https://labs.parabola.nu/issues/877
  44. # http://www.fsfla.org/pipermail/linux-libre/2015-November/003202.html
  45. 0002-fix-Atmel-maXTouch-touchscreen-support.patch
  46. # Arch Linux patches
  47. # https://gitlab.archlinux.org/archlinux/packaging/upstream/linux-rt-lts
  48. 0001-ZEN-Add-sysctl-and-CONFIG-to-disallow-unprivileged-C.patch
  49. 0002-Set-distribution-specific-version.patch
  50. )
  51. source_i686=(
  52. # avoid using zstd compression in ultra mode (exhausts virtual memory)
  53. no-ultra-zstd.patch
  54. )
  55. validpgpkeys=(
  56. 474402C8C582DAFBE389C427BCB7CF877E7D47A7 # Alexandre Oliva
  57. 6DB9C4B4F0D8C0DC432CF6E4227CA7C556B2BA78 # David P.
  58. 64254695FFF0AA4466CC19E67B96E8162A8CF5D1 # Sebastian Andrzej Siewior
  59. D5653EA39C8675DA4BD5971C13B55DD07C53B851 # Clark Williams
  60. )
  61. sha256sums=('8c027c3a0f67e262d2713fef0852a5d6eed45c3da817feee2a4cce86f226cc11'
  62. 'SKIP'
  63. 'b3fb50b6eae92e5f399d3dd9d723f473d9fb467ada2cb518f15c2341d678ba37'
  64. 'SKIP'
  65. 'a0c41c53fc6b5fdd1ce19c56f03c5da4807b9b08fa1b145ef2466e6d21bee0e4'
  66. 'SKIP'
  67. 'bfd4a7f61febe63c880534dcb7c31c5b932dde6acf991810b41a939a93535494'
  68. 'SKIP'
  69. '6de8a8319271809ffdb072b68d53d155eef12438e6d04ff06a5a4db82c34fa8a'
  70. 'SKIP'
  71. '13bd7a8d9ed6b6bc971e4cd162262c5a20448a83796af39ce394d827b0e5de74'
  72. 'SKIP'
  73. '20dbe3daec3b9d4b7514a56337a1f4b46d48310a0f80b1843ddf9293b365e711'
  74. '532a71b772eab5eff67ca6a3a087ac3e33682896776ce84e79abcaf83e5fbb45'
  75. 'f0070e55f002dddd8fb8f983c450399a224b568587126943a1d7cde2ff428a50'
  76. 'ca1708abbd2f8960c278722dc81a7c635973d92872386ad9e2fff10b86836e98'
  77. '0376bd5efa31d4e2a9d52558777cebd9f0941df8e1adab916c868bf0c05f2fc3'
  78. '351fd96be8cd5ebd0435c0a8a978673fc023e3b1026085e67f86d815b2285e25'
  79. '5be77a4886cab9ab3f650ff032b39b0a5cc5029c16b49fb5d6f4469a4994e9b6'
  80. 'f61249fe6f286037fd8be8217427df6bf4def5745e29d2d2d9fc186b72c39b91')
  81. sha256sums_i686=('d32270be5fd9c3e3ba50f3aef33f6cfcb85be0c8216f03b777287cc621fdff28')
  82. b2sums=('a43ef1c448a28131e92d6fc03021542cdb858c9ad3dd3529993cdce0f81896eb6b3add11d1462791ad1f171f924a4d2feb720594b3807fd5a64ea3f77dbc4392'
  83. 'SKIP'
  84. '1834a1cd5094caa933f23be04b610f028ae34bdc104dbea225df707e73ce4afc34272bd429d125cc3bf5b817360e403c99e4405b0f7a9790a13e0c87e4e6fbab'
  85. 'SKIP'
  86. 'fdb0ba0ed28b744c94472e584d1dd169d583689dd036ead5965d8550780581c725a23cea7b2b3fe8f3d6ad5a44807699eede7db2330a7a469324213598866209'
  87. 'SKIP'
  88. '73fee2ae5cb1ffd3e6584e56da86a8b1ff6c713aae54d77c0dab113890fc673dc5f300eb9ed93fb367b045ece8fa80304ff277fe61665eccf7b7ce24f0c045eb'
  89. 'SKIP'
  90. 'd02a1153a4285b32c774dca4560fe37907ccf30b8e487a681b717ed95ae9bed5988875c0a118938e5885ae9d2857e53a6f216b732b6fa3368e3c5fe08c86382c'
  91. 'SKIP'
  92. '580911af9431c066bbc072fd22d5e2ef65f12d8358cec5ff5a4f1b7deebb86cef6b5c1ad631f42350af72c51d44d2093c71f761234fb224a8b9dbb3b64b8201d'
  93. 'SKIP'
  94. '168ecd73b12ea6bb505fae968e863328efe72522d5d33b27743e083a293c047e8c98dae55b85ebb7e936d9907e8b316f41d294d0660659df30b81bba30bd144e'
  95. '241a95f8266b10118ecb3a5b7d2e6b10d6c622bf022160bd79d08d17e8aaeedc9337eaeb56246788648fe0504a2c82c16ae1579062b927481d0e4677d0f47e10'
  96. '57e9597cd8b0568d49070abf127868e02f250b02c6597fa4402858b068d9455f2b1a4c5606970a34f4a3c7ec49b5ff49410997af3462a8d8e1d62541f427fcc7'
  97. 'af69176b1117b94e56b043e97b0bd5873a2974a6a2fd52b102d0ffdca440ff68cfb241d6c4d4ef453cc8c220c236b739bad232e53fd500ce7672fa6e5ba87383'
  98. 'c2214154c36900e311531bfe68184f31639f5c50fed23bc3803a7f18439b7ff258552a39f02fed0ea92f10744e17a6c55cef0ef1a98187f978fe480fb3dddc14'
  99. '0c7ceba7cd90087db3296610a07886f337910bad265a32c052d3a703e6eb8e53f355ab9948d72d366408d968d8ee7435084dd89bef5ed0b69355fd884c2cd468'
  100. '7441d065d411f7c8449f7d809e6e5666d97de61ce7ced2ea54aa2a7cf98411eebafb0c724de27a93e43c9841dea871957a5977b959f4f88e0159fcaa9c1a88f9'
  101. 'ce25c92dc7ed569ac5cb99de6391bd980cbbd807ac2328e50a38bc7234ae104136418c6bf870deef5a38fff29ea4608311fbc7a488f68aa8cd34b939c347473b')
  102. b2sums_i686=('165ab9dd8cedeaae5327accc1581c19cf0be55f923b03feb889cad3351b74c7c4cd3d3c206938e5152bfe1d947513dea8f630f8f5544099ec13d16d254725c40')
  103. _replacesarchkernel=("${_replacesarchkernel[@]/\%/${pkgbase#linux-libre}}")
  104. _replacesoldkernels=("${_replacesoldkernels[@]/\%/${pkgbase#linux-libre}}")
  105. _replacesoldmodules=("${_replacesoldmodules[@]/\%/${pkgbase#linux-libre}}")
  106. case "$CARCH" in
  107. i686|x86_64) KARCH=x86;;
  108. armv7h) KARCH=arm;;
  109. esac
  110. export KBUILD_BUILD_HOST=parabola
  111. export KBUILD_BUILD_USER=$pkgbase
  112. export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
  113. prepare() {
  114. cd $_srcname
  115. if [ "${_srcname##*-}" != "$_kver" ]; then
  116. echo "Applying upstream patch..."
  117. patch -Np1 < "../patch-${_srcname##*-}-gnu-$_kver-gnu"
  118. fi
  119. echo "Adding freedo as boot logo..."
  120. install -m644 -t drivers/video/logo \
  121. ../logo_linux_{clut224.ppm,vga16.ppm,mono.pbm}
  122. echo "Setting version..."
  123. echo "-$pkgrel" > localversion.10-pkgrel
  124. echo "${pkgbase#linux-libre}" > localversion.20-pkgname
  125. sed '/^EXTRAVERSION =/s/= .*/=/' -i Makefile
  126. local source=("${source[@]}")
  127. case "$CARCH" in
  128. "armv7h")
  129. source+=("${source_armv7h[@]}") ;;
  130. "i686")
  131. source+=("${source_i686[@]}") ;;
  132. esac
  133. local src
  134. for src in "${source[@]}"; do
  135. src="${src%%::*}"
  136. src="${src##*/}"
  137. # picking up the RT patch
  138. src="${src//patch.xz/patch}"
  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. license=(
  161. 'Apache-2.0 OR MIT'
  162. 'BSD-2-Clause OR GPL-2.0-or-later'
  163. BSD-3-Clause
  164. 'BSD-3-Clause OR GPL-2.0-only'
  165. 'BSD-3-Clause OR GPL-2.0-or-later'
  166. BSD-3-Clause-Clear
  167. GPL-1.0-or-later
  168. 'GPL-1.0-or-later OR BSD-3-Clause'
  169. GPL-2.0-only
  170. 'GPL-2.0-only OR Apache-2.0'
  171. 'GPL-2.0-only OR BSD-2-Clause'
  172. 'GPL-2.0-only OR BSD-3-Clause'
  173. 'GPL-2.0-only OR CDDL-1.0'
  174. 'GPL-2.0-only OR Linux-OpenIB'
  175. 'GPL-2.0-only OR MIT'
  176. 'GPL-2.0-only OR MPL-1.1'
  177. 'GPL-2.0-only OR X11'
  178. 'GPL-2.0-only WITH Linux-syscall-note'
  179. GPL-2.0-or-later
  180. 'GPL-2.0-or-later OR BSD-2-Clause'
  181. 'GPL-2.0-or-later OR BSD-3-Clause'
  182. 'GPL-2.0-or-later OR MIT'
  183. 'GPL-2.0-or-later OR X11'
  184. 'GPL-2.0-or-later WITH GCC-exception-2.0'
  185. ISC
  186. LGPL-2.0-or-later
  187. 'LGPL-2.1-only'
  188. 'LGPL-2.1-only OR BSD-2-Clause'
  189. LGPL-2.1-or-later
  190. MIT
  191. MPL-1.1
  192. X11
  193. Zlib
  194. )
  195. depends=(
  196. coreutils
  197. initramfs
  198. kmod
  199. )
  200. optdepends=(
  201. 'wireless-regdb: to set the correct wireless channels of your country'
  202. 'linux-libre-firmware: firmware images needed for some devices'
  203. )
  204. provides=(
  205. KSMBD-MODULE
  206. VIRTUALBOX-GUEST-MODULES
  207. WIREGUARD-MODULE
  208. )
  209. provides+=("${_replacesarchkernel[@]/%/=$pkgver}" "LINUX-ABI_VERSION=$pkgver")
  210. conflicts+=("${_replacesarchkernel[@]}" "${_replacesoldkernels[@]}" "${_replacesoldmodules[@]}")
  211. replaces+=("${_replacesarchkernel[@]}" "${_replacesoldkernels[@]}" "${_replacesoldmodules[@]}")
  212. cd $_srcname
  213. local modulesdir="$pkgdir/usr/lib/modules/$(<version)"
  214. echo "Installing boot image..."
  215. # systemd expects to find the kernel here to allow hibernation
  216. # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
  217. install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"
  218. # On armv7h, the uboot4extlinux-* packages provide and use a extlinux.conf
  219. # file in /boot/extlinux/. This file is needed for the bootloader to find the
  220. # kernel, initramfs and devicetree. Because of that we need the kernel image
  221. # to also be installed in /boot for several reasons:
  222. #
  223. # - First the $modulesdir name contains the kernel version, and extlinux.conf
  224. # is supposed to be edited by hand by users. Users can't be expected to do
  225. # that at each kernel updates beause at some point they will forget and get
  226. # a mismatch between the kernel image and modules which often breaks boot.
  227. # In addition people know that the kernel image is in /boot. Having it in
  228. # $moduledir instead is not documented anywhere. And we don't have code that
  229. # can automatically generate an extlinux.conf.
  230. #
  231. # - Then we also need the kernel image in /boot to be able to use LVM rootfs
  232. # as this requires a separate /boot partition and u-boot can't read LVM.
  233. #
  234. # - Finally, doing the copy manually might be straigtforward in some cases,
  235. # as computers like the Lime 2 A20 are well supported, boot on a microSD or
  236. # other removable storage that can be read by a laptop/desktop computer and
  237. # even has a display that works at boot. But some of the supported ARM
  238. # computers have an internal eMMC and no display that works at boot (like
  239. # the TBS2910 or beaglebone black) and no way to export the internal storage
  240. # as an usb mass storage (because the ums command is not compiled in u-boot)
  241. # and sometimes even no way to connect a display at all (like the BegaleBone
  242. # green). So that makes the simple way of copying a file way more complex.
  243. # So it is a good idea not to break the boot if possible.
  244. if [ "$CARCH" = "armv7h" ]; then
  245. install -Dm644 "$(make -s image_name)" "$pkgdir/boot/vmlinuz-${pkgbase}"
  246. fi
  247. # Used by mkinitcpio to name the kernel
  248. echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
  249. echo "Installing modules..."
  250. ZSTD_CLEVEL=19 make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 \
  251. DEPMOD=/doesnt/exist modules_install # Suppress depmod
  252. # remove build and source links
  253. rm "$modulesdir"/{source,build}
  254. # licenses
  255. install -vDm 644 LICENSES/deprecated/{GPL-1.0,ISC,Linux-OpenIB,X11,Zlib} -t "$pkgdir/usr/share/licenses/$pkgname/"
  256. install -vDm 644 LICENSES/preferred/{BSD,MIT}* -t "$pkgdir/usr/share/licenses/$pkgname/"
  257. install -vDm 644 LICENSES/exceptions/* -t "$pkgdir/usr/share/licenses/$pkgname/"
  258. if [ "$CARCH" = "armv7h" ]; then
  259. echo "Installing device tree binaries..."
  260. make INSTALL_DTBS_PATH="$pkgdir/boot/dtbs/$pkgbase" dtbs_install
  261. # armv7h presets only work with ALL_kver=$(<version)
  262. backup+=("etc/mkinitcpio.d/$pkgbase.preset")
  263. echo "Installing mkinitcpio preset..."
  264. sed "s|%PKGBASE%|$pkgbase|g;s|%KERNVER%|$(<version)|g" ../linux-armv7h.preset \
  265. | install -Dm644 /dev/stdin "$pkgdir/etc/mkinitcpio.d/$pkgbase.preset"
  266. fi
  267. }
  268. _package-headers() {
  269. license=(
  270. BSD-3-Clause
  271. 'BSD-3-Clause OR GPL-2.0-only'
  272. GPL-1.0-or-later
  273. 'GPL-1.0-or-later WITH Linux-syscall-note'
  274. GPL-2.0-only
  275. 'GPL-2.0-only OR Apache-2.0'
  276. 'GPL-2.0-only OR BSD-2-Clause'
  277. 'GPL-2.0-only OR BSD-3-Clause'
  278. 'GPL-2.0-only OR CDDL-1.0'
  279. 'GPL-2.0-only OR Linux-OpenIB'
  280. 'GPL-2.0-only OR Linux-OpenIB OR BSD-2-Clause'
  281. 'GPL-2.0-only OR MIT'
  282. 'GPL-2.0-only OR MPL-1.1'
  283. 'GPL-2.0-only OR X11'
  284. 'GPL-2.0-only WITH Linux-syscall-note'
  285. '(GPL-2.0-only WITH Linux-syscall-note) AND MIT'
  286. '(GPL-2.0-only WITH Linux-syscall-note) OR BSD-2-Clause'
  287. '(GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause'
  288. '(GPL-2.0-only WITH Linux-syscall-note) OR CDDL-1.0'
  289. '(GPL-2.0-only WITH Linux-syscall-note) OR Linux-OpenIB'
  290. '(GPL-2.0-only WITH Linux-syscall-note) OR MIT'
  291. GPL-2.0-or-later
  292. 'GPL-2.0-or-later OR BSD-2-Clause'
  293. 'GPL-2.0-or-later OR BSD-3-Clause'
  294. 'GPL-2.0-or-later OR MIT'
  295. 'GPL-2.0-or-later WITH Linux-syscall-note'
  296. '(GPL-2.0-or-later WITH Linux-syscall-note) OR BSD-3-Clause'
  297. '(GPL-2.0-or-later WITH Linux-syscall-note) OR MIT'
  298. 'LGPL-2.0-or-later OR BSD-2-Clause'
  299. 'LGPL-2.0-or-later WITH Linux-syscall-note'
  300. ISC
  301. 'LGPL-2.0-or-later WITH Linux-syscall-note'
  302. 'LGPL-2.0-or-later OR BSD-2-Clause'
  303. LGPL-2.1-only
  304. 'LGPL-2.1-only OR BSD-2-Clause'
  305. 'LGPL-2.1-only OR MIT'
  306. 'LGPL-2.1-only WITH Linux-syscall-note'
  307. LGPL-2.1-or-later
  308. 'LGPL-2.1-or-later OR BSD-2-Clause'
  309. 'LGPL-2.1-or-later WITH Linux-syscall-note'
  310. MIT
  311. Zlib
  312. )
  313. pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
  314. depends=(pahole)
  315. provides=("${_replacesarchkernel[@]/%/-headers=$pkgver}")
  316. conflicts=("${_replacesarchkernel[@]/%/-headers}" "${_replacesoldkernels[@]/%/-headers}")
  317. replaces=("${_replacesarchkernel[@]/%/-headers}" "${_replacesoldkernels[@]/%/-headers}")
  318. cd $_srcname
  319. local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
  320. echo "Installing build files..."
  321. install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
  322. localversion.* version vmlinux
  323. install -Dt "$builddir/kernel" -m644 kernel/Makefile
  324. install -Dt "$builddir/arch/$KARCH" -m644 arch/$KARCH/Makefile
  325. if [[ $CARCH = i686 ]]; then
  326. install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile_32.cpu
  327. fi
  328. cp -t "$builddir" -a scripts
  329. # required when STACK_VALIDATION is enabled
  330. if [[ -e tools/objtool/objtool ]]; then
  331. install -Dt "$builddir/tools/objtool" tools/objtool/objtool
  332. fi
  333. # required when DEBUG_INFO_BTF_MODULES is enabled
  334. if [[ -e tools/bpf/resolve_btfids/resolve_btfids ]]; then
  335. install -Dt "$builddir/tools/bpf/resolve_btfids" tools/bpf/resolve_btfids/resolve_btfids
  336. fi
  337. echo "Installing headers..."
  338. cp -t "$builddir" -a include
  339. cp -t "$builddir/arch/$KARCH" -a arch/$KARCH/include
  340. install -Dt "$builddir/arch/$KARCH/kernel" -m644 arch/$KARCH/kernel/asm-offsets.s
  341. install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
  342. install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
  343. # https://bugs.archlinux.org/task/13146
  344. install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
  345. # https://bugs.archlinux.org/task/20402
  346. install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
  347. install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
  348. install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
  349. # https://bugs.archlinux.org/task/71392
  350. install -Dt "$builddir/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h
  351. echo "Installing KConfig files..."
  352. find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
  353. echo "Removing unneeded architectures..."
  354. local arch
  355. for arch in "$builddir"/arch/*/; do
  356. [[ $arch = */$KARCH/ ]] && continue
  357. echo "Removing $(basename "$arch")"
  358. rm -r "$arch"
  359. done
  360. echo "Removing documentation..."
  361. rm -r "$builddir/Documentation"
  362. echo "Removing broken symlinks..."
  363. find -L "$builddir" -type l -printf 'Removing %P\n' -delete
  364. echo "Removing loose objects..."
  365. find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
  366. echo "Stripping build tools..."
  367. local file
  368. while read -rd '' file; do
  369. case "$(file -Sib "$file")" in
  370. application/x-sharedlib\;*) # Libraries (.so)
  371. strip -v $STRIP_SHARED "$file" ;;
  372. application/x-archive\;*) # Libraries (.a)
  373. strip -v $STRIP_STATIC "$file" ;;
  374. application/x-executable\;*) # Binaries
  375. strip -v $STRIP_BINARIES "$file" ;;
  376. application/x-pie-executable\;*) # Relocatable binaries
  377. strip -v $STRIP_SHARED "$file" ;;
  378. esac
  379. done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
  380. echo "Stripping vmlinux..."
  381. strip -v $STRIP_STATIC "$builddir/vmlinux"
  382. echo "Adding symlink..."
  383. mkdir -p "$pkgdir/usr/src"
  384. ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
  385. # licenses
  386. install -vDm 644 LICENSES/deprecated/{ISC,Linux-OpenIB,X11,Zlib} -t "$pkgdir/usr/share/licenses/$pkgname/"
  387. install -vDm 644 LICENSES/preferred/{BSD*,MIT} -t "$pkgdir/usr/share/licenses/$pkgname/"
  388. install -vDm 644 LICENSES/exceptions/* -t "$pkgdir/usr/share/licenses/$pkgname/"
  389. }
  390. _package-docs() {
  391. license=(
  392. BSD-3-Clause
  393. GFDL-1.1-no-invariants-or-later
  394. GPL-2.0-only
  395. 'GPL-2.0-only OR BSD-2-Clause'
  396. 'GPL-2.0-only OR BSD-3-Clause'
  397. 'GPL-2.0-only OR GFDL-1.1-no-invariants-or-later'
  398. 'GPL-2.0-only OR GFDL-1.2-no-invariants-only'
  399. 'GPL-2.0-only OR MIT'
  400. GPL-2.0-or-later
  401. 'GPL-2.0-or-later OR BSD-2-Clause'
  402. 'GPL-2.0-or-later OR CC-BY-4.0'
  403. 'GPL-2.0-or-later OR MIT'
  404. 'GPL-2.0-or-later OR X11'
  405. 'LGPL-2.1-only OR BSD-2-Clause'
  406. MIT
  407. )
  408. pkgdesc="Documentation for the $pkgdesc kernel"
  409. provides=("${_replacesarchkernel[@]/%/-docs=$pkgver}")
  410. conflicts=("${_replacesarchkernel[@]/%/-docs}" "${_replacesoldkernels[@]/%/-docs}")
  411. replaces=("${_replacesarchkernel[@]/%/-docs}" "${_replacesoldkernels[@]/%/-docs}")
  412. cd $_srcname
  413. local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
  414. echo "Installing documentation..."
  415. local src dst
  416. while read -rd '' src; do
  417. dst="${src#Documentation/}"
  418. dst="$builddir/Documentation/${dst#output/}"
  419. install -Dm644 "$src" "$dst"
  420. done < <(find Documentation -name '.*' -prune -o ! -type d -print0)
  421. echo "Adding symlink..."
  422. mkdir -p "$pkgdir/usr/share/doc"
  423. ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
  424. # licenses
  425. install -vDm 644 LICENSES/deprecated/X11 -t "$pkgdir/usr/share/licenses/$pkgname/"
  426. install -vDm 644 LICENSES/preferred/{BSD*,MIT} -t "$pkgdir/usr/share/licenses/$pkgname/"
  427. }
  428. pkgname=(
  429. "$pkgbase"
  430. "$pkgbase-headers"
  431. "$pkgbase-docs"
  432. )
  433. for _p in "${pkgname[@]}"; do
  434. eval "package_$_p() {
  435. $(declare -f "_package${_p#$pkgbase}")
  436. _package${_p#$pkgbase}
  437. }"
  438. done
  439. # vim:set ts=8 sts=2 sw=2 et: