PKGBUILD 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  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 (arch32:linux): Andreas Baumann <mail@andreasbaumann.cc>
  13. # Maintainer (archarm:linux-armv7): Kevin Mihelich <kevin@archlinuxarm.org>
  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.12.1
  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{,-lts}-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=('5f4cdba1223d94058f9b07ad80a4c078f47a157eeaa77fb78ba50819285b37ccfda3c3211273f68548e5ded6250b8dc891c81c5fc95cd360d811c3e6c1457f92'
  72. 'SKIP'
  73. '13cb5bc42542e7b8bb104d5f68253f6609e463b6799800418af33eb0272cc269aaa36163c3e6f0aacbdaaa1d05e2827a4a7c4a08a029238439ed08b89c564bb3'
  74. 'SKIP'
  75. '7a3716bfe3b9f546da309c7492f3e08f8f506813afeb1c737a474c83313d5c313cf4582b65215c2cfce3b74d9d1021c96e8badafe8f6e5b01fe28d2b5c61ae78'
  76. 'SKIP'
  77. '267295aa0cea65684968420c68b32f1a66a22d018b9d2b2c1ef14267bcf4cb68aaf7099d073cbfefe6c25c8608bdcbbd45f7ac8893fdcecbf1e621abdfe9ecc1'
  78. 'SKIP')
  79. (( _is_patch_release )) && sha512sums+=('d2c9e33e2407e68703f302bd397ea05a02cbc7b4b129bd745b8e61c00ba1023729a08dec4466d7b09d39e29ee7e2fe04927c192cd46b5dd09a2bb87c602d5465'
  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. # Used by mkinitcpio to name the kernel
  230. echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
  231. echo "Installing modules..."
  232. ZSTD_CLEVEL=19 make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 \
  233. DEPMOD=/doesnt/exist modules_install # Suppress depmod
  234. # remove build link
  235. rm "$modulesdir"/build
  236. # licenses
  237. install -vDm 644 LICENSES/deprecated/{GPL-1.0,ISC,Linux-OpenIB,X11,Zlib} -t "$pkgdir/usr/share/licenses/$pkgname/"
  238. install -vDm 644 LICENSES/preferred/{BSD,MIT}* -t "$pkgdir/usr/share/licenses/$pkgname/"
  239. install -vDm 644 LICENSES/exceptions/* -t "$pkgdir/usr/share/licenses/$pkgname/"
  240. if [ "$CARCH" = "armv7h" ]; then
  241. echo "Installing device tree binaries..."
  242. make INSTALL_DTBS_PATH="${pkgdir}/boot/dtbs/${pkgbase}" dtbs_install
  243. fi
  244. if [ "$CARCH" = "armv7h" ]; then
  245. local _kernver="$(<version)" # minimize diff
  246. cp ../{${pkgbase}-armv7h,linux}.preset # minimize diff
  247. # now we call depmod...
  248. depmod -b "${pkgdir}/usr" -F System.map "${_kernver}"
  249. # sed expression for following substitutions
  250. local _subst="
  251. s|%PKGBASE%|${pkgbase}|g
  252. s|%KERNVER%|${_kernver}|g
  253. "
  254. echo "Installing mkinitcpio preset..."
  255. # install mkinitcpio preset file
  256. sed "${_subst}" ../linux.preset |
  257. install -Dm644 /dev/stdin "${pkgdir}/etc/mkinitcpio.d/${pkgbase}.preset"
  258. fi
  259. }
  260. _package-headers() {
  261. pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
  262. license=(
  263. BSD-3-Clause
  264. 'BSD-3-Clause OR GPL-2.0-only'
  265. GPL-1.0-or-later
  266. 'GPL-1.0-or-later WITH Linux-syscall-note'
  267. GPL-2.0-only
  268. 'GPL-2.0-only OR Apache-2.0'
  269. 'GPL-2.0-only OR BSD-2-Clause'
  270. 'GPL-2.0-only OR BSD-3-Clause'
  271. 'GPL-2.0-only OR CDDL-1.0'
  272. 'GPL-2.0-only OR Linux-OpenIB'
  273. 'GPL-2.0-only OR Linux-OpenIB OR BSD-2-Clause'
  274. 'GPL-2.0-only OR MIT'
  275. 'GPL-2.0-only OR MPL-1.1'
  276. 'GPL-2.0-only OR X11'
  277. 'GPL-2.0-only WITH Linux-syscall-note'
  278. '(GPL-2.0-only WITH Linux-syscall-note) AND MIT'
  279. '(GPL-2.0-only WITH Linux-syscall-note) OR BSD-2-Clause'
  280. '(GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause'
  281. '(GPL-2.0-only WITH Linux-syscall-note) OR CDDL-1.0'
  282. '(GPL-2.0-only WITH Linux-syscall-note) OR Linux-OpenIB'
  283. '(GPL-2.0-only WITH Linux-syscall-note) OR MIT'
  284. GPL-2.0-or-later
  285. 'GPL-2.0-or-later OR BSD-2-Clause'
  286. 'GPL-2.0-or-later OR BSD-3-Clause'
  287. 'GPL-2.0-or-later OR MIT'
  288. 'GPL-2.0-or-later WITH Linux-syscall-note'
  289. '(GPL-2.0-or-later WITH Linux-syscall-note) OR BSD-3-Clause'
  290. '(GPL-2.0-or-later WITH Linux-syscall-note) OR MIT'
  291. 'LGPL-2.0-or-later OR BSD-2-Clause'
  292. 'LGPL-2.0-or-later WITH Linux-syscall-note'
  293. ISC
  294. 'LGPL-2.0-or-later WITH Linux-syscall-note'
  295. 'LGPL-2.0-or-later OR BSD-2-Clause'
  296. LGPL-2.1-only
  297. 'LGPL-2.1-only OR BSD-2-Clause'
  298. 'LGPL-2.1-only OR MIT'
  299. 'LGPL-2.1-only WITH Linux-syscall-note'
  300. LGPL-2.1-or-later
  301. 'LGPL-2.1-or-later OR BSD-2-Clause'
  302. 'LGPL-2.1-or-later WITH Linux-syscall-note'
  303. MIT
  304. Zlib
  305. )
  306. depends=(pahole)
  307. provides=("linux-libre-headers=${pkgver}")
  308. cd $_srcname
  309. local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
  310. echo "Installing build files..."
  311. (( _BUILD_BPFTOOL )) || touch tools/bpf/bpftool/vmlinux.h
  312. install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
  313. localversion.* version vmlinux tools/bpf/bpftool/vmlinux.h
  314. install -Dt "$builddir/kernel" -m644 kernel/Makefile
  315. install -Dt "$builddir/arch/$KARCH" -m644 arch/$KARCH/Makefile
  316. (( _BUILD_BPFTOOL )) || rm "$builddir"/vmlinux.h
  317. if [ "$CARCH" = "i686" ]; then
  318. install -Dt "$builddir/arch/$KARCH" -m644 arch/$KARCH/Makefile_32.cpu
  319. fi
  320. cp -t "$builddir" -a scripts
  321. # required when STACK_VALIDATION is enabled
  322. if [[ -e tools/objtool/objtool ]]; then
  323. install -Dt "$builddir/tools/objtool" tools/objtool/objtool
  324. fi
  325. # required when DEBUG_INFO_BTF_MODULES is enabled
  326. if [[ -e tools/bpf/resolve_btfids/resolve_btfids ]]; then
  327. install -Dt "$builddir/tools/bpf/resolve_btfids" tools/bpf/resolve_btfids/resolve_btfids
  328. fi
  329. echo "Installing headers..."
  330. cp -t "$builddir" -a include
  331. cp -t "$builddir/arch/$KARCH" -a arch/$KARCH/include
  332. install -Dt "$builddir/arch/$KARCH/kernel" -m644 arch/$KARCH/kernel/asm-offsets.s
  333. # ARM-specific headers
  334. if [ "$CARCH" = "armv7h" ]; then
  335. local _builddir="${builddir}" # minimize diff
  336. cp -t "${_builddir}/arch/${KARCH}" -a arch/${KARCH}/include
  337. fi
  338. install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
  339. install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
  340. # https://bugs.archlinux.org/task/13146
  341. install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
  342. # https://bugs.archlinux.org/task/20402
  343. install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
  344. install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
  345. install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
  346. # https://bugs.archlinux.org/task/71392
  347. install -Dt "$builddir/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h
  348. echo "Installing KConfig files..."
  349. find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
  350. echo "Removing unneeded architectures..."
  351. local arch
  352. for arch in "$builddir"/arch/*/; do
  353. [[ $arch = */$KARCH/ ]] && continue
  354. echo "Removing $(basename "$arch")"
  355. rm -r "$arch"
  356. done
  357. echo "Removing documentation..."
  358. rm -r "$builddir/Documentation"
  359. echo "Removing broken symlinks..."
  360. find -L "$builddir" -type l -printf 'Removing %P\n' -delete
  361. echo "Removing loose objects..."
  362. find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
  363. echo "Stripping build tools..."
  364. local file
  365. while read -rd '' file; do
  366. case "$(file -Sib "$file")" in
  367. application/x-sharedlib\;*) # Libraries (.so)
  368. strip -v $STRIP_SHARED "$file" ;;
  369. application/x-archive\;*) # Libraries (.a)
  370. strip -v $STRIP_STATIC "$file" ;;
  371. application/x-executable\;*) # Binaries
  372. strip -v $STRIP_BINARIES "$file" ;;
  373. application/x-pie-executable\;*) # Relocatable binaries
  374. strip -v $STRIP_SHARED "$file" ;;
  375. esac
  376. done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
  377. echo "Stripping vmlinux..."
  378. strip -v $STRIP_STATIC "$builddir/vmlinux"
  379. echo "Adding symlink..."
  380. mkdir -p "$pkgdir/usr/src"
  381. ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
  382. # licenses
  383. install -vDm 644 LICENSES/deprecated/{ISC,Linux-OpenIB,X11,Zlib} -t "$pkgdir/usr/share/licenses/$pkgname/"
  384. install -vDm 644 LICENSES/preferred/{BSD*,MIT} -t "$pkgdir/usr/share/licenses/$pkgname/"
  385. install -vDm 644 LICENSES/exceptions/* -t "$pkgdir/usr/share/licenses/$pkgname/"
  386. }
  387. _package-docs() {
  388. pkgdesc="Documentation for the $pkgdesc kernel"
  389. license=(
  390. BSD-3-Clause
  391. GFDL-1.1-no-invariants-or-later
  392. GPL-2.0-only
  393. 'GPL-2.0-only OR BSD-2-Clause'
  394. 'GPL-2.0-only OR BSD-3-Clause'
  395. 'GPL-2.0-only OR GFDL-1.1-no-invariants-or-later'
  396. 'GPL-2.0-only OR GFDL-1.2-no-invariants-only'
  397. 'GPL-2.0-only OR MIT'
  398. GPL-2.0-or-later
  399. 'GPL-2.0-or-later OR BSD-2-Clause'
  400. 'GPL-2.0-or-later OR CC-BY-4.0'
  401. 'GPL-2.0-or-later OR MIT'
  402. 'GPL-2.0-or-later OR X11'
  403. 'LGPL-2.1-only OR BSD-2-Clause'
  404. MIT
  405. )
  406. provides=("linux-libre-docs=${pkgver}")
  407. cd $_srcname
  408. local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
  409. echo "Installing documentation..."
  410. local src dst
  411. while read -rd '' src; do
  412. dst="${src#Documentation/}"
  413. dst="$builddir/Documentation/${dst#output/}"
  414. install -Dm644 "$src" "$dst"
  415. done < <(find Documentation -name '.*' -prune -o ! -type d -print0)
  416. echo "Adding symlink..."
  417. mkdir -p "$pkgdir/usr/share/doc"
  418. ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
  419. # licenses
  420. install -vDm 644 LICENSES/deprecated/X11 -t "$pkgdir/usr/share/licenses/$pkgname/"
  421. install -vDm 644 LICENSES/preferred/{BSD*,MIT} -t "$pkgdir/usr/share/licenses/$pkgname/"
  422. }
  423. _package-chromebook() {
  424. pkgdesc="$pkgdesc kernel sign for Veyron Chromebooks"
  425. depends=("${pkgbase}=${pkgver}")
  426. provides=("linux-libre=${pkgver}")
  427. replaces=("linux-libre-armv7-chromebook")
  428. install=${pkgname}.install
  429. cd $_srcname
  430. cp ../kernel.its .
  431. mkimage -D "-I dts -O dtb -p 2048" -f kernel.its vmlinux.uimg
  432. dd if=/dev/zero of=bootloader.bin bs=512 count=1
  433. echo 'console=tty0 init=/sbin/init root=PARTUUID=%U/PARTNROFF=1 rootwait rw noinitrd' > cmdline
  434. echo "Creating kernel sign..."
  435. vbutil_kernel \
  436. --pack vmlinux.kpart \
  437. --version 1 \
  438. --vmlinuz vmlinux.uimg \
  439. --arch arm \
  440. --keyblock ../kernel.keyblock \
  441. --signprivate ../kernel_data_key.vbprivk \
  442. --config cmdline \
  443. --bootloader bootloader.bin
  444. echo "Installing kernel sign..."
  445. mkdir -p "${pkgdir}/boot"
  446. cp vmlinux.kpart "${pkgdir}/boot"
  447. }
  448. pkgname=(
  449. "$pkgbase"
  450. "$pkgbase-headers"
  451. "$pkgbase-docs"
  452. )
  453. [ "$CARCH" = "armv7h" ] && pkgname+=("$pkgbase-chromebook")
  454. for _p in "${pkgname[@]}"; do
  455. eval "package_$_p() {
  456. $(declare -f "_package${_p#$pkgbase}")
  457. _package${_p#$pkgbase}
  458. }"
  459. done
  460. (( _BUILD_DOCS )) || pkgname=( ${pkgname[*]/$pkgbase-docs/} )
  461. # FIXME: `mkimage kernel.signed` command fails in _package-chromebook()
  462. # FATAL ERROR: Couldn't open "arch/arm/boot/dts/exynos5250-snow.dtb": No such file or directory
  463. # mkimage: Can't open vmlinux.uimg.tmp: No such file or directory
  464. [[ "$CARCH" == armv7h ]] && pkgname=( ${pkgname[*]/$pkgbase-chromebook/} ) || :