PKGBUILD 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. # Maintainers: Parabola hackers <dev@lists.parabola.nu>
  2. # Rationale: This package enables to run 64bit kernels with 32bit rootfs.
  3. #
  4. # For armv7k/aarch64, we have no aarch64 port yet, and the 32bit
  5. # kernels don't work for 64bit computers (for instance the dtb for
  6. # 64bit computers are not shipped).
  7. #
  8. # In turn if we can boot Parabola on these computers, it enables
  9. # people to work on an aarch64 port more easily as chrooting in 64bit
  10. # rootfs from 32bit rootfs work when we have a 64bit kernel (tested on
  11. # an x86_64 computer with a Parabola i686 rootfs and a Parabola x86_64
  12. # chroot).
  13. #
  14. # This enable to make rootfs that work on both 64bit and 32bit
  15. # computers. In that case the user will still need to select the right
  16. # kernel at boot.
  17. #
  18. # Generally speaking it also enable users to benefit from many of the
  19. # improvements of 64bit kernels (ability to chroot in 64bit rootfs,
  20. # better security, 4GiB address space per process instead of 3GiB for
  21. # 32bit rootfs, etc) without having to reinstall everything. In
  22. # addition, there was and is still no conversion guide to convert a
  23. # 32bit Parabola installation to 64bit), and in some cases (lot of
  24. # self-built software in /usr/local, PostgreSQL database, etc) the
  25. # migration to 64bit requires some work.
  26. #
  27. # As for using i686 for new installation on x86_64 computers, it can
  28. # enable people doing that to find and fix bugs on Parabola i686 to
  29. # enable people with 32bit-only computers (like Libreboot compatible
  30. # I945 Thinkpads) to still be able to use Parabola.
  31. #
  32. # Having both architectures (arm and x86) in the same PKGBUILD enables
  33. # to more widely test this package (if we find issues on x86, they'll
  34. # most likely apply to arm as well). Though it can become a problem if
  35. # we need different kernel versions for both architectures.
  36. #
  37. # Status:
  38. # - Tested on both arm and x86.
  39. # - The build is currently broken on ARM due to a missing cross
  40. # compiler for armv7h (it was accidentally removed and it doesn't
  41. # build anymore).
  42. # - External modules (like Wireguard or tp_smapi) also need to be
  43. # cross compiled. So modules for linux-libre-64 need to be added
  44. # (like tp_smapi-64) and dkms packages need to be adapted to also
  45. # work for this kernel.
  46. # - Some software (like building Guix) break with 32bit rootfs and
  47. # 64bit kernels due to wrong assumption about the number of bits,
  48. # through other software (like building rust with mrustc) work
  49. # better (here because we have 3GiB instead of 3GiB of memory per
  50. # process). Most software is not affected though.
  51. # Based on the linux-libre package
  52. _replacesarchkernel=('linux%') # '%' gets replaced with kernel suffix
  53. _replacesoldkernels=() # '%' gets replaced with kernel suffix
  54. _replacesoldmodules=() # '%' gets replaced with kernel suffix
  55. pkgbase=linux-libre-64
  56. pkgver=5.15.12
  57. pkgrel=1
  58. pkgdesc="64bit Linux-libre for Parabola $CARCH"
  59. rcnver=5.11.11
  60. rcnrel=armv7-x14
  61. url='https://linux-libre.fsfla.org/'
  62. arch=(armv7h i686)
  63. license=(GPL2)
  64. conflicts_armv7h=('linux-libre-aarch64')
  65. replaces_armv7h=('linux-libre-aarch64')
  66. conflicts_i686=('linux-libre-x86_64')
  67. replaces_i686=('linux-libre-x86_64')
  68. makedepends=(
  69. bc kmod libelf pahole cpio perl tar xz
  70. xmlto python-sphinx python-sphinx_rtd_theme graphviz imagemagick
  71. )
  72. makedepends_i686+=('x86_64-pc-linux-gnu-gcc')
  73. makedepends_armv7h=(uboot-tools vboot-utils dtc) # required by linux-libre-chromebook
  74. makedepends_armv7h+=('aarch64-linux-gnu-gcc-initial')
  75. options=('!strip')
  76. _srcname=linux-5.15
  77. source=(
  78. "https://linux-libre.fsfla.org/pub/linux-libre/releases/${_srcname##*-}-gnu/linux-libre-${_srcname##*-}-gnu.tar.xz"{,.sign}
  79. "https://linux-libre.fsfla.org/pub/linux-libre/releases/$pkgver-gnu/patch-${_srcname##*-}-gnu-$pkgver-gnu.xz"{,.sign}
  80. "https://repo.parabola.nu/other/linux-libre/logos/logo_linux_"{clut224.ppm,vga16.ppm,mono.pbm}{,.sig}
  81. config.i686 config.x86_64 config.armv7h # the main kernel config files
  82. linux-armv7h.preset # armv7h preset file for mkinitcpio ramdisk
  83. "kernel"{.its,.keyblock,_data_key.vbprivk} # files for signing Chromebooks kernels
  84. # maintain the TTY over USB disconnects
  85. # http://www.coreboot.org/EHCI_Gadget_Debug
  86. 0001-usb-serial-gadget-no-TTY-hangup-on-USB-disconnect-WI.patch
  87. # fix Atmel maXTouch touchscreen support
  88. # https://labs.parabola.nu/issues/877
  89. # http://www.fsfla.org/pipermail/linux-libre/2015-November/003202.html
  90. 0002-fix-Atmel-maXTouch-touchscreen-support.patch
  91. # Arch Linux patches
  92. 0001-ZEN-Add-sysctl-and-CONFIG-to-disallow-unprivileged-C.patch
  93. 0002-PCI-Add-more-NVIDIA-controllers-to-the-MSI-masking-q.patch
  94. 0003-iommu-intel-do-deep-dma-unmapping-to-avoid-kernel-fl.patch
  95. 0004-cpufreq-intel_pstate-ITMT-support-for-overclocked-sy.patch
  96. 0005-Bluetooth-btintel-Fix-bdaddress-comparison-with-garb.patch
  97. 0006-lg-laptop-Recognize-more-models.patch
  98. )
  99. source_i686=(
  100. # avoid using zstd compression in ultra mode (exhausts virtual memory)
  101. no-ultra-zstd.patch
  102. )
  103. source_armv7h=(
  104. # RCN patch (CM3 firmware deblobbed and bloatware removed)
  105. "https://repo.parabola.nu/other/rcn-libre/patches/$rcnver/rcn-libre-$rcnver-$rcnrel.patch"{,.sig}
  106. # Arch Linux ARM patches
  107. 0001-ARM-atags-add-support-for-Marvell-s-u-boot.patch
  108. 0002-ARM-atags-fdt-retrieve-MAC-addresses-from-Marvell-bo.patch
  109. 0003-SMILE-Plug-device-tree-file.patch
  110. 0004-fix-mvsdio-eMMC-timing.patch
  111. 0005-net-smsc95xx-Allow-mac-address-to-be-set-as-a-parame.patch
  112. 0006-set-default-cubietruck-led-triggers.patch
  113. 0007-exynos4412-odroid-set-higher-minimum-buck2-regulator.patch
  114. 0008-ARM-dove-enable-ethernet-on-D3Plug.patch
  115. 0009-USB-Armory-MkII-support.patch
  116. # ChromiumOS patches
  117. 0001-CHROMIUM-block-partitions-efi-Add-support-for-IGNORE.patch
  118. )
  119. source_armv7h+=(config.aarch64)
  120. validpgpkeys=(
  121. '474402C8C582DAFBE389C427BCB7CF877E7D47A7' # Alexandre Oliva
  122. '6DB9C4B4F0D8C0DC432CF6E4227CA7C556B2BA78' # David P.
  123. )
  124. sha512sums=('3c586054285ea0cb4d1a1ff257757d092db80c2413dcec6e58c63b22490d42b8f2c441cee62839603599d5ad75fbd7560bf51ec6c2f3ab9354adae0c2c7234e5'
  125. 'SKIP'
  126. '80a0d8903c6ee462f966e3360d22f4894dc69239c99ef28d62a1ea6643008580a368b61cee5e6691f2bbf0ff162fb10e13ca31904ab89a5e679f91ae9860999b'
  127. 'SKIP'
  128. '13cb5bc42542e7b8bb104d5f68253f6609e463b6799800418af33eb0272cc269aaa36163c3e6f0aacbdaaa1d05e2827a4a7c4a08a029238439ed08b89c564bb3'
  129. 'SKIP'
  130. '7a3716bfe3b9f546da309c7492f3e08f8f506813afeb1c737a474c83313d5c313cf4582b65215c2cfce3b74d9d1021c96e8badafe8f6e5b01fe28d2b5c61ae78'
  131. 'SKIP'
  132. '267295aa0cea65684968420c68b32f1a66a22d018b9d2b2c1ef14267bcf4cb68aaf7099d073cbfefe6c25c8608bdcbbd45f7ac8893fdcecbf1e621abdfe9ecc1'
  133. 'SKIP'
  134. '4d20c1d0eed64bc64ac04e41e10288259212e00bc0967887e20e5ae277735d3a036c0a5ded08276455d2748af5787ebcf910329491eb43e84c204d6a9d76065f'
  135. '51de84caf459ba526afaf11ce9e4b697bc828edaf841c512ee0438ed14b7c3beaa269f95446eeb6b6a87f91b20d075b43dfea901b6aed8ef45a476bc5ac6a3b2'
  136. '51e8b4da770067e8257d292622d865cb16ac57fdfd8967bdfb74efec197dae9eab958e5637a728640ae60885bdde41c06c8076227a4f83db0b752215f91f3a87'
  137. '53103bf55b957b657039510527df0df01279dec59cda115a4d6454e4135025d4546167fa30bdc99107f232561c1e096d8328609ab5a876cf7017176f92ad3e0b'
  138. '167bc73c6c1c63931806238905dc44c7d87c5a5c0f6293159f2133dfe717fb44081018d810675716d1605ec7dff5e8333b87b19e09e2de21d0448e447437873b'
  139. 'bb6718984a7357c9b00c37e4788480e5b8b75018c172ecc1441bc3fc5d2d42444eb5d8c7f9d2e3a7d6fed6d03acb565e3c0559486e494c40a7fe6bd0570c9ede'
  140. '143dea30c6da00e504c99984a98a0eb2411f558fcdd9dfa7f607d6c14e9e7dffff9cb00121d9317044b07e3e210808286598c785ee854084b993ec9cb14d8232'
  141. '02af4dd2a007e41db0c63822c8ab3b80b5d25646af1906dc85d0ad9bb8bbf5236f8e381d7f91cf99ed4b0978c50aee37cb9567cdeef65b7ec3d91b882852b1af'
  142. 'b8fe56e14006ab866970ddbd501c054ae37186ddc065bb869cf7d18db8c0d455118d5bda3255fb66a0dde38b544655cfe9040ffe46e41d19830b47959b2fb168'
  143. '5ad31d899fa56b49efb6eec6d721e85e1b723f65c83a9aaec52c3281f1862c7b0ccf5ddac077af669aa222b4818c4ddbc64f39739fc2946c5ddab49101ba0924'
  144. 'c12a450a5026216676bd5728b43e04641d28a0eacd916e9304b6c38b03699005cf74ed8d3e4de67cab73f47cdaef728fdb1f75b3b1e5221cfc62c2a37e52ff67'
  145. '65f4ecc64551d3e644fb6e95ed70dcb694aedd58fc6bed694a912c6d89bfdfd2382d1f20c3b79c0a9e6f5c479efe7e950e47f88b10925ac71276e4cad94ab07e'
  146. '5b052dfc8f62ac2f86b1a08620109ec06154273a67ef011b18d38f7098b5b42026da2a8ba79a9234d10766bc00f740a2ce900552806a49937b7e33a35bca2809'
  147. '6f139510d047cf0f915daded5221ea4cf2551ebb50c7350965ba417b9b2d0df8796e0508d772cdc6d50cdc5b8c1d8589ace86d6e7a779ea2abed0013696396a3'
  148. 'e54423a3f0162f76cd211706c48f05f4fd96ea99453ca84821018947dd05b3d1bb943c8ba9e5ce190d237663136122601e7edfe50540fef24ab16c813c6a02e1')
  149. sha512sums_i686=('3a346ff5e0fdefafd28bc3dd0e4b6cd68e3f0014e59d1611d99f2edb8d074fd32649eeb0894a7e340e4f907b5cfc0e08e0753e0427a68dc113bb22835a892968')
  150. sha512sums_armv7h=('a4aa00ca3f03d524d3fb6379116c4e4e7908e7c30f6347f55be256c44d806d8db5f04c96369d5a725e45b7390e9fde842f388cdc5d5699d80ec5d1519f7367f4'
  151. 'SKIP'
  152. 'b832287560c841e292d71be01c65045ee2ee6ac41f05176ebe349d730b5b79887bb629d176d5fd16a3e7ebb5e51de30b6d6fad6fad53821063188248bd1415bb'
  153. 'f997a0afaaffb66533168f5d9cc341871eb54feb88d6ce578e816add82596bedf4dc242510e171e1e5b56464cf701384a32ed916176ea0c2db24209d754d3c58'
  154. '96b97f6e721d179d88e7b4084ebb62ce30ddd13cbbcb367147e6646c8487107af36b3610d10e53abffae3a83736cdd7734e5dbcadb1909ced278f40a20302861'
  155. '14f3ef9f2211e98198e96bd4f91978720acd703ee778698b85916cef73c1aea648d1d08a075f2ed334f5c27b9933274fa0651401e0baa3570f389a20aaec54e8'
  156. 'b464e9af459c37c929ba30cdb7eb575038e970c9d91ff98fa37c0bc6161538b42a802dde34882772cf665130038158cb985fe06d65313f7c584c6c63045199d8'
  157. '9d8019b8f525d5614d476ac34a35a40e8e1994f444a686b561c57b8ae488fcc44ffca9d034cea7b2271a2b7a7fa3a2ba2fcaa452504c320eff0bc3fc4de64ed2'
  158. 'b3cf13c44b8b35bb7610206161a251cbf90299b0533e8e23465b9ae566feed510c5722aceadb7e2097de439362d0689de5692a091cbe8bec2994ef5290622095'
  159. '463d68de99f434fd3409ee620eaa7b648d6627c5a04cfeab65b91053129e71bf906db817fd9770297ae1e38f8a5a84be4d20a1d1717e6821478f2c1bbc416cb2'
  160. '813fbfb17659e4e7512367f03b06f9bc54070886f5e7206548deced60032f92d3ca0beb78416706662bf713cb0f7a5d8d81f8f08b911ca8254b417e82306d829'
  161. '7bda2ad7eb81af802873cb6764cb9c675ec50ceeb5adc487881ebc8c316cf55f836e56c2cc67494a2920e86494861db2eb924b7ff9b151ae3c5b0e493c373bf9')
  162. sha512sums_armv7h+=('bc7b70863929737346fe6757373897391b43af36bb6884d5351a95aca0f9120f2d2cf9b9c2c6426a440c6b394e9fb334c280711d64081563322a834ecdfb2ba6')
  163. _replacesarchkernel=("${_replacesarchkernel[@]/\%/${pkgbase#linux-libre}}")
  164. _replacesoldkernels=("${_replacesoldkernels[@]/\%/${pkgbase#linux-libre}}")
  165. _replacesoldmodules=("${_replacesoldmodules[@]/\%/${pkgbase#linux-libre}}")
  166. case "$CARCH" in
  167. i686) KARCH=x86;CROSS_COMPILE=x86_64-pc-linux-gnu-;;
  168. armv7h) KARCH=arm64;CROSS_COMPILE=aarch64-linux-gnu-;;
  169. esac
  170. export STRIP=${CROSS_COMPILE}strip
  171. export KBUILD_BUILD_HOST=parabola
  172. export KBUILD_BUILD_USER=$pkgbase
  173. export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
  174. prepare() {
  175. cd $_srcname
  176. if [ "${_srcname##*-}" != "$pkgver" ]; then
  177. echo "Applying upstream patch..."
  178. patch -Np1 < "../patch-${_srcname##*-}-gnu-$pkgver-gnu"
  179. fi
  180. echo "Adding freedo as boot logo..."
  181. install -m644 -t drivers/video/logo \
  182. ../logo_linux_{clut224.ppm,vga16.ppm,mono.pbm}
  183. echo "Setting version..."
  184. scripts/setlocalversion --save-scmversion
  185. echo "-$pkgrel" > localversion.10-pkgrel
  186. echo "${pkgbase#linux-libre}" > localversion.20-pkgname
  187. if [ "$CARCH" = "armv7h" ]; then
  188. local src_armv7h
  189. for src_armv7h in "${source_armv7h[@]}"; do
  190. src_armv7h="${src_armv7h%%::*}"
  191. src_armv7h="${src_armv7h##*/}"
  192. [[ $src_armv7h = *.patch ]] || continue
  193. echo "Applying patch $src_armv7h..."
  194. patch -Np1 < "../$src_armv7h"
  195. done
  196. fi
  197. if [ "$CARCH" = "i686" ]; then
  198. local src_i686
  199. for src_i686 in "${source_i686[@]}"; do
  200. src_i686="${src_i686%%::*}"
  201. src_i686="${src_i686##*/}"
  202. [[ $src_i686 = *.patch ]] || continue
  203. echo "Applying patch $src_i686..."
  204. patch -Np1 < "../$src_i686"
  205. done
  206. fi
  207. local src
  208. for src in "${source[@]}"; do
  209. src="${src%%::*}"
  210. src="${src##*/}"
  211. [[ $src = *.patch ]] || continue
  212. echo "Applying patch $src..."
  213. patch -Np1 < "../$src"
  214. done
  215. echo "Setting config..."
  216. case "$CARCH" in
  217. i686) cp ../config.x86_64 .config;;
  218. # config.aarch64 comes straight from Arch Linux ARM and doesn't have the
  219. # compatibility for 32bit rootfs enabled. This makes maintenance faster than
  220. # having to modify the configuration file by hand at each new kernel release.
  221. armv7h) cp ../config.aarch64 .config;echo 'CONFIG_COMPAT=y' >> .config;;
  222. esac
  223. make ARCH=$KARCH CROSS_COMPILE=$CROSS_COMPILE olddefconfig
  224. make ARCH=$KARCH CROSS_COMPILE=$CROSS_COMPILE -s kernelrelease > version
  225. echo "Prepared $pkgbase version $(<version)"
  226. }
  227. build() {
  228. cd $_srcname
  229. make ARCH=$KARCH CROSS_COMPILE=$CROSS_COMPILE all
  230. make ARCH=$KARCH CROSS_COMPILE=$CROSS_COMPILE htmldocs
  231. }
  232. _package() {
  233. pkgdesc="The $pkgdesc kernel and modules"
  234. depends=(coreutils kmod initramfs)
  235. optdepends=('crda: to set the correct wireless channels of your country'
  236. 'linux-libre-firmware: firmware images needed for some devices')
  237. provides=(VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE)
  238. replaces=(virtualbox-guest-modules-arch wireguard-arch)
  239. provides+=("${_replacesarchkernel[@]/%/=$pkgver}" "LINUX-ABI_VERSION=$pkgver")
  240. conflicts+=("${_replacesarchkernel[@]}" "${_replacesoldkernels[@]}" "${_replacesoldmodules[@]}")
  241. replaces+=("${_replacesarchkernel[@]}" "${_replacesoldkernels[@]}" "${_replacesoldmodules[@]}")
  242. cd $_srcname
  243. local kernver="$(<version)"
  244. local modulesdir="$pkgdir/usr/lib/modules/$kernver"
  245. echo "Installing boot image..."
  246. # systemd expects to find the kernel here to allow hibernation
  247. # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
  248. # The default image target is Image.gz on arm64 but some u-boot
  249. # configurations and/or versions don't support that, so we use Image instead.
  250. if [ "$KARCH" = "arm64" ]; then
  251. install -Dm644 arch/$KARCH/boot/Image "$modulesdir/vmlinuz"
  252. else
  253. install -Dm644 "$(make ARCH=$KARCH CROSS_COMPILE=$CROSS_COMPILE -s image_name)" "$modulesdir/vmlinuz"
  254. fi
  255. # Used by mkinitcpio to name the kernel
  256. echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
  257. echo "Installing modules..."
  258. make ARCH=$KARCH CROSS_COMPILE=$CROSS_COMPILE INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 modules_install
  259. # remove build and source links
  260. rm "$modulesdir"/{source,build}
  261. if [ "$CARCH" = "armv7h" ]; then
  262. echo "Installing device tree binaries..."
  263. make ARCH=$KARCH CROSS_COMPILE=$CROSS_COMPILE INSTALL_DTBS_PATH="$pkgdir/boot/dtbs/$pkgbase" dtbs_install
  264. # armv7h presets only work with ALL_kver=$kernver
  265. backup=("etc/mkinitcpio.d/$pkgbase.preset")
  266. echo "Installing mkinitcpio preset..."
  267. sed "s|%PKGBASE%|$pkgbase|g;s|%KERNVER%|$kernver|g" ../linux-armv7h.preset \
  268. | install -Dm644 /dev/stdin "$pkgdir/etc/mkinitcpio.d/$pkgbase.preset"
  269. fi
  270. }
  271. _package-headers() {
  272. pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
  273. depends=(pahole)
  274. provides=("${_replacesarchkernel[@]/%/-headers=$pkgver}")
  275. conflicts=("${_replacesarchkernel[@]/%/-headers}" "${_replacesoldkernels[@]/%/-headers}")
  276. replaces=("${_replacesarchkernel[@]/%/-headers}" "${_replacesoldkernels[@]/%/-headers}")
  277. cd $_srcname
  278. local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
  279. echo "Installing build files..."
  280. install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
  281. localversion.* version vmlinux
  282. install -Dt "$builddir/kernel" -m644 kernel/Makefile
  283. install -Dt "$builddir/arch/$KARCH" -m644 arch/$KARCH/Makefile
  284. if [[ $CARCH = i686 ]]; then
  285. install -Dt "$builddir/arch/$KARCH" -m644 arch/$KARCH/Makefile_32.cpu
  286. fi
  287. cp -t "$builddir" -a scripts
  288. # add objtool for external module building and enabled VALIDATION_STACK option
  289. if [[ -e tools/objtool/objtool ]]; then
  290. install -Dt "$builddir/tools/objtool" tools/objtool/objtool
  291. fi
  292. # add xfs and shmem for aufs building
  293. mkdir -p "$builddir"/{fs/xfs,mm}
  294. echo "Installing headers..."
  295. cp -t "$builddir" -a include
  296. cp -t "$builddir/arch/$KARCH" -a arch/$KARCH/include
  297. install -Dt "$builddir/arch/$KARCH/kernel" -m644 arch/$KARCH/kernel/asm-offsets.s
  298. install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
  299. install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
  300. # https://bugs.archlinux.org/task/13146
  301. install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
  302. # https://bugs.archlinux.org/task/20402
  303. install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
  304. install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
  305. install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
  306. # https://bugs.archlinux.org/task/71392
  307. install -Dt "$builddir/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h
  308. echo "Installing KConfig files..."
  309. find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
  310. echo "Removing unneeded architectures..."
  311. local arch
  312. for arch in "$builddir"/arch/*/; do
  313. [[ $arch = */$KARCH/ ]] && continue
  314. echo "Removing $(basename "$arch")"
  315. rm -r "$arch"
  316. done
  317. echo "Removing documentation..."
  318. rm -r "$builddir/Documentation"
  319. echo "Removing broken symlinks..."
  320. find -L "$builddir" -type l -printf 'Removing %P\n' -delete
  321. echo "Removing loose objects..."
  322. find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
  323. echo "Stripping build tools..."
  324. local file
  325. while read -rd '' file; do
  326. case "$(file -bi "$file")" in
  327. application/x-sharedlib\;*) # Libraries (.so)
  328. ${STRIP} -v $STRIP_SHARED "$file" ;;
  329. application/x-archive\;*) # Libraries (.a)
  330. ${STRIP} -v $STRIP_STATIC "$file" ;;
  331. application/x-executable\;*) # Binaries
  332. ${STRIP} -v $STRIP_BINARIES "$file" ;;
  333. application/x-pie-executable\;*) # Relocatable binaries
  334. ${STRIP} -v $STRIP_SHARED "$file" ;;
  335. esac
  336. done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
  337. echo "Stripping vmlinux..."
  338. ${STRIP} -v $STRIP_STATIC "$builddir/vmlinux"
  339. echo "Adding symlink..."
  340. mkdir -p "$pkgdir/usr/src"
  341. ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
  342. }
  343. _package-docs() {
  344. pkgdesc="Documentation for the $pkgdesc kernel"
  345. provides=("${_replacesarchkernel[@]/%/-docs=$pkgver}")
  346. conflicts=("${_replacesarchkernel[@]/%/-docs}" "${_replacesoldkernels[@]/%/-docs}")
  347. replaces=("${_replacesarchkernel[@]/%/-docs}" "${_replacesoldkernels[@]/%/-docs}")
  348. cd $_srcname
  349. local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
  350. echo "Installing documentation..."
  351. local src dst
  352. while read -rd '' src; do
  353. dst="${src#Documentation/}"
  354. dst="$builddir/Documentation/${dst#output/}"
  355. install -Dm644 "$src" "$dst"
  356. done < <(find Documentation -name '.*' -prune -o ! -type d -print0)
  357. echo "Adding symlink..."
  358. mkdir -p "$pkgdir/usr/share/doc"
  359. ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
  360. }
  361. _package-chromebook() {
  362. pkgdesc="Experimental $pkgdesc kernel sign for Veyron Chromebooks"
  363. depends=(linux-libre-64=$pkgver)
  364. provides+=("linux-libre-chromebook=$pkgver")
  365. conflicts+=('linux-libre-chromebook')
  366. replaces+=('linux-libre-chromebook')
  367. install=linux-libre-chromebook.install
  368. cd $_srcname
  369. cp ../kernel.its .
  370. mkimage -D "-I dts -O dtb -p 2048" -f kernel.its kernel.signed
  371. dd if=/dev/zero of=bootloader.bin bs=512 count=1
  372. echo 'console=tty0 init=/sbin/init root=PARTUUID=%U/PARTNROFF=1 rootwait rw noinitrd' > cmdline
  373. echo "Creating kernel sign..."
  374. vbutil_kernel \
  375. --pack vmlinux.kpart \
  376. --version 1 \
  377. --vmlinuz kernel.signed \
  378. --arch aarch64 \
  379. --keyblock ../kernel.keyblock \
  380. --signprivate ../kernel_data_key.vbprivk \
  381. --config cmdline \
  382. --bootloader bootloader.bin
  383. echo "Installing kernel sign..."
  384. mkdir -p "$pkgdir/boot"
  385. cp vmlinux.kpart "$pkgdir/boot"
  386. }
  387. pkgname=("$pkgbase" "$pkgbase-headers" "$pkgbase-docs")
  388. # The chromebook package is disabled until the following error is fixed:
  389. # | ==> Starting package_linux-libre-64-chromebook()...
  390. # | FATAL ERROR: Couldn't open "arch/arm/boot/zImage": No such file or directory
  391. # | mkimage: Can't read kernel.signed.tmp: Invalid argument
  392. # [[ $CARCH = armv7h ]] && pkgname+=("$pkgbase-chromebook")
  393. for _p in "${pkgname[@]}"; do
  394. eval "package_$_p() {
  395. $(declare -f "_package${_p#$pkgbase}")
  396. _package${_p#$pkgbase}
  397. }"
  398. done
  399. # vim:set ts=8 sts=2 sw=2 et: