Skip to content

Commit caf2ef0

Browse files
committed
Import scripts and actions workflow
Signed-off-by: Yahya Wessam <yahyawessam2002@gmail.com>
1 parent a04ca2f commit caf2ef0

7 files changed

Lines changed: 268 additions & 0 deletions

File tree

.github/workflows/compile-aosp.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Compiling kernel for AOSP
2+
3+
on:
4+
push:
5+
branches:
6+
- "AOSP-buildout"
7+
8+
jobs:
9+
compile:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout current repo
14+
uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 1
17+
18+
- name: Set up dependencies
19+
run: |
20+
sudo apt update
21+
sudo apt install bc build-essential bison flex zip p7zip-full libc6 curl libstdc++6 git wget libssl-dev zstd lld python3 -y
22+
23+
- name: Set Build Variables
24+
run: |
25+
echo "ZIPNAME=[AOSP]-Spiteful-sweet-$(date '+%Y%m%d').zip" >> $GITHUB_ENV
26+
echo "START_TIME=$(date +%s)" >> $GITHUB_ENV
27+
28+
- name: Setup Telegram bot
29+
env:
30+
TELEGRAM_TOKEN: ${{ secrets.tg_token }}
31+
TELEGRAM_CHAT: ${{ secrets.tg_chat }}
32+
run: |
33+
wget https://raw.githubusercontent.com/fabianonline/telegram.sh/refs/heads/master/telegram
34+
chmod +x ./telegram
35+
36+
- name: Clone KernelSU-Next and compile
37+
# --- FIX: 'run:' was incorrectly indented ---
38+
run: |
39+
git clone https://github.com/vbajs/KernelSU-Next --depth=1 -b next KernelSU
40+
export KSU_BASE="ksun"
41+
chmod +x ./compile.sh
42+
./compile.sh
43+
44+
- name: Clone RissuKSU and compile
45+
# --- FIX: 'run:' was incorrectly indented ---
46+
run: |
47+
rm -rf KernelSU
48+
git clone https://github.com/rsuntk/KernelSU --depth=1 -b v1.0.5-75-legacy KernelSU
49+
export KSU_BASE="rksu"
50+
make O=out mrproper
51+
./compile.sh
52+
53+
- name: Compile without KSU
54+
# --- FIX: 'run:' was incorrectly indented ---
55+
run: |
56+
rm -rf KernelSU
57+
patch -p1 < revert-ksu-config.patch
58+
unset KSU_BASE
59+
make O=out mrproper
60+
./compile.sh
61+
62+
- name: Zip up and send to telegram
63+
# --- FIX: 'run:' was incorrectly indented ---
64+
run: |
65+
END_TIME=$(date +%s)
66+
DURATION=$((END_TIME - START_TIME))
67+
# --- FIX: Added a closing quote " at the end of the line ---
68+
HASH="$(echo $(git rev-parse --verify HEAD 2>/dev/null) | cut -c1-8)"
69+
chmod +x ./zipup.sh
70+
./zipup.sh
71+
echo "Zip: $ZIPNAME"
72+
./telegram -f $ZIPNAME -C "Completed in $((DURATION / 60)) minute(s) and $((DURATION % 60)) second(s) ! Latest commit: $HASH"
73+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
CONFIG_KSU=y
2+
CONFIG_KSU_LSM_SECURITY_HOOKS=y
3+
CONFIG_KSU_SUSFS=y
4+
CONFIG_KSU_SUSFS_HAS_MAGIC_MOUNT=y
5+
CONFIG_KSU_SUSFS_SUS_PATH=y
6+
CONFIG_KSU_SUSFS_SUS_MOUNT=y
7+
CONFIG_KSU_SUSFS_AUTO_ADD_SUS_KSU_DEFAULT_MOUNT=y
8+
CONFIG_KSU_SUSFS_AUTO_ADD_SUS_BIND_MOUNT=y
9+
CONFIG_KSU_SUSFS_SUS_KSTAT=y
10+
CONFIG_KSU_SUSFS_TRY_UMOUNT=y
11+
CONFIG_KSU_SUSFS_AUTO_ADD_TRY_UMOUNT_FOR_BIND_MOUNT=y
12+
CONFIG_KSU_SUSFS_SPOOF_UNAME=y
13+
CONFIG_KSU_SUSFS_ENABLE_LOG=y
14+
CONFIG_KSU_SUSFS_HIDE_KSU_SUSFS_SYMBOLS=y
15+
CONFIG_KSU_SUSFS_SPOOF_CMDLINE_OR_BOOTCONFIG=y
16+
CONFIG_KSU_SUSFS_OPEN_REDIRECT=y
17+
CONFIG_KSU_SUSFS_SUS_MAP=y
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_KSU=y
2+
CONFIG_KSU_MANUAL_HOOK=y

