Advertisement
Guest User

Untitled

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