# Based on the file created for Arch Linux by: # Tobias Powalowski # Thomas Baechler # Contributor: Tk-Glitch plain ' .---.` `.---.' plain ' `/syhhhyso- -osyhhhys/`' plain ' .syNMdhNNhss/``.---.``/sshNNhdMNys.' plain ' +sdMh.`+MNsssssssssssssssNM+`.hMds+' plain ' :syNNdhNNhssssssssssssssshNNhdNNys:' plain ' /ssyhhhysssssssssssssssssyhhhyss/' plain ' .ossssssssssssssssssssssssssssso.' plain ' :sssssssssssssssssssssssssssssssss:' plain ' /sssssssssssssssssssssssssssssssssss/' plain ' :sssssssssssssoosssssssoosssssssssssss:' plain ' osssssssssssssoosssssssoossssssssssssso' plain ' osssssssssssyyyyhhhhhhhyyyyssssssssssso' plain ' /yyyyyyhhdmmmmNNNNNNNNNNNmmmmdhhyyyyyy/' plain ' smmmNNNNNNNNNNNNNNNNNNNNNNNNNNNNNmmms' plain ' /dNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNd/' plain ' `:sdNNNNNNNNNNNNNNNNNNNNNNNNNds:`' plain ' `-+shdNNNNNNNNNNNNNNNdhs+-`' plain ' `.-:///////:-.`' _where="$PWD" # track basedir as different Arch based distros are moving srcdir around cp "$_where"/linux57-tkg-patches/* "$_where" # copy patches inside the PKGBUILD's dir to preserve makepkg sourcing and md5sum checking cp "$_where"/linux57-tkg-config/* "$_where" # copy config files and hooks inside the PKGBUILD's dir to preserve makepkg sourcing and md5sum checking source "$_where"/customization.cfg # load default configuration from file # Load external configuration file if present. Available variable values will overwrite customization.cfg ones. if [ -e "$_EXT_CONFIG_PATH" ]; then source "$_EXT_CONFIG_PATH" && msg2 "External configuration file $_EXT_CONFIG_PATH will be used to override customization.cfg values." && msg2 "" fi if [ -z "$_OPTIPROFILE" ] && [ ! -e "$_where"/cpuschedset ]; then # Prompt about optimized configurations. Available variable values will overwrite customization.cfg/external config ones. plain "Do you want to use a predefined optimized profile?" read -rp "`echo $' > 1.Custom\n 2.Ryzen Desktop (Performance)\n 3.Other Desktop (Performance)\nchoice[1-3?]: '`" _OPTIPROFILE; fi if [ "$_OPTIPROFILE" == "2" ]; then source "$_where"/ryzen-desktop-profile.cfg && msg2 "Ryzen Desktop (Performance) profile will be used." && msg2 "" elif [ "$_OPTIPROFILE" == "3" ]; then source "$_where"/generic-desktop-profile.cfg && msg2 "Generic Desktop (Performance) profile will be used." && msg2 "" fi # source cpuschedset early if present if [ -e "$_where"/cpuschedset ]; then source "$_where"/cpuschedset fi # CPU SCHED selector if [ -z "$_cpusched" ] && [ ! -e "$_where"/cpuschedset ]; then plain "What CPU sched variant do you want to build/install?" read -rp "`echo $' > 1.PDS\n 2.MuQSS\n 3.BMQ\n 4.CFS\nchoice[1-4?]: '`" CONDITION; if [ "$CONDITION" == "2" ]; then echo "_cpusched=\"MuQSS\"" > "$_where"/cpuschedset elif [ "$CONDITION" == "3" ]; then echo "_cpusched=\"bmq\"" > "$_where"/cpuschedset elif [ "$CONDITION" == "4" ]; then echo "_cpusched=\"cfs\"" > "$_where"/cpuschedset else echo "_cpusched=\"pds\"" > "$_where"/cpuschedset fi if [ -n "$_custom_pkgbase" ]; then echo "_custom_pkgbase=\"${_custom_pkgbase}\"" >> "$_where"/cpuschedset fi elif [ "$_cpusched" == "muqss" ] || [ "$_cpusched" == "MuQSS" ]; then echo "_cpusched=\"MuQSS\"" > "$_where"/cpuschedset elif [ "$_cpusched" == "pds" ]; then echo "_cpusched=\"pds\"" > "$_where"/cpuschedset elif [ "$_cpusched" == "bmq" ]; then echo "_cpusched=\"bmq\"" > "$_where"/cpuschedset else echo "_cpusched=\"cfs\"" > "$_where"/cpuschedset fi source "$_where"/cpuschedset _basever=57 if [ -n "$_custom_pkgbase" ]; then pkgbase="${_custom_pkgbase}" else pkgbase=linux"${_basever}"-tkg-"${_cpusched}" fi pkgname=("${pkgbase}" "${pkgbase}-headers") _basekernel=5.7 _sub=7 pkgver="${_basekernel}"."${_sub}" pkgrel=15 pkgdesc='Linux-tkg' arch=('x86_64') # no i686 in here url="http://www.kernel.org/" license=('GPL2') makedepends=('xmlto' 'docbook-xsl' 'kmod' 'inetutils' 'bc' 'libelf' 'patchutils' 'flex' 'python-sphinx' 'python-sphinx_rtd_theme' 'graphviz' 'imagemagick' 'git') optdepends=('schedtool') options=('!strip') source=("https://www.kernel.org/pub/linux/kernel/v5.x/linux-${_basekernel}.tar.xz" "https://www.kernel.org/pub/linux/kernel/v5.x/patch-${pkgver}.xz" "https://raw.githubusercontent.com/graysky2/kernel_gcc_patch/master/enable_additional_cpu_optimizations_for_gcc_v10.1%2B_kernel_v5.7%2B.patch" 'config.x86_64' # stock Arch config #'config_hardened.x86_64' # hardened Arch config 90-cleanup.hook cleanup # ARCH Patches 0001-add-sysctl-to-disallow-unprivileged-CLONE_NEWUSER-by.patch # TkG 0002-clear-patches.patch 0003-glitched-base.patch 0003-glitched-cfs.patch 0004-glitched-ondemand-muqss.patch 0004-glitched-muqss.patch 0004-5.7-ck1.patch 0005-glitched-ondemand-pds.patch 0005-glitched-pds.patch 0005-v5.7_undead-pds099o.patch 0006-add-acs-overrides_iommu.patch 0007-v5.7-fsync.patch 0008-5.7-bcachefs.patch 0009-glitched-ondemand-bmq.patch 0009-glitched-bmq.patch 0009-bmq_v5.7-r1.patch 0011-ZFS-fix.patch #0012-linux-hardened.patch ) sha256sums=('de8163bb62f822d84f7a3983574ec460060bf013a78ff79cd7c979ff1ec1d7e0' 'dc533b4b9756d417d59c2514237401d2c5d0814d13083b4f5736df48cf9312f4' '1f56a2466bd9b4477925682d8f944fabb38727140e246733214fe50aa326fc47' '71030461a03fe30133f357001394ca2644c5fe0aae52161fe00c74aec0f900fe' '1e15fc2ef3fa770217ecc63a220e5df2ddbcf3295eb4a021171e7edd4c6cc898' '66a03c246037451a77b4d448565b1d7e9368270c7d02872fbd0b5d024ed0a997' '31dc68e84aecfb7d069efb1305049122c65694676be8b955634abcf0675922a2' 'd02bf5ca08fd610394b9d3a0c3b176d74af206f897dee826e5cbaec97bb4a4aa' '968b248660d5432939c1ef80dc588bdd6ffcdc76eb1818d93afbfe10b3181afb' '7058e57fd68367b029adc77f2a82928f1433daaf02c8c279cb2d13556c8804d7' 'c605f638d74c61861ebdc36ebd4cb8b6475eae2f6273e1ccb2bbb3e10a2ec3fe' 'bc69d6e5ee8172b0242c8fa72d13cfe2b8d2b6601468836908a7dfe8b78a3bbb' '88c73f8960a3b7d0685a2f19b8624de3b592e451a47a51be6b66f86b7c91a0bd' '62496f9ca788996181ef145f96ad26291282fcc3fb95cdc04080dcf84365be33' '7fd8e776209dac98627453fda754bdf9aff4a09f27cb0b3766d7983612eb3c74' '010dad2c2922c29a6d3b39dd4e78afb215e86fd1f6e0b7fc6e2e06eb0107812d' '19661ec0d39f9663452b34433214c755179894528bf73a42f6ba52ccf572832a' 'cd225e86d72eaf6c31ef3d7b20df397f4cc44ddd04389850691292cdf292b204' 'b89d5c0e242ab2515211bf02de3098df9c0a51fe36a679817f9cb15e2e5e2b8b' '9fad4a40449e09522899955762c8928ae17f4cdaa16e01239fd12592e9d58177' '965a517a283f265a012545fbb5cc9e516efc9f6166d2aa1baf7293a32a1086b7' '72eaeaed0749b5853b28678869e69a08883e4b0b4894eb4c8c6958e7de692638' '49262ce4a8089fa70275aad742fc914baa28d9c384f710c9a62f64796d13e104') export KBUILD_BUILD_HOST=archlinux export KBUILD_BUILD_USER=$pkgbase export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})" user_patcher() { # To patch the user because all your base are belong to us local _patches=("$_where"/*."${_userpatch_ext}revert") if [ ${#_patches[@]} -ge 2 ] || [ -e "${_patches}" ]; then if [ "$_user_patches_no_confirm" != "true" ]; then msg2 "Found ${#_patches[@]} 'to revert' userpatches for ${_userpatch_target}:" printf '%s\n' "${_patches[@]}" read -rp "Do you want to install it/them? - Be careful with that ;)"$'\n> N/y : ' _CONDITION; fi if [ "$_CONDITION" == "y" ] || [ "$_user_patches_no_confirm" == "true" ]; then for _f in "${_patches[@]}"; do if [ -e "${_f}" ]; then msg2 "######################################################" msg2 "" msg2 "Reverting your own ${_userpatch_target} patch ${_f}" msg2 "" msg2 "######################################################" patch -Np1 -R < "${_f}" echo "Reverted your own patch ${_f}" >> "$_where"/last_build_config.log fi done fi fi _patches=("$_where"/*."${_userpatch_ext}patch") if [ ${#_patches[@]} -ge 2 ] || [ -e "${_patches}" ]; then if [ "$_user_patches_no_confirm" != "true" ]; then msg2 "Found ${#_patches[@]} userpatches for ${_userpatch_target}:" printf '%s\n' "${_patches[@]}" read -rp "Do you want to install it/them? - Be careful with that ;)"$'\n> N/y : ' _CONDITION; fi if [ "$_CONDITION" == "y" ] || [ "$_user_patches_no_confirm" == "true" ]; then for _f in "${_patches[@]}"; do if [ -e "${_f}" ]; then msg2 "######################################################" msg2 "" msg2 "Applying your own ${_userpatch_target} patch ${_f}" msg2 "" msg2 "######################################################" patch -Np1 < "${_f}" echo "Applied your own patch ${_f}" >> "$_where"/last_build_config.log fi done fi fi } prepare() { rm -rf $pkgdir # Nuke the entire pkg folder so it'll get regenerated clean on next build ln -s "${_where}/customization.cfg" "${srcdir}" # workaround cd "${srcdir}/linux-${_basekernel}" source "$_where/linux$_basever-tkg-config/prepare" _tkg_srcprep } build() { cd "${srcdir}/linux-${_basekernel}" # Use custom compiler paths if defined if [ -n "${CUSTOM_GCC_PATH}" ]; then PATH=${CUSTOM_GCC_PATH}/bin:${CUSTOM_GCC_PATH}/lib:${CUSTOM_GCC_PATH}/include:${PATH} fi if [ "$_force_all_threads" == "true" ]; then _force_all_threads="-j$((`nproc`*2))" else _force_all_threads="${MAKEFLAGS}" fi # ccache if [ "$_noccache" != "true" ] && pacman -Qq ccache &> /dev/null; then export PATH="/usr/lib/ccache/bin/:$PATH" export CCACHE_SLOPPINESS="file_macro,locale,time_macros" export CCACHE_NOHASHDIR="true" msg2 'ccache was found and will be used' fi # build! _runtime=$( time ( schedtool -B -n 1 -e ionice -n 1 make ${_force_all_threads} LOCALVERSION= bzImage modules 2>&1 ) 3>&1 1>&2 2>&3 ) || _runtime=$( time ( make ${_force_all_threads} LOCALVERSION= bzImage modules 2>&1 ) 3>&1 1>&2 2>&3 ) } hackbase() { pkgdesc="The $pkgdesc kernel and modules" depends=('coreutils' 'kmod' 'initramfs') optdepends=('linux-docs: Kernel hackers manual - HTML documentation that comes with the Linux kernel.' 'crda: to set the correct wireless channels of your country.' 'linux-firmware: Firmware files for Linux' 'modprobed-db: Keeps track of EVERY kernel module that has ever been probed. Useful for make localmodconfig.' 'nvidia-tkg: NVIDIA drivers for all installed kernels - non-dkms version.' 'nvidia-dkms-tkg: NVIDIA drivers for all installed kernels - dkms version.' 'update-grub: Simple wrapper around grub-mkconfig.') provides=("linux=${pkgver}" "${pkgbase}" VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE) replaces=(virtualbox-guest-modules-arch wireguard-arch) cd "${srcdir}/linux-${_basekernel}" # get kernel version local _kernver="$(