PKGBUILD 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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. # Maintainers: Parabola hackers <dev@lists.parabola.nu>
  10. # Based on linux package
  11. _replacesarchkernel=('linux%') # '%' gets replaced with kernel suffix
  12. _replacesoldkernels=() # '%' gets replaced with kernel suffix
  13. _replacesoldmodules=() # '%' gets replaced with kernel suffix
  14. pkgbase=linux-next-tests
  15. pkgver=20220408
  16. pkgrel=1
  17. pkgdesc='Deblobbed linux-next for testing patches (for upstreaming work)'
  18. arch=(i686 x86_64 armv7h)
  19. license=(GPL2)
  20. makedepends=(
  21. bc libelf pahole cpio perl tar xz
  22. xmlto python-sphinx python-sphinx_rtd_theme graphviz imagemagick texlive-latexextra
  23. )
  24. makedepends=( ${makedepends[*]/git/} )
  25. options=('!strip')
  26. _srcname=linux-next
  27. source=(
  28. "git+https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git"
  29. config.i686 config.x86_64 config.armv7h # the main kernel config files
  30. linux-armv7h.preset # armv7h preset file for mkinitcpio ramdisk
  31. )
  32. sha512sums=('SKIP'
  33. 'b1f013835dcf521dcadb58ed22f271f7f01b3b15403924bd0076eb9ef4e8aa31f98b1b99d47ae726f8e981b3da44f1c484ce14e2030e31a67ad7c8eea55848d9'
  34. '5a955a795f9f49d8617897300d3d03c431b1a6fa2bc9ed4106606617e4f16b28f94906498b13c24fd5c186c76a685e5f877013093184ae80435e7b86f52e8755'
  35. '47d16ffc94510d4a8773146a46cfb35aca8cfdae38d17283334cd62d92de36250fbec90e9892357033398ecc7d970127b1a41b703a8372972422ca4af7c90c70'
  36. '53103bf55b957b657039510527df0df01279dec59cda115a4d6454e4135025d4546167fa30bdc99107f232561c1e096d8328609ab5a876cf7017176f92ad3e0b')
  37. _replacesarchkernel=("${_replacesarchkernel[@]/\%/${pkgbase#linux-libre}}")
  38. _replacesoldkernels=("${_replacesoldkernels[@]/\%/${pkgbase#linux-libre}}")
  39. _replacesoldmodules=("${_replacesoldmodules[@]/\%/${pkgbase#linux-libre}}")
  40. case "$CARCH" in
  41. i686|x86_64) KARCH=x86;;
  42. armv7h) KARCH=arm;;
  43. esac
  44. export KBUILD_BUILD_HOST=parabola
  45. export KBUILD_BUILD_USER=$pkgbase
  46. export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
  47. pkgver() {
  48. cd $_srcname
  49. git describe --tags | sed 's/^next-//'
  50. }
  51. mksource() {
  52. cd $_srcname
  53. # Here we don't use linux-libre but we still remove the nonfree
  54. # software found in the Linux kernel. This avoids legal issues and
  55. # make sure we stay FSDG compliant.
  56. # We do it this way to stay as close as possible to the upstream
  57. # kernel.
  58. # The list of files to remove has been taken from debian/copyright in the
  59. # Debian kernel git repository[1].
  60. # [1] https://salsa.debian.org/kernel-team/linux.git
  61. rm -f \
  62. Documentation/netlabel/draft-ietf-cipso-ipsecurity-01.txt \
  63. arch/powerpc/platforms/8xx/micropatch.c \
  64. drivers/media/usb/dvb-usb/af9005-script.h \
  65. drivers/media/i2c/vs6624.c \
  66. drivers/net/appletalk/cops* \
  67. drivers/video/fbdev/nvidia \
  68. drivers/video/fbdev/riva
  69. }
  70. prepare() {
  71. cd $_srcname
  72. echo "Setting version..."
  73. scripts/setlocalversion --save-scmversion
  74. echo "-$pkgrel" > localversion.10-pkgrel
  75. echo "${pkgbase#linux-libre}" > localversion.20-pkgname
  76. echo "Setting config..."
  77. cp ../../config.$CARCH .config
  78. make olddefconfig
  79. make -s kernelrelease > version
  80. echo "Prepared $pkgbase version $(<version)"
  81. }
  82. build() {
  83. cd $_srcname
  84. make all
  85. make htmldocs
  86. }
  87. _package() {
  88. pkgdesc="The $pkgdesc kernel and modules"
  89. depends=(coreutils kmod initramfs)
  90. optdepends=('wireless-regdb: to set the correct wireless channels of your country'
  91. 'linux-libre-firmware: firmware images needed for some devices')
  92. provides=(VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE)
  93. replaces=(virtualbox-guest-modules-arch wireguard-arch)
  94. provides+=("${_replacesarchkernel[@]/%/=$pkgver}" "LINUX-ABI_VERSION=$pkgver")
  95. conflicts+=("${_replacesarchkernel[@]}" "${_replacesoldkernels[@]}" "${_replacesoldmodules[@]}")
  96. replaces+=("${_replacesarchkernel[@]}" "${_replacesoldkernels[@]}" "${_replacesoldmodules[@]}")
  97. cd $_srcname
  98. local kernver="$(<version)"
  99. local modulesdir="$pkgdir/usr/lib/modules/$kernver"
  100. echo "Installing boot image..."
  101. # systemd expects to find the kernel here to allow hibernation
  102. # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
  103. install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"
  104. # Used by mkinitcpio to name the kernel
  105. echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
  106. echo "Installing modules..."
  107. make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 \
  108. DEPMOD=/doesnt/exist modules_install # Suppress depmod
  109. # remove build and source links
  110. rm "$modulesdir"/{source,build}
  111. if [ "$CARCH" = "armv7h" ]; then
  112. echo "Installing device tree binaries..."
  113. make INSTALL_DTBS_PATH="$pkgdir/boot/dtbs/$pkgbase" dtbs_install
  114. # armv7h presets only work with ALL_kver=$kernver
  115. backup=("etc/mkinitcpio.d/$pkgbase.preset")
  116. echo "Installing mkinitcpio preset..."
  117. sed "s|%PKGBASE%|$pkgbase|g;s|%KERNVER%|$kernver|g" ../../linux-armv7h.preset \
  118. | install -Dm644 /dev/stdin "$pkgdir/etc/mkinitcpio.d/$pkgbase.preset"
  119. fi
  120. }
  121. _package-headers() {
  122. pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
  123. depends=(pahole)
  124. provides=("${_replacesarchkernel[@]/%/-headers=$pkgver}")
  125. conflicts=("${_replacesarchkernel[@]/%/-headers}" "${_replacesoldkernels[@]/%/-headers}")
  126. replaces=("${_replacesarchkernel[@]/%/-headers}" "${_replacesoldkernels[@]/%/-headers}")
  127. cd $_srcname
  128. local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
  129. echo "Installing build files..."
  130. install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
  131. localversion.* version vmlinux
  132. install -Dt "$builddir/kernel" -m644 kernel/Makefile
  133. install -Dt "$builddir/arch/$KARCH" -m644 arch/$KARCH/Makefile
  134. if [[ $CARCH = i686 ]]; then
  135. install -Dt "$builddir/arch/$KARCH" -m644 arch/$KARCH/Makefile_32.cpu
  136. fi
  137. cp -t "$builddir" -a scripts
  138. # required when STACK_VALIDATION is enabled
  139. if [[ -e tools/objtool/objtool ]]; then
  140. install -Dt "$builddir/tools/objtool" tools/objtool/objtool
  141. fi
  142. # required when DEBUG_INFO_BTF_MODULES is enabled
  143. if [[ -e tools/bpf/resolve_btfids/resolve_btfids ]]; then
  144. install -Dt "$builddir/tools/bpf/resolve_btfids" tools/bpf/resolve_btfids/resolve_btfids
  145. fi
  146. echo "Installing headers..."
  147. cp -t "$builddir" -a include
  148. cp -t "$builddir/arch/$KARCH" -a arch/$KARCH/include
  149. install -Dt "$builddir/arch/$KARCH/kernel" -m644 arch/$KARCH/kernel/asm-offsets.s
  150. # from linux-armv7
  151. if [ "$CARCH" = "armv7h" ]; then
  152. for i in dove omap2; do
  153. mkdir -p "$builddir/arch/$KARCH/mach-$i"
  154. cp -t "$builddir/arch/$KARCH/mach-$i/" -a arch/$KARCH/mach-$i/include
  155. done
  156. for i in omap orion versatile; do
  157. mkdir -p "$builddir/arch/$KARCH/plat-$i"
  158. cp -t "$builddir/arch/$KARCH/plat-$i/" -a arch/$KARCH/plat-$i/include
  159. done
  160. fi
  161. install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
  162. install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
  163. # https://bugs.archlinux.org/task/13146
  164. install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
  165. # https://bugs.archlinux.org/task/20402
  166. install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
  167. install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
  168. install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
  169. # https://bugs.archlinux.org/task/71392
  170. install -Dt "$builddir/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h
  171. echo "Installing KConfig files..."
  172. find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
  173. echo "Removing unneeded architectures..."
  174. local arch
  175. for arch in "$builddir"/arch/*/; do
  176. [[ $arch = */$KARCH/ ]] && continue
  177. echo "Removing $(basename "$arch")"
  178. rm -r "$arch"
  179. done
  180. echo "Removing documentation..."
  181. rm -r "$builddir/Documentation"
  182. echo "Removing broken symlinks..."
  183. find -L "$builddir" -type l -printf 'Removing %P\n' -delete
  184. echo "Removing loose objects..."
  185. find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
  186. echo "Stripping build tools..."
  187. local file
  188. while read -rd '' file; do
  189. case "$(file -bi "$file")" in
  190. application/x-sharedlib\;*) # Libraries (.so)
  191. strip -v $STRIP_SHARED "$file" ;;
  192. application/x-archive\;*) # Libraries (.a)
  193. strip -v $STRIP_STATIC "$file" ;;
  194. application/x-executable\;*) # Binaries
  195. strip -v $STRIP_BINARIES "$file" ;;
  196. application/x-pie-executable\;*) # Relocatable binaries
  197. strip -v $STRIP_SHARED "$file" ;;
  198. esac
  199. done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
  200. echo "Stripping vmlinux..."
  201. strip -v $STRIP_STATIC "$builddir/vmlinux"
  202. echo "Adding symlink..."
  203. mkdir -p "$pkgdir/usr/src"
  204. ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
  205. }
  206. _package-docs() {
  207. pkgdesc="Documentation for the $pkgdesc kernel"
  208. provides=("${_replacesarchkernel[@]/%/-docs=$pkgver}")
  209. conflicts=("${_replacesarchkernel[@]/%/-docs}" "${_replacesoldkernels[@]/%/-docs}")
  210. replaces=("${_replacesarchkernel[@]/%/-docs}" "${_replacesoldkernels[@]/%/-docs}")
  211. cd $_srcname
  212. local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
  213. echo "Installing documentation..."
  214. local src dst
  215. while read -rd '' src; do
  216. dst="${src#Documentation/}"
  217. dst="$builddir/Documentation/${dst#output/}"
  218. install -Dm644 "$src" "$dst"
  219. done < <(find Documentation -name '.*' -prune -o ! -type d -print0)
  220. echo "Adding symlink..."
  221. mkdir -p "$pkgdir/usr/share/doc"
  222. ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
  223. }
  224. pkgname=("$pkgbase" "$pkgbase-headers" "$pkgbase-docs")
  225. for _p in "${pkgname[@]}"; do
  226. eval "package_$_p() {
  227. $(declare -f "_package${_p#$pkgbase}")
  228. _package${_p#$pkgbase}
  229. }"
  230. done
  231. # vim:set ts=8 sts=2 sw=2 et: