Skip to content

Commit 23a6948

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

File tree

6 files changed

+266
-0
lines changed

6 files changed

+266
-0
lines changed

.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 ./drivers/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 ./drivers/kernelsu
48+
git clone https://github.com/rsuntk/KernelSU --depth=1 -b v1.0.5-75-legacy ./drivers/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 ./drivers/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: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
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 [ -z "$KSU_BASE" ]; then
16+
echo "Warning: KSU_BASE environment variable is not set."
17+
echo "Please set it to the name of the .config fragment to apply for compiling KSU"
18+
echo "Example: export KSU_BASE=\"rksu\""
19+
echo "Assuming building with NoSU now..."
20+
fi
21+
}
22+
23+
setup_environment() {
24+
echo "Setting up build environment..."
25+
export ARCH=arm64
26+
export KBUILD_BUILD_USER=vbajs
27+
export KBUILD_BUILD_HOST=tbyool
28+
29+
export GCC64_DIR=$PWD/gcc64
30+
export GCC32_DIR=$PWD/gcc32
31+
}
32+
33+
setup_toolchain() {
34+
echo "Setting up toolchains..."
35+
36+
# Setup Clang
37+
if [ ! -d "$PWD/clang" ]; then
38+
echo "Cloning Clang..."
39+
git clone https://gitlab.com/crdroidandroid/android_prebuilts_clang_host_linux-x86_clang-r547379.git --depth=1 -b 15.0 clang
40+
else
41+
echo "Local clang dir found, using it."
42+
fi
43+
44+
# Setup GCC
45+
if [ ! -d "$PWD/gcc32" ] && [ ! -d "$PWD/gcc64" ]; then
46+
echo "Downloading GCC..."
47+
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")
48+
for url in $ASSET_URLS; do
49+
wget --content-disposition -L "$url"
50+
done
51+
52+
for file in eva-gcc-arm*.xz; do
53+
# The files are actually just plain tarballs named as .xz
54+
if [[ "$file" == *arm64* ]]; then
55+
tar -xf "$file" && mv gcc-arm64 gcc64
56+
else
57+
tar -xf "$file" && mv gcc-arm gcc32
58+
fi
59+
rm -rf "$file"
60+
done
61+
else
62+
echo "Local gcc dirs found, using them."
63+
fi
64+
}
65+
66+
update_path() {
67+
echo "Updating PATH..."
68+
export GCC64_DIR=$PWD/gcc64
69+
export GCC32_DIR=$PWD/gcc32
70+
export PATH="$PWD/clang/bin/:$GCC64_DIR/bin/:$GCC32_DIR/bin/:/usr/bin:$PATH"
71+
}
72+
73+
compile_kernel() {
74+
echo -e "\nStarting compilation..."
75+
76+
# 1. Make the base defconfig
77+
make O=out ARCH=arm64 sweet_defconfig
78+
if [ -z "$KSU_BASE" ]; then
79+
make O=out ARCH=arm64 vendor/{$KSU_BASE}.config
80+
fi
81+
82+
# 3. Run the main build
83+
make -j$(nproc --all) \
84+
O=out \
85+
ARCH=arm64 \
86+
LLVM=1 \
87+
LLVM_IAS=1 \
88+
CROSS_COMPILE=$GCC64_DIR/bin/aarch64-elf- \
89+
CROSS_COMPILE_COMPAT=$GCC32_DIR/bin/arm-eabi-
90+
}
91+
92+
package_output() {
93+
echo -e "\nPackaging outputs..."
94+
95+
local kernel="out/arch/arm64/boot/Image"
96+
local dtbo="out/arch/arm64/boot/dtbo.img"
97+
local dtb="out/arch/arm64/boot/dtb.img"
98+
99+
if [ ! -f "$kernel" ] || [ ! -f "$dtbo" ] || [ ! -f "$dtb" ]; then
100+
echo -e "\nCompilation failed! Output files not found."
101+
exit 1
102+
fi
103+
104+
# Copy outputs to current directory with KSU_BASE prefix if exists
105+
if [ -z "$KSU_BASE" ]; then
106+
cp "$kernel" "./${KSU_BASE}-Image"
107+
else
108+
cp "$kernel" "./Image"
109+
fi
110+
cp "$dtbo" "./dtbo.img"
111+
cp "$dtb" "./dtb.img"
112+
113+
echo "Outputs copied to root directory with prefix '${KSU_BASE}'"
114+
}
115+
116+
print_summary() {
117+
echo -e "\nCompleted in $((SECONDS / 60)) minute(s) and $((SECONDS % 60)) second(s) !"
118+
}
119+
120+
# --- Main Execution ---
121+
122+
main() {
123+
check_variables
124+
setup_environment
125+
setup_toolchain
126+
update_path
127+
compile_kernel
128+
package_output
129+
print_summary
130+
}
131+
132+
# Run the main function
133+
main

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
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)