Skip to content

Commit 401bc92

Browse files
committed
build.sh: Cleanup and add more features
Signed-off-by: Addster09 <aadityasingh.cs9@gmail.com>
1 parent 13ffb64 commit 401bc92

1 file changed

Lines changed: 26 additions & 20 deletions

File tree

build.sh

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/bin/bash
22

3-
# Compile script for Hydrogen kernel
4-
# Optimized by ChatGPT
3+
# Compile script for Aqua kernel
54

65
# Remove out directory
76
rm -rf out/arch/arm64/boot
@@ -48,23 +47,36 @@ echo
4847
CLEAN_BUILD=false
4948
INCLUDE_KSU=false
5049

50+
for arg in "$@"; do
51+
case $arg in
52+
--clean)
53+
CLEAN_BUILD=true
54+
;;
55+
--with-ksu)
56+
INCLUDE_KSU=true
57+
;;
58+
--redo-ksu)
59+
rm -f .ksu_applied
60+
INCLUDE_KSU=true
61+
;;
62+
esac
63+
done
64+
5165
# Perform clean build if specified
5266
[ "$CLEAN_BUILD" = true ] && rm -rf out
5367

68+
[ -f .ksu_applied ] && echo "Including KernelSU Next!"
69+
5470
# Include KernelSU if specified
55-
if [ "$INCLUDE_KSU" = true ]; then
56-
echo "Including KernelSU Next... Save your stuff!"
57-
curl -LSs "https://raw.githubusercontent.com/KernelSU-Next/KernelSU-Next/next/kernel/setup.sh" | bash -s next
58-
git clone https://github.com/WildKernels/kernel_patches.git kernel_patches
59-
cd KernelSU-Next
60-
wget -q https://github.com/devnoname120/susfs4ksu-toco/raw/refs/heads/kernel-4.14-backport/kernel_patches/KernelSU/10_enable_susfs_for_ksu.patch
61-
patch -p1 --forward < 10_enable_susfs_for_ksu.patch
62-
for file in $(find ./kernel -maxdepth 2 -name "*.rej" -printf "%f\n" | cut -d'.' -f1); do
63-
echo "Patching file: $file.c with fix_$file.c.patch"
64-
patch -p1 --forward < "../kernel_patches/next/susfs_fix_patches/v1.5.9/fix_$file.c.patch"
71+
if [[ "$INCLUDE_KSU" = true && ! -f .ksu_applied ]]; then
72+
echo "Including KernelSU Next!"
73+
git clone https://github.com/Addster09/EverpalPatches --depth=1
74+
for patch in EverpalPatches/KSUPatches/000*.patch; do
75+
patch -p1 < "$patch"
6576
done
66-
sed -i '/susfs_set_kernel_sid();/d' kernel/selinux/rules.c
67-
cd ..
77+
rm -rf EverpalPatches
78+
curl -LSs "https://raw.githubusercontent.com/KernelSU-Next/KernelSU-Next/next/kernel/setup.sh" | bash -s legacy_susfs
79+
touch .ksu_applied
6880
fi
6981

7082
# Compilation process
@@ -92,12 +104,6 @@ if \
92104
(cd AnyKernel3 && zip -r9 "../$ZIPNAME" * -x '*.git*' README.md '*placeholder')
93105
rm -rf AnyKernel3
94106

95-
# Clean up KernelSU changes if applied
96-
if [ "$INCLUDE_KSU" = true ]; then
97-
git restore drivers/{Makefile,Kconfig}
98-
rm -rf KernelSU drivers/kernelsu
99-
fi
100-
101107
echo -e "\nCompleted in $((SECONDS / 60)) minute(s) and $((SECONDS % 60)) second(s)!"
102108
echo "Zip: $ZIPNAME"
103109
else

0 commit comments

Comments
 (0)