Advertisement
Guest User

PKGBUILD_vrrtest

a guest
Jun 29th, 2022
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.49 KB | None | 0 0
  1. # Maintainer: David Cohen <[email protected]>
  2. # Contributor: Jan Alexander Steffens (heftig) <[email protected]>
  3.  
  4. # This PKGBUILD script and the config file are based on official Arch's linux package
  5. # Refer to config file to get the exact versions it's based on. Any changes to the config
  6. # will be on config.extra file.
  7.  
  8. pkgbase=linux-mainline-git
  9. pkgver=v5.19.rc4.r14.941e3e791269.patched
  10. pkgrel=1
  11. pkgdesc="Linus Torvalds' Mainline Linux"
  12. url="https://www.kernel.org"
  13. arch=(x86_64)
  14. license=(GPL2)
  15. _userconfig="${pkgbase}/config"
  16. _userremote="${pkgbase}/remote"
  17. _userpatches="${pkgbase}/u_patches/patches"
  18. backup=(
  19. "${_userconfig##/}"
  20. "${_userremote##/}"
  21. )
  22. makedepends=(
  23. bc kmod libelf pahole cpio perl tar xz
  24. xmlto python-sphinx python-sphinx_rtd_theme graphviz imagemagick
  25. git
  26. )
  27. options=('!strip')
  28. _srcname=linux-torvalds
  29. source=(
  30. "$_srcname::git+https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/"
  31. config # the main kernel config file
  32. config.extra # additional configs
  33. config.user # user custom config
  34. remote # custom remote config
  35. patches # user patches config
  36. force_hdmi-fs.patch
  37. )
  38. validpgpkeys=(
  39. 'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds
  40. '647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman
  41. )
  42. sha256sums=('SKIP'
  43. '5088714ec20c9c5b063decbf2210f5b153a908a71678aa156f5f3e81394e9c38'
  44. '6e41a729c2f2946d3606ca2c0cb3a058c9700b0f73110eed36dcba91a271e50f'
  45. 'b5ced6ad1f03a5cfe6dccc0b2b31f91420cfe97823e5d15d5b94b7224362daa9'
  46. 'b5560bc5fb8967aec989b757af8eb4d2f5166a830abb732c8c880fb953dcb52f'
  47. 'SKIP'
  48. 'SKIP')
  49.  
  50.  
  51. export KBUILD_BUILD_HOST=archlinux
  52. export KBUILD_BUILD_USER=$pkgbase
  53. export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
  54.  
  55. pkgver() {
  56. cd "$srcdir/$_srcname"
  57. if [[ -n "$REMOTE_URL" ]]; then
  58. # if $REMOTE_URL was created, it's safe to use $REMOTE
  59. printf "%s" "$(git describe --dirty=-patched --long | sed 's/\([^-]*-\)g/r\1/;s/-/./g').${REMOTE/\//.}"
  60. else
  61. printf "%s" "$(git describe --dirty=-patched --long | sed 's/\([^-]*-\)g/r\1/;s/-/./g')"
  62. fi
  63. }
  64.  
  65. prepare() {
  66. cd $_srcname
  67.  
  68. [[ -f "$_userremote" ]] && source "$_userremote"
  69. if [[ -n "$REMOTE" && -n "$COMMIT" ]]; then
  70. REMOTE_PREFIX=${source[0]##${_srcname}::git+}
  71. REMOTE_PREFIX=${REMOTE_PREFIX%%torvalds/linux}
  72. REMOTE_URL=${REMOTE_PREFIX}${REMOTE}
  73. echo
  74. echo "================================================================================"
  75. echo "Build script detected custom variables \$REMOTE and \$COMMIT are being used:"
  76. echo "REMOTE_PREFIX: $REMOTE_PREFIX"
  77. echo "REMOTE_TIP : $REMOTE"
  78. echo "COMMIT : $COMMIT"
  79. echo "================================================================================"
  80. echo
  81. echo "Fetching ${REMOTE_PREFIX}${REMOTE} ${COMMIT}"
  82. git fetch ${REMOTE_URL} ${COMMIT}
  83. git checkout -f FETCH_HEAD
  84. fi
  85.  
  86. echo "Setting version..."
  87. scripts/setlocalversion --save-scmversion
  88. echo "-$pkgrel" > localversion.10-pkgrel
  89. echo "${pkgbase#linux}" > localversion.20-pkgname
  90.  
  91. local src
  92. for src in "${source[@]}"; do
  93. src="${src%%::*}"
  94. src="${src##*/}"
  95. [[ $src = *.patch ]] || continue
  96. echo "Applying patch $src..."
  97. patch -Np1 < "../$src"
  98. done
  99.  
  100. [[ -f "$_userpatches" ]] && source "$_userpatches"
  101. PATCHES_PREFIX=${_userpatches%%patches}
  102. _USER_PATCHES="0"
  103. for src in "${PATCHES}"; do
  104. [[ $src = *.patch ]] || continue
  105. echo "Applying user patch $src..."
  106. patch -Np1 < "${PATCHES_PREFIX}$src"
  107. _USER_PATCHES="1"
  108. done
  109.  
  110. # Let user see the patches were applied before proceed with the build
  111. [[ ${_USER_PATCHES} = "1" ]] && sleep 2
  112.  
  113. echo "Setting config..."
  114. cat ../config ../config.extra > .config
  115. if [[ -f "$_userconfig" ]]; then
  116. cat $_userconfig >> .config
  117. fi
  118. make olddefconfig
  119. diff -u ../config .config || :
  120.  
  121. make -s kernelrelease > version
  122. echo "Prepared $pkgbase version $(<version)"
  123. }
  124.  
  125. build() {
  126. cd $_srcname
  127. make all
  128. }
  129.  
  130. _package() {
  131. pkgdesc="The $pkgdesc kernel and modules"
  132. depends=(coreutils kmod initramfs)
  133. optdepends=('crda: to set the correct wireless channels of your country'
  134. 'linux-firmware: firmware images needed for some devices')
  135. provides=(VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE)
  136. replaces=(virtualbox-guest-modules-arch wireguard-arch)
  137.  
  138. cd $_srcname
  139. local kernver="$(<version)"
  140. local modulesdir="$pkgdir/usr/lib/modules/$kernver"
  141.  
  142. echo "Installing boot image..."
  143. # systemd expects to find the kernel here to allow hibernation
  144. # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
  145. install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"
  146.  
  147. # Used by mkinitcpio to name the kernel
  148. echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
  149.  
  150. echo "Installing modules..."
  151. make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 modules_install
  152.  
  153. # remove build and source links
  154. rm "$modulesdir"/{source,build}
  155.  
  156. # install config files
  157. install -Dm644 $srcdir/config.user "${pkgdir}${_userconfig}"
  158. install -Dm644 $srcdir/remote "${pkgdir}${_userremote}"
  159. install -Dm644 $srcdir/patches "${pkgdir}${_userpatches}"
  160. }
  161.  
  162. _package-headers() {
  163. pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
  164. depends=(pahole)
  165.  
  166. cd $_srcname
  167. local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
  168.  
  169. echo "Installing build files..."
  170. install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
  171. localversion.* version vmlinux
  172. install -Dt "$builddir/kernel" -m644 kernel/Makefile
  173. install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile
  174. cp -t "$builddir" -a scripts
  175.  
  176. # required when STACK_VALIDATION is enabled
  177. install -Dt "$builddir/tools/objtool" tools/objtool/objtool
  178.  
  179. # required when DEBUG_INFO_BTF_MODULES is enabled
  180. install -Dt "$builddir/tools/bpf/resolve_btfids" tools/bpf/resolve_btfids/resolve_btfids
  181.  
  182. echo "Installing headers..."
  183. cp -t "$builddir" -a include
  184. cp -t "$builddir/arch/x86" -a arch/x86/include
  185. install -Dt "$builddir/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s
  186.  
  187. install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
  188. install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
  189.  
  190. # https://bugs.archlinux.org/task/13146
  191. install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
  192.  
  193. # https://bugs.archlinux.org/task/20402
  194. install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
  195. install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
  196. install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
  197.  
  198. # https://bugs.archlinux.org/task/71392
  199. install -Dt "$builddir/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h
  200.  
  201. echo "Installing KConfig files..."
  202. find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
  203.  
  204. echo "Removing unneeded architectures..."
  205. local arch
  206. for arch in "$builddir"/arch/*/; do
  207. [[ $arch = */x86/ ]] && continue
  208. echo "Removing $(basename "$arch")"
  209. rm -r "$arch"
  210. done
  211.  
  212. echo "Removing documentation..."
  213. rm -r "$builddir/Documentation"
  214.  
  215. echo "Removing broken symlinks..."
  216. find -L "$builddir" -type l -printf 'Removing %P\n' -delete
  217.  
  218. echo "Removing loose objects..."
  219. find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
  220.  
  221. echo "Stripping build tools..."
  222. local file
  223. while read -rd '' file; do
  224. case "$(file -bi "$file")" in
  225. application/x-sharedlib\;*) # Libraries (.so)
  226. strip -v $STRIP_SHARED "$file" ;;
  227. application/x-archive\;*) # Libraries (.a)
  228. strip -v $STRIP_STATIC "$file" ;;
  229. application/x-executable\;*) # Binaries
  230. strip -v $STRIP_BINARIES "$file" ;;
  231. application/x-pie-executable\;*) # Relocatable binaries
  232. strip -v $STRIP_SHARED "$file" ;;
  233. esac
  234. done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
  235.  
  236. echo "Stripping vmlinux..."
  237. strip -v $STRIP_STATIC "$builddir/vmlinux"
  238.  
  239. echo "Adding symlink..."
  240. mkdir -p "$pkgdir/usr/src"
  241. ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
  242. }
  243.  
  244. pkgname=("$pkgbase" "$pkgbase-headers")
  245. for _p in "${pkgname[@]}"; do
  246. eval "package_$_p() {
  247. $(declare -f "_package${_p#$pkgbase}")
  248. _package${_p#$pkgbase}
  249. }"
  250. done
  251.  
  252. # vim:set ts=8 sts=2 sw=2 et:
  253.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement