Advertisement
Guest User

PKGBUILD_linux514

a guest
Sep 4th, 2021
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.50 KB | None | 0 0
  1. # Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
  2.  
  3. pkgbase=linux-mo
  4. _ver=5.14.1
  5. pkgver=${_ver}.arch1
  6. pkgrel=1
  7. pkgdesc='Linux'
  8. url="https://kernel.org"
  9. arch=(x86_64)
  10. license=(GPL2)
  11. makedepends=(
  12. bc kmod libelf pahole cpio perl tar xz
  13. xmlto python-sphinx python-sphinx_rtd_theme graphviz imagemagick
  14. git
  15. )
  16. options=('!strip')
  17. _srcname=linux-${_ver}
  18. source=(
  19. "https://mirrors.edge.kernel.org/pub/linux/kernel/v5.x/linux-${_ver}.tar.gz"
  20. "config" # the main kernel config file
  21. "5010_enable-cpu-optimizations-universal.patch"
  22. )
  23. validpgpkeys=(
  24. 'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds
  25. '647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman
  26. 'A2FF3A36AAA56654109064AB19802F8B0D70FC30' # Jan Alexander Steffens (heftig)
  27. )
  28. sha256sums=('1706cc6830848c92b8e748f86b6659b94a39ff2f9a037bfff6c26d757848be03'
  29. '6dc4051024d8657de52ecb98dedb2f64400e0ce2db4bd52bd691515b0d8250eb'
  30. '09945620d24a83608a66b1104477a1c1073701ac04b7aeae2f7819a2bf185c85')
  31.  
  32. export KBUILD_BUILD_HOST=archlinux
  33. export KBUILD_BUILD_USER=$pkgbase
  34. export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
  35.  
  36. prepare() {
  37. cd $_srcname
  38.  
  39. echo "Setting version..."
  40. scripts/setlocalversion --save-scmversion
  41. echo "-$pkgrel" > localversion.10-pkgrel
  42. echo "${pkgbase#linux}" > localversion.20-pkgname
  43.  
  44. local src
  45. for src in "${source[@]}"; do
  46. src="${src%%::*}"
  47. src="${src##*/}"
  48. [[ $src = *.patch ]] || continue
  49. echo "Applying patch $src..."
  50. patch -Np1 < "../$src"
  51. done
  52.  
  53. echo "Setting config..."
  54. cp ../config .config
  55. make olddefconfig
  56.  
  57. make -s kernelrelease > version
  58. echo "Prepared $pkgbase version $(<version)"
  59. }
  60.  
  61. build() {
  62. cd $_srcname
  63. make all
  64. }
  65.  
  66. _package() {
  67. pkgdesc="The $pkgdesc kernel and modules"
  68. depends=(coreutils kmod initramfs)
  69. optdepends=('crda: to set the correct wireless channels of your country'
  70. 'linux-firmware: firmware images needed for some devices')
  71. provides=(VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE)
  72. replaces=(virtualbox-guest-modules-arch wireguard-arch)
  73.  
  74. cd $_srcname
  75. local kernver="$(<version)"
  76. local modulesdir="$pkgdir/usr/lib/modules/$kernver"
  77.  
  78. echo "Installing boot image..."
  79. # systemd expects to find the kernel here to allow hibernation
  80. # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
  81. install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"
  82.  
  83. # Used by mkinitcpio to name the kernel
  84. echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
  85.  
  86. echo "Installing modules..."
  87. make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 modules_install
  88.  
  89. # remove build and source links
  90. rm "$modulesdir"/{source,build}
  91. }
  92.  
  93. _package-headers() {
  94. pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
  95. depends=(pahole)
  96.  
  97. cd $_srcname
  98. local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
  99.  
  100. echo "Installing build files..."
  101. install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
  102. localversion.* version vmlinux
  103. install -Dt "$builddir/kernel" -m644 kernel/Makefile
  104. install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile
  105. cp -t "$builddir" -a scripts
  106.  
  107. # add objtool for external module building and enabled VALIDATION_STACK option
  108. install -Dt "$builddir/tools/objtool" tools/objtool/objtool
  109.  
  110. # add xfs and shmem for aufs building
  111. mkdir -p "$builddir"/{fs/xfs,mm}
  112.  
  113. echo "Installing headers..."
  114. cp -t "$builddir" -a include
  115. cp -t "$builddir/arch/x86" -a arch/x86/include
  116. install -Dt "$builddir/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s
  117.  
  118. install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
  119. install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
  120.  
  121. # https://bugs.archlinux.org/task/13146
  122. install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
  123.  
  124. # https://bugs.archlinux.org/task/20402
  125. install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
  126. install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
  127. install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
  128.  
  129. # https://bugs.archlinux.org/task/71392
  130. install -Dt "$builddir/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h
  131.  
  132. echo "Installing KConfig files..."
  133. find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
  134.  
  135. echo "Removing unneeded architectures..."
  136. local arch
  137. for arch in "$builddir"/arch/*/; do
  138. [[ $arch = */x86/ ]] && continue
  139. echo "Removing $(basename "$arch")"
  140. rm -r "$arch"
  141. done
  142.  
  143. echo "Removing documentation..."
  144. rm -r "$builddir/Documentation"
  145.  
  146. echo "Removing broken symlinks..."
  147. find -L "$builddir" -type l -printf 'Removing %P\n' -delete
  148.  
  149. echo "Removing loose objects..."
  150. find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
  151.  
  152. echo "Stripping build tools..."
  153. local file
  154. while read -rd '' file; do
  155. case "$(file -bi "$file")" in
  156. application/x-sharedlib\;*) # Libraries (.so)
  157. strip -v $STRIP_SHARED "$file" ;;
  158. application/x-archive\;*) # Libraries (.a)
  159. strip -v $STRIP_STATIC "$file" ;;
  160. application/x-executable\;*) # Binaries
  161. strip -v $STRIP_BINARIES "$file" ;;
  162. application/x-pie-executable\;*) # Relocatable binaries
  163. strip -v $STRIP_SHARED "$file" ;;
  164. esac
  165. done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
  166.  
  167. echo "Stripping vmlinux..."
  168. strip -v $STRIP_STATIC "$builddir/vmlinux"
  169.  
  170. echo "Adding symlink..."
  171. mkdir -p "$pkgdir/usr/src"
  172. ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
  173. }
  174.  
  175. _package-docs() {
  176. pkgdesc="Documentation for the $pkgdesc kernel"
  177.  
  178. cd $_srcname
  179. local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
  180.  
  181. echo "Installing documentation..."
  182. local src dst
  183. while read -rd '' src; do
  184. dst="${src#Documentation/}"
  185. dst="$builddir/Documentation/${dst#output/}"
  186. install -Dm644 "$src" "$dst"
  187. done < <(find Documentation -name '.*' -prune -o ! -type d -print0)
  188.  
  189. echo "Adding symlink..."
  190. mkdir -p "$pkgdir/usr/share/doc"
  191. ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
  192. }
  193.  
  194. pkgname=("$pkgbase" "$pkgbase-headers")
  195. for _p in "${pkgname[@]}"; do
  196. eval "package_$_p() {
  197. $(declare -f "_package${_p#$pkgbase}")
  198. _package${_p#$pkgbase}
  199. }"
  200. done
  201.  
  202. # vim:set ts=8 sts=2 sw=2 et:
  203.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement