From fc35c46bcfd7553ec2693ac06e5e386fbf3aac46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=BB=E3=83=AA=E3=82=AB=E3=83=BB=E3=82=B7=E3=83=AB?= =?UTF-8?q?=E3=83=95=E3=82=A3=E3=83=AB?= <64072399+natsumerinchan@users.noreply.github.com> Date: Fri, 3 Feb 2023 22:29:03 +0800 Subject: [PATCH] Initial commit --- .gitattributes | 2 + .github/workflows/PixelExperience.yml | 161 ++++++++++++++++++++++++++ .github/workflows/PixelOS.yml | 160 +++++++++++++++++++++++++ LICENSE | 24 ++++ README.md | 91 +++++++++++++++ README_zh_cn.md | 92 +++++++++++++++ arch_build.sh | 112 ++++++++++++++++++ debian_build.sh | 127 ++++++++++++++++++++ 8 files changed, 769 insertions(+) create mode 100644 .gitattributes create mode 100644 .github/workflows/PixelExperience.yml create mode 100644 .github/workflows/PixelOS.yml create mode 100644 LICENSE create mode 100644 README.md create mode 100644 README_zh_cn.md create mode 100644 arch_build.sh create mode 100644 debian_build.sh diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/.github/workflows/PixelExperience.yml b/.github/workflows/PixelExperience.yml new file mode 100644 index 0000000..412ad68 --- /dev/null +++ b/.github/workflows/PixelExperience.yml @@ -0,0 +1,161 @@ +name: Pixel Experience + + +on: + + workflow_dispatch: + inputs: + RELEASE_CONFIG: + description: 'Upload to Releases' + required: true + default: true + type: boolean + KERNEL_SOURCE: + description: 'Kernel Source' + required: true + default: "https://github.com/PixelExperience-Devices/kernel_oneplus_martini.git" + type: string + KERNEL_SOURCE_BRANCH: + description: 'kernel Branch' + required: true + default: "thirteen" + type: string + KERNEL_DEFCONFIG: + description: 'Kernel Config' + required: true + default: "vendor/lahaina-qgki_defconfig" + type: string + KERNELSU_CONFIG: + description: 'Compile KernelSU' + required: true + default: true + type: boolean + CCACHE_CONFIG: + description: 'Use Ccache' + required: true + default: true + type: boolean + KERNELSU_TAG: + description: 'Choose KernelSU branch or tag' + required: false + default: "main" + type: string + +jobs: + + build: + + runs-on: ubuntu-latest + env: + CCACHE_COMPILERCHECK: "%compiler% -dumpmachine; %compiler% -dumpversion" + CCACHE_NOHASHDIR: "true" + CCACHE_MAXSIZE: "2G" + CCACHE_HARDLINK: "true" + + + steps: + + - uses: actions/checkout@v3 + + - name: Ccache + if: github.event.inputs.CCACHE_CONFIG == 'true' + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: Pixel-Experience + + - name: Setup Environment + run: | + export CLANG_PATH=~/neutron-clang + mkdir -p $CLANG_PATH && cd $CLANG_PATH + sudo apt update && sudo apt install zstd tar wget curl libarchive-tools + curl -LO "https://raw.githubusercontent.com/Neutron-Toolchains/antman/main/antman" + bash antman -S=latest + bash antman --patch=glibc + sh -c "$(curl -sSL https://raw.githubusercontent.com/akhilnarang/scripts/master/setup/android_build_env.sh)" + sudo apt install --fix-missing + export LLVM_VERSION=17 + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh $LLVM_VERSION + rm ./llvm.sh + sudo apt install --fix-missing + sudo ln -s --force /usr/bin/clang-$LLVM_VERSION /usr/bin/clang + sudo ln -s --force /usr/bin/ld.lld-$LLVM_VERSION /usr/bin/ld.lld + sudo ln -s --force /usr/bin/llvm-objdump-$LLVM_VERSION /usr/bin/llvm-objdump + sudo ln -s --force /usr/bin/llvm-ar-$LLVM_VERSION /usr/bin/llvm-ar + sudo ln -s --force /usr/bin/llvm-nm-$LLVM_VERSION /usr/bin/llvm-nm + sudo ln -s --force /usr/bin/llvm-strip-$LLVM_VERSION /usr/bin/llvm-strip + sudo ln -s --force /usr/bin/llvm-objcopy-$LLVM_VERSION /usr/bin/llvm-objcopy + sudo ln -s --force /usr/bin/llvm-readelf-$LLVM_VERSION /usr/bin/llvm-readelf + sudo ln -s --force /usr/bin/clang++-$LLVM_VERSION /usr/bin/clang++ + + - name: Git kernel + run: | + git clone "${{ github.event.inputs.KERNEL_SOURCE }}" -b "${{ github.event.inputs.KERNEL_SOURCE_BRANCH }}" kernel --depth=1 + echo "TAG_NAME=PE-v5.4.$(grep "^SUBLEVEL =" kernel/Makefile | awk '{print $3}')-$(date +"%Y%m%d")" >> $GITHUB_ENV + + - name: Setup KernelSU + if: github.event.inputs.KERNELSU_CONFIG == 'true' + run: | + cd $GITHUB_WORKSPACE/kernel + curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -s "${{ github.event.inputs.KERNELSU_TAG }}" + scripts/config --file "arch/arm64/configs/${{ github.event.inputs.KERNEL_DEFCONFIG }}" -e MODULES -e KPROBES -e HAVE_KPROBES -e KPROBE_EVENTS + + - name: Make kernel + run: | + cd $GITHUB_WORKSPACE/kernel + export KERNEL_DEFCONFIG=${{ github.event.inputs.KERNEL_DEFCONFIG }} + echo "===================Setup Export=========================" + export KERNEL_PATH=$PWD + export CLANG_PATH=~/neutron-clang + export PATH=${CLANG_PATH}/bin:${PATH} + export CLANG_TRIPLE=aarch64-linux-gnu- + export ARCH=arm64 + export SUBARCH=arm64 + echo "===================Setup Environment Again===================" + if [ ! -e "$CLANG_PATH/build.info" ]; then + cd $CLANG_PATH + curl -LO "https://raw.githubusercontent.com/Neutron-Toolchains/antman/main/antman" + bash antman -S=latest + bash antman --patch=glibc + fi + sudo apt install --fix-missing + echo "=========================Make==========================" + make O=out CC="ccache clang" CXX="ccache clang++" ARCH=arm64 CROSS_COMPILE=$CLANG_PATH/bin/aarch64-linux-gnu- CROSS_COMPILE_ARM32=$CLANG_PATH/bin/arm-linux-gnueabi- LD=ld.lld $KERNEL_DEFCONFIG + # Disable LTO + if [[ $(echo "$(awk '/MemTotal/ {print $2}' /proc/meminfo) < 16000000" | bc -l) -eq 1 ]]; then + scripts/config --file out/.config -d LTO -d LTO_CLANG -d THINLTO -e LTO_NONE + fi + make O=out CC="ccache clang" CXX="ccache clang++" ARCH=arm64 -j`nproc` CROSS_COMPILE=$CLANG_PATH/bin/aarch64-linux-gnu- CROSS_COMPILE_ARM32=$CLANG_PATH/bin/arm-linux-gnueabi- LD=ld.lld 2>&1 | tee kernel.log + + + - name: Create Anykernel3 file + run: | + cd $GITHUB_WORKSPACE/kernel + export KERNEL_PATH=$PWD + git clone https://gitlab.com/inferno0230/AnyKernel3 --depth=1 $KERNEL_PATH/AnyKernel3 + if test -e $KERNEL_PATH/out/arch/arm64/boot/Image && test -d $KERNEL_PATH/AnyKernel3; then + zip_name="PE-martini-${{ env.TAG_NAME }}.zip" + cd $KERNEL_PATH/AnyKernel3 + cp $KERNEL_PATH/out/arch/arm64/boot/Image $KERNEL_PATH/AnyKernel3 + zip -r ${zip_name} * + mv ${zip_name} $KERNEL_PATH/out/arch/arm64/boot + fi + + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: PE-martini-${{ env.TAG_NAME }} + path: | + kernel/AnyKernel3/* + + - name: Upload to Release + if: github.event.inputs.RELEASE_CONFIG == 'true' + uses: ncipollo/release-action@v1 + with: + artifacts: "kernel/out/arch/arm64/boot/PE-martini-${{ env.TAG_NAME }}.zip" + tag: "PE-martini-${{ env.TAG_NAME }}" + name: "Pixel Experience martini ${{ env.TAG_NAME }}" + allowUpdates: true + replacesArtifacts: true + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/PixelOS.yml b/.github/workflows/PixelOS.yml new file mode 100644 index 0000000..edc5f56 --- /dev/null +++ b/.github/workflows/PixelOS.yml @@ -0,0 +1,160 @@ +name: Pixel OS + + +on: + + workflow_dispatch: + inputs: + RELEASE_CONFIG: + description: 'Upload to Releases' + required: true + default: true + type: boolean + KERNEL_SOURCE: + description: 'Kernel Source' + required: true + default: "https://github.com/PixelOS-Devices/kernel_oneplus_sm8350.git" + type: string + KERNEL_SOURCE_BRANCH: + description: 'kernel Branch' + required: true + default: "fourteen" + type: string + KERNEL_DEFCONFIG: + description: 'Kernel Config' + required: true + default: "vendor/lahaina-qgki_defconfig" + type: string + KERNELSU_CONFIG: + description: 'Compile KernelSU' + required: true + default: true + type: boolean + CCACHE_CONFIG: + description: 'Use Ccache' + required: true + default: true + type: boolean + KERNELSU_TAG: + description: 'Choose KernelSU branch or tag' + required: false + default: main + type: string + +jobs: + + build: + + runs-on: ubuntu-latest + env: + CCACHE_COMPILERCHECK: "%compiler% -dumpmachine; %compiler% -dumpversion" + CCACHE_NOHASHDIR: "true" + CCACHE_MAXSIZE: "2G" + CCACHE_HARDLINK: "true" + + steps: + + - uses: actions/checkout@v3 + + - name: Ccache + if: github.event.inputs.CCACHE_CONFIG == 'true' + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: PixelOS-inline + + - name: Setup Environment + run: | + export CLANG_PATH=~/neutron-clang + mkdir -p $CLANG_PATH && cd $CLANG_PATH + sudo apt update && sudo apt install zstd tar wget curl libarchive-tools + curl -LO "https://raw.githubusercontent.com/Neutron-Toolchains/antman/main/antman" + bash antman -S=latest + bash antman --patch=glibc + sh -c "$(curl -sSL https://raw.githubusercontent.com/akhilnarang/scripts/master/setup/android_build_env.sh)" + sudo apt install --fix-missing + export LLVM_VERSION=17 + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh $LLVM_VERSION + rm ./llvm.sh + sudo apt install --fix-missing + sudo ln -s --force /usr/bin/clang-$LLVM_VERSION /usr/bin/clang + sudo ln -s --force /usr/bin/ld.lld-$LLVM_VERSION /usr/bin/ld.lld + sudo ln -s --force /usr/bin/llvm-objdump-$LLVM_VERSION /usr/bin/llvm-objdump + sudo ln -s --force /usr/bin/llvm-ar-$LLVM_VERSION /usr/bin/llvm-ar + sudo ln -s --force /usr/bin/llvm-nm-$LLVM_VERSION /usr/bin/llvm-nm + sudo ln -s --force /usr/bin/llvm-strip-$LLVM_VERSION /usr/bin/llvm-strip + sudo ln -s --force /usr/bin/llvm-objcopy-$LLVM_VERSION /usr/bin/llvm-objcopy + sudo ln -s --force /usr/bin/llvm-readelf-$LLVM_VERSION /usr/bin/llvm-readelf + sudo ln -s --force /usr/bin/clang++-$LLVM_VERSION /usr/bin/clang++ + + - name: Git kernel + run: | + git clone "${{ github.event.inputs.KERNEL_SOURCE }}" -b "${{ github.event.inputs.KERNEL_SOURCE_BRANCH }}" kernel --depth=1 + echo "TAG_NAME=PixelOS-v5.4.$(grep "^SUBLEVEL =" kernel/Makefile | awk '{print $3}')-$(date +"%Y%m%d")" >> $GITHUB_ENV + + - name: Setup KernelSU + if: github.event.inputs.KERNELSU_CONFIG == 'true' + run: | + cd $GITHUB_WORKSPACE/kernel + curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -s "${{ github.event.inputs.KERNELSU_TAG }}" + scripts/config --file "arch/arm64/configs/${{ github.event.inputs.KERNEL_DEFCONFIG }}" -e MODULES -e KPROBES -e HAVE_KPROBES -e KPROBE_EVENTS + + - name: Make kernel + run: | + cd $GITHUB_WORKSPACE/kernel + export KERNEL_DEFCONFIG=${{ github.event.inputs.KERNEL_DEFCONFIG }} + echo "===================Setup Export=========================" + export KERNEL_PATH=$PWD + export CLANG_PATH=~/neutron-clang + export PATH=${CLANG_PATH}/bin:${PATH} + export CLANG_TRIPLE=aarch64-linux-gnu- + export ARCH=arm64 + export SUBARCH=arm64 + echo "===================Setup Environment Again===================" + if [ ! -e "$CLANG_PATH/build.info" ]; then + cd $CLANG_PATH + curl -LO "https://raw.githubusercontent.com/Neutron-Toolchains/antman/main/antman" + bash antman -S=latest + bash antman --patch=glibc + fi + sudo apt install --fix-missing + echo "=========================Make==========================" + make O=out CC="ccache clang" CXX="ccache clang++" ARCH=arm64 CROSS_COMPILE=$CLANG_PATH/bin/aarch64-linux-gnu- CROSS_COMPILE_ARM32=$CLANG_PATH/bin/arm-linux-gnueabi- LD=ld.lld $KERNEL_DEFCONFIG + # Disable LTO + if [[ $(echo "$(awk '/MemTotal/ {print $2}' /proc/meminfo) < 16000000" | bc -l) -eq 1 ]]; then + scripts/config --file out/.config -d LTO -d LTO_CLANG -d THINLTO -e LTO_NONE + fi + make O=out CC="ccache clang" CXX="ccache clang++" ARCH=arm64 -j`nproc` CROSS_COMPILE=$CLANG_PATH/bin/aarch64-linux-gnu- CROSS_COMPILE_ARM32=$CLANG_PATH/bin/arm-linux-gnueabi- LD=ld.lld 2>&1 | tee kernel.log + + + - name: Create Anykernel3 file + run: | + cd $GITHUB_WORKSPACE/kernel + export KERNEL_PATH=$PWD + git clone https://gitlab.com/inferno0230/AnyKernel3 --depth=1 $KERNEL_PATH/AnyKernel3 + if test -e $KERNEL_PATH/out/arch/arm64/boot/Image && test -d $KERNEL_PATH/AnyKernel3; then + zip_name="PixelOS-martini-${{ env.TAG_NAME }}.zip" + cd $KERNEL_PATH/AnyKernel3 + cp $KERNEL_PATH/out/arch/arm64/boot/Image $KERNEL_PATH/AnyKernel3 + zip -r ${zip_name} * + mv ${zip_name} $KERNEL_PATH/out/arch/arm64/boot + fi + + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: PixelOS-martini-${{ env.TAG_NAME }} + path: | + kernel/AnyKernel3/* + + - name: Upload to Release + if: github.event.inputs.RELEASE_CONFIG == 'true' + uses: ncipollo/release-action@v1 + with: + artifacts: "kernel/out/arch/arm64/boot/PixelOS-martini-${{ env.TAG_NAME }}.zip" + tag: "PixelOS-martini-${{ env.TAG_NAME }}" + name: "PixelOS martini ${{ env.TAG_NAME }}" + allowUpdates: true + replacesArtifacts: true + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..fdddb29 --- /dev/null +++ b/LICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to diff --git a/README.md b/README.md new file mode 100644 index 0000000..76fdff3 --- /dev/null +++ b/README.md @@ -0,0 +1,91 @@ +[ **简体中文** ](README_zh_cn.md) || **English** + +# KernelSU_Oneplus_martini_Guide +Guide of compile KernelSU for Oneplus 9RT(martini)[MT2110/MT2111] + +## Warning :warning: :warning: :warning: +- 1.Please backup the offical boot.img and vendor_dlkm.img before you flash!!!You can use [ssut/payload-dumper-go](https://github.com/ssut/payload-dumper-go.git) to extract them from `payload.bin` in ROM.zip.(The ROM package version must as same as your using OS.) +- 2.I am not the author of these kernel, so I will not release any compiled products in this repository, please fork this repository (Sync to your private repository is better) and run workflow by yourself. +- 3."If you are not the author of the Kernel, and are using someone else's labor to build KernelSU, please use it for personal use only and do not share it with others. This is to show respect for the author's labor achievements." --[xiaoleGun/KernelSU_Action](https://github.com/xiaoleGun/KernelSU_Action.git) + +## Support ROMS + +| Action Name | Kernel source | Used Branch | Kernel Author | Notes | +|:--:|:--:|:--:|:--:|:--:| +| Pixel Experience | [PixelExperience-Devices/kernel_oneplus_martini](https://github.com/PixelExperience-Devices/kernel_oneplus_martini.git) | thirteen | [inferno0230](https://github.com/inferno0230) | Unsupport OOS and ColorOS. | +| Pixel OS | [PixelOS-Devices/kernel_oneplus_sm8350](https://github.com/PixelOS-Devices/kernel_oneplus_sm8350) | fourteen | [bheatleyyy](https://github.com/bheatleyyy) | Unsupport OOS and ColorOS. | + +## How to build +### 1.Github Action +Fork this repository and run workflows by yourselves. +If you can not found Actions tab,please go to `settings`-`actions`-`General`,set Actions permissions as 'Allow all actions and reusable workflows' + +![Github Action](https://user-images.githubusercontent.com/64072399/216762170-8cce9b81-7dc1-4e7d-a774-b05f281a9bff.png) + +``` +Run ncipollo/release-action@v1 +Error: Error 403: Resource not accessible by integration +``` +If you get this notice when you try to upload to releases,please go to `settings`-`actions`-`General`,set Workflow permissions as 'Read and write permissions'. + +### 2.Build on your PC + +`debian_build.sh` :for Debian distributions (e.g. Debian, Ubuntu, etc.) + +`arch_build.sh` :for Arch distributions (e.g. Arch Linux, Manjaro, etc.) + +- `export SETUP_KERNELSU=true` (If you don't want to compile KernelSU,please set it as `false`) + +## Instructions +### 1.How to Install +- 1.Download and install [KernelSU Manager](https://github.com/tiann/KernelSU/actions/workflows/build-manager.yml).Install branches other than `main` is not recommended, because they may not work properly. +- 2.Download [platform-tools](https://developer.android.com/studio/releases/platform-tools) (Don't install from Ubuntu20.04 source.) +- 3.Reboot to Recovery Sideload mode,flash "xxx-v5.4.xxx-xxxxxxxx.zip" +``` +adb reboot sideload +adb sideload ./xxx-v5.4.xxx-xxxxxxxx.zip +``` + +### 2.Notes for Update +You may encounter the fastbootd or recovery mode can not connect to the PC, please enter bootloader mode to reflash the official boot.img +``` +adb reboot bootloader +fastboot flash boot ./boot.img +fastboot reboot recovery +``` +Now you can continue to update. + +### 3.How to uninstall +Please reflash the offical boot.img and vendor_dlkm.img +``` +adb reboot bootloader +fastboot flash boot ./boot.img +``` + +### 4.How to sync updates to your private repository +Use Github Desktop to clone your private repository to local, then go to the directory and open a terminal. + +``` +// Sync mainline branch to the repository + +git remote add Celica https://github.com/natsumerinchan/KernelSU_Oneplus_martini_Guide.git //This step is only required for the first time update. + +git fetch Celica main +``` + +``` +// Cherry-pick commit from the mainline repository to your private one. + +git cherry-pick +``` + +Then use Github Desktop to upload commits to Github + +## Credits and Thanks +* [tiann/KernelSU](https://github.com/tiann/KernelSU.git): A Kernel based root solution for Android GKI +* [PixelOS-Devices/kernel_oneplus_sm8350](https://github.com/PixelOS-Devices/kernel_oneplus_sm8350.git): PixelOS kernel for OnePlus 9RT 5G (martini) +* [PixelExperience-Devices/kernel_oneplus_martini](https://github.com/PixelExperience-Devices/kernel_oneplus_martini.git): Pixel Experience kernel for OnePlus 9RT (martini) +* [Gainss/Action_Kernel](https://github.com/Gainss/Action_Kernel.git): Kernel Action template +* [xiaoleGun/KernelSU_action](https://github.com/xiaoleGun/KernelSU_action.git): Action for Non-GKI Kernel has some common and requires knowledge of kernel and Android to be used. +* [osm0sis/AnyKernel3](https://github.com/osm0sis/AnyKernel3.git): Flashable Zip Template for Kernel Releases with Ramdisk Modifications +* [@Dreamail](https://github.com/Dreamail): This [commit](https://github.com/tiann/KernelSU/commit/bf87b134ded3b81a864db20d8d25d0bfb9e74ebe) fix error for non-GKI kernel diff --git a/README_zh_cn.md b/README_zh_cn.md new file mode 100644 index 0000000..c45e5fd --- /dev/null +++ b/README_zh_cn.md @@ -0,0 +1,92 @@ + **简体中文** || [ **English** ](README.md) + +# KernelSU_Oneplus_martini_Guide +一加9RT(martini)[MT2110/MT2111]的KernelSU编译指南 + +## 警告 :warning: :warning: :warning: +- 1.在刷机之前请务必备份官方的boot.img和vendor_dlkm.img!!!你可以使用[ssut/payload-dumper-go](https://github.com/ssut/payload-dumper-go.git)从ROM包的`payload.bin`中提取镜像。(必须从和当前系统相同版本的ROM包提取) +- 2.我不是这些内核的作者,因此我不会在本仓库发布任何编译产物,请你自行fork本仓库(同步到你的私人仓库更好),然后自行运行工作流编译内核。 +- 3."如果你不是内核作者,使用他人的劳动成果构建 KernelSU,请仅供自己使用,不要分享给别人,这是对原作者的劳动成果的尊重。" --[xiaoleGun/KernelSU_Action](https://github.com/xiaoleGun/KernelSU_Action.git) + +## 支持的系统 + +| 工作流名称 | 源码地址 | 分支 | 内核作者 | 备注 | +|:--:|:--:|:--:|:--:|:--:| +| Pixel Experience | [PixelExperience-Devices/kernel_oneplus_martini](https://github.com/PixelExperience-Devices/kernel_oneplus_martini.git) | thirteen | [inferno0230](https://github.com/inferno0230) | 不支持ColorOS和OOS。 | +| Pixel OS | [PixelOS-Devices/kernel_oneplus_sm8350](https://github.com/PixelOS-Devices/kernel_oneplus_sm8350.git) | fourteen | [bheatleyyy](https://github.com/bheatleyyy) | 不支持ColorOS和OOS。 | + +## 如何编译 +### 1.Github Action +Fork这个仓库并在Action运行工作流。 +如果你没看到Action这个标签栏,请到`settings`-`actions`-`General`把Actions permissions设置为'Allow all actions and reusable workflows' + +![Github Action](https://user-images.githubusercontent.com/64072399/216762170-8cce9b81-7dc1-4e7d-a774-b05f281a9bff.png) + +``` +Run ncipollo/release-action@v1 +Error: Error 403: Resource not accessible by integration +``` +如果你在尝试上传到Release时看到这个报错,请到 `settings`-`actions`-`General`把 Workflow permissions设置为'Read and write permissions'. + +### 2.在电脑上编译 + +`debian_build.sh` :用于Debian系发行版(如Debian,Ubuntu等) + +`arch_build.sh` :用于Arch系发行版(如Arch Linux,Manjaro等) + + +- `export SETUP_KERNELSU=true` (如果你不想把KernelSU集成进内核,请把它设置为`false`) + +## 食用指南 +### 1.如何刷入 +- 1.下载并安装 [KernelSU Manager](https://github.com/tiann/KernelSU/actions/workflows/build-manager.yml)。不建议安装除了`main`以外的分支,因为它们可能无法正常工作。 +- 2.下载 [platform-tools](https://developer.android.com/studio/releases/platform-tools) (不要从Ubuntu 20.04源安装) +- 3.重启到Recovery Sideload模式,刷入"xxx-v5.4.xxx-xxxxxxxx.zip" +``` +adb reboot sideload +adb sideload ./xxx-v5.4.xxx-xxxxxxxx.zip +``` + +### 2.更新时可能遇到的问题 +你可能会遇上手机进入fastbootd或recovery后无法连接电脑的情况, 请进入bootloader 重新刷入官方boot.img +``` +adb reboot bootloader +fastboot flash boot ./boot.img +fastboot reboot recovery +``` +现在你可以继续更新了 + +### 3.如何卸载 +刷回官方的boot.img和vendor_dlkm.img即可 +``` +adb reboot bootloader +fastboot flash boot ./boot.img +``` + +### 4.如何将更新同步到你的私有仓库 +使用Github Desktop将你的私有仓库克隆到本地,然后进入目录并打开终端。 + +``` +// 将主线分支同步到仓库 + +git remote add Celica https://github.com/natsumerinchan/KernelSU_Oneplus_martini_Guide.git //仅在第一次更新时需要这一步 + +git fetch Celica main +``` + +``` +// 从主线仓库cherry-pick提交到你的私有仓库 + +git cherry-pick +``` + +再用Github Desktop将提交上传到Github + +## Credits and Thanks +* [tiann/KernelSU](https://github.com/tiann/KernelSU.git): A Kernel based root solution for Android GKI +* [PixelOS-Devices/kernel_oneplus_sm8350](https://github.com/PixelOS-Devices/kernel_oneplus_sm8350.git): PixelOS kernel for OnePlus 9RT 5G (martini) +* [PixelExperience-Devices/kernel_oneplus_martini](https://github.com/PixelExperience-Devices/kernel_oneplus_martini.git): Pixel Experience kernel for OnePlus 9RT (martini) +* [Gainss/Action_Kernel](https://github.com/Gainss/Action_Kernel.git): Kernel Action template +* [xiaoleGun/KernelSU_action](https://github.com/xiaoleGun/KernelSU_action.git): Action for Non-GKI Kernel has some common and requires knowledge of kernel and Android to be used. +* [osm0sis/AnyKernel3](https://github.com/osm0sis/AnyKernel3.git): Flashable Zip Template for Kernel Releases with Ramdisk Modifications +* [@Dreamail](https://github.com/Dreamail): This [commit](https://github.com/tiann/KernelSU/commit/bf87b134ded3b81a864db20d8d25d0bfb9e74ebe) fix error for non-GKI kernel diff --git a/arch_build.sh b/arch_build.sh new file mode 100644 index 0000000..2d968c7 --- /dev/null +++ b/arch_build.sh @@ -0,0 +1,112 @@ +#! /bin/bash + +set -eux + +export KERNEL_PATH=$PWD +export CLANG_PATH=~/toolchains/neutron-clang +export PATH=${CLANG_PATH}/bin:${PATH} +export CLANG_TRIPLE=aarch64-linux-gnu- +export ARCH=arm64 +export SUBARCH=arm64 +export KERNEL_DEFCONFIG=vendor/lahaina-qgki_defconfig +export SETUP_KERNELSU=true # Enable if you want KernelSU +export KernelSU_TAG=main # Select KernelSU tag or branch +# Custom Keystore hash and size for KernelSU Manager +# Use `ksud debug get-sign ` to get them +if [ "${1-}" == "custom" ] || [ "${2-}" == "custom" ]; then + export KSU_EXPECTED_SIZE=0x352 + export KSU_EXPECTED_HASH=f29d8d0129230b6d09edeec28c6b17ab13d842da73b0bc7552feb81090f9b09e +else + unset KSU_EXPECTED_SIZE + unset KSU_EXPECTED_HASH +fi + + +if [ "${1-}" == "clean" ] || [ "${2-}" == "clean" ]; then + test -d ~/.ccache && rm -rf ~/.ccache + test -d ~/.cache/ccache && rm -rf ~/.cache/ccache + test -d "$KERNEL_PATH/out" && rm -rf "$KERNEL_PATH/out" +fi + +update_kernel() { + cd $KERNEL_PATH + git stash + git pull +} + +setup_environment() { + cd $KERNEL_PATH + sudo pacman -S zstd tar wget curl base-devel --noconfirm + yay -S lineageos-devel python2-bin lib32-ncurses lib32-zlib lib32-readline --noconfirm + if [ ! -d $CLANG_PATH ]; then + mkdir -p $CLANG_PATH + cd $CLANG_PATH + bash <(curl -s "https://raw.githubusercontent.com/Neutron-Toolchains/antman/main/antman") -S + fi +} + +setup_kernelsu() { + cd $KERNEL_PATH + curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -s $KernelSU_TAG + # Enable KPROBES + scripts/config --file "arch/$ARCH/configs/$KERNEL_DEFCONFIG" -e MODULES -e KPROBES -e HAVE_KPROBES -e KPROBE_EVENTS +} + +unsetup_kernelsu() { + cd $KERNEL_PATH + test -e "$KERNEL_PATH/drivers/kernelsu" && rm "$KERNEL_PATH/drivers/kernelsu" + grep -q "kernelsu" "$KERNEL_PATH/drivers/Makefile" && sed -i '/kernelsu/d' "$KERNEL_PATH/drivers/Makefile" + grep -q "kernelsu" "$KERNEL_PATH/drivers/Kconfig" && sed -i '/kernelsu/d' "$KERNEL_PATH/drivers/Kconfig" +} + +build_kernel() { + cd $KERNEL_PATH + make O=out CC="ccache clang" CXX="ccache clang++" ARCH=arm64 CROSS_COMPILE=$CLANG_PATH/bin/aarch64-linux-gnu- CROSS_COMPILE_ARM32=$CLANG_PATH/bin/arm-linux-gnueabi- LD=ld.lld $KERNEL_DEFCONFIG + # Disable LTO + if [[ $(echo "$(awk '/MemTotal/ {print $2}' /proc/meminfo) < 16000000" | bc -l) -eq 1 ]]; then + scripts/config --file out/.config -d LTO -d LTO_CLANG -d THINLTO -e LTO_NONE + fi + # Delete old files + test -d $KERNEL_PATH/out/arch/arm64/boot && rm -rf $KERNEL_PATH/out/arch/arm64/boot/* + # Begin compile + time make O=out CC="ccache clang" CXX="ccache clang++" ARCH=arm64 -j`nproc` CROSS_COMPILE=$CLANG_PATH/bin/aarch64-linux-gnu- CROSS_COMPILE_ARM32=$CLANG_PATH/bin/arm-linux-gnueabi- LD=ld.lld 2>&1 | tee kernel.log +} + +make_anykernel3_zip() { + cd $KERNEL_PATH + test -d $KERNEL_PATH/AnyKernel3 && rm -rf $KERNEL_PATH/AnyKernel3 + git clone https://gitlab.com/inferno0230/AnyKernel3 --depth=1 $KERNEL_PATH/AnyKernel3 + if test -e $KERNEL_PATH/out/arch/arm64/boot/Image && test -d $KERNEL_PATH/AnyKernel3; then + zip_name="ONEPLUS9RT-v5.4.$(grep "^SUBLEVEL =" Makefile | awk '{print $3}')-$(date +"%Y%m%d").zip" + cd $KERNEL_PATH/AnyKernel3 + cp $KERNEL_PATH/out/arch/arm64/boot/Image $KERNEL_PATH/AnyKernel3 + zip -r ${zip_name} * + mv ${zip_name} $KERNEL_PATH/out/arch/arm64/boot + cd $KERNEL_PATH + fi +} + +clear + +# update_kernel //Please uncomment if you need it + +if test -e $CLANG_PATH/env_is_setup; then + echo [INFO]Environment have been setup! +else + setup_environment + touch $CLANG_PATH/env_is_setup +fi + +if test "$SETUP_KERNELSU" == "true"; then + setup_kernelsu +else + echo [INFO] KernelSU will not be Compiled + unsetup_kernelsu +fi + +build_kernel + +make_anykernel3_zip +cd $KERNEL_PATH +echo [INFO] Products are put in $KERNEL_PATH/out/arch/arm64/boot +echo [INFO] Done. diff --git a/debian_build.sh b/debian_build.sh new file mode 100644 index 0000000..ac27ebb --- /dev/null +++ b/debian_build.sh @@ -0,0 +1,127 @@ +#! /bin/bash + +set -eux + +export KERNEL_PATH=$PWD +export CLANG_PATH=~/toolchains/neutron-clang +export PATH=${CLANG_PATH}/bin:${PATH} +export CLANG_TRIPLE=aarch64-linux-gnu- +export ARCH=arm64 +export SUBARCH=arm64 +export KERNEL_DEFCONFIG=vendor/lahaina-qgki_defconfig +export LLVM_VERSION=17 +export SETUP_KERNELSU=true # Enable if you want KernelSU +export KernelSU_TAG=main # Select KernelSU tag or branch +# Custom Keystore hash and size for KernelSU Manager +# Use `ksud debug get-sign ` to get them +if [ "${1-}" == "custom" ] || [ "${2-}" == "custom" ]; then + export KSU_EXPECTED_SIZE=0x352 + export KSU_EXPECTED_HASH=f29d8d0129230b6d09edeec28c6b17ab13d842da73b0bc7552feb81090f9b09e +else + unset KSU_EXPECTED_SIZE + unset KSU_EXPECTED_HASH +fi + +if [ "${1-}" == "clean" ] || [ "${2-}" == "clean" ]; then + test -d ~/.ccache && rm -rf ~/.ccache + test -d ~/.cache/ccache && rm -rf ~/.cache/ccache + test -d "$KERNEL_PATH/out" && rm -rf "$KERNEL_PATH/out" +fi + +update_kernel() { + cd $KERNEL_PATH + git stash + git pull +} + +setup_environment() { + cd $KERNEL_PATH + sudo apt update + sudo apt install zstd tar wget curl libarchive-tools + if [ ! -d $CLANG_PATH ]; then + mkdir -p $CLANG_PATH + cd $CLANG_PATH + curl -LO "https://raw.githubusercontent.com/Neutron-Toolchains/antman/main/antman" + bash antman -S=latest + bash antman --patch=glibc + fi + chmod +x llvm.sh + sudo ./llvm.sh $LLVM_VERSION + rm ./llvm.sh + sudo apt install --fix-missing + sudo ln -s --force /usr/bin/clang-$LLVM_VERSION /usr/bin/clang + sudo ln -s --force /usr/bin/ld.lld-$LLVM_VERSION /usr/bin/ld.lld + sudo ln -s --force /usr/bin/llvm-objdump-$LLVM_VERSION /usr/bin/llvm-objdump + sudo ln -s --force /usr/bin/llvm-ar-$LLVM_VERSION /usr/bin/llvm-ar + sudo ln -s --force /usr/bin/llvm-nm-$LLVM_VERSION /usr/bin/llvm-nm + sudo ln -s --force /usr/bin/llvm-strip-$LLVM_VERSION /usr/bin/llvm-strip + sudo ln -s --force /usr/bin/llvm-objcopy-$LLVM_VERSION /usr/bin/llvm-objcopy + sudo ln -s --force /usr/bin/llvm-readelf-$LLVM_VERSION /usr/bin/llvm-readelf + sudo ln -s --force /usr/bin/clang++-$LLVM_VERSION /usr/bin/clang++ +} + +setup_kernelsu() { + cd $KERNEL_PATH + curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -s $KernelSU_TAG + # Enable KPROBES + scripts/config --file "arch/$ARCH/configs/$KERNEL_DEFCONFIG" -e MODULES -e KPROBES -e HAVE_KPROBES -e KPROBE_EVENTS +} + +unsetup_kernelsu() { + cd $KERNEL_PATH + test -e "$KERNEL_PATH/drivers/kernelsu" && rm "$KERNEL_PATH/drivers/kernelsu" + grep -q "kernelsu" "$KERNEL_PATH/drivers/Makefile" && sed -i '/kernelsu/d' "$KERNEL_PATH/drivers/Makefile" + grep -q "kernelsu" "$KERNEL_PATH/drivers/Kconfig" && sed -i '/kernelsu/d' "$KERNEL_PATH/drivers/Kconfig" +} + +build_kernel() { + cd $KERNEL_PATH + make O=out CC="ccache clang" CXX="ccache clang++" ARCH=arm64 CROSS_COMPILE=$CLANG_PATH/bin/aarch64-linux-gnu- CROSS_COMPILE_ARM32=$CLANG_PATH/bin/arm-linux-gnueabi- LD=ld.lld $KERNEL_DEFCONFIG + # Disable LTO + if [[ $(echo "$(awk '/MemTotal/ {print $2}' /proc/meminfo) < 16000000" | bc -l) -eq 1 ]]; then + scripts/config --file out/.config -d LTO -d LTO_CLANG -d THINLTO -e LTO_NONE + fi + # Delete old files + test -d $KERNEL_PATH/out/arch/arm64/boot && rm -rf $KERNEL_PATH/out/arch/arm64/boot/* + # Begin compile + time make O=out CC="ccache clang" CXX="ccache clang++" ARCH=arm64 -j`nproc` CROSS_COMPILE=$CLANG_PATH/bin/aarch64-linux-gnu- CROSS_COMPILE_ARM32=$CLANG_PATH/bin/arm-linux-gnueabi- LD=ld.lld 2>&1 | tee kernel.log +} + +make_anykernel3_zip() { + cd $KERNEL_PATH + test -d $KERNEL_PATH/AnyKernel3 && rm -rf $KERNEL_PATH/AnyKernel3 + git clone https://gitlab.com/inferno0230/AnyKernel3 --depth=1 $KERNEL_PATH/AnyKernel3 + if test -e $KERNEL_PATH/out/arch/arm64/boot/Image && test -d $KERNEL_PATH/AnyKernel3; then + zip_name="ONEPLUS9RT-v5.4.$(grep "^SUBLEVEL =" Makefile | awk '{print $3}')-$(date +"%Y%m%d").zip" + cd $KERNEL_PATH/AnyKernel3 + cp $KERNEL_PATH/out/arch/arm64/boot/Image $KERNEL_PATH/AnyKernel3 + zip -r ${zip_name} * + mv ${zip_name} $KERNEL_PATH/out/arch/arm64/boot + cd $KERNEL_PATH + fi +} + +clear + +# update_kernel //Please uncomment if you need it + +if test -e $CLANG_PATH/env_is_setup; then + echo [INFO]Environment have been setup! +else + setup_environment + touch $CLANG_PATH/env_is_setup +fi + +if test "$SETUP_KERNELSU" == "true"; then + setup_kernelsu +else + echo [INFO] KernelSU will not be Compiled + unsetup_kernelsu +fi + +build_kernel + +make_anykernel3_zip +cd $KERNEL_PATH +echo [INFO] Products are put in $KERNEL_PATH/out/arch/arm64/boot +echo [INFO] Done.