Skip to content

Commit 02bdfd4

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

7 files changed

Lines changed: 267 additions & 0 deletions

File tree

.github/workflows/compile-aosp.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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: Clone KernelSU-Next and compile
29+
# --- FIX: 'run:' was incorrectly indented ---
30+
run: |
31+
git clone https://github.com/vbajs/KernelSU-Next --depth=1 -b next KernelSU
32+
export KSU_BASE="ksun"
33+
chmod +x ./compile.sh
34+
./compile.sh
35+
36+
- name: Clone RissuKSU and compile
37+
# --- FIX: 'run:' was incorrectly indented ---
38+
run: |
39+
rm -rf KernelSU
40+
git clone https://github.com/rsuntk/KernelSU --depth=1 -b v1.0.5-81-legacy KernelSU
41+
export KSU_BASE="rksu"
42+
make O=out mrproper
43+
./compile.sh
44+
45+
- name: Compile without KSU
46+
# --- FIX: 'run:' was incorrectly indented ---
47+
run: |
48+
rm -rf KernelSU
49+
patch -p1 < revert-ksu-config.patch
50+
unset KSU_BASE
51+
make O=out mrproper
52+
./compile.sh
53+
54+
- name: Zip up and send to telegram
55+
# This step now also includes downloading the telegram script
56+
env:
57+
TELEGRAM_TOKEN: ${{ secrets.tg_token }}
58+
TELEGRAM_CHAT: ${{ secrets.tg_chat }}
59+
run: |
60+
# Setup telegram script
61+
wget https://raw.githubusercontent.com/fabianonline/telegram.sh/refs/heads/master/telegram
62+
chmod +x ./telegram
63+
64+
# Zip up the artifacts
65+
END_TIME=$(date +%s)
66+
DURATION=$((END_TIME - START_TIME))
67+
HASH="$(echo $(git rev-parse --verify HEAD 2>/dev/null) | cut -c1-8)"
68+
chmod +x ./zipup.sh
69+
./zipup.sh
70+
71+
# Send the message
72+
echo "Zip: $ZIPNAME"
73+
./telegram -f $ZIPNAME -C "Completed in $((DURATION / 60)) minute(s) and $((DURATION % 60)) second(s) ! Latest commit: $HASH"
74+
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: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
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 PATH="$PWD/clang/bin/:$GCC64_DIR/bin/:$GCC32_DIR/bin/:/usr/bin:$PATH"
70+
}
71+
72+
compile_kernel() {
73+
echo -e "\nStarting compilation..."
74+
75+
# 1. Make the base defconfig
76+
make O=out ARCH=arm64 sweet_defconfig
77+
if [ "$KSU_BASE" ]; then
78+
make O=out ARCH=arm64 vendor/$KSU_BASE.config
79+
fi
80+
81+
# 3. Run the main build
82+
make -j$(nproc --all) \
83+
O=out \
84+
ARCH=arm64 \
85+
LLVM=1 \
86+
LLVM_IAS=1 \
87+
CROSS_COMPILE=$GCC64_DIR/bin/aarch64-elf- \
88+
CROSS_COMPILE_COMPAT=$GCC32_DIR/bin/arm-eabi-
89+
}
90+
91+
package_output() {
92+
echo -e "\nPackaging outputs..."
93+
94+
local kernel="out/arch/arm64/boot/Image"
95+
local dtbo="out/arch/arm64/boot/dtbo.img"
96+
local dtb="out/arch/arm64/boot/dtb.img"
97+
98+
if [ ! -f "$kernel" ] || [ ! -f "$dtbo" ] || [ ! -f "$dtb" ]; then
99+
echo -e "\nCompilation failed! Output files not found."
100+
exit 1
101+
fi
102+
103+
# Copy outputs to current directory with KSU_BASE prefix if exists
104+
if [ "$KSU_BASE" ]; then
105+
cp "$kernel" "./$KSU_BASE-Image"
106+
else
107+
cp "$kernel" "./Image"
108+
fi
109+
cp "$dtbo" "./dtbo.img"
110+
cp "$dtb" "./dtb.img"
111+
112+
echo "Outputs copied to root directory with prefix '$KSU_BASE'"
113+
}
114+
115+
print_summary() {
116+
echo -e "\nCompleted in $((SECONDS / 60)) minute(s) and $((SECONDS % 60)) second(s) !"
117+
}
118+
119+
# --- Main Execution ---
120+
121+
main() {
122+
check_variables
123+
setup_environment
124+
setup_toolchain
125+
update_path
126+
compile_kernel
127+
package_output
128+
print_summary
129+
}
130+
131+
# Run the main function
132+
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)