compile.sh

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
#!/bin/bash
2+
#
3+
# Compile script for kernel
4+
#
5+
6+
# Exit immediately if a command exits with a non-zero status.
7+
set -e
8+
9+
# Start builtin bash timer
10+
SECONDS=0
11+
12+
# --- Helper Functions ---
13+
14+
check_variables() {
15+
if [ "$KSU_BASE" ]; then
16+
# This block runs if $KSU_BASE is set and NOT empty
17+
echo "KSU_BASE is set to: $KSU_BASE"
18+
else
19+
# This block runs if $KSU_BASE is unset OR empty (e.g., KSU_BASE="")
20+
echo "KSU_BASE is not set."
21+
fi
22+
}
23+
24+
setup_environment() {
25+
echo "Setting up build environment..."
26+
export ARCH=arm64
27+
export KBUILD_BUILD_USER=vbajs
28+
export KBUILD_BUILD_HOST=tbyool
29+
30+
export GCC64_DIR=$PWD/gcc64
31+
export GCC32_DIR=$PWD/gcc32
32+
}
33+
34+
setup_toolchain() {
35+
echo "Setting up toolchains..."
36+
37+
# Setup Clang
38+
if [ ! -d "$PWD/clang" ]; then
39+
echo "Cloning Clang..."
40+
git clone https://gitlab.com/crdroidandroid/android_prebuilts_clang_host_linux-x86_clang-r547379.git --depth=1 -b 15.0 clang
41+
else
42+
echo "Local clang dir found, using it."
43+
fi
44+
45+
# Setup GCC
46+
if [ ! -d "$PWD/gcc32" ] && [ ! -d "$PWD/gcc64" ]; then
47+
echo "Downloading GCC..."
48+
ASSET_URLS=$(curl -s "https://api.github.com/repos/mvaisakh/gcc-build/releases/latest" | grep "browser_download_url" | cut -d '"' -f 4 | grep -E "eva-gcc-arm.*\.xz")
49+
for url in $ASSET_URLS; do
50+
wget --content-disposition -L "$url"
51+
done
52+
53+
for file in eva-gcc-arm*.xz; do
54+
# The files are actually just plain tarballs named as .xz
55+
if [[ "$file" == *arm64* ]]; then
56+
tar -xf "$file" && mv gcc-arm64 gcc64
57+
else
58+
tar -xf "$file" && mv gcc-arm gcc32
59+
fi
60+
rm -rf "$file"
61+
done
62+
else
63+
echo "Local gcc dirs found, using them."
64+
fi
65+
}
66+
67+
update_path() {
68+
echo "Updating PATH..."
69+
export GCC64_DIR=$PWD/gcc64
70+
export GCC32_DIR=$PWD/gcc32
71+
export PATH="$PWD/clang/bin/:$GCC64_DIR/bin/:$GCC32_DIR/bin/:/usr/bin:$PATH"
72+
}
73+
74+
compile_kernel() {
75+
echo -e "\nStarting compilation..."
76+
77+
# 1. Make the base defconfig
78+
make O=out ARCH=arm64 sweet_defconfig
79+
if [ "$KSU_BASE" ]; then
80+
make O=out ARCH=arm64 vendor/{$KSU_BASE}.config
81+
fi
82+
83+
# 3. Run the main build
84+
make -j$(nproc --all) \
85+
O=out \
86+
ARCH=arm64 \
87+
LLVM=1 \
88+
LLVM_IAS=1 \
89+
CROSS_COMPILE=$GCC64_DIR/bin/aarch64-elf- \
90+
CROSS_COMPILE_COMPAT=$GCC32_DIR/bin/arm-eabi-
91+
}
92+
93+
package_output() {
94+
echo -e "\nPackaging outputs..."
95+
96+
local kernel="out/arch/arm64/boot/Image"
97+
local dtbo="out/arch/arm64/boot/dtbo.img"
98+
local dtb="out/arch/arm64/boot/dtb.img"
99+
100+
if [ ! -f "$kernel" ] || [ ! -f "$dtbo" ] || [ ! -f "$dtb" ]; then
101+
echo -e "\nCompilation failed! Output files not found."
102+
exit 1
103+
fi
104+
105+
# Copy outputs to current directory with KSU_BASE prefix if exists
106+
if [ "$KSU_BASE" ]; then
107+
cp "$kernel" "./${KSU_BASE}-Image"
108+
else
109+
cp "$kernel" "./Image"
110+
fi
111+
cp "$dtbo" "./dtbo.img"
112+
cp "$dtb" "./dtb.img"
113+
114+
echo "Outputs copied to root directory with prefix '${KSU_BASE}'"
115+
}
116+
117+
print_summary() {
118+
echo -e "\nCompleted in $((SECONDS / 60)) minute(s) and $((SECONDS % 60)) second(s) !"
119+
}
120+
121+
# --- Main Execution ---
122+
123+
main() {
124+
check_variables
125+
setup_environment
126+
setup_toolchain
127+
update_path
128+
compile_kernel
129+
package_output
130+
print_summary
131+
}
132+
133+
# Run the main function
134+
main

