PKGBUILD 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. # Contributor: 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. # Maintainer: Parabola Hackers <dev@lists.parabola.nu>
  10. # Contributor: bill-auger <bill-auger@programmer.net>
  11. # Maintainer (arch:linux-lts): Andreas Radke <andyrtr@archlinux.org>
  12. # Maintainer (arch32:linux-lts): Andreas Baumann <mail@andreasbaumann.cc>
  13. # CAVEATS:
  14. # Provides linux-libre-lts{,-docs,-headers} but not linux-lts{,-docs,-headers}.
  15. # Otherwise, it is not possible to install along-side linux-libre-lts,
  16. # because linux-libre-lts conflicts and replaces any other package which provides linux-lts.
  17. # Until we get this sorted out (eg: add linux-libre provision to linux-libre{,lts,...}),
  18. # the trade-off is that packages which require linux-libre-lts{,-docs,-headers}
  19. # will pull in linux-libre-lts, even if linux-libre-vanilla-lts is installed.
  20. # - linux-libre-lts: acpi_call-lts and tp_smapi-lts require linux-libre-lts
  21. # - linux-libre-lts-headers: nothing requires linux-libre{,-lts}-headers (but provided for completeness)
  22. # - linux-libre-lts-docs: extra/systeroid requires linux-docs
  23. pkgbase=linux-libre-vanilla-lts
  24. pkgver=6.6.32
  25. _minor_ver=$(sed 's|\([0-9]\+\.[0-9]\+\).*|\1|' <<<${pkgver}) # eg: 6.1
  26. _upstream_minor_ver=${_minor_ver}-gnu # eg: 6.1-gnu
  27. _upstream_ver=${pkgver}-gnu # eg: 6.1.5-gnu
  28. _is_patch_release=$( [[ ${_upstream_minor_ver} != ${_upstream_ver} ]] ; echo $((!$?)) ; )
  29. pkgrel=2
  30. pkgdesc="Linux-libre LTS (pristine upstream release)"
  31. url=https://linux-libre.fsfla.org/
  32. arch=(armv7h i686 x86_64)
  33. license=(GPL2)
  34. makedepends=(
  35. bc
  36. cpio
  37. gettext
  38. libelf
  39. pahole
  40. perl
  41. python
  42. tar
  43. xz
  44. # htmldocs
  45. graphviz
  46. imagemagick
  47. python-sphinx
  48. #python-yaml # next major release will probably need this un-commented
  49. texlive-latexextra
  50. )
  51. makedepends_armv7h=(uboot-tools vboot-utils dtc) # required by linux-libre-lts-chromebook
  52. makedepends_armv7h+=(kmod ) # explicit `depmod`
  53. options=(
  54. !debug
  55. !strip
  56. )
  57. _srcname=linux-${_minor_ver}
  58. source=(https://linux-libre.fsfla.org/pub/linux-libre/releases/${_upstream_minor_ver}/linux-libre-${_upstream_minor_ver}.tar.xz{,.sign}
  59. https://repo.parabola.nu/other/linux-libre/logos/logo_linux_{clut224.ppm,vga16.ppm,mono.pbm}{,.sig})
  60. (( _is_patch_release )) && source+=(https://linux-libre.fsfla.org/pub/linux-libre/releases/${_upstream_ver}/patch-${_upstream_minor_ver}-${_upstream_ver}.xz{,.sign})
  61. source_armv7h=(config.armv7h
  62. 'kernel.its'
  63. 'kernel.keyblock'
  64. 'kernel_data_key.vbprivk'
  65. linux-libre-vanilla-armv7h.preset)
  66. source_i686=(config.i686
  67. no-ultra-zstd.patch)
  68. source_x86_64=(config.x86_64)
  69. sha512sums=('ccc9e2ad65f351d129aad604d4bc476627e4243cd09824a85832fece8df5a676bb12d3db9856d91dc3bb1cca6bfa11e1a9dccb1441b12a0f54507595cbeb5694'
  70. 'SKIP'
  71. '13cb5bc42542e7b8bb104d5f68253f6609e463b6799800418af33eb0272cc269aaa36163c3e6f0aacbdaaa1d05e2827a4a7c4a08a029238439ed08b89c564bb3'
  72. 'SKIP'
  73. '7a3716bfe3b9f546da309c7492f3e08f8f506813afeb1c737a474c83313d5c313cf4582b65215c2cfce3b74d9d1021c96e8badafe8f6e5b01fe28d2b5c61ae78'
  74. 'SKIP'
  75. '267295aa0cea65684968420c68b32f1a66a22d018b9d2b2c1ef14267bcf4cb68aaf7099d073cbfefe6c25c8608bdcbbd45f7ac8893fdcecbf1e621abdfe9ecc1'
  76. 'SKIP')
  77. (( _is_patch_release )) && sha512sums+=('4cce11c92079c657b3d1d596f02322dcfe0aac16cec286f58ea2ba043a62e8ff872fba0e356b28c37fa9f3b0ac62757deecf643ff02947275364acaa14a855cd'
  78. 'SKIP')
  79. sha512sums_armv7h=('725c453abb9f8b42148d4dd8d4cf53a6b6512d5fda35aa15bfa998a819e539e19d649e080ff2c0f4a6e00d29ae62ef2868c56cbb42c3d1f720319a513595659d'
  80. 'f10af02f0cb2d31259d9633e1ba845f555f525789f750fc2ddc51bd18c5ff64fcdd242dae801623887f5ce5cdb5528bce890459f0fab9fd31a28868bb7f6bba5'
  81. 'bb6718984a7357c9b00c37e4788480e5b8b75018c172ecc1441bc3fc5d2d42444eb5d8c7f9d2e3a7d6fed6d03acb565e3c0559486e494c40a7fe6bd0570c9ede'
  82. '143dea30c6da00e504c99984a98a0eb2411f558fcdd9dfa7f607d6c14e9e7dffff9cb00121d9317044b07e3e210808286598c785ee854084b993ec9cb14d8232'
  83. 'f01e7925b262d2874a8a991b1f27d057356a2a384d2012b61be5a631d4e4d7cf87461c8fb9e7f183831f5a829ad204897f1f0545a52df6288a0e04a5c2e31b96')
  84. sha512sums_i686=('50d3529a9a279a880c07a4bb6f46374b1fb260861b776ab5791136c176ae1f0a24c4b0c8837f06000317017d21cb46ca307b1ee0644385cc200be96a79723ae6'
  85. 'bca15cc96f64c38adcd13a46752866b5b30555ac21e19b3f7afcd20fcb7ec585c9d990fe8f842f44d5f69d477d72867fe6a9102729f26f93f5a80b372e41ce85')
  86. sha512sums_x86_64=('a5ba89d6f95d5d18462303cafd751bb9c96fb4266c58afbd60df1eb3deb8be8fa7f6e5d3b48cda4a750b88751b078d783f9cf101af6d449d9d4dbe238efa2d59')
  87. validpgpkeys=('474402C8C582DAFBE389C427BCB7CF877E7D47A7' # Alexandre Oliva
  88. '6DB9C4B4F0D8C0DC432CF6E4227CA7C556B2BA78') # David P.
  89. # reproducibility
  90. export KBUILD_BUILD_HOST=parabola
  91. export KBUILD_BUILD_USER=$pkgbase
  92. export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
  93. # per-arch KARCH
  94. case "$CARCH" in
  95. i686|x86_64) KARCH=x86;;
  96. armv7h) KARCH=arm;;
  97. esac
  98. # per-arch dependency tweaks
  99. _BUILD_DOCS=$( [[ "$CARCH" =~ ^(armv7h|i686)$ ]] && echo 0 || echo 1)
  100. _BUILD_BPFTOOL=$([[ "$CARCH" =~ ^(armv7h|i686)$ ]] && echo 0 || echo 1)
  101. _BUILD_BPFTOOL=0 # next major release will probably need this LOC deleted
  102. # FIXME: x86_64 succeeded with CONFIG_DEBUG_INFO_BTF=y and _BUILD_BPFTOOL=0
  103. # but i686 failed, suggesting to disable CONFIG_DEBUG_INFO_BTF
  104. if ! (( _BUILD_DOCS )); then
  105. # temporarily disabled documentation due to sphinx_rtd_theme (FS32#163)
  106. # FIXME: sphinx-build returned an error at ./scripts/sphinx-pre-install line 317.
  107. makedepends=( ${makedepends[*]/graphviz/} )
  108. makedepends=( ${makedepends[*]/imagemagick/} )
  109. makedepends=( ${makedepends[*]/python-sphinx/} )
  110. makedepends=( ${makedepends[*]/python-yaml/} )
  111. makedepends=( ${makedepends[*]/texlive-latexextra/} )
  112. fi
  113. if ! (( _BUILD_BPFTOOL )); then
  114. # Also avoid building/running bpftool
  115. makedepends=( ${makedepends[*]/pahole/} )
  116. fi
  117. prepare() {
  118. cd $_srcname
  119. # upstream patch release
  120. if [ "${_minor_ver}" != "$pkgver" ]; then
  121. echo "Applying upstream patch release"
  122. patch -Np1 < "../patch-${_minor_ver}-gnu-${pkgver}-gnu"
  123. fi
  124. # freedo boot logo
  125. install -m644 -t drivers/video/logo ../logo_linux_{clut224.ppm,vga16.ppm,mono.pbm}
  126. echo "Setting version..."
  127. echo "-$pkgrel" > localversion.10-pkgrel
  128. echo "${pkgbase#linux}" > localversion.20-pkgname
  129. sed -i 's|^-libre||' localversion.20-pkgname # minimize diff
  130. local src
  131. declare -n per_arch_source=source_${CARCH} # minimize diff
  132. source+=( "${per_arch_source[@]}" ) # minimize diff
  133. for src in "${source[@]}"; do
  134. src="${src%%::*}"
  135. src="${src##*/}"
  136. # *.zst n/a - linux-libre patches are compressed only once
  137. [[ $src = *.patch ]] || continue
  138. echo "Applying patch $src..."
  139. patch -Np1 < "../$src"
  140. done
  141. echo "Setting config..."
  142. mv ../config{.$CARCH,} # minimize diff
  143. cp ../config .config
  144. make olddefconfig
  145. diff -u ../config .config || :
  146. if [ "$CARCH" = "armv7h" ]; then
  147. # don't run depmod on 'make install'. We'll do this ourselves in packaging
  148. sed -i '2iexit 0' scripts/depmod.sh
  149. fi
  150. make -s kernelrelease > version
  151. echo "Prepared $pkgbase version $(<version)"
  152. }
  153. build() {
  154. cd $_srcname
  155. make all
  156. # Also avoid building/running bpftool
  157. if (( _BUILD_BPFTOOL )); then
  158. make -C tools/bpf/bpftool vmlinux.h feature-clang-bpf-co-re=1
  159. fi
  160. # temporarily disabled documentation due to sphinx_rtd_theme (FS32#163)
  161. if (( _BUILD_DOCS )); then
  162. make htmldocs
  163. fi
  164. }
  165. _package() {
  166. pkgdesc="The $pkgdesc kernel and modules"
  167. license=(
  168. 'Apache-2.0 OR MIT'
  169. 'BSD-2-Clause OR GPL-2.0-or-later'
  170. BSD-3-Clause
  171. 'BSD-3-Clause OR GPL-2.0-only'
  172. 'BSD-3-Clause OR GPL-2.0-or-later'
  173. BSD-3-Clause-Clear
  174. GPL-1.0-or-later
  175. 'GPL-1.0-or-later OR BSD-3-Clause'
  176. GPL-2.0-only
  177. 'GPL-2.0-only OR Apache-2.0'
  178. 'GPL-2.0-only OR BSD-2-Clause'
  179. 'GPL-2.0-only OR BSD-3-Clause'
  180. 'GPL-2.0-only OR CDDL-1.0'
  181. 'GPL-2.0-only OR Linux-OpenIB'
  182. 'GPL-2.0-only OR MIT'
  183. 'GPL-2.0-only OR MPL-1.1'
  184. 'GPL-2.0-only OR X11'
  185. 'GPL-2.0-only WITH Linux-syscall-note'
  186. GPL-2.0-or-later
  187. 'GPL-2.0-or-later OR BSD-2-Clause'
  188. 'GPL-2.0-or-later OR BSD-3-Clause'
  189. 'GPL-2.0-or-later OR MIT'
  190. 'GPL-2.0-or-later OR X11'
  191. 'GPL-2.0-or-later WITH GCC-exception-2.0'
  192. ISC
  193. LGPL-2.0-or-later
  194. 'LGPL-2.1-only'
  195. 'LGPL-2.1-only OR BSD-2-Clause'
  196. LGPL-2.1-or-later
  197. MIT
  198. MPL-1.1
  199. X11
  200. Zlib
  201. )
  202. depends=(
  203. coreutils
  204. initramfs
  205. kmod
  206. )
  207. optdepends=(
  208. 'wireless-regdb: to set the correct wireless channels of your country'
  209. 'linux-firmware: firmware images needed for some devices'
  210. )
  211. optdepends=( "${optdepends[@]/linux/linux-libre}" ) # minimize diff
  212. provides=(
  213. # KSMBD-MODULE # no parabola package requires this
  214. # VIRTUALBOX-GUEST-MODULES # no parabola package requires this
  215. # WIREGUARD-MODULE # no parabola package requires this
  216. )
  217. provides+=("linux-libre-lts=${pkgver}")
  218. replaces=(
  219. # virtualbox-guest-modules-arch # no such parabola package since 2021
  220. # wireguard-arch # no such parabola package since 2020
  221. )
  222. backup=("etc/mkinitcpio.d/${pkgbase}.preset")
  223. cd $_srcname
  224. local modulesdir="$pkgdir/usr/lib/modules/$(<version)"
  225. echo "Installing boot image..."
  226. # systemd expects to find the kernel here to allow hibernation
  227. # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
  228. install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"
  229. # On armv7h, the uboot4extlinux-* packages provide and use a extlinux.conf
  230. # file in /boot/extlinux/. This file is needed for the bootloader to find the
  231. # kernel, initramfs and devicetree. Because of that we need the kernel image
  232. # to also be installed in /boot for several reasons:
  233. #
  234. # - First the $modulesdir name contains the kernel version, and extlinux.conf
  235. # is supposed to be edited by hand by users. Users can't be expected to do
  236. # that at each kernel updates beause at some point they will forget and get
  237. # a mismatch between the kernel image and modules which often breaks boot.
  238. # In addition people know that the kernel image is in /boot. Having it in
  239. # $moduledir instead is not documented anywhere. And we don't have code that
  240. # can automatically generate an extlinux.conf.
  241. #
  242. # - Then we also need the kernel image in /boot to be able to use LVM rootfs
  243. # as this requires a separate /boot partition and u-boot can't read LVM.
  244. #
  245. # - Finally, doing the copy manually might be straigtforward in some cases,
  246. # as computers like the Lime 2 A20 are well supported, boot on a microSD or
  247. # other removable storage that can be read by a laptop/desktop computer and
  248. # even has a display that works at boot. But some of the supported ARM
  249. # computers have an internal eMMC and no display that works at boot (like
  250. # the TBS2910 or beaglebone black) and no way to export the internal storage
  251. # as an usb mass storage (because the ums command is not compiled in u-boot)
  252. # and sometimes even no way to connect a display at all (like the BegaleBone
  253. # green). So that makes the simple way of copying a file way more complex.
  254. # So it is a good idea not to break the boot if possible.
  255. if [ "$CARCH" = "armv7h" ]; then
  256. install -Dm644 "$(make -s image_name)" "$pkgdir/boot/vmlinuz-${pkgbase}"
  257. fi
  258. # Used by mkinitcpio to name the kernel
  259. echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
  260. echo "Installing modules..."
  261. ZSTD_CLEVEL=19 make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 \
  262. DEPMOD=/doesnt/exist modules_install # Suppress depmod
  263. # remove build link
  264. rm "$modulesdir"/build
  265. # licenses
  266. install -vDm 644 LICENSES/deprecated/{GPL-1.0,ISC,Linux-OpenIB,X11,Zlib} -t "$pkgdir/usr/share/licenses/$pkgname/"
  267. install -vDm 644 LICENSES/preferred/{BSD,MIT}* -t "$pkgdir/usr/share/licenses/$pkgname/"
  268. install -vDm 644 LICENSES/exceptions/* -t "$pkgdir/usr/share/licenses/$pkgname/"
  269. if [ "$CARCH" = "armv7h" ]; then
  270. echo "Installing device tree binaries..."
  271. make INSTALL_DTBS_PATH="${pkgdir}/boot/dtbs/${pkgbase}" dtbs_install
  272. fi
  273. if [ "$CARCH" = "armv7h" ]; then
  274. local _kernver="$(<version)" # minimize diff
  275. cp ../{${pkgbase%-lts}-armv7h,linux}.preset # minimize diff
  276. # now we call depmod...
  277. depmod -b "${pkgdir}/usr" -F System.map "${_kernver}"
  278. # sed expression for following substitutions
  279. local _subst="
  280. s|%PKGBASE%|${pkgbase}|g
  281. s|%KERNVER%|${_kernver}|g
  282. "
  283. echo "Installing mkinitcpio preset..."
  284. # install mkinitcpio preset file
  285. sed "${_subst}" ../linux.preset |
  286. install -Dm644 /dev/stdin "${pkgdir}/etc/mkinitcpio.d/${pkgbase}.preset"
  287. fi
  288. }
  289. _package-headers() {
  290. pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
  291. license=(
  292. BSD-3-Clause
  293. 'BSD-3-Clause OR GPL-2.0-only'
  294. GPL-1.0-or-later
  295. 'GPL-1.0-or-later WITH Linux-syscall-note'
  296. GPL-2.0-only
  297. 'GPL-2.0-only OR Apache-2.0'
  298. 'GPL-2.0-only OR BSD-2-Clause'
  299. 'GPL-2.0-only OR BSD-3-Clause'
  300. 'GPL-2.0-only OR CDDL-1.0'
  301. 'GPL-2.0-only OR Linux-OpenIB'
  302. 'GPL-2.0-only OR Linux-OpenIB OR BSD-2-Clause'
  303. 'GPL-2.0-only OR MIT'
  304. 'GPL-2.0-only OR MPL-1.1'
  305. 'GPL-2.0-only OR X11'
  306. 'GPL-2.0-only WITH Linux-syscall-note'
  307. '(GPL-2.0-only WITH Linux-syscall-note) AND MIT'
  308. '(GPL-2.0-only WITH Linux-syscall-note) OR BSD-2-Clause'
  309. '(GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause'
  310. '(GPL-2.0-only WITH Linux-syscall-note) OR CDDL-1.0'
  311. '(GPL-2.0-only WITH Linux-syscall-note) OR Linux-OpenIB'
  312. '(GPL-2.0-only WITH Linux-syscall-note) OR MIT'
  313. GPL-2.0-or-later
  314. 'GPL-2.0-or-later OR BSD-2-Clause'
  315. 'GPL-2.0-or-later OR BSD-3-Clause'
  316. 'GPL-2.0-or-later OR MIT'
  317. 'GPL-2.0-or-later WITH Linux-syscall-note'
  318. '(GPL-2.0-or-later WITH Linux-syscall-note) OR BSD-3-Clause'
  319. '(GPL-2.0-or-later WITH Linux-syscall-note) OR MIT'
  320. 'LGPL-2.0-or-later OR BSD-2-Clause'
  321. 'LGPL-2.0-or-later WITH Linux-syscall-note'
  322. ISC
  323. 'LGPL-2.0-or-later WITH Linux-syscall-note'
  324. 'LGPL-2.0-or-later OR BSD-2-Clause'
  325. LGPL-2.1-only
  326. 'LGPL-2.1-only OR BSD-2-Clause'
  327. 'LGPL-2.1-only OR MIT'
  328. 'LGPL-2.1-only WITH Linux-syscall-note'
  329. LGPL-2.1-or-later
  330. 'LGPL-2.1-or-later OR BSD-2-Clause'
  331. 'LGPL-2.1-or-later WITH Linux-syscall-note'
  332. MIT
  333. Zlib
  334. )
  335. depends=(pahole)
  336. provides=("linux-libre-lts-headers=${pkgver}")
  337. cd $_srcname
  338. local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
  339. echo "Installing build files..."
  340. # next major release will probably need this next LOC
  341. #(( _BUILD_BPFTOOL )) || touch tools/bpf/bpftool/vmlinux.h
  342. install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
  343. localversion.* version vmlinux
  344. install -Dt "$builddir/kernel" -m644 kernel/Makefile
  345. install -Dt "$builddir/arch/$KARCH" -m644 arch/$KARCH/Makefile
  346. # next major release will probably need this next LOC
  347. #(( _BUILD_BPFTOOL )) || rm "$builddir"/vmlinux.h
  348. if [ "$CARCH" = "i686" ]; then
  349. install -Dt "$builddir/arch/$KARCH" -m644 arch/$KARCH/Makefile_32.cpu
  350. fi
  351. cp -t "$builddir" -a scripts
  352. # required when STACK_VALIDATION is enabled
  353. if [[ -e tools/objtool/objtool ]]; then
  354. install -Dt "$builddir/tools/objtool" tools/objtool/objtool
  355. fi
  356. # required when DEBUG_INFO_BTF_MODULES is enabled
  357. if [[ -e tools/bpf/resolve_btfids/resolve_btfids ]]; then
  358. install -Dt "$builddir/tools/bpf/resolve_btfids" tools/bpf/resolve_btfids/resolve_btfids
  359. fi
  360. echo "Installing headers..."
  361. cp -t "$builddir" -a include
  362. cp -t "$builddir/arch/$KARCH" -a arch/$KARCH/include
  363. install -Dt "$builddir/arch/$KARCH/kernel" -m644 arch/$KARCH/kernel/asm-offsets.s
  364. # ARM-specific headers
  365. if [ "$CARCH" = "armv7h" ]; then
  366. local _builddir="${builddir}" # minimize diff
  367. cp -t "${_builddir}/arch/${KARCH}" -a arch/${KARCH}/include
  368. fi
  369. install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
  370. install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
  371. # https://bugs.archlinux.org/task/13146
  372. install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
  373. # https://bugs.archlinux.org/task/20402
  374. install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
  375. install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
  376. install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
  377. # https://bugs.archlinux.org/task/71392
  378. install -Dt "$builddir/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h
  379. echo "Installing KConfig files..."
  380. find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
  381. echo "Removing unneeded architectures..."
  382. local arch
  383. for arch in "$builddir"/arch/*/; do
  384. [[ $arch = */$KARCH/ ]] && continue
  385. echo "Removing $(basename "$arch")"
  386. rm -r "$arch"
  387. done
  388. echo "Removing documentation..."
  389. rm -r "$builddir/Documentation"
  390. echo "Removing broken symlinks..."
  391. find -L "$builddir" -type l -printf 'Removing %P\n' -delete
  392. echo "Removing loose objects..."
  393. find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
  394. echo "Stripping build tools..."
  395. local file
  396. while read -rd '' file; do
  397. case "$(file -Sib "$file")" in
  398. application/x-sharedlib\;*) # Libraries (.so)
  399. strip -v $STRIP_SHARED "$file" ;;
  400. application/x-archive\;*) # Libraries (.a)
  401. strip -v $STRIP_STATIC "$file" ;;
  402. application/x-executable\;*) # Binaries
  403. strip -v $STRIP_BINARIES "$file" ;;
  404. application/x-pie-executable\;*) # Relocatable binaries
  405. strip -v $STRIP_SHARED "$file" ;;
  406. esac
  407. done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
  408. echo "Stripping vmlinux..."
  409. strip -v $STRIP_STATIC "$builddir/vmlinux"
  410. echo "Adding symlink..."
  411. mkdir -p "$pkgdir/usr/src"
  412. ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
  413. # licenses
  414. install -vDm 644 LICENSES/deprecated/{ISC,Linux-OpenIB,X11,Zlib} -t "$pkgdir/usr/share/licenses/$pkgname/"
  415. install -vDm 644 LICENSES/preferred/{BSD*,MIT} -t "$pkgdir/usr/share/licenses/$pkgname/"
  416. install -vDm 644 LICENSES/exceptions/* -t "$pkgdir/usr/share/licenses/$pkgname/"
  417. }
  418. _package-docs() {
  419. pkgdesc="Documentation for the $pkgdesc kernel"
  420. license=(
  421. BSD-3-Clause
  422. GFDL-1.1-no-invariants-or-later
  423. GPL-2.0-only
  424. 'GPL-2.0-only OR BSD-2-Clause'
  425. 'GPL-2.0-only OR BSD-3-Clause'
  426. 'GPL-2.0-only OR GFDL-1.1-no-invariants-or-later'
  427. 'GPL-2.0-only OR GFDL-1.2-no-invariants-only'
  428. 'GPL-2.0-only OR MIT'
  429. GPL-2.0-or-later
  430. 'GPL-2.0-or-later OR BSD-2-Clause'
  431. 'GPL-2.0-or-later OR CC-BY-4.0'
  432. 'GPL-2.0-or-later OR MIT'
  433. 'GPL-2.0-or-later OR X11'
  434. 'LGPL-2.1-only OR BSD-2-Clause'
  435. MIT
  436. )
  437. provides=("linux-libre-lts-docs=${pkgver}")
  438. cd $_srcname
  439. local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
  440. echo "Installing documentation..."
  441. local src dst
  442. while read -rd '' src; do
  443. dst="${src#Documentation/}"
  444. dst="$builddir/Documentation/${dst#output/}"
  445. install -Dm644 "$src" "$dst"
  446. done < <(find Documentation -name '.*' -prune -o ! -type d -print0)
  447. echo "Adding symlink..."
  448. mkdir -p "$pkgdir/usr/share/doc"
  449. ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
  450. # licenses
  451. install -vDm 644 LICENSES/deprecated/X11 -t "$pkgdir/usr/share/licenses/$pkgname/"
  452. install -vDm 644 LICENSES/preferred/{BSD*,MIT} -t "$pkgdir/usr/share/licenses/$pkgname/"
  453. }
  454. _package-chromebook() {
  455. pkgdesc="$pkgdesc kernel sign for Veyron Chromebooks"
  456. depends=("${pkgbase}=${pkgver}")
  457. provides=("linux-libre-lts=${pkgver}")
  458. conflicts=(linux-libre{,-vanilla}-chromebook) # just 'cuz i dun wanna
  459. install=${pkgname}.install
  460. cd $_srcname
  461. cp ../kernel.its .
  462. mkimage -D "-I dts -O dtb -p 2048" -f kernel.its vmlinux.uimg
  463. dd if=/dev/zero of=bootloader.bin bs=512 count=1
  464. echo 'console=tty0 init=/sbin/init root=PARTUUID=%U/PARTNROFF=1 rootwait rw noinitrd' > cmdline
  465. echo "Creating kernel sign..."
  466. vbutil_kernel \
  467. --pack vmlinux.kpart \
  468. --version 1 \
  469. --vmlinuz vmlinux.uimg \
  470. --arch arm \
  471. --keyblock ../kernel.keyblock \
  472. --signprivate ../kernel_data_key.vbprivk \
  473. --config cmdline \
  474. --bootloader bootloader.bin
  475. echo "Installing kernel sign..."
  476. mkdir -p "${pkgdir}/boot"
  477. cp vmlinux.kpart "${pkgdir}/boot"
  478. }
  479. pkgname=(
  480. "$pkgbase"
  481. "$pkgbase-headers"
  482. "$pkgbase-docs"
  483. )
  484. [ "$CARCH" = "armv7h" ] && pkgname+=("$pkgbase-chromebook")
  485. for _p in "${pkgname[@]}"; do
  486. eval "package_$_p() {
  487. $(declare -f "_package${_p#$pkgbase}")
  488. _package${_p#$pkgbase}
  489. }"
  490. done
  491. (( _BUILD_DOCS )) || pkgname=( ${pkgname[*]/$pkgbase-docs/} )
  492. # FIXME: `mkimage kernel.signed` command fails in _package-chromebook()
  493. # FATAL ERROR: Couldn't open "arch/arm/boot/dts/exynos5250-snow.dtb": No such file or directory
  494. # mkimage: Can't open vmlinux.uimg.tmp: No such file or directory
  495. [[ "$CARCH" == armv7h ]] && pkgname=( ${pkgname[*]/$pkgbase-chromebook/} ) || :