Advertisement
Guest User

linux-manjaro-xanmod 6.12.1

a guest
Dec 15th, 2024
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.03 KB | Source Code | 0 0
  1. # Maintainer: parov0z <andrey.android7890@gmail.com>
  2.  
  3. # https://gitlab.manjaro.org/packages/core/linux515
  4. #
  5. # Maintainer: Philip Müller
  6. # Maintainer: Bernhard Landauer
  7. # Maintainer: Helmut Stult
  8.  
  9. # http://aur.archlinux.org/packages/linux-xanmod
  10. #
  11. # Maintainer: Joan Figueras
  12. # Contributor: Torge Matthies
  13. # Contributor: Jan Alexander Steffens (heftig)
  14.  
  15. ##
  16. ## The following variables can be customized at build time. Use env or export to change at your wish
  17. ##
  18. ## Example: env _microarchitecture=99 use_numa=n use_tracers=n makepkg -sc
  19. ##
  20. ## Look inside 'choose-gcc-optimization.sh' to choose your microarchitecture
  21. ## Valid numbers between: 0 to 99
  22. ## Default is: 0 => generic
  23. ## Good option if your package is for one machine: 98 (Intel native) or 99 (AMD native)
  24. if [ -z ${_microarchitecture+x} ]; then
  25. _microarchitecture=0
  26. fi
  27.  
  28. ## Disable NUMA since most users do not have multiple processors. Breaks CUDA/NvEnc.
  29. ## Archlinux and Xanmod enable it by default.
  30. ## Set variable "use_numa" to: n to disable (possibly increase performance)
  31. ## y to enable (stock default)
  32. if [ -z ${use_numa+x} ]; then
  33. use_numa=y
  34. fi
  35.  
  36. ## Since upstream disabled CONFIG_STACK_TRACER (limits debugging and analyzing of the kernel)
  37. ## you can enable them setting this option. Caution, because they have an impact in performance.
  38. ## Stock Archlinux has this enabled.
  39. ## Set variable "use_tracers" to: n to disable (possibly increase performance, XanMod default)
  40. if [ -z ${use_tracers+x} ]; then
  41. use_tracers=n
  42. fi
  43.  
  44. # Unique compiler supported upstream is GCC
  45. ## Choose between GCC and CLANG config (default is GCC)
  46. ## Use the environment variable "_compiler=clang"
  47. if [ "${_compiler}" = "clang" ]; then
  48. _compiler_flags="CC=clang HOSTCC=clang LLVM=1 LLVM_IAS=1"
  49. fi
  50.  
  51. # Choose between the 4 main configs for stable branch. Default x86-64-v1 which use CONFIG_GENERIC_CPU2:
  52. # Possible values: config_x86-64-v1 / config_x86-64-v2 (default) / config_x86-64-v3 / config_x86-64-v4
  53. # This will be overwritten by selecting any option in microarchitecture script
  54. # Source files: https://github.com/xanmod/linux/tree/5.17/CONFIGS/xanmod/gcc
  55. if [ -z ${_config+x} ]; then
  56. _config=config_x86-64-v2
  57. fi
  58.  
  59. # Compress modules with ZSTD (to save disk space)
  60. if [ -z ${_compress_modules+x} ]; then
  61. _compress_modules=n
  62. fi
  63.  
  64. # Compile ONLY used modules to VASTLY reduce the number of modules built
  65. # and the build time.
  66. #
  67. # To keep track of which modules are needed for your specific system/hardware,
  68. # give module_db script a try: https://aur.archlinux.org/packages/modprobed-db
  69. # This PKGBUILD read the database kept if it exists
  70. #
  71. # More at this wiki page ---> https://wiki.archlinux.org/index.php/Modprobed-db
  72. if [ -z ${_localmodcfg} ]; then
  73. _localmodcfg=n
  74. fi
  75.  
  76. # Tweak kernel options prior to a build via nconfig
  77. if [ -z ${_makenconfig} ]; then
  78. _makenconfig=n
  79. fi
  80.  
  81. ### IMPORTANT: Do no edit below this line unless you know what you're doing
  82.  
  83.  
  84. pkgbase=linux-manjaro-xanmod
  85. pkgname=("${pkgbase}" "${pkgbase}-headers")
  86. _major=6.12
  87. pkgver=${_major}.1
  88. _branch=6.x
  89. xanmod=1
  90. _sf_branch=main
  91. pkgrel=4
  92. pkgdesc='Linux Manjaro Xanmod'
  93. url="http://www.xanmod.org/"
  94. arch=(x86_64)
  95.  
  96. __commit="c0edf2683bbf8944068bc96bfd2790266f01a935" # 6.12
  97.  
  98. license=(GPL2)
  99.  
  100. makedepends=(
  101. bc cpio gettext libelf pahole perl python tar xz
  102. python-sphinx inetutils kmod xmlto
  103. )
  104.  
  105. if [ "${_compiler}" = "clang" ]; then
  106. makedepends+=(clang llvm lld)
  107. fi
  108. options=('!strip')
  109. _srcname="linux-${pkgver}-xanmod${xanmod}"
  110.  
  111. source=("https://cdn.kernel.org/pub/linux/kernel/v${_branch}/linux-${_major}.tar."{xz,sign}
  112. "patch-${pkgver}-xanmod${xanmod}.xz::https://sourceforge.net/projects/xanmod/files/releases/edge/6.12.1-xanmod1/patch-6.12.1-xanmod1.xz/download"
  113. #"patch-${pkgver}-xanmod${xanmod}.xz::https://sourceforge.net/projects/xanmod/files/releases/edge/6.12.1-xanmod2/patch-6.12.1-xanmod2.xz/download"
  114. #"patch-${pkgver}-xanmod${xanmod}${_revision}.xz::https://sourceforge.net/projects/xanmod/files/releases/${_sf_branch}/${pkgver}-xanmod${xanmod}/patch-${pkgver}-xanmod${xanmod}.xz/download"
  115. choose-gcc-optimization.sh
  116. #"https://gitlab.manjaro.org/packages/core/linux612/-/archive/7ae2ba409b5d010f43c6bb99d5498a94119bd598/linux612-7ae2ba409b5d010f43c6bb99d5498a94119bd598.tar.gz")
  117. "https://gitlab.manjaro.org/packages/core/linux${_major//.}/-/archive/${__commit}/linux${_major//.}-${__commit}.tar.gz")
  118. #"patch-${pkgver}-xanmod${xanmod}.xz::https://sourceforge.net/projects/xanmod/files/releases/stable/${pkgver}-xanmod${xanmod}/patch-${pkgver}-xanmod${xanmod}.xz/download"
  119.  
  120. # Archlinux patches
  121. _commit="ec9e9a4219fe221dec93fa16fddbe44a34933d8d"
  122. _patches=()
  123. for _patch in ${_patches[@]}; do
  124. source+=("${_patch}::https://raw.githubusercontent.com/archlinux/svntogit-packages/${_commit}/trunk/${_patch}")
  125. done
  126.  
  127. sha256sums=('24fa01fb989c7a3e28453f117799168713766e119c5381dac30115f18f268149' # kernel tar.xz
  128. 'SKIP' # tar.sign
  129. '235f0c325080342fed184ec3d415a865293c66a6010965b6cd3c5cfe02f2c6d9' # xanmod
  130. 'a8b38eb482eb685944757182c4886404abc12703e5e56ec39c7d61298d17d71f' # choose-gcc-optimization.sh
  131. '3dc4bea7a4ffda78d624f59821a0a075d4a9c1d1f7c5c8d7e3b0bcbf824f02c3') # manjaro
  132.  
  133. validpgpkeys=(
  134. 'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linux Torvalds
  135. '647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman
  136. )
  137.  
  138. export KBUILD_BUILD_HOST=${KBUILD_BUILD_HOST:-archlinux}
  139. export KBUILD_BUILD_USER=${KBUILD_BUILD_USER:-makepkg}
  140. export KBUILD_BUILD_TIMESTAMP=${KBUILD_BUILD_TIMESTAMP:-$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})}
  141.  
  142. prepare() {
  143. cd linux-${_major}
  144.  
  145. # Apply Xanmod patch
  146. patch -Np1 -i ../patch-${pkgver}-xanmod${xanmod}
  147.  
  148. msg2 "Setting version..."
  149. #echo "-$pkgrel" > localversion.10-pkgrel
  150. echo "-MANJARO" > localversion.20-pkgname
  151.  
  152. # Archlinux patches
  153. local src
  154. for src in "${source[@]}"; do
  155. src="${src%%::*}"
  156. src="${src##*/}"
  157. [[ $src = *.patch ]] || continue
  158. msg2 "Applying patch $src..."
  159. patch -Np1 < "../$src"
  160. done
  161.  
  162. # Manjaro patches
  163.  
  164. # remove conflicting ones
  165. patchdir=../linux${_major//.}-$__commit
  166. # Stelle sicher, dass das Patch-Verzeichnis korrekt gesetzt ist
  167. #patchdir="$srcdir/linux612-c0edf2683bbf8944068bc96bfd2790266f01a935"
  168. rm $patchdir/0001-steam-deck.patch
  169. rm $patchdir/0002-steamdeck-oled-audio.patch
  170. rm $patchdir/0101-ZEN_Add_sysctl_and_CONFIG_to_disallow_unprivileged_CLONE_NEWUSER.patch
  171.  
  172.  
  173. local _patch
  174. for _patch in ../linux${_major//.}-$__commit/*; do
  175. [[ $_patch = *.patch ]] || continue
  176. msg2 "Applying patch: $_patch..."
  177. patch -Np1 < "../linux${_major//.}-$__commit/$_patch"
  178. done
  179.  
  180.  
  181. # Applying configuration
  182. cp -vf CONFIGS/xanmod/gcc/${_config} .config
  183. # enable LTO_CLANG_THIN
  184. if [ "${_compiler}" = "clang" ]; then
  185. scripts/config --disable LTO_CLANG_FULL
  186. scripts/config --enable LTO_CLANG_THIN
  187. fi
  188.  
  189.  
  190. # CONFIG_STACK_VALIDATION gives better stack traces. Also is enabled in all official kernel packages by Archlinux team
  191. scripts/config --enable CONFIG_STACK_VALIDATION
  192.  
  193. # Enable IKCONFIG following Arch's philosophy
  194. scripts/config --enable CONFIG_IKCONFIG \
  195. --enable CONFIG_IKCONFIG_PROC
  196.  
  197. # User set. See at the top of this file
  198. if [ "$use_tracers" = "n" ]; then
  199. msg2 "Disabling FUNCTION_TRACER/GRAPH_TRACER only if we are not compiling with clang..."
  200. if [ "${_compiler}" = "gcc" ] || [ "${_compiler}q" = "q" ]; then
  201. scripts/config --disable CONFIG_FUNCTION_TRACER \
  202. --disable CONFIG_STACK_TRACER
  203. fi
  204. fi
  205.  
  206. if [ "$use_numa" = "n" ]; then
  207. msg2 "Disabling NUMA..."
  208. scripts/config --disable CONFIG_NUMA
  209. fi
  210.  
  211. msg2 "add anbox support"
  212. # CONFIG_ION is not set
  213. scripts/config --enable CONFIG_ANDROID
  214. scripts/config --enable CONFIG_ANDROID_BINDER_IPC
  215. scripts/config --enable CONFIG_ANDROID_BINDERFS
  216. scripts/config --set-str CONFIG_ANDROID_BINDER_DEVICES "binder,hwbinder,vndbinder"
  217. # CONFIG_ANDROID_BINDER_IPC_SELFTEST is not set
  218.  
  219. scripts/config --set-str CONFIG_DEFAULT_HOSTNAME "manjaro"
  220.  
  221. # Compress modules by default (following Arch's kernel)
  222. if [ "$_compress_modules" = "y" ]; then
  223. scripts/config --enable CONFIG_MODULE_COMPRESS_ZSTD
  224. fi
  225.  
  226. # Let's user choose microarchitecture optimization in GCC
  227. # Use default microarchitecture only if we have not choosen another microarchitecture
  228. if [ "$_microarchitecture" -ne "0" ]; then
  229. ../choose-gcc-optimization.sh $_microarchitecture
  230. fi
  231.  
  232. # This is intended for the people that want to build this package with their own config
  233. # Put the file "myconfig" at the package folder (this will take preference) or "${XDG_CONFIG_HOME}/linux-xanmod/myconfig"
  234. # If we detect partial file with scripts/config commands, we execute as a script
  235. # If not, it's a full config, will be replaced
  236. for _myconfig in "${SRCDEST}/myconfig" "${HOME}/.config/linux-xanmod/myconfig" "${XDG_CONFIG_HOME}/linux-xanmod/myconfig" ; do
  237. if [ -f "${_myconfig}" ] && [ "$(wc -l <"${_myconfig}")" -gt "0" ]; then
  238. if grep -q 'scripts/config' "${_myconfig}"; then
  239. # myconfig is a partial file. Executing as a script
  240. msg2 "Applying myconfig..."
  241. bash -x "${_myconfig}"
  242. else
  243. # myconfig is a full config file. Replacing default .config
  244. msg2 "Using user CUSTOM config..."
  245. cp -f "${_myconfig}" .config
  246. fi
  247. echo
  248. break
  249. fi
  250. done
  251.  
  252. ### Optionally load needed modules for the make localmodconfig
  253. # See https://aur.archlinux.org/packages/modprobed-db
  254. if [ "$_localmodcfg" = "y" ]; then
  255. if [ -f $HOME/.config/modprobed.db ]; then
  256. msg2 "Running Steven Rostedt's make localmodconfig now"
  257. make ${_compiler_flags} LSMOD=$HOME/.config/modprobed.db localmodconfig
  258. else
  259. msg2 "No modprobed.db data found"
  260. exit 1
  261. fi
  262. fi
  263.  
  264. msg2 "make ${_compiler_flags} olddefconfig"
  265. make ${_compiler_flags} olddefconfig
  266. #diff -u CONFIGS/xanmod/gcc/${_config} .config || :
  267.  
  268. make -s kernelrelease > version
  269. msg2 "Prepared %s version %s" "$pkgbase" "$(<version)"
  270.  
  271. if [ "$_makenconfig" = "y" ]; then
  272. make ${_compiler_flags} nconfig
  273. fi
  274.  
  275. # save configuration for later reuse
  276. cat .config > "${SRCDEST}/config.last"
  277. }
  278.  
  279. build() {
  280. cd linux-${_major}
  281. make ${_compiler_flags} all
  282. make -C tools/bpf/bpftool vmlinux.h feature-clang-bpf-co-re=1
  283. }
  284.  
  285. _package() {
  286. pkgdesc="The Linux kernel and modules with Xanmod and Manjaro patches"
  287. depends=('coreutils' 'linux-firmware' 'kmod' 'initramfs')
  288. optdepends=('wireless-regdb: to set the correct wireless channels of your country'
  289. 'linux-firmware: firmware images needed for some devices')
  290. provides=(VIRTUALBOX-GUEST-MODULES
  291. WIREGUARD-MODULE
  292. KSMBD-MODULE
  293. NTFS3-MODULE)
  294. replaces=()
  295. conflicts=()
  296.  
  297. cd linux-${_major}
  298. local modulesdir="$pkgdir/usr/lib/modules/$(<version)"
  299.  
  300. msg2 "Installing boot image..."
  301. # systemd expects to find the kernel here to allow hibernation
  302. # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
  303. install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"
  304.  
  305. # Used by mkinitcpio to name the kernel
  306. echo "manjaro-xanmod" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
  307.  
  308. # add kernel version
  309. echo "${pkgver}-${pkgrel}-Manjaro-Xanmod x64" | install -Dm644 /dev/stdin "${pkgdir}/boot/${pkgbase}.kver"
  310.  
  311. msg2 "Installing modules..."
  312. ZSTD_CLEVEL=19 make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 \
  313. DEPMOD=/doesnt/exist modules_install # Suppress depmod
  314.  
  315. # remove build link
  316. rm "$modulesdir"/build
  317. }
  318.  
  319. _package-headers() {
  320. pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
  321. depends=(pahole)
  322. provides=()
  323. replaces=()
  324. conflicts=()
  325.  
  326. cd linux-${_major}
  327. local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
  328.  
  329. msg2 "Installing build files..."
  330. install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
  331. localversion.* version vmlinux tools/bpf/bpftool/vmlinux.h
  332. install -Dt "$builddir/kernel" -m644 kernel/Makefile
  333. install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile
  334. cp -t "$builddir" -a scripts
  335.  
  336. # required when STACK_VALIDATION is enabled
  337. install -Dt "$builddir/tools/objtool" tools/objtool/objtool
  338.  
  339. # required when DEBUG_INFO_BTF_MODULES is enabled
  340. install -Dt "$builddir/tools/bpf/resolve_btfids" tools/bpf/resolve_btfids/resolve_btfids
  341.  
  342. msg2 "Installing headers..."
  343. cp -t "$builddir" -a include
  344. cp -t "$builddir/arch/x86" -a arch/x86/include
  345. install -Dt "$builddir/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s
  346.  
  347. install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
  348. install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
  349.  
  350. # https://bugs.archlinux.org/task/13146
  351. install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
  352.  
  353. # https://bugs.archlinux.org/task/20402
  354. install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
  355. install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
  356. install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
  357.  
  358. # https://bugs.archlinux.org/task/71392
  359. install -Dt "$builddir/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h
  360.  
  361. msg2 "Installing KConfig files..."
  362. find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
  363.  
  364. msg2 "Removing unneeded architectures..."
  365. local arch
  366. for arch in "$builddir"/arch/*/; do
  367. [[ $arch = */x86/ ]] && continue
  368. echo "Removing $(basename "$arch")"
  369. rm -r "$arch"
  370. done
  371.  
  372. msg2 "Removing documentation..."
  373. rm -r "$builddir/Documentation"
  374.  
  375. msg2 "Removing broken symlinks..."
  376. find -L "$builddir" -type l -printf 'Removing %P\n' -delete
  377.  
  378. msg2 "Removing loose objects..."
  379. find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
  380.  
  381. msg2 "Stripping build tools..."
  382. local file
  383. while read -rd '' file; do
  384. case "$(file -Sib "$file")" in
  385. application/x-sharedlib\;*) # Libraries (.so)
  386. strip -v $STRIP_SHARED "$file" ;;
  387. application/x-archive\;*) # Libraries (.a)
  388. strip -v $STRIP_STATIC "$file" ;;
  389. application/x-executable\;*) # Binaries
  390. strip -v $STRIP_BINARIES "$file" ;;
  391. application/x-pie-executable\;*) # Relocatable binaries
  392. strip -v $STRIP_SHARED "$file" ;;
  393. esac
  394. done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
  395.  
  396. msg2 "Stripping vmlinux..."
  397. strip -v $STRIP_STATIC "$builddir/vmlinux"
  398. msg2 "Adding symlink..."
  399. mkdir -p "$pkgdir/usr/src"
  400. ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
  401. }
  402.  
  403. pkgname=("${pkgbase}" "${pkgbase}-headers")
  404. for _p in "${pkgname[@]}"; do
  405. eval "package_$_p() {
  406. $(declare -f "_package${_p#$pkgbase}")
  407. _package${_p#$pkgbase}
  408. }"
  409. done
  410.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement