# Maintainer: Jan Alexander Steffens (heftig) pkgbase=linux-g14 pkgver=5.12.13.arch1 pkgrel=1 pkgdesc='Linux' _srctag=v${pkgver%.*}-${pkgver##*.} url="https://lab.retarded.farm/zappel/asus-rog-zephyrus-g14/" arch=(x86_64) license=(GPL2) makedepends=( bc kmod libelf pahole cpio tar xz xmlto git "gcc>=11.0" ) options=('!strip') _srcname=archlinux-linux _fedora_kernel_commit_id=19ba47dedb21773e0338321928a8580e214409fb source=( "$_srcname::git+https://github.com/archlinux/linux?signed#tag=$_srctag" config # the main kernel config file "choose-gcc-optimization.sh" #"sys-kernel_arch-sources-g14_files_0001-HID-asus-Filter-keyboard-EC-for-old-ROG-keyboard.patch" #"sys-kernel_arch-sources-g14_files-0002-acpi_unused.patch" "sys-kernel_arch-sources-g14_files-0003-flow-x13-sound.patch" "sys-kernel_arch-sources-g14_files-0004-5.8+--more-uarches-for-kernel.patch"::"https://raw.githubusercontent.com/graysky2/kernel_compiler_patch/master/more-uarches-for-kernel-5.8+.patch" "sys-kernel_arch-sources-g14_files-0005-lru-multi-generational.patch" #"sys-kernel_arch-sources-g14_files-0006-ACPI-PM-s2idle-Add-missing-LPS0-functions.patch" #"sys-kernel_arch-sources-g14_files-0007-ACPI-processor-idle-Fix-up-C-state-latency.patch" #"sys-kernel_arch-sources-g14_files-0008-NVMe-set-some-AMD-PCIe-downstream-storage-device-to-D3-for-s2idle.patch" #"sys-kernel_arch-sources-g14_files-0009-PCI-quirks-Quirk-PCI-d3hot-delay.patch" #"sys-kernel_arch-sources-g14_files-0010-platform-x86-force-LPS0-functions-for-AMD.patch" #"sys-kernel_arch-sources-g14_files-0011-USB-pci-quirks-disable-D3cold-on-s2idle-Renoire.patch" "https://gitlab.com/asus-linux/fedora-kernel/-/archive/$_fedora_kernel_commit_id/fedora-kernel-$_fedora_kernel_commit_id.zip" "sys-kernel_arch-sources-g14_files-0012-acpi-1of2-turn-off-unused.patch"::"https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git/patch/?id=4b9ee772eaa82188b0eb8e05bdd1707c2a992004" "sys-kernel_arch-sources-g14_files-0013-acpi-2of2-turn-off-unconditionally.patch"::"https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git/patch/?id=7e4fdeafa61f2b653fcf9678f09935e55756aed2" "sys-kernel_arch-sources-g14_files-0014-acpi_unused-v2.patch" ) validpgpkeys=( 'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds '647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman 'A2FF3A36AAA56654109064AB19802F8B0D70FC30' # Jan Alexander Steffens (heftig) ) sha256sums=('SKIP' '1c48dc71e8dabd48e538b2284ab3b9e2a768e7d80c2c74e552dc1d93239370e2' '1ac18cad2578df4a70f9346f7c6fccbb62f042a0ee0594817fdef9f2704904ee' '4a9e44dfbc7e9574ae86cf53a896b6c67f03b224e90e18982dfb0e4ba02a6c1b' 'fa6cee9527d8e963d3398085d1862edc509a52e4540baec463edb8a9dd95bee0' 'b9e4b11f6ca413fa7fcd1d810215bf3a36e69eedc4570f4209f7c1957083b2f3' 'e0977edd01cc1dd9cc8720d3ee2170bb3ba1e8a37eb77fe1c76c0852d580af4a' '5af4796400245fec2e84d6e3f847b8896600558aa85f5e9c4706dd50994a9802' '9cf7519ee1a0544f431c9fe57735aae7b9d150e62abed318837befc3b6af7c5f' '87f133d34d84b8b34b0dad2bfd4cbbd557c6018f413a1852120d650273c628fb') # notable microarch levels: # # 14, Zen2 # 15, Zen3 # 38, Skylake (Comet Lake laptops) # 93, x86-64-v3 (package default) # 98, Intel Native # 99, AMD Native if [ -z ${_microarchitecture+x} ]; then _microarchitecture=93 fi _fedora_kernel_patch_skip_list=( # fedora kernel patches to skip # use plain file names or bash glob syntax, ** don't quote globs ** # multi-select and ranges examples #00{03,05,08}-drm-amdgpu*.patch #00{01..12}-drm-amdgpu*.patch "linux-kernel-test.patch" # test patch, please ignore patch-*-redhat.patch # wildcard match any redhat patch version 00{01..12}-drm-amdgpu*.patch # upstreamed in 5.12 # upstreamed "0001-HID-asus-Filter-keyboard-EC-for-old-ROG-keyboard.patch" "0001-ALSA-hda-realtek-GA503-use-same-quirks-as-GA401.patch" # patch broken in 5.12.4, updated and included in package sources "0001-Add-jack-toggle-support-for-headphones-on-Asus-ROG-Z.patch" # applied a new version above in sources "0013-ACPI-idle-override-and-update-c-state-latency-when-n.patch" # applied a new version above in sources "0014-usb-pci-quirks-disable-D3cold-on-AMD-xhci-suspend-fo.patch" # applied above "0001-GV301QH-Flow-X13-Audio.patch" ) export KBUILD_BUILD_HOST=archlinux export KBUILD_BUILD_USER=$pkgbase export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})" _fedora_patch_in_skip_list() { for p in "${_fedora_kernel_patch_skip_list[@]}"; do [[ "$1" == $p ]] && return 0; done return 1 } prepare() { cd $_srcname rm Documentation/vm/multigen_lru.rst || echo 0 echo "Setting version..." scripts/setlocalversion --save-scmversion echo "-$pkgrel" > localversion.99-pkgrel echo "${pkgbase#linux}" > localversion.20-pkgname local src for src in "${source[@]}"; do src="${src%%::*}" src="${src##*/}" [[ $src = *.patch ]] || continue echo "Applying patch $src..." patch -Np1 < "../$src" done msg2 "Applying asus-linux patches..." local p_err=() local p_meh=() # this will apply only enabled patches from the fedora-linux kernel.spec # this stops us from applying broken or in-progress patches that are in git but aren't actually in use local _fkernel_path="../fedora-kernel-${_fedora_kernel_commit_id}" for src in $(awk -F ' ' '/^ApplyOptionalPatch.*(patch|diff)$/{print $2}' "${_fkernel_path}/kernel.spec"); do src="${src##*/}" _fedora_patch_in_skip_list "$src" && continue echo "Applying patch $src..." if OUT="$(patch --forward -Np1 < "${_fkernel_path}/$src")"; then : #plain "Applied patch $src..." else # if you want to ignore a specific patch failure for some reason do it right here, then 'continue' if { echo "$OUT" | grep -qiE 'hunk(|s) FAILED'; }; then error "Patch failed $src" && echo "$OUT" && p_err+=("$src") && _throw=y else warning "Duplicate patch $src" && p_meh+=("$src") fi fi done (( ${#p_err[@]} > 0 )) && error "Failed patches:" && for p in ${p_err[@]}; do plain "$p"; done (( ${#p_meh[@]} > 0 )) && warning "Duplicate patches:" && for p in ${p_meh[@]}; do plain "$p"; done # if throw is defined we had a hard patch failure, propagate it and stop so we can address [[ -z "$_throw" ]] echo "Setting config..." cp ../config .config # let user choose microarchitecture optimization in GCC sh ${srcdir}/choose-gcc-optimization.sh $_microarchitecture make olddefconfig make -s kernelrelease > version echo "Prepared $pkgbase version $(