drivers/kernelsu

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../KernelSU/kernel

revert-ksu-config.patch

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
diff --git a/drivers/Kconfig b/drivers/Kconfig
2+
index 3c4623814d2f..fd1806645ec5 100644
3+
--- a/drivers/Kconfig
4+
+++ b/drivers/Kconfig
5+
@@ -229,6 +229,4 @@ source "drivers/esoc/Kconfig"
6+
7+
source "drivers/kprofiles/Kconfig"
8+
9+
-source "drivers/kernelsu/Kconfig"
10+
-
11+
endmenu
12+
diff --git a/drivers/Makefile b/drivers/Makefile
13+
index 3177fd028c83..eeefcca58dfd 100644
14+
--- a/drivers/Makefile
15+
+++ b/drivers/Makefile
16+
@@ -194,5 +194,3 @@ obj-$(CONFIG_GNSS_SIRF) += gnsssirf/
17+
obj-$(CONFIG_GNSS) += gnss/
18+
19+
obj-$(CONFIG_KPROFILES) += kprofiles/
20+
-
21+
-obj-$(CONFIG_KSU) += kernelsu/

zipup.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
#
3+
# Zipup script for kernel
4+
#
5+
6+
# Exit immediately if a command exits with a non-zero status.
7+
set -e
8+
9+
7z a -t7z -mx=9 "Image.7z" ./*-Image ./Image
10+
if ! git clone https://github.com/tbyool/AnyKernel3.git -b master AnyKernel3; then
11+
echo -e "\nCouldn't clone AnyKernel3! Aborting..."
12+
exit 1
13+
fi
14+
cp ./Image.7z AnyKernel3
15+
cp ./dtbo.img AnyKernel3
16+
cp ./dtb.img AnyKernel3
17+
cd AnyKernel3
18+
zip -r9 "../$ZIPNAME" * -x .git README.md
19+
cd ..
20+
rm -rf AnyKernel3

0 commit comments

Comments
 (0)