Compare commits

...

10 Commits

Author SHA1 Message Date
29d4643e59 add additional scripts 2025-11-26 21:03:24 -05:00
fd0b9bc3c8 add sukisu + susfs 2025-11-26 20:34:43 -05:00
ae8206d5ad add clang rev 2025-11-26 16:19:18 -05:00
2ec0fcec27 change clang repo to subtree'd version to save space 2025-11-26 16:17:24 -05:00
0325a62606 oops wrong build tools 2025-11-26 10:53:30 -05:00
de25aebac4 add build tools 2025-11-26 10:49:40 -05:00
82c6f16557 add the thing for externals 2025-11-26 10:21:40 -05:00
8c2dff66cf add busybox-ndk 2025-11-26 10:09:40 -05:00
e8f977961a add anykernel3 source 2025-11-26 09:40:30 -05:00
6c061f763d change clang 2025-11-25 16:30:41 -05:00
4 changed files with 259 additions and 24 deletions

104
anykernel.sh Executable file
View File

@@ -0,0 +1,104 @@
### AnyKernel3 Ramdisk Mod Script
## osm0sis @ xda-developers
### AnyKernel setup
# global properties
properties() { '
kernel.string=LiteKernel for OnePlus SM8750
do.devicecheck=0
do.modules=0
do.systemless=0
do.cleanup=1
do.cleanuponabort=0
device.name1=
device.name2=
device.name3=
device.name4=
device.name5=
supported.versions=
supported.patchlevels=
supported.vendorpatchlevels=
'; } # end properties
### AnyKernel install
## boot shell variables
block=boot
is_slot_device=auto
ramdisk_compression=auto
patch_vbmeta_flag=auto
no_magisk_check=1
# import functions/variables and setup patching - see for reference (DO NOT REMOVE)
. tools/ak3-core.sh
# boot install
split_boot
if [ -f "split_img/ramdisk.cpio" ]; then
unpack_ramdisk
write_boot
else
flash_boot
fi
## end boot install
## init_boot files attributes
#init_boot_attributes() {
#set_perm_recursive 0 0 755 644 $RAMDISK/*;
#set_perm_recursive 0 0 750 750 $RAMDISK/init* $RAMDISK/sbin;
#} # end attributes
# init_boot shell variables
#BLOCK=init_boot;
#IS_SLOT_DEVICE=1;
#RAMDISK_COMPRESSION=auto;
#PATCH_VBMETA_FLAG=auto;
# reset for init_boot patching
#reset_ak;
# init_boot install
#dump_boot; # unpack ramdisk since it is the new first stage init ramdisk where overlay.d must go
#write_boot;
## end init_boot install
## vendor_kernel_boot shell variables
#BLOCK=vendor_kernel_boot;
#IS_SLOT_DEVICE=1;
#RAMDISK_COMPRESSION=auto;
#PATCH_VBMETA_FLAG=auto;
# reset for vendor_kernel_boot patching
#reset_ak;
# vendor_kernel_boot install
#split_boot; # skip unpack/repack ramdisk, e.g. for dtb on devices with hdr v4 and vendor_kernel_boot
#flash_boot;
## end vendor_kernel_boot install
## vendor_boot files attributes
#vendor_boot_attributes() {
#set_perm_recursive 0 0 755 644 $RAMDISK/*;
#set_perm_recursive 0 0 750 750 $RAMDISK/init* $RAMDISK/sbin;
#} # end attributes
# vendor_boot shell variables
#BLOCK=vendor_boot;
#IS_SLOT_DEVICE=1;
#RAMDISK_COMPRESSION=auto;
#PATCH_VBMETA_FLAG=auto;
# reset for vendor_boot patching
#reset_ak;
# vendor_boot install
#dump_boot; # use split_boot to skip ramdisk unpack, e.g. for dtb on devices with hdr v4 but no vendor_kernel_boot
#write_boot; # use flash_boot to skip ramdisk repack, e.g. for dtb on devices with hdr v4 but no vendor_kernel_boot
## end vendor_boot install

124
build.sh Executable file
View File

@@ -0,0 +1,124 @@
#!/usr/bin/env bash
# Set $BASEDIR and use it to ensure we're in the correct directory.
BASEDIR=$(realpath "$(dirname -- "$(realpath -- "${BASH_SOURCE[0]}")")/..")
# Ensure that .repo is present in $BASEDIR.
# This code probably won't ever fire unless you're doing something weird.
if [ ! -d "$BASEDIR/.repo" ]; then
echo ".dir missing, initializing..."
pushd "$BASEDIR" > /dev/null
repo init -u "$BASEDIR/repo" --git-lfs
repo sync
popd > /dev/null
fi
# Download latest magisk and extract it.
# TODO: Put extracted Magisk in a repo so that it can be handled by repo.
if [ ! -d "$BASEDIR/prebuilts/magisk" ]; then
echo "Magisk binaries missing, downloading..."
mkdir -p "$BASEDIR/prebuilts/magisk"
pushd "$BASEDIR/prebuilts/magisk" > /dev/null
wget "https://github.com/topjohnwu/Magisk/releases/download/v29.0/Magisk-v29.0.apk" || curl -OL "https://github.com/topjohnwu/Magisk/releases/download/v29.0/Magisk-v29.0.apk"
unzip "Magisk-v29.0.apk"
popd > /dev/null
fi
# Set some variables for well-known directories.
GCCDIR="$BASEDIR/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9"
GCCDIR32="$BASEDIR/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9"
CLANGDIR="$BASEDIR/prebuilts/clang/host/linux-x86/clang-r547379"
KERNELBUILDTOOLS="$BASEDIR/prebuilts/kernel-build-tools/linux-x86"
# Define common options used with make
MAKEOPTS=(
O="$BASEDIR/work"
ARCH=arm64
PATH="$CLANGDIR/bin:$GCCDIR/bin:$KERNELBUILDTOOLS/bin:$PATH"
LD_LIBRARY_PATH="$CLANGDIR/lib"
LLVM=1
CROSS_COMPILE="$GCCDIR/bin/aarch64-linux-android-"
CROSS_COMPILE_ARM32="$GCCDIR32/bin/arm-linux-androideabi-"
CLANG_TRIPLE=aarch64-linux-gnu-
)
echo Preparing source...
pushd "$BASEDIR/kernel/oneplus/sm8750" > /dev/null
# Reset everything
git reset --hard
git clean -fd
ln -s "${BASEDIR}/external/SukiSU-Ultra" "KernelSU"
ln -s "${BASEDIR}/external/SukiSU-Ultra/kernel" "drivers/kernelsu"
# Add SukiSU
MOD=false
grep -q "kernelsu" "drivers/Makefile" || printf "\nobj-\$(CONFIG_KSU) += kernelsu/\n" >> "drivers/Makefile" || echo "[+] Modified Makefile."
grep -q "source \"drivers/kernelsu/Kconfig\"" "drivers/Kconfig" || sed -i "/endmenu/i\source \"drivers/kernelsu/Kconfig\"" "drivers/Kconfig" && echo "[+] Modified Kconfig."
# Add SUSFS
cp "${BASEDIR}/external/susfs4ksu/kernel_patches/fs/"* "fs/"
cp "${BASEDIR}/external/susfs4ksu/kernel_patches/include/linux/"* "include/linux/"
patch --fuzz=3 -p1 < "${BASEDIR}/external/susfs4ksu/kernel_patches/50_add_susfs_in_gki-android15-6.6.patch"
mkdir -p "$BASEDIR/out"
mkdir -p "$BASEDIR/work"
# Ensure things are clean?
make ${MAKEOPTS[@]} mrproper
# Start with the GKI base configuration
make ${MAKEOPTS[@]} gki_defconfig
# Merge configurations that are specific to the device
scripts/kconfig/merge_config.sh -m -O "$BASEDIR/work" \
"$BASEDIR/work/.config" \
arch/arm64/configs/vendor/sun_perf.config \
arch/arm64/configs/vendor/oplus/sun_perf.config
if [ -e "${BASEDIR}/.config" ]; then
echo Adding custom configuration...
scripts/kconfig/merge_config.sh -m -O "${BASEDIR}/work" \
"${BASEDIR}/work/.config" \
"${BASEDIR}/.config"
fi
# Add in things that are missing from the above config templates
echo "CONFIG_DODGE_DTB=y" >> "$BASEDIR/work/.config"
echo "CONFIG_OPLUS_DEVICE_DTBS=y" >> "$BASEDIR/work/.config"
echo "CONFIG_COMPAT=y" >> "$BASEDIR/work/.config"
echo "CONFIG_COMPAT_VDSO=y" >> "$BASEDIR/work/.config"
# Re-process the configuration and accept defaults for unknowns.
make ${MAKEOPTS[@]} olddefconfig
# Compile the kernel
make ${MAKEOPTS[@]} \
KCFLAGS="-Wno-error=frame-larger-than=" \
-j$(nproc) 2>&1 | tee "$BASEDIR/work/build.log"
popd > /dev/null
# Prepare AnyKernel3 with our customizations
echo "Preparing AnyKernel3 package..."
rm -rf "${BASEDIR}/work/AnyKernel3"
mkdir -p "${BASEDIR}/work/AnyKernel3"
cp -ra "${BASEDIR}/external/AnyKernel3/"* "${BASEDIR}/work/AnyKernel3/"
cp "${BASEDIR}/repo/anykernel.sh" "${BASEDIR}/work/AnyKernel3/anykernel.sh"
cp "${BASEDIR}/prebuilts/magisk/lib/arm64-v8a/libbusybox.so" "${BASEDIR}/work/AnyKernel3/tools/busybox"
cp "${BASEDIR}/prebuilts/magisk/lib/arm64-v8a/libmagiskboot.so" "${BASEDIR}/work/AnyKernel3/tools/magiskboot"
chmod +x "${BASEDIR}/work/AnyKernel3/tools/"*
# Copy kernel Image
echo "Copying kernel Image..."
cp "${BASEDIR}/work/arch/arm64/boot/Image" "${BASEDIR}/work/AnyKernel3/"
# Create flashable zip
echo "Creating flashable zip..."
KERNEL_VERSION=$(cat "${BASEDIR}/kernel/oneplus/sm8750/include/config/kernel.release" 2>/dev/null || echo "unknown")
OUTPUT_ZIP="${BASEDIR}/out/LiteKernel-${KERNEL_VERSION}-$(date +%Y%m%d-%H%M%S).zip"
pushd "${BASEDIR}/work/AnyKernel3" > /dev/null
zip -r9 "${OUTPUT_ZIP}" * -x .git README.md .gitignore ./*.zip
popd > /dev/null
echo "Build complete!"
echo "Flashable zip: ${OUTPUT_ZIP}"

View File

@@ -1,34 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote name="github"
fetch="https://github.com"
review="review.lineageos.org" />
<remote name="github" fetch="https://github.com" review="review.lineageos.org" />
<remote name="gitlab" fetch="https://gitlab.com" />
<remote name="aosp" fetch="https://android.googlesource.com" review="android-review.googlesource.com" revision="refs/tags/android-16.0.0_r1" />
<default revision="refs/heads/lineage-23.0" remote="github" sync-c="true" sync-j="4" />
<remote name="private"
fetch="ssh://git@github.com" />
<remote name="aosp"
fetch="https://android.googlesource.com"
review="android-review.googlesource.com"
revision="refs/tags/android-16.0.0_r1" />
<default revision="refs/heads/lineage-23.0"
remote="github"
sync-c="true"
sync-j="4" />
<contactinfo bugurl="go/repo-bug" />
<project path="prebuilts/clang/kernel/linux-x86/clang-r416183b" name="LineageOS/android_prebuilts_clang_kernel_linux-x86_clang-r416183b" clone-depth="1" revision="lineage-20.0" />
<project path="prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9" name="LineageOS/android_prebuilts_gcc_linux-x86_aarch64_aarch64-linux-android-4.9" groups="pdk,linux,arm" clone-depth="1" revision="lineage-19.1" />
<project path="prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9" name="LineageOS/android_prebuilts_gcc_linux-x86_arm_arm-linux-androideabi-4.9" groups="pdk,linux,arm" clone-depth="1" revision="lineage-19.1" />
<project path="kernel/oneplus/sm8750" remote="github" name="LineageOS/android_kernel_oneplus_sm8750" clone-depth="1" />
<project path="kernel/oneplus/sm8750-modules" remote="github" name="LineageOS/android_kernel_oneplus_sm8750-modules" clone-depth="1" >
<project path="prebuilts/clang/host/linux-x86/clang-r547379" name="KiTTYsh/clang-r547379" clone-depth="1" revision="main" />
<project path="prebuilts/kernel-build-tools" name="kernel/prebuilts/build-tools" clone-depth="1" remote="aosp" revision="main-kernel-build-2024" />
<project path="prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9" name="LineageOS/android_prebuilts_gcc_linux-x86_aarch64_aarch64-linux-android-4.9" clone-depth="1" revision="lineage-19.1" />
<project path="prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9" name="LineageOS/android_prebuilts_gcc_linux-x86_arm_arm-linux-androideabi-4.9" clone-depth="1" revision="lineage-19.1" />
<project path="kernel/oneplus/sm8750" name="LineageOS/android_kernel_oneplus_sm8750" clone-depth="1" />
<project path="kernel/oneplus/sm8750-modules" name="LineageOS/android_kernel_oneplus_sm8750-modules" clone-depth="1" >
<linkfile src="oplus/kernel/touchpanel/kernelFwUpdate" dest="kernel/oneplus/sm8750/drivers/base" />
</project>
<project path="kernel/oneplus/sm8750-devicetrees" remote="github" name="LineageOS/android_kernel_oneplus_sm8750-devicetrees" clone-depth="1" >
<project path="kernel/oneplus/sm8750-devicetrees" name="LineageOS/android_kernel_oneplus_sm8750-devicetrees" clone-depth="1" >
<linkfile src="." dest="kernel/oneplus/sm8750/arch/arm64/boot/dts/vendor" />
<linkfile src="bindings" dest="kernel/oneplus/sm8750/Documentation/devicetree/bindings" />
</project>
<project path="external/AnyKernel3" name="osm0sis/AnyKernel3" clone-depth="1" revision="master" />
<project path="external/SukiSU-Ultra" name="SukiSU-Ultra/SukiSU-Ultra" clone-depth="1" revision="susfs-main" >
<linkfile src="." dest="kernel/oneplus/sm8750/KernelSU" />
<linkfile src="kernel" dest="kernel/oneplus/sm8750/drivers/kernelsu" />
</project>
<project path="external/susfs4ksu" name="simonpunk/susfs4ksu" clone-depth="1" remote="gitlab" revision="gki-android15-6.6" />
</manifest>

14
repack.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
BASEDIR=$(realpath "$(dirname -- "$(realpath -- "${BASH_SOURCE[0]}")")/..")
MAGISKBOOT="${BASEDIR}/prebuilts/magisk/lib/x86_64/libmagiskboot.so"
chmod +x "${MAGISKBOOT}"
rm -rf "${BASEDIR}/out/repack"
mkdir -p "${BASEDIR}/out/repack"
pushd "${BASEDIR}/out/repack" > /dev/null
${MAGISKBOOT} unpack "${BASEDIR}/stock_boot.img"
cp "${BASEDIR}/out/arch/arm64/boot/Image" kernel
${MAGISKBOOT} repack "${BASEDIR}/stock_boot.img" "${BASEDIR}/new_boot.img"
popd > /dev/null