Cobra_Fast

Linux Kernel PKGBUILD

Mar 9th, 2023
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.88 KB | None | 0 0
  1. # Maintainer: Jan Alexander Steffens (heftig) <[email protected]>
  2.  
  3. pkgbase=linux-lost
  4. pkgver=6.2.2.arch1
  5. pkgrel=1
  6. pkgdesc='Linux'
  7. _srctag=v${pkgver%.*}-${pkgver##*.}
  8. url="https://github.com/archlinux/linux/commits/$_srctag"
  9. arch=(x86_64)
  10. license=(GPL2)
  11. makedepends=(
  12. bc libelf pahole cpio perl tar xz gettext
  13. xmlto python-sphinx python-sphinx_rtd_theme graphviz imagemagick texlive-latexextra
  14. git
  15. )
  16. options=('!strip')
  17. _srcname=archlinux-linux
  18. source=(
  19. "$_srcname::git+https://github.com/archlinux/linux?signed#tag=$_srctag"
  20. lost.patch
  21. config # the main kernel config file
  22. )
  23. validpgpkeys=(
  24. 'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds
  25. '647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman
  26. 'A2FF3A36AAA56654109064AB19802F8B0D70FC30' # Jan Alexander Steffens (heftig)
  27. 'C7E7849466FE2358343588377258734B41C31549' # David Runge <[email protected]>
  28. )
  29. sha256sums=('SKIP'
  30. '01ec3ceb15b01e9c060ca5a713026109aa2cf91176b81ef059a17e2c446e4b76'
  31. 'cd0d66c4ab39b2cb6edd3284161589f4e306320cb12468e6c0e6b08ae5299b85')
  32.  
  33. export KBUILD_BUILD_HOST=archlinux
  34. export KBUILD_BUILD_USER=$pkgbase
  35. export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
  36. export KCFLAGS="-mmmx -msse -msse2"
  37. #export KCFLAGS="-march=skylake -mmmx -mpopcnt -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mno-avx -mno-avx2 -mno-sse4a -mno-fma4 -mno-xop -mno-fma -mno-avx512f -mno-bmi -mno-bmi2 -maes -mpclmul -mno-avx512vl -mno-avx512bw -mno-avx512dq -mno-avx512cd -mno-avx512er -mno-avx512pf -mno-avx512vbmi -mno-avx512ifma -mno-avx5124vnniw -mno-avx5124fmaps -mno-avx512vpopcntdq -mno-avx512vbmi2 -mno-gfni -mno-vpclmulqdq -mno-avx512vnni -mno-avx512bitalg -mno-avx512bf16 -mno-avx512vp2intersect -mno-3dnow -mno-adx -mabm -mno-cldemote -mclflushopt -mno-clwb -mno-clzero -mcx16 -mno-enqcmd -mno-f16c -mfsgsbase -mfxsr -mno-hle -msahf -mno-lwp -mlzcnt -mmovbe -mno-movdir64b -mno-movdiri -mno-mwaitx -mno-pconfig -mno-pku -mno-prefetchwt1 -mprfchw -mno-ptwrite -mno-rdpid -mrdrnd -mrdseed -mno-rtm -mno-serialize -msgx -mno-sha -mno-shstk -mno-tbm -mno-tsxldtrk -mno-vaes -mno-waitpkg -mno-wbnoinvd -mxsave -mxsavec -mxsaveopt -mxsaves -mno-amx-tile -mno-amx-int8 -mno-amx-bf16 -mno-uintr -mno-hreset -mno-kl -mno-widekl -mno-avxvnni -mno-avx512fp16 --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=3072 -mtune=skylake"
  38.  
  39. prepare() {
  40. cd $_srcname
  41.  
  42. echo "Setting version..."
  43. scripts/setlocalversion --save-scmversion
  44. echo "-$pkgrel" > localversion.10-pkgrel
  45. echo "${pkgbase#linux}" > localversion.20-pkgname
  46.  
  47. local src
  48. for src in "${source[@]}"; do
  49. src="${src%%::*}"
  50. src="${src##*/}"
  51. [[ $src = *.patch ]] || continue
  52. echo "Applying patch $src..."
  53. patch -Np1 < "../$src"
  54. done
  55.  
  56. echo "Setting config..."
  57. cp ../config .config
  58. make olddefconfig
  59. #make nconfig
  60. #make oldconfig
  61. make prepare
  62.  
  63. make -s kernelrelease > version
  64. echo "Prepared $pkgbase version $(<version)"
  65. }
  66.  
  67. build() {
  68. cd $_srcname
  69. #make htmldocs all
  70. make all
  71. }
  72.  
  73. _package() {
  74. pkgdesc="The $pkgdesc kernel and modules"
  75. depends=(coreutils kmod initramfs)
  76. optdepends=('wireless-regdb: to set the correct wireless channels of your country'
  77. 'linux-firmware: firmware images needed for some devices')
  78. provides=(VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE KSMBD-MODULE)
  79. replaces=(virtualbox-guest-modules-arch wireguard-arch)
  80.  
  81. cd $_srcname
  82. local kernver="$(<version)"
  83. local modulesdir="$pkgdir/usr/lib/modules/$kernver"
  84.  
  85. echo "Installing boot image..."
  86. # systemd expects to find the kernel here to allow hibernation
  87. # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
  88. install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"
  89.  
  90. # Used by mkinitcpio to name the kernel
  91. echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
  92.  
  93. echo "Installing modules..."
  94. make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 \
  95. DEPMOD=/doesnt/exist modules_install # Suppress depmod
  96.  
  97. # remove build and source links
  98. rm "$modulesdir"/{source,build}
  99. }
  100.  
  101. _package-headers() {
  102. pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
  103. depends=(pahole)
  104.  
  105. cd $_srcname
  106. local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
  107.  
  108. echo "Installing build files..."
  109. install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
  110. localversion.* version vmlinux
  111. install -Dt "$builddir/kernel" -m644 kernel/Makefile
  112. install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile
  113. cp -t "$builddir" -a scripts
  114.  
  115. # required when STACK_VALIDATION is enabled
  116. install -Dt "$builddir/tools/objtool" tools/objtool/objtool
  117.  
  118. # required when DEBUG_INFO_BTF_MODULES is enabled
  119. install -Dt "$builddir/tools/bpf/resolve_btfids" tools/bpf/resolve_btfids/resolve_btfids
  120.  
  121. echo "Installing headers..."
  122. cp -t "$builddir" -a include
  123. cp -t "$builddir/arch/x86" -a arch/x86/include
  124. install -Dt "$builddir/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s
  125.  
  126. install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
  127. install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
  128.  
  129. # https://bugs.archlinux.org/task/13146
  130. install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
  131.  
  132. # https://bugs.archlinux.org/task/20402
  133. install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
  134. install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
  135. install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
  136.  
  137. # https://bugs.archlinux.org/task/71392
  138. install -Dt "$builddir/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h
  139.  
  140. echo "Installing KConfig files..."
  141. find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
  142.  
  143. echo "Removing unneeded architectures..."
  144. local arch
  145. for arch in "$builddir"/arch/*/; do
  146. [[ $arch = */x86/ ]] && continue
  147. echo "Removing $(basename "$arch")"
  148. rm -r "$arch"
  149. done
  150.  
  151. echo "Removing documentation..."
  152. rm -r "$builddir/Documentation"
  153.  
  154. echo "Removing broken symlinks..."
  155. find -L "$builddir" -type l -printf 'Removing %P\n' -delete
  156.  
  157. echo "Removing loose objects..."
  158. find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
  159.  
  160. echo "Stripping build tools..."
  161. local file
  162. while read -rd '' file; do
  163. case "$(file -Sib "$file")" in
  164. application/x-sharedlib\;*) # Libraries (.so)
  165. strip -v $STRIP_SHARED "$file" ;;
  166. application/x-archive\;*) # Libraries (.a)
  167. strip -v $STRIP_STATIC "$file" ;;
  168. application/x-executable\;*) # Binaries
  169. strip -v $STRIP_BINARIES "$file" ;;
  170. application/x-pie-executable\;*) # Relocatable binaries
  171. strip -v $STRIP_SHARED "$file" ;;
  172. esac
  173. done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
  174.  
  175. echo "Stripping vmlinux..."
  176. strip -v $STRIP_STATIC "$builddir/vmlinux"
  177.  
  178. echo "Adding symlink..."
  179. mkdir -p "$pkgdir/usr/src"
  180. ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
  181. }
  182.  
  183. _package-docs() {
  184. pkgdesc="Documentation for the $pkgdesc kernel"
  185.  
  186. cd $_srcname
  187. local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
  188.  
  189. echo "Installing documentation..."
  190. local src dst
  191. while read -rd '' src; do
  192. dst="${src#Documentation/}"
  193. dst="$builddir/Documentation/${dst#output/}"
  194. install -Dm644 "$src" "$dst"
  195. done < <(find Documentation -name '.*' -prune -o ! -type d -print0)
  196.  
  197. echo "Adding symlink..."
  198. mkdir -p "$pkgdir/usr/share/doc"
  199. ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
  200. }
  201.  
  202. pkgname=("$pkgbase" "$pkgbase-headers")
  203. for _p in "${pkgname[@]}"; do
  204. eval "package_$_p() {
  205. $(declare -f "_package${_p#$pkgbase}")
  206. _package${_p#$pkgbase}
  207. }"
  208. done
  209.  
  210. # vim:set ts=8 sts=2 sw=2 et:
Advertisement
Add Comment
Please, Sign In to add comment