GithubHelp home page GithubHelp logo

th1nhhdk / lineageos_kernel_builder Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 3.0 30 KB

Bash script to build a custom LineageOS Kernel without having to download unnecessary source code.

License: Apache License 2.0

Shell 100.00%

lineageos_kernel_builder's Introduction

lineageos_kernel_builder

Bash script to build a custom LineageOS Kernel without having to download unnecessary source code.

Supported devices

  • Sony Xperia 1 II (pdx203)
  • Sony Xperia 5 II (pdx206) (not regularly tested, should work)
  • OnePlus 6 (enchilada) (untested)
  • OnePlus 6T (fajita) (untested)
  • Xiaomi Mi Mix 2S (polaris) (not regularly tested, should work)

How to use

  • Check ./config.sh for configuration options.

  • Symlink a device configuration file from ./device_configs/ to ./include/device_config.sh before running lineageos_kernel_builder.sh, for example:

ln -sf ./device_configs/pdx206_device_config.sh ./include/device_config.sh # We are now building for pdx206
  • Then:
lineageos_kernel_builder.sh download_sources
# lineageos_kernel_builder.sh make_defconfig  # optional: run "make defconfig" in Kernel source directory
# lineageos_kernel_builder.sh make_menuconfig # optional: run "make menuconfig" in Kernel source directory
lineageos_kernel_builder.sh make_kernel
lineageos_kernel_builder.sh make_anykernel3_zip # ${enable_anykernel3_zip} needs to be "true" for this to work
  • You can also run build_all_configs.sh to build for all device configs in ./device_configs/.

(Recommended) Using cached prebuilts_clang_host_linux_x86

  • Because prebuilts_clang_host_linux_x86 is very big (about 13GB!), you can cache it to avoid redownloading everytime you build the Kernel:
lineageos_kernel_builder.sh download_sources
mkdir -p ./cache/
source ./include/device_config.sh
cp -r ./build/prebuilts/clang/host/linux-x86 ./cache/prebuilts_clang_host_linux_x86-${aosp_tag}
  • Now everytime you build the script will use the cached prebuilts_clang_host_linux_x86 instead.

Differences compared to building with the whole LineageOS ROM

  • none (as far as I know)

lineageos_kernel_builder's People

Contributors

th1nhhdk avatar

Stargazers

zomps avatar Itsfitts avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

lineageos_kernel_builder's Issues

Unintended behaviour if one uses the one-liner in README.md

First, thanks for providing this script for building LineageOS kernel with KernelSU for Xperia 5 II && 1 II.

I tried to find out why the zips provided in https://github.com/th1nhhdk/android_kernel_sony_sm8250-kernelsu/releases since 2023-07-28 have been unable to activate KernelSU on my Xperia 5 II. After several tries, my finds are as follows.

If I build for pdx206 directly, then the output zip works fine. But if I use the one-liner provided in README.md

rm -rf ./build && ./build.sh download_sources && ./build.sh build_kernel && ./build.sh make_anykernel3_zip && mv device_config.sh pdx203_device_config.sh && mv pdx206_device_config.sh device_config.sh && rm -rf build/android_kernel_sony_sm8250/out build/AnyKernel3 && ./build.sh download_sources && ./build.sh build_kernel && ./build.sh make_anykernel3_zip && mv device_config.sh pdx206_device_config.sh && mv pdx203_device_config.sh device_config.sh && rm -rf build/android_kernel_sony_sm8250/out build/AnyKernel3 && ./build.sh download_sources

, then the output zip fails to activate KernelSU on my phone.

I found out that the cause is probably the if condition in the function add_kernelsu() in build.sh

add_kernelsu() {
    if [ ! -d $workdir/build/$kernel_name/KernelSU ]; then
        cd $workdir/build/$kernel_name
	    	echo "=> Adding KernelSU to kernel source tree..."
	    	curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -
	    	echo "=> Configuring kprobe which is needed by KernelSU..."
	    	sed -i -e '/^CONFIG_KPROBES$/d' \
	        	-e '/^CONFIG_HAVE_KPROBES$/d' \
	        	-e '/^CONFIG_KPROBE_EVENTS$/d' \
	        	./arch/$kernel_arch/configs/"$device_name"_defconfig
	    	cat >> ./arch/$kernel_arch/configs/"$device_name"_defconfig << EOF
# Required for KernelSU
CONFIG_KPROBES=y
CONFIG_HAVE_KPROBES=y
CONFIG_KPROBE_EVENTS=y
EOF
	    	echo "=> Adding -kernelsu to EXTRAVERSION..."
	    	sed -i 's/\(EXTRAVERSION\s*=\s*\)/\1 -kernelsu/' ./Makefile
	    cd $workdir
    fi
}

. If the $workdir/build/$kernel_name/KernelSU folder from the building for pdx203 exists, then in the building for pdx206, ./arch/$kernel_arch/configs/"$device_name"_defconfig won't be altered.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.