action.yml 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. name: 'Setup Misc Configs'
  2. description: 'Set up kernel configuration fragment with miscellaneous options'
  3. inputs:
  4. version:
  5. description: 'Kernel config version (e.g., android14-6.12)'
  6. required: true
  7. kernel_version:
  8. description: 'Kernel version (e.g., 6.1)'
  9. required: true
  10. android_version:
  11. description: 'Android version (e.g., android14)'
  12. required: true
  13. sublevel:
  14. description: 'Sublevel of kernel version (e.g., 1)'
  15. required: true
  16. variant:
  17. description: 'Build variant (Normal, Bypass, Wild, boot-time)'
  18. required: true
  19. runs:
  20. using: "composite"
  21. steps:
  22. - name: Enable Kernel Configs
  23. uses: ./.github/actions/set-kernel-config
  24. with:
  25. config_list: |
  26. CONFIG_OVERLAY_FS=y
  27. CONFIG_TMPFS_XATTR=y
  28. CONFIG_TMPFS_POSIX_ACL=y
  29. CONFIG_KALLSYMS=y
  30. CONFIG_KALLSYMS_ALL=y
  31. - name: Enable Kernel Configs
  32. uses: ./.github/actions/set-kernel-config
  33. with:
  34. config_list: |
  35. CONFIG_CIFS=y
  36. CONFIG_NETWORK_FILESYSTEMS=y
  37. CONFIG_KEYS=y
  38. CONFIG_CIFS_XATTR=y
  39. CONFIG_CIFS_POSIX=y
  40. - name: Apply NTSync Patch
  41. shell: bash
  42. working-directory: ${{ github.workspace }}/kernel/common
  43. run: |
  44. set -euo pipefail
  45. echo "Using patch: $(basename $NTSYNC_PATCH)"
  46. if [[ ${{ inputs.version }} = "android16-6.12" ]]; then
  47. echo "Removing pre-existing ntsync files for android16-6.12"
  48. rm -f include/uapi/linux/ntsync.h
  49. rm -f drivers/misc/ntsync.c
  50. fi
  51. cp ${{ github.workspace }}/kernel_patches/common/ntsync/ntsync_compat_${{ inputs.version }}.patch ${{ github.workspace }}/kernel/common
  52. patch -p1 ntsync_compat_${{ inputs.version }}.patch
  53. cp ${{ github.workspace }}/kernel_patches/common/ntsync/ntsync_base.patch ${{ github.workspace }}/kernel/common
  54. patch -p1 < ntsync_base.patch
  55. cat >> "${{ github.workspace }}/kernel/common/arch/arm64/configs/gki_defconfig" << 'EOF'
  56. CONFIG_NTSYNC=y
  57. EOF
  58. - name: Apply Ptrace Patch
  59. shell: bash
  60. working-directory: ${{ github.workspace }}/kernel/common
  61. run: |
  62. set -euo pipefail
  63. KERNEL_VERSION="${{ inputs.kernel_version }}"
  64. MIN_VERSION="5.16"
  65. if [ "$(printf '%s\n' "$KERNEL_VERSION" "$MIN_VERSION" | sort -V | head -n1)" = "$KERNEL_VERSION" ]; then
  66. echo "Patching ptrace!"
  67. patch -p1 -F 3 < "${{ github.workspace }}/kernel_patches/gki_ptrace.patch"
  68. else
  69. echo "Kernel >= $MIN_VERSION, skipping ptrace patch"
  70. fi
  71. - name: Apply Unicode Fix Patch
  72. shell: bash
  73. working-directory: ${{ github.workspace }}/kernel/common
  74. run: |
  75. set -euo pipefail
  76. KERNEL_VERSION="${{ inputs.kernel_version }}"
  77. MIN_VERSION="5.16"
  78. echo "Patching unicode!"
  79. if [ "$(printf '%s\n' "$KERNEL_VERSION" "$MIN_VERSION" | sort -V | head -n1)" = "$KERNEL_VERSION" ]; then
  80. patch -p1 --forward < "${{ github.workspace }}/kernel_patches/common/unicode_bypass_fix_6.1-.patch"
  81. else
  82. patch -p1 --forward < "${{ github.workspace }}/kernel_patches/common/unicode_bypass_fix_6.1+.patch"
  83. fi
  84. - name: Apply Other Patches
  85. shell: bash
  86. if: true
  87. working-directory: ${{ github.workspace }}/kernel/common
  88. run: |
  89. set -euo pipefail
  90. KERNEL_VERSION="${{ inputs.kernel_version }}"
  91. MIN_VERSION="5.16"
  92. patch -p1 --forward < "${{ github.workspace }}/kernel_patches/common/optimized_mem_operations.patch"
  93. patch -p1 --forward < "${{ github.workspace }}/kernel_patches/common/file_struct_8bytes_align.patch"
  94. patch -p1 --forward < "${{ github.workspace }}/kernel_patches/common/reduce_cache_pressure.patch"
  95. patch -p1 --forward < "${{ github.workspace }}/kernel_patches/common/mem_opt_prefetch.patch"
  96. if [ "$(printf '%s\n' "$KERNEL_VERSION" "$MIN_VERSION" | sort -V | tail -n1)" = "$KERNEL_VERSION" ]; then
  97. patch -p1 --forward < "${{ github.workspace }}/kernel_patches/common/optimise_memcmp.patch"
  98. elif [ "$(printf '%s\n' "$KERNEL_VERSION" "5.11" | sort -V | tail -n1)" = "$KERNEL_VERSION" ]; then
  99. sed -e 's/SYM_FUNC_START(__pi_memcmp)/SYM_FUNC_START_WEAK_PI(memcmp)/' -e 's/SYM_FUNC_END(__pi_memcmp)/SYM_FUNC_END_PI(memcmp)/' -e 's/SYM_FUNC_ALIAS_WEAK(memcmp, __pi_memcmp)/EXPORT_SYMBOL_NOKASAN(memcmp)/' "${{ github.workspace }}/kernel_patches/common/optimise_memcmp.patch" | patch -p1 --forward
  100. else
  101. echo "Optimised memcmp patch not found!"
  102. fi
  103. patch -p1 --forward < "${{ github.workspace }}/kernel_patches/common/minimise_wakeup_time.patch"
  104. patch -p1 --forward < "${{ github.workspace }}/kernel_patches/common/int_sqrt.patch"
  105. patch -p1 --forward < "${{ github.workspace }}/kernel_patches/common/force_tcp_nodelay.patch"
  106. patch -p1 --forward < "${{ github.workspace }}/kernel_patches/common/reduce_gc_thread_sleep_time.patch"
  107. patch -p1 --forward < "${{ github.workspace }}/kernel_patches/common/add_timeout_wakelocks_globally.patch"
  108. patch -p1 --forward < "${{ github.workspace }}/kernel_patches/common/f2fs_reduce_congestion.patch"
  109. patch -p1 --forward < "${{ github.workspace }}/kernel_patches/common/reduce_freeze_timeout.patch"
  110. if [ "$(printf '%s\n' "$KERNEL_VERSION" "$MIN_VERSION" | sort -V | head -n1)" = "$KERNEL_VERSION" ]; then
  111. patch -p1 --forward < "${{ github.workspace }}/kernel_patches/common/clear_page_16bytes_align.patch"
  112. else
  113. cat "${{ github.workspace }}/kernel_patches/common/clear_page_16bytes_align.patch" | sed -e 's/SYM_FUNC_START_PI(clear_page)/SYM_FUNC_START_PI(__pi_clear_page)/' | patch -p1 -F3 --forward
  114. fi
  115. echo "Patching add_limitation_scaling_min_freq.patch"
  116. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/add_limitation_scaling_min_freq.patch"
  117. echo "Patching re_write_limitation_scaling_min_freq.patch"
  118. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/re_write_limitation_scaling_min_freq.patch"
  119. echo "Patching adjust_cpu_scan_order.patch"
  120. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/adjust_cpu_scan_order.patch"
  121. echo "Patching avoid_extra_s2idle_wake_attempts.patch"
  122. FILE="drivers/base/power/wakeup.c"
  123. # Check if the function exists
  124. if grep -q "^void pm_system_wakeup(void)" "$FILE"; then
  125. # Check if the line exists inside the function
  126. if sed -n '/^void pm_system_wakeup(void)/,/^}/p' "$FILE" | grep -q 'suspend_abort_fs_sync();'; then
  127. # Remove the line
  128. sed -i '/^void pm_system_wakeup(void)/,/^}/{
  129. /suspend_abort_fs_sync();/d
  130. }' "$FILE"
  131. fi
  132. fi
  133. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/avoid_extra_s2idle_wake_attempts.patch"
  134. echo "Patching disable_cache_hot_buddy.patch"
  135. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/disable_cache_hot_buddy.patch"
  136. echo "Patching f2fs_enlarge_min_fsync_blocks.patch"
  137. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/f2fs_enlarge_min_fsync_blocks.patch"
  138. echo "Patching increase_ext4_default_commit_age.patch"
  139. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/increase_ext4_default_commit_age.patch"
  140. echo "Patching increase_sk_mem_packets.patch"
  141. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/increase_sk_mem_packets.patch"
  142. echo "Patching reduce_pci_pme_wakeups.patch"
  143. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/reduce_pci_pme_wakeups.patch"
  144. echo "Patching silence_irq_cpu_logspam.patch"
  145. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/silence_irq_cpu_logspam.patch"
  146. echo "Patching silence_system_logspam.patch"
  147. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/silence_system_logspam.patch"
  148. echo "Patching use_unlikely_wrap_cpufreq.patch"
  149. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/use_unlikely_wrap_cpufreq.patch"
  150. echo "✅ Other patches applied"