name: 'Kernel Fixes' description: 'Applies compatibility fixes based on android/kernel/sublevel' inputs: android_version: required: true type: string kernel_version: required: true type: string sublevel: required: true type: string os_patch_level: required: true type: string runs: using: composite steps: - shell: bash run: | set -euo pipefail ANDROID_VERSION="${{ inputs.android_version }}" KERNEL_VERSION="${{ inputs.kernel_version }}" SUBLEVEL="${{ inputs.sublevel }}" OS_PATCH_LEVEL="${{ inputs.os_patch_level }}" if { [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.10" && "$SUBLEVEL" -le 186 ]] || \ [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.15" && "$SUBLEVEL" -le 119 ]] || \ [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "5.15" && "$SUBLEVEL" -le 110 ]] || \ [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "6.1" && "$SUBLEVEL" -le 43 ]]; }; then GLIBC_VERSION="$(ldd --version 2>/dev/null | head -n 1 | awk '{print $NF}')" if [ "$(printf '%s\n' "2.38" "$GLIBC_VERSION" | sort -V | head -n 1)" = "2.38" ]; then cd "$GITHUB_WORKSPACE/kernel/common" sed -i '/\$(Q)\$(MAKE) -C \$(SUBCMD_SRC) OUTPUT=\$(abspath \$(dir \$@))\/ \$(abspath \$@)/s//$(Q)$(MAKE) -C $(SUBCMD_SRC) EXTRA_CFLAGS="$(CFLAGS)" OUTPUT=$(abspath $(dir $@))\/ $(abspath $@)/' tools/bpf/resolve_btfids/Makefile 2>/dev/null || true if { [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.10" && "$SUBLEVEL" -le 186 ]] || \ [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.15" && "$SUBLEVEL" -le 119 ]] || \ [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "5.15" && "$SUBLEVEL" -le 110 ]]; }; then sed -i '/char \*buf = NULL;/a int i;' tools/lib/subcmd/parse-options.c 2>/dev/null || true sed -i 's/for (int i = 0; subcommands\[i\]; i++) {/for (i = 0; subcommands[i]; i++) {/' tools/lib/subcmd/parse-options.c 2>/dev/null || true sed -i '/if (subcommands) {/a int i;' tools/lib/subcmd/parse-options.c 2>/dev/null || true sed -i 's/for (int i = 0; subcommands\[i\]; i++)/for (i = 0; subcommands[i]; i++)/' tools/lib/subcmd/parse-options.c 2>/dev/null || true fi fi fi if [ "$ANDROID_VERSION" = "android15" ] && [ "$KERNEL_VERSION" = "6.6" ]; then cd "$GITHUB_WORKSPACE/kernel/common" if ! grep -qxF '#include ' ./fs/namespace.c; then sed -i '/#include /a #include ' ./fs/namespace.c fi fi