Update SCX Patch #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | ||
permissions: | ||
contents: write # Allow writing to repository contents (for pushing tags) | ||
actions: write # Allows triggering actions | ||
on: | ||
workflow_call: # This allows this workflow to be called from another workflow | ||
inputs: | ||
model: | ||
required: true | ||
type: string | ||
soc: | ||
required: true | ||
type: string | ||
branch: | ||
required: true | ||
type: string | ||
manifest: | ||
required: true | ||
type: string | ||
android_version: | ||
required: true | ||
type: string | ||
kernel_version: | ||
required: true | ||
type: string | ||
ksun_branch: | ||
required: true | ||
type: string | ||
default: stable | ||
jobs: | ||
build-kernel-oneplus-kernelsu-susfs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup System | ||
run: | | ||
export DEBIAN_FRONTEND=noninteractive | ||
echo "DEBIAN_FRONTEND=noninteractive" >> $GITHUB_ENV | ||
df -h | ||
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /usr/local/.ghcup /opt/hostedtoolcache/CodeQL /usr/local/share/powershell /usr/share/swift || true | ||
sudo docker image prune --all --force | ||
echo "some directories deleted" | ||
# Remove large unwanted packages | ||
sudo apt-get purge -y \ | ||
aria2 ansible azure-cli shellcheck rpm xorriso zsync \ | ||
esl-erlang firefox gfortran-8 gfortran-9 google-chrome-stable \ | ||
google-cloud-sdk imagemagick \ | ||
libmagickcore-dev libmagickwand-dev libmagic-dev ant ant-optional kubectl \ | ||
mercurial apt-transport-https mono-complete libmysqlclient \ | ||
unixodbc-dev yarn chrpath libssl-dev libxft-dev \ | ||
libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev \ | ||
snmp pollinate libpq-dev postgresql-client powershell ruby-full \ | ||
sphinxsearch subversion mongodb-org microsoft-edge-stable || true | ||
# Regex-based purges (for bulk families like mysql, php, dotnet) | ||
sudo apt-get purge -y $(dpkg-query -W -f='${binary:Package}\n' | grep -E '^mysql|^php|^dotnet') || true | ||
# Clean up | ||
sudo apt-get autoremove -y | ||
sudo apt-get autoclean -y | ||
echo "some packages purged" | ||
df -h | ||
- name: Install Repo and Python | ||
run: | | ||
# Install dependencies | ||
sudo apt update | ||
sudo apt install -y python3 python-is-python3 | ||
mkdir -p ./git-repo | ||
curl -sSL https://storage.googleapis.com/git-repo-downloads/repo > ./git-repo/repo | ||
chmod a+rx ./git-repo/repo | ||
echo "REPO=$GITHUB_WORKSPACE/./git-repo/repo" >> $GITHUB_ENV | ||
- name: Set CONFIG Environment Variable | ||
run: | | ||
CONFIG="${{ inputs.model }}" | ||
# Set CONFIG as an environment variable for future steps | ||
echo "CONFIG=$CONFIG" >> $GITHUB_ENV | ||
echo "CONFIG set to: $CONFIG" | ||
- name: Clone AnyKernel3 and Other Dependencies | ||
run: | | ||
echo "Cloning AnyKernel3 and other dependencies..." | ||
ANYKERNEL_BRANCH="gki-2.0" | ||
SUSFS_BRANCH="gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}" | ||
# Debug print the branches | ||
echo "Using branch for AnyKernel3: $ANYKERNEL_BRANCH" | ||
echo "Using branch for SUSFS: $SUSFS_BRANCH" | ||
# Clone repositories using the branch names | ||
git clone https://github.com/TheWildJames/AnyKernel3.git -b "$ANYKERNEL_BRANCH" | ||
git clone https://gitlab.com/simonpunk/susfs4ksu.git -b "$SUSFS_BRANCH" | ||
git clone https://github.com/TheWildJames/kernel_patches.git | ||
- name: Initialize and Sync Kernel Source | ||
run: | | ||
echo "Creating folder for configuration: $CONFIG..." | ||
mkdir -p "$CONFIG" | ||
cd "$CONFIG" | ||
# Initialize and sync kernel source | ||
echo "Initializing and syncing kernel source..." | ||
$REPO init -u https://github.com/OnePlusOSS/kernel_manifest.git -b ${{ inputs.branch }} -m ${{ inputs.manifest }} --repo-rev=v2.16 --depth=1 --no-clone-bundle --no-tags | ||
# Sync repo and apply patches | ||
$REPO --version | ||
$REPO --trace sync -c --no-clone-bundle --no-tags --optimized-fetch -j$(nproc --all) --fail-fast | ||
- name: Add KernelSU Next | ||
run: | | ||
echo "Changing to configuration directory: $CONFIG..." | ||
cd "$CONFIG/kernel_platform" | ||
echo "Adding KernelSU Next..." | ||
if [ "${{ inputs.ksun_branch }}" == "stable" ]; then | ||
curl -LSs "https://raw.githubusercontent.com/KernelSU-Next/KernelSU-Next/next/kernel/setup.sh" | bash - | ||
else | ||
curl -LSs "https://raw.githubusercontent.com/KernelSU-Next/KernelSU-Next/next/kernel/setup.sh" | bash -s ${{ inputs.ksun_branch }} | ||
fi | ||
git submodule update --init --recursive | ||
- name: Apply SUSFS Patches | ||
run: | | ||
echo "Changing to configuration directory: $CONFIG..." | ||
cd "$CONFIG/kernel_platform" | ||
echo "Applying SUSFS patches..." | ||
# Copy SUSFS patches | ||
cp ../../susfs4ksu/kernel_patches/50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch ./common/ | ||
cp ../../susfs4ksu/kernel_patches/fs/* ./common/fs/ | ||
cp ../../susfs4ksu/kernel_patches/include/linux/* ./common/include/linux/ | ||
cd ./KernelSU-Next | ||
if [ "${{ inputs.ksun_branch }}" == "stable" ] || [ "${{ inputs.ksun_branch }}" == "next" ]; then | ||
echo "Applying next SUSFS patches..." | ||
cp ../../../kernel_patches/next/ksun_susfs_v1.5.7_patch_12647+.patch ./ksun_susfs_latest.patch | ||
patch -p1 --forward < ksun_susfs_latest.patch || true | ||
fi | ||
# Determine base version based on branch | ||
case "${{ inputs.ksun_branch }}" in | ||
next|stable) | ||
BASE_VERSION=10200 | ||
;; | ||
next-susfs|next-susfs-dev) | ||
BASE_VERSION=10198 | ||
;; | ||
*) | ||
BASE_VERSION=10200 | ||
;; | ||
esac | ||
cd ./kernel | ||
KSU_VERSION=$(expr $(/usr/bin/git rev-list --count HEAD) "+" $BASE_VERSION) | ||
echo "KSUVER=$KSU_VERSION" >> $GITHUB_ENV | ||
sed -i "s/DKSU_VERSION=11998/DKSU_VERSION=${KSU_VERSION}/" Makefile | ||
# Change to common directory and apply SUSFS patch | ||
cd ../../common | ||
if [ "${{ inputs.soc }}" = "sun" ]; then | ||
if ! grep -qxF '#include <trace/hooks/fs.h>' ./fs/namespace.c; then | ||
sed -i '/#include <trace\/hooks\/blk.h>/a #include <trace\/hooks\/fs.h>' ./fs/namespace.c | ||
else | ||
echo "Line already present. Skipping insert." | ||
fi | ||
fi | ||
patch -p1 < 50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch || true | ||
if ! grep -qxF '#define CMD_SUSFS_HIDE_SUS_MNTS_FOR_ALL_PROCS 0x55561' ./include/linux/susfs_def.h; then | ||
curl -Ls https://raw.githubusercontent.com/fatalcoder524/kernel_patches_additional/refs/heads/main/hide_sus_mnts_for_all_procs.patch | patch -p1 -F 3 | ||
else | ||
echo "Line already present. Skipping SUSFS_HIDE_SUS_MNTS_FOR_ALL_PROCS Patch." | ||
fi | ||
KERNEL_VERSION="${{ inputs.kernel_version }}" | ||
MIN_VERSION="5.16" | ||
if [ "$(printf '%s\n' "$KERNEL_VERSION" "$MIN_VERSION" | sort -V | head -n1)" = "$KERNEL_VERSION" ]; then | ||
echo "Patching ptrace!" | ||
curl -Ls https://raw.githubusercontent.com/fatalcoder524/kernel_patches_additional/refs/heads/main/ptrace.patch | patch -p1 -F 3 | ||
else | ||
echo "Kernel >= $MIN_VERSION, skipping ptrace patch" | ||
fi | ||
if [ "${{ inputs.model }}" == "OPAce5Pro" ] || [ "${{ inputs.model }}" == "OP13" ]; then | ||
echo "Patching hmdird!" | ||
echo 'obj-y += hmbird_patch.o' >> ./drivers/Makefile | ||
curl -Ls https://raw.githubusercontent.com/Numbersf/Action-Build/refs/heads/SukiSU-Ultra/patches/hmbird_patch.patch | patch -p1 -F 3 --verbose | ||
echo "Patching hmbird files!" | ||
# curl -Ls https://github.com/schqiushui/android_kernel_common_oneplus_sm8750/commit/5d2cc9706a35f5e4b5dbbd5d247487225a46e02c.patch | patch -p1 -F 3 | ||
cd ./kernel/sched | ||
rm -rf ext.c ext.h build_policy.c slim.h slim_sysctl.c | ||
curl -Ls https://github.com/HanKuCha/sched_ext/commit/7ab1d04d5cb622d6c32c932add617803074ec5a7.patch | patch -p1 -F 3 | ||
else | ||
echo "Not OPAce5Pro / OP13, skipping fengchi patch" | ||
fi | ||
- name: Apply KSUN Hooks | ||
run: | | ||
echo "Changing to configuration directory: $CONFIG..." | ||
cd "$CONFIG/kernel_platform/common" | ||
echo "Applying KSUN Hooks..." | ||
cp ../../../kernel_patches/next/scope_min_manual_hooks_v1.4.patch ./manual_hooks.patch | ||
patch -p1 --fuzz=3 < ./manual_hooks.patch | ||
- name: Apply Hide Stuff Patches | ||
run: | | ||
echo "Changing to configuration directory: $CONFIG..." | ||
cd "$CONFIG/kernel_platform/common" | ||
# Apply additional patch | ||
cp ../../../kernel_patches/69_hide_stuff.patch ./ | ||
patch -p1 -F 3 < 69_hide_stuff.patch | ||
- name: Add KernelSU-Next and SUSFS Configuration Settings | ||
run: | | ||
echo "Changing to configuration directory: $CONFIG..." | ||
cd "$CONFIG/kernel_platform" | ||
echo "Adding configuration settings to gki_defconfig..." | ||
# Add KSU configuration settings | ||
echo "CONFIG_KSU=y" >> ./common/arch/arm64/configs/gki_defconfig | ||
echo "CONFIG_KSU_KPROBES_HOOK=n" >> ./common/arch/arm64/configs/gki_defconfig | ||
# Add SUSFS configuration settings | ||
echo "CONFIG_KSU_SUSFS=y" >> ./common/arch/arm64/configs/gki_defconfig | ||
echo "CONFIG_KSU_SUSFS_HAS_MAGIC_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig | ||
echo "CONFIG_KSU_SUSFS_SUS_PATH=y" >> ./common/arch/arm64/configs/gki_defconfig | ||
echo "CONFIG_KSU_SUSFS_SUS_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig | ||
echo "CONFIG_KSU_SUSFS_AUTO_ADD_SUS_KSU_DEFAULT_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig | ||
echo "CONFIG_KSU_SUSFS_AUTO_ADD_SUS_BIND_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig | ||
echo "CONFIG_KSU_SUSFS_SUS_KSTAT=y" >> ./common/arch/arm64/configs/gki_defconfig | ||
echo "CONFIG_KSU_SUSFS_SUS_OVERLAYFS=n" >> ./common/arch/arm64/configs/gki_defconfig | ||
echo "CONFIG_KSU_SUSFS_TRY_UMOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig | ||
echo "CONFIG_KSU_SUSFS_AUTO_ADD_TRY_UMOUNT_FOR_BIND_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig | ||
echo "CONFIG_KSU_SUSFS_SPOOF_UNAME=y" >> ./common/arch/arm64/configs/gki_defconfig | ||
echo "CONFIG_KSU_SUSFS_ENABLE_LOG=y" >> ./common/arch/arm64/configs/gki_defconfig | ||
echo "CONFIG_KSU_SUSFS_HIDE_KSU_SUSFS_SYMBOLS=y" >> ./common/arch/arm64/configs/gki_defconfig | ||
echo "CONFIG_KSU_SUSFS_SPOOF_CMDLINE_OR_BOOTCONFIG=y" >> ./common/arch/arm64/configs/gki_defconfig | ||
echo "CONFIG_KSU_SUSFS_OPEN_REDIRECT=y" >> ./common/arch/arm64/configs/gki_defconfig | ||
echo "CONFIG_KSU_SUSFS_SUS_SU=n" >> ./common/arch/arm64/configs/gki_defconfig | ||
# Add additional tmpfs config setting | ||
echo "CONFIG_TMPFS_XATTR=y" >> ./common/arch/arm64/configs/gki_defconfig | ||
echo "CONFIG_TMPFS_POSIX_ACL=y" >> ./common/arch/arm64/configs/gki_defconfig | ||
- name: Add BBR Support | ||
run: | | ||
echo "Changing to configuration directory: $CONFIG..." | ||
cd "$CONFIG/kernel_platform" | ||
echo "Adding configuration settings to gki_defconfig..." | ||
echo "CONFIG_TCP_CONG_ADVANCED=y" >> ./common/arch/arm64/configs/gki_defconfig | ||
echo "CONFIG_TCP_CONG_BBR=y" >> ./common/arch/arm64/configs/gki_defconfig | ||
echo "CONFIG_TCP_CONG_BIC=n" >> ./common/arch/arm64/configs/gki_defconfig | ||
echo "CONFIG_TCP_CONG_WESTWOOD=n" >> ./common/arch/arm64/configs/gki_defconfig | ||
echo "CONFIG_TCP_CONG_HTCP=n" >> ./common/arch/arm64/configs/gki_defconfig | ||
echo "CONFIG_NET_SCH_FQ=y" >> ./common/arch/arm64/configs/gki_defconfig | ||
echo "CONFIG_NET_SCH_FQ_CODEL=y" >> ./common/arch/arm64/configs/gki_defconfig | ||
- name: Add TTL Target Support | ||
run: | | ||
echo "Changing to configuration directory: $CONFIG..." | ||
cd "$CONFIG/kernel_platform" | ||
echo "Adding configuration settings to gki_defconfig..." | ||
echo "CONFIG_IP_NF_TARGET_TTL=y" >> ./common/arch/arm64/configs/gki_defconfig | ||
echo "CONFIG_IP6_NF_TARGET_HL=y" >> ./common/arch/arm64/configs/gki_defconfig | ||
echo "CONFIG_IP6_NF_MATCH_HL=y" >> ./common/arch/arm64/configs/gki_defconfig | ||
- name: Run sed and perl Commands | ||
run: | | ||
echo "Changing to configuration directory: $CONFIG..." | ||
cd "$CONFIG/kernel_platform" | ||
echo "Running sed commands..." | ||
sed -i 's/CONFIG_LTO=n/CONFIG_LTO=y/' "./common/arch/arm64/configs/gki_defconfig" | ||
sed -i 's/CONFIG_LTO_CLANG_FULL=y/CONFIG_LTO_CLANG_THIN=y/' "./common/arch/arm64/configs/gki_defconfig" | ||
sed -i 's/CONFIG_LTO_CLANG_NONE=y/CONFIG_LTO_CLANG_THIN=y/' "./common/arch/arm64/configs/gki_defconfig" | ||
# Run sed commands for modifications | ||
sed -i 's/check_defconfig//' ./common/build.config.gki | ||
# For Old setlocalversion Script | ||
tac ./common/scripts/setlocalversion | sed '0,/echo "\$res"/s//res=\$\(echo \$res \| cut -d- -f1-2\)-OP-Wild\;echo "\$res"\;/' | tac > ./common/scripts/setlocalversion.tmp && mv ./common/scripts/setlocalversion.tmp ./common/scripts/setlocalversion | ||
tac ./msm-kernel/scripts/setlocalversion | sed '0,/echo "\$res"/s//res=\$\(echo \$res \| cut -d- -f1-2\)-OP-Wild\;echo "\$res"\;/' | tac > ./msm-kernel/scripts/setlocalversion.tmp && mv ./msm-kernel/scripts/setlocalversion.tmp ./msm-kernel/scripts/setlocalversion | ||
tac ./external/dtc/scripts/setlocalversion | sed '0,/echo "\$res"/s//res=\$\(echo \$res \| cut -d- -f1-2\)-OP-Wild\;echo "\$res"\;/' | tac > ./external/dtc/scripts/setlocalversion.tmp && mv ./external/dtc/scripts/setlocalversion.tmp ./external/dtc/scripts/setlocalversion | ||
# For New setlocalversion Script | ||
sed -i 's/echo "${KERNELVERSION}${file_localversion}${config_localversion}${LOCALVERSION}${scm_version}"/echo "${KERNELVERSION}-${{ inputs.android_version }}-OP-Wild"/' ./common/scripts/setlocalversion | ||
sed -i 's/echo "${KERNELVERSION}${file_localversion}${config_localversion}${LOCALVERSION}${scm_version}"/echo "${KERNELVERSION}-${{ inputs.android_version }}-OP-Wild"/' ./msm-kernel/scripts/setlocalversion | ||
sed -i 's/echo "${KERNELVERSION}${file_localversion}${config_localversion}${LOCALVERSION}${scm_version}"/echo "${KERNELVERSION}-${{ inputs.android_version }}-OP-Wild"/' ./external/dtc/scripts/setlocalversion | ||
chmod +x ./common/scripts/setlocalversion | ||
chmod +x ./msm-kernel/scripts/setlocalversion | ||
chmod +x ./external/dtc/scripts/setlocalversion | ||
sed -i "/stable_scmversion_cmd/s/-maybe-dirty//g" ./build/kernel/kleaf/impl/stamp.bzl || echo "No stamp.bzl!" | ||
sed -i 's/-dirty//' ./common/scripts/setlocalversion | ||
sed -i 's/-dirty//' ./msm-kernel/scripts/setlocalversion | ||
sed -i 's/-dirty//' ./external/dtc/scripts/setlocalversion | ||
sed -i 's/-dirty//' ./build/kernel/kleaf/workspace_status_stamp.py || echo "No workspace_status_stamp.py!" | ||
sed -i '/echo "LTO $LTO "/i export LTO=thin' ./oplus/build/oplus_setup.sh | ||
sed -i 's/export REPACK_IMG=true/export REPACK_IMG=false/g' ./oplus/build/oplus_setup.sh | ||
# Run perl command to modify UTS_VERSION | ||
DATESTR=$(date -u) | ||
perl -pi -e 's{UTS_VERSION="\$\(echo \$UTS_VERSION \$CONFIG_FLAGS \$TIMESTAMP \| cut -b -\$UTS_LEN\)"}{UTS_VERSION="#1 SMP PREEMPT $DATESTR"}' ./common/scripts/mkcompile_h | ||
perl -pi -e 's{UTS_VERSION="\$\(echo \$UTS_VERSION \$CONFIG_FLAGS \$TIMESTAMP \| cut -b -\$UTS_LEN\)"}{UTS_VERSION="#1 SMP PREEMPT $DATESTR"}' ./msm-kernel/scripts/mkcompile_h | ||
# find . -type f -exec sed -i 's/\(make\s\+-C[^\n]*\)\s\+/\1 -j$(nproc) /g' {} + | ||
- name: Build the Kernel | ||
run: | | ||
echo "Changing to configuration directory: $CONFIG..." | ||
cd "$CONFIG" | ||
echo "Building the kernel..." | ||
# Clear Cache | ||
sudo sh -c 'sync; echo 3 > /proc/sys/vm/drop_caches' | ||
rm ./kernel_platform/common/android/abi_gki_protected_exports_* || echo "No protected exports!" | ||
rm ./kernel_platform/msm-kernel/android/abi_gki_protected_exports_* || echo "No protected exports!" | ||
BUILD_TYPE="gki" | ||
BAZEL_ARGS=(--jobs=$(nproc --all) --lto=thin) | ||
if [ "${{ inputs.soc }}" == "sun" ]; then | ||
BUILD_TYPE="perf" | ||
BAZEL_ARGS+=(-g) | ||
fi | ||
(stdbuf -oL bash -c ' | ||
while true; do | ||
echo "=== $(date) ===" | ||
free -h | ||
echo "======" | ||
df -h | ||
echo "======" | ||
top -b -n 1 | head -n 15 | ||
echo "" | ||
sleep 60 | ||
done | ||
') & | ||
MONITOR_PID=$! | ||
trap "kill $MONITOR_PID" EXIT | ||
if [ -f ./kernel_platform/build_with_bazel.py ]; then | ||
./kernel_platform/oplus/bazel/oplus_modules_variant.sh ${{ inputs.soc }} "$BUILD_TYPE" "" | ||
./kernel_platform/build_with_bazel.py -t ${{ inputs.soc }} $BUILD_TYPE "${BAZEL_ARGS[@]}" -o "$(pwd)/out" | ||
else | ||
LTO=thin ./kernel_platform/oplus/build/oplus_build_kernel.sh ${{ inputs.soc }} "$BUILD_TYPE" | ||
fi | ||
- name: Copy Images | ||
run: | | ||
echo "Changing to configuration directory: $CONFIG..." | ||
cd "$CONFIG" | ||
echo "Copying Image" | ||
cp ./out/dist/Image ../AnyKernel3/Image | ||
- name: Create ZIP Files for Different Formats | ||
run: | | ||
echo "Navigating to AnyKernel3 directory..." | ||
cd ./AnyKernel3 | ||
# Zip the files in the AnyKernel3 directory with a new naming convention | ||
ZIP_NAME="${{ inputs.model }}_${{ inputs.android_version }}_${{ inputs.kernel_version }}_Next_SUSFS_AnyKernel3.zip" | ||
echo "Creating zip file $ZIP_NAME..." | ||
zip -r "../$ZIP_NAME" ./* | ||
- name: Upload Build Artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: kernel-${{ env.CONFIG }} | ||
path: | | ||
*.zip |