PKGBUILD 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  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): Jan Alexander Steffens (heftig) <heftig@archlinux.org>
  12. # Maintainer (archarm:linux-armv7): Kevin Mihelich <kevin@archlinuxarm.org>
  13. # Maintainer (arch32:linux): Andreas Baumann <mail@andreasbaumann.cc>
  14. # CAVEATS:
  15. # Provides linux-libre{,-docs,-headers} but not linux{,-docs,-headers}.
  16. # Otherwise, it is not possible to install along-side linux-libre,
  17. # because linux-libre conflicts and replaces any other package which provides linux.
  18. # Until we get this sorted out (eg: add linux-libre provision to linux-libre{,lts,...}),
  19. # the trade-off is that packages which require linux{,-docs,-headers}
  20. # will pull in linux-libre, even if linux-libre-vanilla is installed.
  21. # - linux-libre: extra/netfilter-fullconenat requires linux
  22. # pcr/xtables-addons required linux - changed to linux-libre
  23. # - linux-libre-headers: nothing requires linux-headers (but provided for completeness)
  24. # - linux-libre-docs: extra/systeroid requires linux-docs
  25. pkgbase=linux-libre-vanilla
  26. pkgver=6.9.3
  27. _minor_ver=$(sed 's|\([0-9]\+\.[0-9]\+\).*|\1|' <<<${pkgver}) # eg: 6.1
  28. _upstream_minor_ver=${_minor_ver}-gnu # eg: 6.1-gnu
  29. _upstream_ver=${pkgver}-gnu # eg: 6.1.5-gnu
  30. _is_patch_release=$( [[ ${_upstream_minor_ver} != ${_upstream_ver} ]] ; echo $((!$?)) ; )
  31. pkgrel=2
  32. pkgdesc="Linux-libre (pristine upstream release)"
  33. url=https://linux-libre.fsfla.org/
  34. arch=(armv7h i686 x86_64)
  35. license=(GPL2)
  36. makedepends=(
  37. bc
  38. cpio
  39. gettext
  40. libelf
  41. pahole
  42. perl
  43. python
  44. tar
  45. xz
  46. # htmldocs
  47. graphviz
  48. imagemagick
  49. python-sphinx
  50. python-yaml
  51. texlive-latexextra
  52. )
  53. makedepends_armv7h=(uboot-tools vboot-utils dtc) # required by linux-libre-chromebook
  54. makedepends_armv7h+=(kmod ) # explicit `depmod`
  55. options=(
  56. !debug
  57. !strip
  58. )
  59. _srcname=linux-${_minor_ver}
  60. source=(https://linux-libre.fsfla.org/pub/linux-libre/releases/${_upstream_minor_ver}/linux-libre-${_upstream_minor_ver}.tar.xz{,.sign}
  61. https://repo.parabola.nu/other/linux-libre/logos/logo_linux_{clut224.ppm,vga16.ppm,mono.pbm}{,.sig})
  62. (( _is_patch_release )) && source+=(https://linux-libre.fsfla.org/pub/linux-libre/releases/${_upstream_ver}/patch-${_upstream_minor_ver}-${_upstream_ver}.xz{,.sign})
  63. source_armv7h=(config.armv7h
  64. 'kernel.its'
  65. 'kernel.keyblock'
  66. 'kernel_data_key.vbprivk'
  67. linux-libre-vanilla-armv7h.preset)
  68. source_i686=(config.i686
  69. no-ultra-zstd.patch)
  70. source_x86_64=(config.x86_64)
  71. sha512sums=('941743bc1fb3f139b4cf2be085f8f49ed52f86dc1c1c6f67be7812c1cc008f57b97dc37caad8259f9576f4ae9480b970b8e00b30a0831360a2227634a3e1789f'
  72. 'SKIP'
  73. '13cb5bc42542e7b8bb104d5f68253f6609e463b6799800418af33eb0272cc269aaa36163c3e6f0aacbdaaa1d05e2827a4a7c4a08a029238439ed08b89c564bb3'
  74. 'SKIP'
  75. '7a3716bfe3b9f546da309c7492f3e08f8f506813afeb1c737a474c83313d5c313cf4582b65215c2cfce3b74d9d1021c96e8badafe8f6e5b01fe28d2b5c61ae78'
  76. 'SKIP'
  77. '267295aa0cea65684968420c68b32f1a66a22d018b9d2b2c1ef14267bcf4cb68aaf7099d073cbfefe6c25c8608bdcbbd45f7ac8893fdcecbf1e621abdfe9ecc1'
  78. 'SKIP')
  79. (( _is_patch_release )) && sha512sums+=('c024f3678ccb4839435799042e1496e21099666e99856454701e2ea37a77402af219404ae8ad761d1ea805aa5fe484fbccffa71953f9b9e8a4264ca64a9ca649'
  80. 'SKIP')
  81. sha512sums_armv7h=('725c453abb9f8b42148d4dd8d4cf53a6b6512d5fda35aa15bfa998a819e539e19d649e080ff2c0f4a6e00d29ae62ef2868c56cbb42c3d1f720319a513595659d'
  82. 'f10af02f0cb2d31259d9633e1ba845f555f525789f750fc2ddc51bd18c5ff64fcdd242dae801623887f5ce5cdb5528bce890459f0fab9fd31a28868bb7f6bba5'
  83. 'bb6718984a7357c9b00c37e4788480e5b8b75018c172ecc1441bc3fc5d2d42444eb5d8c7f9d2e3a7d6fed6d03acb565e3c0559486e494c40a7fe6bd0570c9ede'
  84. '143dea30c6da00e504c99984a98a0eb2411f558fcdd9dfa7f607d6c14e9e7dffff9cb00121d9317044b07e3e210808286598c785ee854084b993ec9cb14d8232'
  85. 'f01e7925b262d2874a8a991b1f27d057356a2a384d2012b61be5a631d4e4d7cf87461c8fb9e7f183831f5a829ad204897f1f0545a52df6288a0e04a5c2e31b96')
  86. sha512sums_i686=('50d3529a9a279a880c07a4bb6f46374b1fb260861b776ab5791136c176ae1f0a24c4b0c8837f06000317017d21cb46ca307b1ee0644385cc200be96a79723ae6'
  87. 'bca15cc96f64c38adcd13a46752866b5b30555ac21e19b3f7afcd20fcb7ec585c9d990fe8f842f44d5f69d477d72867fe6a9102729f26f93f5a80b372e41ce85')
  88. sha512sums_x86_64=('a5ba89d6f95d5d18462303cafd751bb9c96fb4266c58afbd60df1eb3deb8be8fa7f6e5d3b48cda4a750b88751b078d783f9cf101af6d449d9d4dbe238efa2d59')
  89. validpgpkeys=('474402C8C582DAFBE389C427BCB7CF877E7D47A7' # Alexandre Oliva
  90. '6DB9C4B4F0D8C0DC432CF6E4227CA7C556B2BA78') # David P.
  91. # reproducibility
  92. export KBUILD_BUILD_HOST=parabola
  93. export KBUILD_BUILD_USER=$pkgbase
  94. export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
  95. # per-arch KARCH
  96. case "$CARCH" in
  97. i686|x86_64) KARCH=x86;;
  98. armv7h) KARCH=arm;;
  99. esac
  100. # per-arch dependency tweaks
  101. _BUILD_DOCS=$( [[ "$CARCH" =~ ^(i686)$ ]] && echo 0 || echo 1)
  102. _BUILD_BPFTOOL=$([[ "$CARCH" =~ ^(armv7h|i686)$ ]] && echo 0 || echo 1)
  103. if ! (( _BUILD_DOCS )); then
  104. # temporarily disabled documentation due to sphinx_rtd_theme (FS32#163)
  105. # FIXME: sphinx-build returned an error at ./scripts/sphinx-pre-install line 317.
  106. makedepends=( ${makedepends[*]/graphviz/} )
  107. makedepends=( ${makedepends[*]/imagemagick/} )
  108. makedepends=( ${makedepends[*]/python-sphinx/} )
  109. makedepends=( ${makedepends[*]/python-yaml/} )
  110. makedepends=( ${makedepends[*]/texlive-latexextra/} )
  111. fi
  112. if ! (( _BUILD_BPFTOOL )); then
  113. # Also avoid building/running bpftool
  114. makedepends=( ${makedepends[*]/pahole/} )
  115. fi
  116. prepare() {
  117. cd $_srcname
  118. # upstream patch release
  119. if [ "${_minor_ver}" != "$pkgver" ]; then
  120. echo "Applying upstream patch release"
  121. patch -Np1 < "../patch-${_minor_ver}-gnu-${pkgver}-gnu"
  122. fi
  123. # freedo boot logo
  124. install -m644 -t drivers/video/logo ../logo_linux_{clut224.ppm,vga16.ppm,mono.pbm}
  125. echo "Setting version..."
  126. echo "-$pkgrel" > localversion.10-pkgrel
  127. echo "${pkgbase#linux}" > localversion.20-pkgname
  128. sed -i 's|^-libre||' localversion.20-pkgname # minimize diff
  129. local src
  130. declare -n per_arch_source=source_${CARCH} # minimize diff
  131. source+=( "${per_arch_source[@]}" ) # minimize diff
  132. for src in "${source[@]}"; do
  133. src="${src%%::*}"
  134. src="${src##*/}"
  135. # *.zst n/a - linux-libre patches are compressed only once
  136. [[ $src = *.patch ]] || continue
  137. echo "Applying patch $src..."
  138. patch -Np1 < "../$src"
  139. done
  140. echo "Setting config..."
  141. mv ../config{.$CARCH,} # minimize diff
  142. cp ../config .config
  143. make olddefconfig
  144. diff -u ../config .config || :
  145. if [ "$CARCH" = "armv7h" ]; then
  146. # don't run depmod on 'make install'. We'll do this ourselves in packaging
  147. sed -i '2iexit 0' scripts/depmod.sh
  148. fi
  149. make -s kernelrelease > version
  150. echo "Prepared $pkgbase version $(<version)"
  151. }
  152. build() {
  153. cd $_srcname
  154. make all
  155. # Also avoid building/running bpftool
  156. if (( _BUILD_BPFTOOL )); then
  157. make -C tools/bpf/bpftool vmlinux.h feature-clang-bpf-co-re=1
  158. fi
  159. # temporarily disabled documentation due to sphinx_rtd_theme (FS32#163)
  160. if (( _BUILD_DOCS )); then
  161. make htmldocs
  162. fi
  163. }
  164. _package() {
  165. pkgdesc="The $pkgdesc kernel and modules"
  166. license=(
  167. 'Apache-2.0 OR MIT'
  168. 'BSD-2-Clause OR GPL-2.0-or-later'
  169. BSD-3-Clause
  170. 'BSD-3-Clause OR GPL-2.0-only'
  171. 'BSD-3-Clause OR GPL-2.0-or-later'
  172. BSD-3-Clause-Clear
  173. GPL-1.0-or-later
  174. 'GPL-1.0-or-later OR BSD-3-Clause'
  175. GPL-2.0-only
  176. 'GPL-2.0-only OR Apache-2.0'
  177. 'GPL-2.0-only OR BSD-2-Clause'
  178. 'GPL-2.0-only OR BSD-3-Clause'
  179. 'GPL-2.0-only OR CDDL-1.0'
  180. 'GPL-2.0-only OR Linux-OpenIB'
  181. 'GPL-2.0-only OR MIT'
  182. 'GPL-2.0-only OR MPL-1.1'
  183. 'GPL-2.0-only OR X11'
  184. 'GPL-2.0-only WITH Linux-syscall-note'
  185. GPL-2.0-or-later
  186. 'GPL-2.0-or-later OR BSD-2-Clause'
  187. 'GPL-2.0-or-later OR BSD-3-Clause'
  188. 'GPL-2.0-or-later OR MIT'
  189. 'GPL-2.0-or-later OR X11'
  190. 'GPL-2.0-or-later WITH GCC-exception-2.0'
  191. ISC
  192. LGPL-2.0-or-later
  193. 'LGPL-2.1-only'
  194. 'LGPL-2.1-only OR BSD-2-Clause'
  195. LGPL-2.1-or-later
  196. MIT
  197. MPL-1.1
  198. X11
  199. Zlib
  200. )
  201. depends=(
  202. coreutils
  203. initramfs
  204. kmod
  205. )
  206. optdepends=(
  207. 'wireless-regdb: to set the correct wireless channels of your country'
  208. 'linux-firmware: firmware images needed for some devices'
  209. )
  210. optdepends=( "${optdepends[@]/linux/linux-libre}" ) # minimize diff
  211. provides=(
  212. # KSMBD-MODULE # no parabola package requires this
  213. # VIRTUALBOX-GUEST-MODULES # no parabola package requires this
  214. # WIREGUARD-MODULE # no parabola package requires this
  215. )
  216. provides+=("linux-libre=${pkgver}")
  217. replaces=(
  218. # virtualbox-guest-modules-arch # no such parabola package since 2021
  219. # wireguard-arch # no such parabola package since 2020
  220. )
  221. backup=("etc/mkinitcpio.d/${pkgbase}.preset")
  222. if [[ "$CARCH" == armv7h ]] ; then install=${pkgname}-armv7h.install ; fi ; # BR #3520
  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}-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-headers=${pkgver}")
  337. cd $_srcname
  338. local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
  339. echo "Installing build files..."
  340. (( _BUILD_BPFTOOL )) || touch tools/bpf/bpftool/vmlinux.h
  341. install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
  342. localversion.* version vmlinux tools/bpf/bpftool/vmlinux.h
  343. install -Dt "$builddir/kernel" -m644 kernel/Makefile
  344. install -Dt "$builddir/arch/$KARCH" -m644 arch/$KARCH/Makefile
  345. (( _BUILD_BPFTOOL )) || rm "$builddir"/vmlinux.h
  346. if [ "$CARCH" = "i686" ]; then
  347. install -Dt "$builddir/arch/$KARCH" -m644 arch/$KARCH/Makefile_32.cpu
  348. fi
  349. cp -t "$builddir" -a scripts
  350. # required when STACK_VALIDATION is enabled
  351. if [[ -e tools/objtool/objtool ]]; then
  352. install -Dt "$builddir/tools/objtool" tools/objtool/objtool
  353. fi
  354. # required when DEBUG_INFO_BTF_MODULES is enabled
  355. if [[ -e tools/bpf/resolve_btfids/resolve_btfids ]]; then
  356. install -Dt "$builddir/tools/bpf/resolve_btfids" tools/bpf/resolve_btfids/resolve_btfids
  357. fi
  358. echo "Installing headers..."
  359. cp -t "$builddir" -a include
  360. cp -t "$builddir/arch/$KARCH" -a arch/$KARCH/include
  361. install -Dt "$builddir/arch/$KARCH/kernel" -m644 arch/$KARCH/kernel/asm-offsets.s
  362. # ARM-specific headers
  363. if [ "$CARCH" = "armv7h" ]; then
  364. local _builddir="${builddir}" # minimize diff
  365. cp -t "${_builddir}/arch/${KARCH}" -a arch/${KARCH}/include
  366. fi
  367. install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
  368. install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
  369. # https://bugs.archlinux.org/task/13146
  370. install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
  371. # https://bugs.archlinux.org/task/20402
  372. install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
  373. install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
  374. install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
  375. # https://bugs.archlinux.org/task/71392
  376. install -Dt "$builddir/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h
  377. echo "Installing KConfig files..."
  378. find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
  379. echo "Removing unneeded architectures..."
  380. local arch
  381. for arch in "$builddir"/arch/*/; do
  382. [[ $arch = */$KARCH/ ]] && continue
  383. echo "Removing $(basename "$arch")"
  384. rm -r "$arch"
  385. done
  386. echo "Removing documentation..."
  387. rm -r "$builddir/Documentation"
  388. echo "Removing broken symlinks..."
  389. find -L "$builddir" -type l -printf 'Removing %P\n' -delete
  390. echo "Removing loose objects..."
  391. find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
  392. echo "Stripping build tools..."
  393. local file
  394. while read -rd '' file; do
  395. case "$(file -Sib "$file")" in
  396. application/x-sharedlib\;*) # Libraries (.so)
  397. strip -v $STRIP_SHARED "$file" ;;
  398. application/x-archive\;*) # Libraries (.a)
  399. strip -v $STRIP_STATIC "$file" ;;
  400. application/x-executable\;*) # Binaries
  401. strip -v $STRIP_BINARIES "$file" ;;
  402. application/x-pie-executable\;*) # Relocatable binaries
  403. strip -v $STRIP_SHARED "$file" ;;
  404. esac
  405. done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
  406. echo "Stripping vmlinux..."
  407. strip -v $STRIP_STATIC "$builddir/vmlinux"
  408. echo "Adding symlink..."
  409. mkdir -p "$pkgdir/usr/src"
  410. ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
  411. # licenses
  412. install -vDm 644 LICENSES/deprecated/{ISC,Linux-OpenIB,X11,Zlib} -t "$pkgdir/usr/share/licenses/$pkgname/"
  413. install -vDm 644 LICENSES/preferred/{BSD*,MIT} -t "$pkgdir/usr/share/licenses/$pkgname/"
  414. install -vDm 644 LICENSES/exceptions/* -t "$pkgdir/usr/share/licenses/$pkgname/"
  415. }
  416. _package-docs() {
  417. pkgdesc="Documentation for the $pkgdesc kernel"
  418. license=(
  419. BSD-3-Clause
  420. GFDL-1.1-no-invariants-or-later
  421. GPL-2.0-only
  422. 'GPL-2.0-only OR BSD-2-Clause'
  423. 'GPL-2.0-only OR BSD-3-Clause'
  424. 'GPL-2.0-only OR GFDL-1.1-no-invariants-or-later'
  425. 'GPL-2.0-only OR GFDL-1.2-no-invariants-only'
  426. 'GPL-2.0-only OR MIT'
  427. GPL-2.0-or-later
  428. 'GPL-2.0-or-later OR BSD-2-Clause'
  429. 'GPL-2.0-or-later OR CC-BY-4.0'
  430. 'GPL-2.0-or-later OR MIT'
  431. 'GPL-2.0-or-later OR X11'
  432. 'LGPL-2.1-only OR BSD-2-Clause'
  433. MIT
  434. )
  435. provides=("linux-libre-docs=${pkgver}")
  436. cd $_srcname
  437. local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
  438. echo "Installing documentation..."
  439. local src dst
  440. while read -rd '' src; do
  441. dst="${src#Documentation/}"
  442. dst="$builddir/Documentation/${dst#output/}"
  443. install -Dm644 "$src" "$dst"
  444. done < <(find Documentation -name '.*' -prune -o ! -type d -print0)
  445. echo "Adding symlink..."
  446. mkdir -p "$pkgdir/usr/share/doc"
  447. ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
  448. # licenses
  449. install -vDm 644 LICENSES/deprecated/X11 -t "$pkgdir/usr/share/licenses/$pkgname/"
  450. install -vDm 644 LICENSES/preferred/{BSD*,MIT} -t "$pkgdir/usr/share/licenses/$pkgname/"
  451. }
  452. _package-chromebook() {
  453. pkgdesc="$pkgdesc kernel sign for Veyron Chromebooks"
  454. depends=("${pkgbase}=${pkgver}")
  455. provides=("linux-libre=${pkgver}")
  456. replaces=("linux-libre-armv7-chromebook")
  457. install=${pkgname}.install
  458. cd $_srcname
  459. cp ../kernel.its .
  460. mkimage -D "-I dts -O dtb -p 2048" -f kernel.its vmlinux.uimg
  461. dd if=/dev/zero of=bootloader.bin bs=512 count=1
  462. echo 'console=tty0 init=/sbin/init root=PARTUUID=%U/PARTNROFF=1 rootwait rw noinitrd' > cmdline
  463. echo "Creating kernel sign..."
  464. vbutil_kernel \
  465. --pack vmlinux.kpart \
  466. --version 1 \
  467. --vmlinuz vmlinux.uimg \
  468. --arch arm \
  469. --keyblock ../kernel.keyblock \
  470. --signprivate ../kernel_data_key.vbprivk \
  471. --config cmdline \
  472. --bootloader bootloader.bin
  473. echo "Installing kernel sign..."
  474. mkdir -p "${pkgdir}/boot"
  475. cp vmlinux.kpart "${pkgdir}/boot"
  476. }
  477. pkgname=(
  478. "$pkgbase"
  479. "$pkgbase-headers"
  480. "$pkgbase-docs"
  481. )
  482. [ "$CARCH" = "armv7h" ] && pkgname+=("$pkgbase-chromebook")
  483. for _p in "${pkgname[@]}"; do
  484. eval "package_$_p() {
  485. $(declare -f "_package${_p#$pkgbase}")
  486. _package${_p#$pkgbase}
  487. }"
  488. done
  489. (( _BUILD_DOCS )) || pkgname=( ${pkgname[*]/$pkgbase-docs/} )
  490. # FIXME: `mkimage kernel.signed` command fails in _package-chromebook()
  491. # FATAL ERROR: Couldn't open "arch/arm/boot/dts/exynos5250-snow.dtb": No such file or directory
  492. # mkimage: Can't open vmlinux.uimg.tmp: No such file or directory
  493. [[ "$CARCH" == armv7h ]] && pkgname=( ${pkgname[*]/$pkgbase-chromebook/} ) || :