├── .deepsource.toml ├── .github └── workflows │ └── shellcheck.yml ├── LICENSE ├── Makefile ├── README.md ├── ci-scripts ├── .gitignore ├── README.md ├── builder ├── ci-fake ├── ci-rad ├── ci-x86 └── logger ├── envsetup ├── arch ├── git └── manjaro ├── etc └── workaround ├── kernel ├── kernel ├── kernel-cl_telegraph.py └── wg ├── samples ├── README.md ├── build-kernel-clang └── build-kernel-gcc └── shellfiles /.deepsource.toml: -------------------------------------------------------------------------------- 1 | version = 1 2 | 3 | [[analyzers]] 4 | name = "shell" 5 | enabled = true -------------------------------------------------------------------------------- /.github/workflows/shellcheck.yml: -------------------------------------------------------------------------------- 1 | on: [push, pull_request] 2 | name: ShellCheck scripts 3 | jobs: 4 | shellCheck: 5 | name: ShellCheck 6 | runs-on: ubuntu-latest 7 | steps: 8 | - uses: actions/checkout@v1 9 | - name: Run shellcheck. 10 | run: while read -r script; do shellcheck --exclude=SC1090,SC1091,SC2155 $script; done < shellfiles -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2020 Shashank Baghel 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | check: 2 | while read -r script; do shellcheck --exclude=SC1090,SC1091 $$script; done < files 3 | 4 | .PHONY: check 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## lazyscripts 2 | 3 | These are just my personal scripts mostly BASH and ZSH for Unix/Linux for various tasks and to automate the works, feel free to use. These are always avaible in my bash/zsh env so i can access them quicly from anywhere! Also enabled workflow for shellcheck linting and indenting. 4 | -------------------------------------------------------------------------------- /ci-scripts/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /ci-scripts/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/radcolor/env/81a4dcf9b323b0255cfa5b27d3fe47c7396174b9/ci-scripts/README.md -------------------------------------------------------------------------------- /ci-scripts/builder: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function print() { 4 | echo "Builder" 5 | } 6 | 7 | function build1() { 8 | git clone --depth=1 --quiet "https://theradcolor:${GITHUB_TOKEN}@github.com/theradcolor/BOB-scripts" scripts 9 | sed -i "s/BOT_TOKEN=.*/BOT_TOKEN=$TELEGRAM_TOKEN/g" scripts/build1 10 | script -c "bash -x scripts/build1" build.log 11 | } 12 | 13 | $1 14 | -------------------------------------------------------------------------------- /ci-scripts/ci-fake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright (C) 2020 Shashank Baghel under GPLv3 4 | # Personal kernel CI build script for https://github.com/theradcolor/android_kernel_xiaomi_whyred 5 | 6 | # Only build if trigger event is custom and ci kernel type is fakerad 7 | if [[ ${DRONE_BUILD_EVENT} == "custom" && ${CI_KERNEL_TYPE} == "fakerad" ]]; then 8 | echo "PASS" 9 | else 10 | exit 11 | fi 12 | 13 | # Set enviroment and vaiables 14 | 15 | # Configure system 16 | export TZ=Asia/Kolkata 17 | 18 | # Configure git 19 | git config --global user.name "Shashank Baghel" 20 | git config --global user.email "theradcolor@gmail.com" 21 | 22 | DATE="$(date +%d%m%Y-%H%M%S)" 23 | CONFIG="fakerad_defconfig" 24 | WD=$(pwd) 25 | OUT=${WD}"/out" 26 | KERNEL_DIR=${WD} 27 | ANYKERNEL_DIR=${WD}"/AnyKernel3" 28 | IMG=${OUT}"/arch/arm64/boot/Image.gz-dtb" 29 | 30 | function clone_clang() { 31 | git clone --depth=1 --quiet https://github.com/theradcolor/clang clang 32 | } 33 | 34 | function clone_proton_clang() { 35 | git clone --depth=1 --quiet https://github.com/kdrag0n/proton-clang clang 36 | } 37 | 38 | function clone_aosp_clang() { 39 | git clone --depth=1 --quiet https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9 gcc64 40 | git clone --depth=1 --quiet https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9 gcc32 41 | mkdir clang 42 | cd clang || exit 43 | wget -q https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+archive/refs/heads/master/clang-r416183.tar.gz 44 | tar -xzf clang* 45 | cd .. || exit 46 | } 47 | 48 | function clone_gcc() { 49 | git clone --depth=1 --quiet https://github.com/theradcolor/arm-eabi -b ${GCC_BRANCH} gcc32 50 | git clone --depth=1 --quiet https://github.com/theradcolor/aarch64-elf -b ${GCC_BRANCH} gcc64 51 | } 52 | 53 | function clone_anykernel() { 54 | git clone --depth=1 --quiet https://github.com/theradcolor/AnyKernel3 -b ${AK_CLONE_BRANCH} 55 | } 56 | 57 | function checkout_source() { 58 | # Checkout to kernel source 59 | cd "${KERNEL_DIR}" 60 | } 61 | 62 | function set_param_gcc() { 63 | #Export compiler dir. 64 | export CROSS_COMPILE=$WD"/gcc64/bin/aarch64-elf-" 65 | export CROSS_COMPILE_ARM32=$WD"/gcc32/bin/arm-eabi-" 66 | 67 | export PATH="/drone/src/source/gcc64"/bin/:"/drone/src/source/gcc32"/bin/:/usr/bin:$PATH 68 | 69 | # Export ARCH 70 | export ARCH=arm64 71 | #Export SUBARCH 72 | export SUBARCH=arm64 73 | 74 | # Kbuild host and user 75 | export KBUILD_BUILD_USER="shashank" 76 | export KBUILD_BUILD_HOST="archlinux" 77 | export KBUILD_JOBS="$(($(grep -c '^processor' /proc/cpuinfo) * 2))" 78 | 79 | TC=$WD/gcc64/bin/aarch64-elf-gcc 80 | COMPILER_STRING="$(${WD}"/gcc64/bin/aarch64-elf-gcc" --version | head -n 1)" 81 | export KBUILD_COMPILER_STRING="${COMPILER_STRING}" 82 | 83 | export COMPILER_HEAD_COMMIT=$(cd gcc64 && git rev-parse HEAD) 84 | export COMPILER_HEAD_COMMIT_URL="https://github.com/theradcolor/aarch64-elf/commit/${COMPILER_HEAD_COMMIT}" 85 | } 86 | 87 | function set_param_clang() { 88 | # Export ARCH 89 | export ARCH=arm64 90 | #Export SUBARCH 91 | export SUBARCH=arm64 92 | 93 | # Kbuild host and user 94 | export KBUILD_BUILD_USER="shashank" 95 | export KBUILD_BUILD_HOST="archlinux" 96 | export KBUILD_JOBS="$(($(grep -c '^processor' /proc/cpuinfo) * 2))" 97 | 98 | # Compiler 99 | GCC32=$WD/clang/bin/arm-linux-gnueabi- 100 | GCC64=$WD/clang/bin/aarch64-linux-gnu- 101 | GCC64_TYPE=aarch64-linux-gnu- 102 | 103 | # Compiler String 104 | TC=$WD/clang/bin/clang 105 | CLANG_DIR=$WD/clang 106 | COMPILER_STRING="$(${TC} --version | head -n 1 | perl -pe 's/\(http.*?\)//gs' | sed -e 's/ */ /g' | sed 's/ *$//')" 107 | export KBUILD_COMPILER_STRING="${COMPILER_STRING}" 108 | 109 | export COMPILER_HEAD_COMMIT=$(cd clang && git rev-parse HEAD) 110 | 111 | if [ ${COMPILER} == "clang" ]; then 112 | export COMPILER_HEAD_COMMIT_URL="https://github.com/theradcolor/clang/commit/${COMPILER_HEAD_COMMIT}" 113 | elif [ ${COMPILER} == "proton-clang" ]; then 114 | export COMPILER_HEAD_COMMIT_URL="https://github.com/kdrag0n/proton-clang/commit/${COMPILER_HEAD_COMMIT}" 115 | else 116 | echo "Compiler not specified" 117 | fi 118 | } 119 | 120 | function set_param_aosp_clang() { 121 | # Export ARCH 122 | export ARCH=arm64 123 | #Export SUBARCH 124 | export SUBARCH=arm64 125 | 126 | # Kbuild host and user 127 | export KBUILD_BUILD_USER="shashank" 128 | export KBUILD_BUILD_HOST="archlinux" 129 | export KBUILD_JOBS="$(($(grep -c '^processor' /proc/cpuinfo) * 2))" 130 | 131 | # Compiler String 132 | CC="${ccache} $WD/clang/bin/clang" 133 | COMPILER_STRING="$(${CC} --version | head -n 1 | perl -pe 's/\(http.*?\)//gs' | sed -e 's/ */ /g')" 134 | export KBUILD_COMPILER_STRING="${COMPILER_STRING}" 135 | 136 | #export COMPILER_HEAD_COMMIT=$(cd clang && git rev-parse HEAD) 137 | #export COMPILER_HEAD_COMMIT_URL="https://github.com/theradcolor/clang/commit/${COMPILER_HEAD_COMMIT}" 138 | } 139 | 140 | function build_gcc() { 141 | clone_gcc 142 | checkout_source 143 | set_param_gcc 144 | # Push build message to telegram 145 | # tg_inform 146 | 147 | # Check kernel type 148 | check_kernel_type 149 | 150 | # Patch kernel for LTO 151 | lto_patches 152 | 153 | #Export compiler dir. 154 | export CROSS_COMPILE=$WD"/gcc64/bin/aarch64-elf-" 155 | export CROSS_COMPILE_ARM32=$WD"/gcc32/bin/arm-eabi-" 156 | 157 | make O="${OUT}" "${CONFIG}" 158 | 159 | BUILD_START=$(date +"%s") 160 | 161 | # Build 162 | make O="${OUT}" CROSS_COMPILE="/drone/src/source/gcc64/bin/aarch64-elf-" CROSS_COMPILE_ARM32="/drone/src/source/gcc32/bin/arm-eabi-" -j"${KBUILD_JOBS}" 2>&1 | tee "${OUT}"/build.log 163 | 164 | BUILD_END=$(date +"%s") 165 | DIFF=$(($BUILD_END - $BUILD_START)) 166 | 167 | if [ -f "${IMG}" ]; then 168 | echo "Build completed in $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) second(s)." 169 | flash_zip 170 | else 171 | tg_push_error 172 | echo "Build failed, please fix the errors first bish!" 173 | fi 174 | } 175 | 176 | function build_clang() { 177 | clone_clang 178 | checkout_source 179 | set_param_clang 180 | # Push build message to telegram 181 | # tg_inform 182 | 183 | # Check kernel type 184 | check_kernel_type 185 | 186 | # Patch kernel for LTO 187 | lto_patches 188 | 189 | make O="$OUT" ${CONFIG} 190 | 191 | BUILD_START=$(date +"%s") 192 | 193 | #Build 194 | make -j"${KBUILD_JOBS}" O=$OUT CC="${TC}" LLVM_AR="${CLANG_DIR}/bin/llvm-ar" LLVM_NM="${CLANG_DIR}/bin/llvm-nm" LD="${CLANG_DIR}/bin/ld.lld" OBJCOPY="${CLANG_DIR}/bin/llvm-objcopy" OBJDUMP="${CLANG_DIR}/bin/llvm-objdump" STRIP="${CLANG_DIR}/bin/llvm-strip" CROSS_COMPILE="${GCC64}" CROSS_COMPILE_ARM32="${GCC32}" CLANG_TRIPLE="${GCC64_TYPE}" 2>&1 | tee $OUT/build.log 195 | 196 | BUILD_END=$(date +"%s") 197 | DIFF=$(($BUILD_END - $BUILD_START)) 198 | 199 | if [ -f "${IMG}" ]; then 200 | echo "Build completed in $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) second(s)." 201 | flash_zip 202 | else 203 | tg_push_error 204 | echo "Build failed, please fix the errors first bish!" 205 | fi 206 | } 207 | 208 | function build_proton_clang() { 209 | clone_proton_clang 210 | checkout_source 211 | set_param_clang 212 | # Push build message to telegram 213 | # tg_inform 214 | 215 | # Check kernel type 216 | check_kernel_type 217 | 218 | # Patch kernel for LTO 219 | lto_patches 220 | 221 | make O="$OUT" ${CONFIG} 222 | 223 | BUILD_START=$(date +"%s") 224 | 225 | # Build 226 | make -j"${KBUILD_JOBS}" O=$OUT CC="${TC}" LLVM_AR="${CLANG_DIR}/bin/llvm-ar" LLVM_NM="${CLANG_DIR}/bin/llvm-nm" LD="${CLANG_DIR}/bin/ld.lld" OBJCOPY="${CLANG_DIR}/bin/llvm-objcopy" OBJDUMP="${CLANG_DIR}/bin/llvm-objdump" STRIP="${CLANG_DIR}/bin/llvm-strip" CROSS_COMPILE="${GCC64}" CROSS_COMPILE_ARM32="${GCC32}" CLANG_TRIPLE="${GCC64_TYPE}" 2>&1 | tee $OUT/build.log 227 | 228 | BUILD_END=$(date +"%s") 229 | DIFF=$(($BUILD_END - $BUILD_START)) 230 | 231 | if [ -f "${IMG}" ]; then 232 | echo "Build completed in $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) second(s)." 233 | flash_zip 234 | else 235 | tg_push_error 236 | echo "Build failed, please fix the errors first bish!" 237 | fi 238 | } 239 | 240 | function build_aosp_clang() { 241 | clone_aosp_clang 242 | checkout_source 243 | set_param_aosp_clang 244 | # Push build message to telegram 245 | # tg_inform 246 | 247 | # Check kernel type 248 | check_kernel_type 249 | 250 | # Patch kernel for LTO 251 | lto_patches 252 | 253 | make O="$OUT" ${CONFIG} 254 | 255 | BUILD_START=$(date +"%s") 256 | 257 | # Build 258 | make -j"${KBUILD_JOBS}" O=$OUT ARCH=arm64 CC=$WD"/clang/bin/clang" CLANG_TRIPLE="aarch64-linux-gnu-" CROSS_COMPILE=$WD"/gcc64/bin/aarch64-linux-android-" CROSS_COMPILE_ARM32=$WD"/gcc32/bin/arm-linux-androideabi-" 2>&1 | tee $OUT/build.log 259 | 260 | if [ -f "${IMG}" ]; then 261 | BUILD_END=$(date +"%s") 262 | DIFF=$(($BUILD_END - $BUILD_START)) 263 | echo "Build completed in $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) seconds." 264 | flash_zip 265 | else 266 | tg_push_error 267 | echo "Build failed, please fix the errors first bish!" 268 | fi 269 | } 270 | 271 | function flash_zip() { 272 | echo "Now making a flashable zip of kernel with AnyKernel3" 273 | 274 | # Clone AnyKernel3 based on EAS/HMP 275 | clone_anykernel 276 | 277 | # Check camera type oldcam/newcam 278 | check_camera 279 | 280 | if [ ${KERNEL_TYPE} == "fakerad" ]; then 281 | export ZIPNAME=fci-${TYPE}-${CAM_TYPE}-${DATE} 282 | else 283 | export ZIPNAME=ci-${TYPE}-${CAM_TYPE}-${DATE} 284 | fi 285 | 286 | # Checkout anykernel3 dir 287 | cd "${ANYKERNEL_DIR}" 288 | 289 | # Patch anykernel3 290 | #patch_anykernel 291 | 292 | # Patch anykernel3 string 293 | #patch_anykernel_string 294 | 295 | # Copy Image.gz-dtb to dir. 296 | cp ${OUT}/arch/arm64/boot/Image.gz-dtb ${ANYKERNEL_DIR}/ 297 | 298 | # Build a flashable zip 299 | zip -r9 ${ZIPNAME} * -x README.md .git 300 | 301 | # Sign the zip 302 | sign_zip 303 | 304 | if [ ${KERNEL_TYPE} == "fakerad" ]; then 305 | SHA256=$(sha256sum fci-*.zip | cut -d' ' -f1) 306 | else 307 | SHA256=$(sha256sum ci-*.zip | cut -d' ' -f1) 308 | fi 309 | 310 | # Push zip(s) to telegram 311 | tg_push 312 | } 313 | 314 | function check_camera() { 315 | CAMERA="$(grep 'BLOBS' ${KERNEL_DIR}/arch/arm64/configs/${CONFIG})" 316 | if [ ${CAMERA} == "CONFIG_XIAOMI_NEW_CAMERA_BLOBS=y" ]; then 317 | export CAM_TYPE="newcam" 318 | elif [ ${CAMERA} == "CONFIG_XIAOMI_NEW_CAMERA_BLOBS=n" ]; then 319 | export CAM_TYPE="oldcam" 320 | fi 321 | } 322 | 323 | function check_kernel_type() { 324 | KERNEL_TYPE="$(grep 'LOCALVERSION=' ${KERNEL_DIR}/arch/arm64/configs/${CONFIG})" 325 | KERNEL_TYPE=$(echo "${KERNEL_TYPE}" | cut -d'"' -f 2) 326 | if [[ ${KERNEL_TYPE} == *"-rad-v"* ]]; then 327 | export TYPE=hmp 328 | export KERNEL_TYPE=rad 329 | export AK_CLONE_BRANCH=ak-hmp 330 | elif [[ ${KERNEL_TYPE} == *"-rad-x"* ]]; then 331 | export TYPE=eas 332 | export KERNEL_TYPE=rad 333 | export AK_CLONE_BRANCH=ak-eas 334 | elif [[ ${KERNEL_TYPE} == *"-fakerad"* ]]; then 335 | export TYPE=eas 336 | export KERNEL_TYPE=fakerad 337 | export AK_CLONE_BRANCH=ak-eas 338 | fi 339 | } 340 | 341 | function tg_inform() { 342 | KERNEL_COMMIT="$(git rev-parse HEAD)" 343 | KERNEL_URL="https://github.com/theradcolor/android_kernel_xiaomi_whyred/commit/" 344 | SCRIPT_COMMIT="$(cd lazyscripts && git log -n 1 --pretty=format:%H -- ci-scripts/ci-rad)" 345 | SCRIPT_URL="https://github.com/theradcolor/lazyscripts/commit/" 346 | 347 | if [ ${CONFIG} == "fakerad_defconfig" ]; then 348 | curl -s -X POST https://api.telegram.org/bot${TG_BOT_API}/sendMessage?chat_id=${TRIGGERED_CHANNEL} -d "disable_web_page_preview=true" -d "parse_mode=markdownV2&text=⚒️ *Building with* [*$(echo ${SCRIPT_COMMIT} | cut -c1-8)*](${SCRIPT_URL}${SCRIPT_COMMIT}) / [*$(echo ${KERNEL_COMMIT} | cut -c1-8)*](${KERNEL_URL}${KERNEL_COMMIT})" 349 | fi 350 | } 351 | 352 | function sign_zip() { 353 | curl -sLo zipsigner-4.0.jar https://raw.githubusercontent.com/baalajimaestro/AnyKernel3/master/zipsigner-4.0.jar 354 | java -jar zipsigner-4.0.jar ${ZIPNAME}.zip ${ZIPNAME}-signed.zip 355 | rm -rf "${ZIPNAME}.zip" 356 | } 357 | 358 | function tg_push() { 359 | if [ ${KERNEL_TYPE} == "fakerad" ]; then 360 | ZIP="${ANYKERNEL_DIR}"/$(echo fci-*.zip) 361 | else 362 | ZIP="${ANYKERNEL_DIR}"/$(echo ci-*.zip) 363 | fi 364 | 365 | CAPTION="⭕️ Build took $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) second(s) | *SHA256 checksum* • \`${SHA256}\` | *Compiler* • [${COMPILER_STRING}](${COMPILER_HEAD_COMMIT_URL})" 366 | 367 | echo ${ZIP} >/drone/src/path-to-zip.txt 368 | echo ${CAPTION} >/drone/src/path-to-zip-caption.txt 369 | } 370 | 371 | function tg_push_error() { 372 | curl -s -X POST https://api.telegram.org/bot${TG_BOT_API}/sendMessage?chat_id=${TRIGGERED_CHANNEL} -d "disable_web_page_preview=true" -d "parse_mode=html&text=❌ Build failed after $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) second(s)." 373 | } 374 | 375 | function tg_push_log() { 376 | LOG=${KERNEL_DIR}/build.log 377 | curl -F document=@"${LOG}" "https://api.telegram.org/bot${TG_BOT_API}/sendDocument" \ 378 | -F chat_id="${TRIGGERED_CHANNEL}" \ 379 | -F "disable_web_page_preview=true" \ 380 | -F "parse_mode=html" \ 381 | -F caption="Build logs for ${TYPE}-${CAM_TYPE}, took $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) second(s). @theradcolor" 382 | } 383 | 384 | function patch_anykernel() { 385 | if [ ${TYPE} == "eas" ]; then 386 | curl https://raw.githubusercontent.com/theradcolor/patches/master/0001-anykernel3-add-our-init.rc-script-to-execute-on-boot-eas.patch | git am 387 | rm -rf *.patch 388 | elif [ ${TYPE} == "hmp" ]; then 389 | curl https://raw.githubusercontent.com/theradcolor/patches/master/0001-anykernel3-add-our-init.rc-script-to-execute-on-boot-hmp.patch | git am 390 | rm -rf *.patch 391 | elif [ ${TYPE} == "staging-eas" ]; then 392 | curl https://raw.githubusercontent.com/theradcolor/patches/master/0001-anykernel3-add-our-init.rc-script-to-execute-on-boot-eas.patch | git am 393 | rm -rf *.patch 394 | elif [ ${TYPE} == "staging-hmp" ]; then 395 | curl https://raw.githubusercontent.com/theradcolor/patches/master/0001-anykernel3-add-our-init.rc-script-to-execute-on-boot-hmp.patch | git am 396 | rm -rf *.patch 397 | else 398 | echo "Type not mentioned, skipping patches!" 399 | fi 400 | } 401 | 402 | function patch_anykernel_string() { 403 | # Append "(CI)" to the kernel output logs of anykernel based on type. 404 | AK_UPDATER_BINARY=${ANYKERNEL_DIR}"/META-INF/com/google/android/update-binary" 405 | if [ ${KERNEL_TYPE} == "fakerad" ]; then 406 | sed -i s/"RAD KERNEL"/"FAKERAD KERNEL (CI)"/g ${AK_UPDATER_BINARY} 407 | elif [ ${KERNEL_TYPE} == "rad" ]; then 408 | sed -i s/"RAD KERNEL"/"RAD KERNEL (CI)"/g ${AK_UPDATER_BINARY} 409 | else 410 | echo "Kernel type is not defined, skipping anykernel string patch!" 411 | fi 412 | } 413 | 414 | function lto_patches() { 415 | if [ ${LTO} == "true" ]; then 416 | if [ ${COMPILER} == "gnu-gcc" ]; then 417 | 418 | if [ ${KERNEL_TYPE} == "fakerad" ]; then 419 | curl https://raw.githubusercontent.com/theradcolor/patches/master/fakerad-gcc-lto-patch.patch | git am 420 | rm -rf *.patch 421 | else 422 | # GCC LTO patches for kernel 423 | curl https://raw.githubusercontent.com/theradcolor/patches/master/rad-kernel-gcc-lto-patch.patch | git am 424 | rm -rf *.patch 425 | fi 426 | 427 | elif [ ${COMPILER} == "proton-clang" ]; then 428 | 429 | if [ ${KERNEL_TYPE} == "fakerad" ]; then 430 | curl https://raw.githubusercontent.com/theradcolor/patches/master/fakerad-clang-lto-patch.patch | git am 431 | rm -rf *.patch 432 | else 433 | # CLANG LTO patches for kernel 434 | curl https://raw.githubusercontent.com/theradcolor/patches/master/rad-kernel-clang-lto-patch.patch | git am 435 | fi 436 | else 437 | echo "Compiler not specified" 438 | fi 439 | else 440 | echo "Skipping LTO patches!" 441 | fi 442 | } 443 | 444 | for i in "$@"; do 445 | case $i in 446 | --gcc) 447 | COMPILER="gnu-gcc" 448 | shift 449 | ;; 450 | --gcc-stable) 451 | GCC_BRANCH="stable-gcc" 452 | shift 453 | ;; 454 | --gcc-master) 455 | GCC_BRANCH="master" 456 | shift 457 | ;; 458 | --clang) 459 | COMPILER="clang" 460 | shift 461 | ;; 462 | --aosp-clang) 463 | COMPILER="aosp-clang" 464 | shift 465 | ;; 466 | --proton-clang) 467 | COMPILER="proton-clang" 468 | shift 469 | ;; 470 | --lto) 471 | LTO="true" 472 | shift 473 | ;; 474 | *) 475 | # unknown option 476 | echo "Unknown option(s)" 477 | exit 478 | ;; 479 | esac 480 | done 481 | 482 | # Start Build (build_clang/build_aosp_clang/build_proton_clang/build_gcc) 483 | if [ "${COMPILER}" == "gnu-gcc" ]; then 484 | build_gcc 485 | elif [ "${COMPILER}" == "clang" ]; then 486 | build_clang 487 | elif [ "${COMPILER}" == "aosp-clang" ]; then 488 | build_aosp_clang 489 | elif [ "${COMPILER}" == "proton-clang" ]; then 490 | build_proton_clang 491 | else 492 | echo "Compiler not specified, building default with gcc master" 493 | COMPILER="gnu-gcc" 494 | GCC_BRANCH="master" 495 | build_gcc 496 | fi 497 | -------------------------------------------------------------------------------- /ci-scripts/ci-rad: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright (C) 2020 Shashank Baghel under GPLv3 4 | # Personal kernel CI build script for https://github.com/theradcolor/android_kernel_xiaomi_whyred 5 | 6 | # Only build if trigger event is custom and ci kernel type is fakerad 7 | if [[ ${DRONE_BUILD_EVENT} == "custom" && ${CI_KERNEL_TYPE} == "fakerad" ]]; then 8 | exit 9 | fi 10 | 11 | # Set enviroment and vaiables 12 | 13 | # Configure system 14 | export TZ=Asia/Kolkata 15 | 16 | # Configure git 17 | git config --global user.name "Shashank Baghel" 18 | git config --global user.email "theradcolor@gmail.com" 19 | 20 | DATE="$(date +%d%m%Y-%H%M%S)" 21 | CHANNEL_ID="-1001487815579" 22 | GRP_CHAT_ID="-1001375712567" 23 | WD="$(pwd)" 24 | OUT=${WD}"/out" 25 | KERNEL_DIR=${WD} 26 | ANYKERNEL_DIR=${WD}"/AnyKernel3" 27 | IMG=${OUT}"/arch/arm64/boot/Image.gz-dtb" 28 | 29 | function clone_clang() { 30 | git clone --depth=1 --quiet https://github.com/radcolor/clang clang 31 | } 32 | 33 | function clone_proton_clang() { 34 | git clone --depth=1 --quiet https://github.com/kdrag0n/proton-clang clang 35 | } 36 | 37 | function clone_aosp_clang() { 38 | git clone --depth=1 --quiet https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9 gcc64 39 | git clone --depth=1 --quiet https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9 gcc32 40 | mkdir clang 41 | cd clang || exit 42 | wget -q https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+archive/refs/heads/master/clang-r416183b.tar.gz 43 | tar -xzf clang* 44 | cd .. || exit 45 | } 46 | 47 | function clone_gcc() { 48 | git clone --depth=1 --quiet https://github.com/radcolor/arm-eabi -b ${GCC_BRANCH} gcc32 49 | git clone --depth=1 --quiet https://github.com/radcolor/aarch64-elf -b ${GCC_BRANCH} gcc64 50 | } 51 | 52 | function clone_anykernel() { 53 | git clone --depth=1 --quiet https://github.com/radcolor/AnyKernel3 -b ${AK_CLONE_BRANCH} 54 | } 55 | 56 | function checkout_source() { 57 | # Checkout to kernel source 58 | cd "${KERNEL_DIR}" 59 | } 60 | 61 | function set_param_gcc() { 62 | #Export compiler dir. 63 | export CROSS_COMPILE=$WD"/gcc64/bin/aarch64-elf-" 64 | export CROSS_COMPILE_ARM32=$WD"/gcc32/bin/arm-eabi-" 65 | 66 | # export PATH="gcc64"/bin/:"gcc32"/bin/:$PATH 67 | 68 | # Export ARCH 69 | export ARCH=arm64 70 | #Export SUBARCH 71 | export SUBARCH=arm64 72 | 73 | # Kbuild host and user 74 | export KBUILD_BUILD_USER="shashank" 75 | export KBUILD_BUILD_HOST="archlinux" 76 | export KBUILD_JOBS="$(($(grep -c '^processor' /proc/cpuinfo) * 2))" 77 | 78 | TC=$WD/gcc64/bin/aarch64-linux-gnu-gcc 79 | COMPILER_STRING="$(${WD}"/gcc64/bin/aarch64-elf-gcc" --version | head -n 1)" 80 | export KBUILD_COMPILER_STRING="${COMPILER_STRING}" 81 | 82 | export COMPILER_HEAD_COMMIT=$(cd gcc64 && git rev-parse HEAD) 83 | export COMPILER_HEAD_COMMIT_URL="https://github.com/radcolor/aarch64-elf/commit/${COMPILER_HEAD_COMMIT}" 84 | } 85 | 86 | function set_param_clang() { 87 | # Export ARCH 88 | export ARCH=arm64 89 | #Export SUBARCH 90 | export SUBARCH=arm64 91 | 92 | # Kbuild host and user 93 | export KBUILD_BUILD_USER="shashank" 94 | export KBUILD_BUILD_HOST="archlinux" 95 | export KBUILD_JOBS="$(($(grep -c '^processor' /proc/cpuinfo) * 2))" 96 | 97 | # Compiler 98 | GCC32=$WD/clang/bin/arm-linux-gnueabi- 99 | GCC64=$WD/clang/bin/aarch64-linux-gnu- 100 | GCC64_TYPE=aarch64-linux-gnu- 101 | 102 | # Compiler String 103 | TC=$WD/clang/bin/clang 104 | CLANG_DIR=$WD/clang 105 | COMPILER_STRING="$(${TC} --version | head -n 1 | perl -pe 's/\(http.*?\)//gs' | sed -e 's/ */ /g' | sed 's/ *$//')" 106 | export KBUILD_COMPILER_STRING="${COMPILER_STRING}" 107 | 108 | export PATH="/drone/src/source/clang"/bin/:$PATH 109 | 110 | export COMPILER_HEAD_COMMIT=$(cd clang && git rev-parse HEAD) 111 | 112 | if [ ${COMPILER} == "clang" ]; then 113 | export COMPILER_HEAD_COMMIT_URL="https://github.com/radcolor/clang/commit/${COMPILER_HEAD_COMMIT}" 114 | elif [ ${COMPILER} == "proton-clang" ]; then 115 | export COMPILER_HEAD_COMMIT_URL="https://github.com/kdrag0n/proton-clang/commit/${COMPILER_HEAD_COMMIT}" 116 | else 117 | echo "Compiler not specified" 118 | fi 119 | } 120 | 121 | function set_param_aosp_clang() { 122 | # Export ARCH 123 | export ARCH=arm64 124 | #Export SUBARCH 125 | export SUBARCH=arm64 126 | 127 | # Kbuild host and user 128 | export KBUILD_BUILD_USER="shashank" 129 | export KBUILD_BUILD_HOST="archlinux" 130 | export KBUILD_JOBS="$(($(grep -c '^processor' /proc/cpuinfo) * 2))" 131 | 132 | # Compiler String 133 | CC="${ccache} $WD/clang/bin/clang" 134 | COMPILER_STRING="$(${CC} --version | head -n 1 | perl -pe 's/\(http.*?\)//gs' | sed -e 's/ */ /g')" 135 | export KBUILD_COMPILER_STRING="${COMPILER_STRING}" 136 | 137 | export PATH="/drone/src/source/clang"/bin/:$PATH 138 | 139 | #export COMPILER_HEAD_COMMIT=$(cd clang && git rev-parse HEAD) 140 | #export COMPILER_HEAD_COMMIT_URL="https://github.com/radcolor/clang/commit/${COMPILER_HEAD_COMMIT}" 141 | } 142 | 143 | function build_gcc() { 144 | clone_gcc 145 | checkout_source 146 | set_param_gcc 147 | # Push build message to telegram 148 | tg_inform 149 | 150 | # Check kernel type 151 | check_kernel_type 152 | 153 | # Patch kernel for LTO 154 | lto_patches 155 | 156 | make O="${OUT}" "${CONFIG}" 157 | 158 | # Check Linux Version 159 | make kernelversion 160 | 161 | BUILD_START=$(date +"%s") 162 | 163 | # Build 164 | make O="${OUT}" -j"${KBUILD_JOBS}" 165 | 166 | BUILD_END=$(date +"%s") 167 | DIFF=$(($BUILD_END - $BUILD_START)) 168 | 169 | if [ -f "${IMG}" ]; then 170 | echo "Build completed in $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) second(s)." 171 | flash_zip 172 | else 173 | tg_push_error 174 | echo "Build failed, please fix the errors first bish!" 175 | fi 176 | } 177 | 178 | function build_clang() { 179 | clone_clang 180 | checkout_source 181 | set_param_clang 182 | # Push build message to telegram 183 | tg_inform 184 | 185 | # Check kernel type 186 | check_kernel_type 187 | 188 | # Patch kernel for LTO 189 | lto_patches 190 | 191 | make O="$OUT" ${CONFIG} 192 | 193 | # Check Linux Version 194 | make kernelversion 195 | 196 | BUILD_START=$(date +"%s") 197 | 198 | #Build 199 | make -j"${KBUILD_JOBS}" O=$OUT CC="${TC}" LLVM_AR="${CLANG_DIR}/bin/llvm-ar" LLVM_NM="${CLANG_DIR}/bin/llvm-nm" LD="${CLANG_DIR}/bin/ld.lld" OBJCOPY="${CLANG_DIR}/bin/llvm-objcopy" OBJDUMP="${CLANG_DIR}/bin/llvm-objdump" STRIP="${CLANG_DIR}/bin/llvm-strip" CROSS_COMPILE="${GCC64}" CROSS_COMPILE_ARM32="${GCC32}" CLANG_TRIPLE="${GCC64_TYPE}" 200 | 201 | BUILD_END=$(date +"%s") 202 | DIFF=$(($BUILD_END - $BUILD_START)) 203 | 204 | if [ -f "${IMG}" ]; then 205 | echo "Build completed in $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) second(s)." 206 | flash_zip 207 | else 208 | tg_push_error 209 | echo "Build failed, please fix the errors first bish!" 210 | fi 211 | } 212 | 213 | function build_proton_clang() { 214 | clone_proton_clang 215 | checkout_source 216 | set_param_clang 217 | # Push build message to telegram 218 | tg_inform 219 | 220 | # Check kernel type 221 | check_kernel_type 222 | 223 | # Patch kernel for LTO 224 | lto_patches 225 | 226 | make O="$OUT" ${CONFIG} 227 | 228 | # Check Linux Version 229 | make kernelversion 230 | 231 | BUILD_START=$(date +"%s") 232 | 233 | # Build 234 | make -j"${KBUILD_JOBS}" O=$OUT CC="${TC}" LLVM_AR="llvm-ar" LLVM_NM="llvm-nm" LD="ld.lld" OBJCOPY="llvm-objcopy" OBJDUMP="llvm-objdump" STRIP="llvm-strip" CROSS_COMPILE="${GCC64}" CROSS_COMPILE_ARM32="${GCC32}" CLANG_TRIPLE="${GCC64_TYPE}" 235 | 236 | BUILD_END=$(date +"%s") 237 | DIFF=$(($BUILD_END - $BUILD_START)) 238 | 239 | if [ -f "${IMG}" ]; then 240 | echo "Build completed in $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) second(s)." 241 | flash_zip 242 | else 243 | tg_push_error 244 | echo "Build failed, please fix the errors first bish!" 245 | fi 246 | } 247 | 248 | function build_aosp_clang() { 249 | clone_aosp_clang 250 | checkout_source 251 | set_param_aosp_clang 252 | # Push build message to telegram 253 | tg_inform 254 | 255 | # Check kernel type 256 | check_kernel_type 257 | 258 | # Patch kernel for LTO 259 | lto_patches 260 | 261 | make O="$OUT" ${CONFIG} 262 | 263 | # Check Linux Version 264 | make kernelversion 265 | 266 | BUILD_START=$(date +"%s") 267 | 268 | # Build 269 | make -j"${KBUILD_JOBS}" O=$OUT ARCH=arm64 CC="clang" LLVM_AR="llvm-ar" LLVM_NM="llvm-nm" LD="ld.lld" OBJCOPY="llvm-objcopy" OBJDUMP="llvm-objdump" STRIP="llvm-strip" CLANG_TRIPLE="aarch64-linux-gnu-" CROSS_COMPILE=$WD"/gcc64/bin/aarch64-linux-android-" CROSS_COMPILE_ARM32=$WD"/gcc32/bin/arm-linux-androideabi-" 270 | 271 | if [ -f "${IMG}" ]; then 272 | BUILD_END=$(date +"%s") 273 | DIFF=$(($BUILD_END - $BUILD_START)) 274 | echo "Build completed in $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) seconds." 275 | flash_zip 276 | else 277 | tg_push_error 278 | echo "Build failed, please fix the errors first bish!" 279 | fi 280 | } 281 | 282 | function flash_zip() { 283 | echo "Now making a flashable zip of kernel with AnyKernel3" 284 | 285 | # Clone AnyKernel3 based on EAS/HMP 286 | clone_anykernel 287 | 288 | # Check camera type oldcam/newcam 289 | check_camera 290 | 291 | if [ ${KERNEL_TYPE} == "fakerad" ]; then 292 | export ZIPNAME=fci-${TYPE}-${CAM_TYPE}-${DATE} 293 | else 294 | export ZIPNAME=ci-${TYPE}-${CAM_TYPE}-${DATE} 295 | fi 296 | 297 | # Checkout anykernel3 dir 298 | cd "${ANYKERNEL_DIR}" 299 | 300 | # Patch anykernel3 301 | #patch_anykernel 302 | 303 | # Patch anykernel3 string 304 | #patch_anykernel_string 305 | 306 | # Copy Image.gz-dtb to dir. 307 | cp ${OUT}/arch/arm64/boot/Image.gz-dtb ${ANYKERNEL_DIR}/ 308 | 309 | # Build a flashable zip 310 | zip -r9 ${ZIPNAME} * -x README.md .git 311 | 312 | # Sign the zip 313 | sign_zip 314 | 315 | if [ ${KERNEL_TYPE} == "fakerad" ]; then 316 | SHA256=$(sha256sum fci-*.zip | cut -d' ' -f1) 317 | else 318 | SHA256=$(sha256sum ci-*.zip | cut -d' ' -f1) 319 | fi 320 | 321 | # Checkout source 322 | cd .. 323 | 324 | # Push zip(s) to telegram 325 | tg_push 326 | } 327 | 328 | function check_camera() { 329 | CAMERA="$(grep 'BLOBS' ${KERNEL_DIR}/arch/arm64/configs/${CONFIG})" 330 | if [ ${CAMERA} == "CONFIG_XIAOMI_NEW_CAMERA_BLOBS=y" ]; then 331 | export CAM_TYPE="newcam" 332 | elif [ ${CAMERA} == "CONFIG_XIAOMI_NEW_CAMERA_BLOBS=n" ]; then 333 | export CAM_TYPE="oldcam" 334 | fi 335 | } 336 | 337 | function check_kernel_type() { 338 | KERNEL_TYPE="$(grep 'LOCALVERSION=' ${KERNEL_DIR}/arch/arm64/configs/${CONFIG})" 339 | KERNEL_TYPE=$(echo "${KERNEL_TYPE}" | cut -d'"' -f 2) 340 | if [[ ${KERNEL_TYPE} == *"-rad-v"* ]]; then 341 | export TYPE=hmp 342 | export KERNEL_TYPE=rad 343 | export AK_CLONE_BRANCH=ak-hmp 344 | elif [[ ${KERNEL_TYPE} == *"-rad-x"* ]]; then 345 | export TYPE=eas 346 | export KERNEL_TYPE=rad 347 | export AK_CLONE_BRANCH=ak-eas 348 | elif [[ ${KERNEL_TYPE} == *"-fakerad"* ]]; then 349 | export TYPE=eas 350 | export KERNEL_TYPE=fakerad 351 | export AK_CLONE_BRANCH=ak-eas 352 | fi 353 | } 354 | 355 | function tg_inform() { 356 | # Only build if trigger event is custom and ci kernel type is fakerad 357 | if [ "${PUBLIC_PUSH}" == "true" ]; then 358 | KERNEL_COMMIT="$(git rev-parse HEAD)" 359 | KERNEL_URL="https://github.com/radcolor/android_kernel_xiaomi_whyred/commit/" 360 | SCRIPT_COMMIT="$(cd lazyscripts && git log -n 1 --pretty=format:%H -- ci-scripts/ci-rad)" 361 | SCRIPT_URL="https://github.com/radcolor/lazyscripts/commit/" 362 | 363 | if [ "${COMPILER}" == "gnu-gcc" ]; then 364 | curl -s -X POST https://api.telegram.org/bot${TG_BOT_API}/sendMessage?chat_id=${CHANNEL_ID} -d "disable_web_page_preview=true" -d "parse_mode=markdownV2&text=⚒️ *Building with* [*$(echo ${SCRIPT_COMMIT} | cut -c1-8)*](${SCRIPT_URL}${SCRIPT_COMMIT}) / [*$(echo ${KERNEL_COMMIT} | cut -c1-8)*](${KERNEL_URL}${KERNEL_COMMIT})" 365 | fi 366 | fi 367 | } 368 | 369 | function sign_zip() { 370 | curl -sLo zipsigner-4.0.jar https://raw.githubusercontent.com/baalajimaestro/AnyKernel3/master/zipsigner-4.0.jar 371 | java -jar zipsigner-4.0.jar ${ZIPNAME}.zip ${ZIPNAME}-signed.zip 372 | rm -rf "${ZIPNAME}.zip" 373 | } 374 | 375 | function tg_push() { 376 | if [ ${KERNEL_TYPE} == "fakerad" ]; then 377 | ZIP="${ANYKERNEL_DIR}"/$(echo fci-*.zip) 378 | else 379 | ZIP="${ANYKERNEL_DIR}"/$(echo ci-*.zip) 380 | fi 381 | 382 | CAPTION="⭕️ Build took $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) second(s) | *SHA256 checksum* • \`${SHA256}\` | *Compiler* • [${COMPILER_STRING}](${COMPILER_HEAD_COMMIT_URL})" 383 | 384 | echo ${ZIP} >path-to-zip.txt 385 | echo ${CAPTION} >path-to-zip-caption.txt 386 | } 387 | 388 | function tg_push_error() { 389 | curl -s -X POST https://api.telegram.org/bot${TG_BOT_API}/sendMessage?chat_id=${GRP_CHAT_ID} -d "disable_web_page_preview=true" -d "parse_mode=html&text=❌ Build failed after $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) second(s)." 390 | } 391 | 392 | function tg_push_log() { 393 | LOG=${KERNEL_DIR}/build.log 394 | curl -F document=@"${LOG}" "https://api.telegram.org/bot${TG_BOT_API}/sendDocument" \ 395 | -F chat_id="${GRP_CHAT_ID}" \ 396 | -F "disable_web_page_preview=true" \ 397 | -F "parse_mode=html" \ 398 | -F caption="Build logs for ${TYPE}-${CAM_TYPE}, took $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) second(s). @theradcolor" 399 | } 400 | 401 | function patch_anykernel() { 402 | if [ ${TYPE} == "eas" ]; then 403 | curl https://raw.githubusercontent.com/radcolor/patches/master/0001-anykernel3-add-our-init.rc-script-to-execute-on-boot-eas.patch | git am 404 | rm -rf *.patch 405 | elif [ ${TYPE} == "hmp" ]; then 406 | curl https://raw.githubusercontent.com/radcolor/patches/master/0001-anykernel3-add-our-init.rc-script-to-execute-on-boot-hmp.patch | git am 407 | rm -rf *.patch 408 | elif [ ${TYPE} == "staging-eas" ]; then 409 | curl https://raw.githubusercontent.com/radcolor/patches/master/0001-anykernel3-add-our-init.rc-script-to-execute-on-boot-eas.patch | git am 410 | rm -rf *.patch 411 | elif [ ${TYPE} == "staging-hmp" ]; then 412 | curl https://raw.githubusercontent.com/radcolor/patches/master/0001-anykernel3-add-our-init.rc-script-to-execute-on-boot-hmp.patch | git am 413 | rm -rf *.patch 414 | else 415 | echo "Type not mentioned, skipping patches!" 416 | fi 417 | } 418 | 419 | function patch_anykernel_string() { 420 | # Append "(CI)" to the kernel output logs of anykernel based on type. 421 | AK_UPDATER_BINARY=${ANYKERNEL_DIR}"/META-INF/com/google/android/update-binary" 422 | if [ ${KERNEL_TYPE} == "fakerad" ]; then 423 | sed -i s/"RAD KERNEL"/"FAKERAD KERNEL (CI)"/g ${AK_UPDATER_BINARY} 424 | elif [ ${KERNEL_TYPE} == "rad" ]; then 425 | sed -i s/"RAD KERNEL"/"RAD KERNEL (CI)"/g ${AK_UPDATER_BINARY} 426 | else 427 | echo "Kernel type is not defined, skipping anykernel string patch!" 428 | fi 429 | } 430 | 431 | function lto_patches() { 432 | if [ "${LTO}" == "true" ]; then 433 | if [ "${COMPILER}" == "gnu-gcc" ]; then 434 | 435 | if [ "${KERNEL_TYPE}" == "fakerad" ]; then 436 | curl https://raw.githubusercontent.com/radcolor/patches/master/fakerad-gcc-lto-patch.patch | git am 437 | rm -rf *.patch 438 | else 439 | # GCC LTO patches for kernel 440 | curl https://raw.githubusercontent.com/radcolor/patches/master/rad-kernel-gcc-lto-patch.patch | git am 441 | rm -rf *.patch 442 | fi 443 | 444 | elif [ "${COMPILER}" == "proton-clang" ]; then 445 | 446 | if [ "${KERNEL_TYPE}" == "fakerad" ]; then 447 | curl https://raw.githubusercontent.com/radcolor/patches/master/fakerad-clang-lto-patch.patch | git am 448 | rm -rf *.patch 449 | else 450 | # CLANG LTO patches for kernel 451 | curl https://raw.githubusercontent.com/radcolor/patches/master/rad-kernel-clang-lto-patch.patch | git am 452 | fi 453 | 454 | elif [ "${COMPILER}" == "aosp-clang" ]; then 455 | 456 | if [ "${KERNEL_TYPE}" == "fakerad" ]; then 457 | curl https://raw.githubusercontent.com/radcolor/patches/master/fakerad-clang-lto-patch.patch | git am 458 | rm -rf *.patch 459 | else 460 | # CLANG LTO patches for kernel 461 | curl https://raw.githubusercontent.com/radcolor/patches/master/rad-kernel-clang-lto-patch.patch | git am 462 | fi 463 | else 464 | echo "Compiler not specified" 465 | fi 466 | else 467 | echo "Skipping LTO patches!" 468 | fi 469 | } 470 | 471 | for i in "$@"; do 472 | case $i in 473 | --oldcam) 474 | CONFIG="whyred_defconfig" 475 | shift 476 | ;; 477 | --newcam) 478 | CONFIG="whyred-newcam_defconfig" 479 | shift 480 | ;; 481 | --fakerad) 482 | CONFIG="fakerad_defconfig" 483 | shift 484 | ;; 485 | --gcc) 486 | COMPILER="gnu-gcc" 487 | shift 488 | ;; 489 | --gcc-stable) 490 | GCC_BRANCH="stable-gcc" 491 | shift 492 | ;; 493 | --gcc-master) 494 | GCC_BRANCH="master" 495 | shift 496 | ;; 497 | --clang) 498 | COMPILER="clang" 499 | shift 500 | ;; 501 | --aosp-clang) 502 | COMPILER="aosp-clang" 503 | shift 504 | ;; 505 | --proton-clang) 506 | COMPILER="proton-clang" 507 | shift 508 | ;; 509 | --lto) 510 | LTO="true" 511 | shift 512 | ;; 513 | *) 514 | # unknown option 515 | echo "Unknown option(s)" 516 | exit 517 | ;; 518 | esac 519 | done 520 | 521 | # Start Build (build_clang/build_aosp_clang/build_proton_clang/build_gcc) 522 | if [ "${COMPILER}" == "gnu-gcc" ]; then 523 | build_gcc 524 | elif [ "${COMPILER}" == "clang" ]; then 525 | build_clang 526 | elif [ "${COMPILER}" == "aosp-clang" ]; then 527 | build_aosp_clang 528 | elif [ "${COMPILER}" == "proton-clang" ]; then 529 | build_proton_clang 530 | else 531 | echo "Compiler not specified" 532 | fi 533 | -------------------------------------------------------------------------------- /ci-scripts/ci-x86: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (C) 2020 Shashank Baghel 4 | # To compile and install mainline/stable kernel for my machine running on arch 5 | 6 | # Set enviroment and vaiables 7 | DATE="$(date +%d%m%Y-%H%M%S)" 8 | WD=$(pwd) 9 | K_DIR=${WD} 10 | K_VERSION=$(make -s kernelrelease) 11 | PACKAGE_NAME="RAD-"${K_VERSION}-${DATE}.tar.zst 12 | TOKEN="123:xyz" 13 | CHAT_ID="-1001375712567" 14 | CHANNEL_ID="-1001487815579" 15 | 16 | function envsetup() { 17 | # Kbuild host and user 18 | export KBUILD_BUILD_USER="shashank" 19 | export KBUILD_BUILD_HOST="archlinux" 20 | 21 | export KBUILD_JOBS="$(($(grep -c '^processor' /proc/cpuinfo) * 2))" 22 | } 23 | 24 | function build() { 25 | # Cleanup dir. 26 | make clean && make mrproper 27 | 28 | # Make config 29 | make arch_defconfig 30 | 31 | # Make kernel 32 | make -j"${KBUILD_JOBS}" all 33 | } 34 | 35 | function package() { 36 | make -s kernelrelease >version 37 | mkdir /drone/src/package 38 | pkgdir="/drone/src/package" 39 | local kernver="$( 28 | export ARCH=arm64 29 | #Export SUBARCH 30 | export SUBARCH=arm64 31 | 32 | # Kbuild host and user 33 | export KBUILD_BUILD_USER="shashank" 34 | export KBUILD_BUILD_HOST="archlinux" 35 | export KBUILD_JOBS="$(($(grep -c '^processor' /proc/cpuinfo) + 1))" 36 | 37 | COMPILER_STRING="$(${WD}"/aarch64-gcc/bin/aarch64-linux-gnu-gcc" --version | head -n 1)" 38 | export KBUILD_COMPILER_STRING="${COMPILER_STRING}" 39 | } 40 | 41 | function set_param_clang() { 42 | # Export ARCH 43 | export ARCH=arm64 44 | #Export SUBARCH 45 | export SUBARCH=arm64 46 | 47 | # Kbuild host and user 48 | export KBUILD_BUILD_USER="shashank" 49 | export KBUILD_BUILD_HOST="archlinux" 50 | export KBUILD_JOBS="$(($(grep -c '^processor' /proc/cpuinfo) + 1))" 51 | 52 | # Compiler 53 | TC=$WD/clang/bin/clang 54 | CLANG_DIR=$WD/clang 55 | GCC32=$WD/clang/bin/arm-linux-gnueabi- 56 | GCC64=$WD/clang/bin/aarch64-linux-gnu- 57 | GCC64_TYPE=aarch64-linux-gnu- 58 | 59 | COMPILER_STRING="$(${TC} --version | head -n 1 | perl -pe 's/\(http.*?\)//gs' | sed -e 's/ */ /g' | sed 's/ *$//')" 60 | export KBUILD_COMPILER_STRING="${COMPILER_STRING}" 61 | } 62 | 63 | function set_param_aosp_clang() { 64 | # Export ARCH 65 | export ARCH=arm64 66 | #Export SUBARCH 67 | export SUBARCH=arm64 68 | 69 | # Kbuild host and user 70 | export KBUILD_BUILD_USER="shashank" 71 | export KBUILD_BUILD_HOST="archlinux" 72 | export KBUILD_JOBS="$(($(grep -c '^processor' /proc/cpuinfo) + 1))" 73 | 74 | COMPILER_STRING="$(${CC} --version | head -n 1 | perl -pe 's/\(http.*?\)//gs' | sed -e 's/ */ /g')" 75 | export KBUILD_COMPILER_STRING="${COMPILER_STRING}" 76 | } 77 | 78 | function build_gcc() { 79 | checkout_source 80 | set_param_gcc 81 | 82 | # Check kernel type 83 | check_kernel_type 84 | 85 | # Patch kernel for LTO 86 | lto_patches 87 | 88 | make O="${OUT}" "${CONFIG}" 89 | 90 | BUILD_START=$(date +"%s") 91 | 92 | # Build 93 | make O="${OUT}" -j"${KBUILD_JOBS}" 94 | 95 | BUILD_END=$(date +"%s") 96 | DIFF=$(($BUILD_END - $BUILD_START)) 97 | 98 | if [ -f "${IMG}" ]; then 99 | echo "Build completed in $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) second(s)." 100 | flash_zip 101 | else 102 | echo "Build failed, please fix the errors first bish!" 103 | fi 104 | } 105 | 106 | function build_clang() { 107 | checkout_source 108 | set_param_clang 109 | 110 | # Check kernel type 111 | check_kernel_type 112 | 113 | # Patch kernel for LTO 114 | lto_patches 115 | 116 | make O="$OUT" ${CONFIG} 117 | 118 | BUILD_START=$(date +"%s") 119 | 120 | #Build 121 | make -j"${KBUILD_JOBS}" O=$OUT CC="${TC}" LLVM_AR="${CLANG_DIR}/bin/llvm-ar" LLVM_NM="${CLANG_DIR}/bin/llvm-nm" LD="${CLANG_DIR}/bin/ld.lld" OBJCOPY="${CLANG_DIR}/bin/llvm-objcopy" OBJDUMP="${CLANG_DIR}/bin/llvm-objdump" STRIP="${CLANG_DIR}/bin/llvm-strip" CROSS_COMPILE="${GCC64}" CROSS_COMPILE_ARM32="${GCC32}" CLANG_TRIPLE="${GCC64_TYPE}" 122 | 123 | BUILD_END=$(date +"%s") 124 | DIFF=$(($BUILD_END - $BUILD_START)) 125 | 126 | if [ -f "${IMG}" ]; then 127 | echo "Build completed in $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) second(s)." 128 | flash_zip 129 | else 130 | echo "Build failed, please fix the errors first bish!" 131 | fi 132 | } 133 | 134 | function build_proton_clang() { 135 | checkout_source 136 | set_param_clang 137 | 138 | # Check kernel type 139 | check_kernel_type 140 | 141 | # Patch kernel for LTO 142 | lto_patches 143 | 144 | make O="$OUT" ${CONFIG} 145 | 146 | BUILD_START=$(date +"%s") 147 | 148 | # Build 149 | make -j"${KBUILD_JOBS}" O=$OUT CC="${TC}" LLVM_AR="llvm-ar" LLVM_NM="llvm-nm" LD="ld.lld" OBJCOPY="llvm-objcopy" OBJDUMP="llvm-objdump" STRIP="llvm-strip" CROSS_COMPILE="${GCC64}" CROSS_COMPILE_ARM32="${GCC32}" CLANG_TRIPLE="${GCC64_TYPE}" 150 | 151 | BUILD_END=$(date +"%s") 152 | DIFF=$(($BUILD_END - $BUILD_START)) 153 | 154 | if [ -f "${IMG}" ]; then 155 | echo "Build completed in $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) second(s)." 156 | flash_zip 157 | else 158 | echo "Build failed, please fix the errors first bish!" 159 | fi 160 | } 161 | 162 | function build_aosp_clang() { 163 | checkout_source 164 | set_param_aosp_clang 165 | 166 | # Check kernel type 167 | check_kernel_type 168 | 169 | # Patch kernel for LTO 170 | lto_patches 171 | 172 | make O="$OUT" ${CONFIG} 173 | 174 | BUILD_START=$(date +"%s") 175 | 176 | # Build 177 | make -j"${KBUILD_JOBS}" O=$OUT ARCH=arm64 CC="clang" LLVM_AR="llvm-ar" LLVM_NM="llvm-nm" LD="ld.lld" OBJCOPY="llvm-objcopy" OBJDUMP="llvm-objdump" STRIP="llvm-strip" CLANG_TRIPLE="aarch64-linux-gnu-" CROSS_COMPILE=$WD"/gcc64/bin/aarch64-linux-android-" CROSS_COMPILE_ARM32=$WD"/gcc32/bin/arm-linux-androideabi-" 178 | 179 | if [ -f "${IMG}" ]; then 180 | BUILD_END=$(date +"%s") 181 | DIFF=$(($BUILD_END - $BUILD_START)) 182 | echo "Build completed in $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) seconds." 183 | flash_zip 184 | else 185 | echo "Build failed, please fix the errors first bish!" 186 | fi 187 | } 188 | 189 | function flash_zip() { 190 | echo "Now making a flashable zip of kernel with AnyKernel3" 191 | 192 | # Check camera type oldcam/newcam 193 | check_camera 194 | 195 | if [ ${KERNEL_TYPE} == "fakerad" ]; then 196 | export ZIPNAME=fci-${TYPE}-${CAM_TYPE}-${DATE} 197 | else 198 | export ZIPNAME=ci-${TYPE}-${CAM_TYPE}-${DATE} 199 | fi 200 | 201 | # Checkout anykernel3 dir 202 | cd "${ANYKERNEL_DIR}" 203 | 204 | if [ ${TYPE} == "hmp" ]; then 205 | git checkout ak-hmp 206 | else 207 | git checkout ak-eas 208 | fi 209 | 210 | # Patch anykernel3 211 | #patch_anykernel 212 | 213 | # Patch anykernel3 string 214 | #patch_anykernel_string 215 | 216 | # Copy Image.gz-dtb to dir. 217 | cp ${OUT}/arch/arm64/boot/Image.gz-dtb ${ANYKERNEL_DIR}/ 218 | 219 | # Build a flashable zip 220 | zip -r9 ${ZIPNAME} * -x README.md .git 221 | 222 | # Sign the zip 223 | # sign_zip 224 | 225 | if [ ${KERNEL_TYPE} == "fakerad" ]; then 226 | SHA256=$(sha256sum fci-*.zip | cut -d' ' -f1) 227 | else 228 | SHA256=$(sha256sum ci-*.zip | cut -d' ' -f1) 229 | fi 230 | 231 | # Push zip(s) to telegram 232 | # tg_push 233 | } 234 | 235 | function check_camera() { 236 | CAMERA="$(grep 'BLOBS' ${KERNEL_DIR}/arch/arm64/configs/${CONFIG})" 237 | if [ ${CAMERA} == "CONFIG_XIAOMI_NEW_CAMERA_BLOBS=y" ]; then 238 | export CAM_TYPE="newcam" 239 | elif [ ${CAMERA} == "CONFIG_XIAOMI_NEW_CAMERA_BLOBS=n" ]; then 240 | export CAM_TYPE="oldcam" 241 | fi 242 | } 243 | 244 | function check_kernel_type() { 245 | KERNEL_TYPE="$(grep 'LOCALVERSION=' ${KERNEL_DIR}/arch/arm64/configs/${CONFIG})" 246 | KERNEL_TYPE=$(echo "${KERNEL_TYPE}" | cut -d'"' -f 2) 247 | if [[ ${KERNEL_TYPE} == *"-rad-v"* ]]; then 248 | export TYPE=hmp 249 | export KERNEL_TYPE=rad 250 | elif [[ ${KERNEL_TYPE} == *"-rad-x"* ]]; then 251 | export TYPE=eas 252 | export KERNEL_TYPE=rad 253 | elif [[ ${KERNEL_TYPE} == *"-fakerad"* ]]; then 254 | export TYPE=eas 255 | export KERNEL_TYPE=fakerad 256 | fi 257 | } 258 | 259 | function sign_zip() { 260 | curl -sLo zipsigner-3.0.jar https://raw.githubusercontent.com/baalajimaestro/AnyKernel2/master/zipsigner-3.0.jar 261 | java -jar zipsigner-3.0.jar ${ZIPNAME}.zip ${ZIPNAME}-signed.zip 262 | rm -rf "${ZIPNAME}.zip" 263 | } 264 | 265 | function lto_patches() { 266 | if [ "${LTO}" == "true" ]; then 267 | if [ "${COMPILER}" == "gnu-gcc" ]; then 268 | 269 | if [ "${KERNEL_TYPE}" == "fakerad" ]; then 270 | curl https://raw.githubusercontent.com/theradcolor/patches/master/fakerad-gcc-lto-patch.patch | git am 271 | rm -rf *.patch 272 | else 273 | # GCC LTO patches for kernel 274 | curl https://raw.githubusercontent.com/theradcolor/patches/master/rad-kernel-gcc-lto-patch.patch | git am 275 | rm -rf *.patch 276 | fi 277 | 278 | elif [ "${COMPILER}" == "proton-clang" ]; then 279 | 280 | if [ "${KERNEL_TYPE}" == "fakerad" ]; then 281 | curl https://raw.githubusercontent.com/theradcolor/patches/master/fakerad-clang-lto-patch.patch | git am 282 | rm -rf *.patch 283 | else 284 | # CLANG LTO patches for kernel 285 | curl https://raw.githubusercontent.com/theradcolor/patches/master/rad-kernel-clang-lto-patch.patch | git am 286 | fi 287 | 288 | elif [ "${COMPILER}" == "aosp-clang" ]; then 289 | 290 | if [ "${KERNEL_TYPE}" == "fakerad" ]; then 291 | curl https://raw.githubusercontent.com/theradcolor/patches/master/fakerad-clang-lto-patch.patch | git am 292 | rm -rf *.patch 293 | else 294 | # CLANG LTO patches for kernel 295 | curl https://raw.githubusercontent.com/theradcolor/patches/master/rad-kernel-clang-lto-patch.patch | git am 296 | fi 297 | else 298 | echo "Compiler not specified" 299 | fi 300 | else 301 | echo "Skipping LTO patches!" 302 | fi 303 | } 304 | 305 | for i in "$@"; do 306 | case $i in 307 | --oldcam) 308 | CONFIG="whyred_defconfig" 309 | shift 310 | ;; 311 | --newcam) 312 | CONFIG="whyred-newcam_defconfig" 313 | shift 314 | ;; 315 | --fakerad) 316 | CONFIG="fakerad_defconfig" 317 | shift 318 | ;; 319 | --gcc) 320 | COMPILER="gnu-gcc" 321 | shift 322 | ;; 323 | --gcc-stable) 324 | GCC_BRANCH="stable-gcc" 325 | shift 326 | ;; 327 | --gcc-master) 328 | GCC_BRANCH="master" 329 | shift 330 | ;; 331 | --clang) 332 | COMPILER="clang" 333 | shift 334 | ;; 335 | --aosp-clang) 336 | COMPILER="aosp-clang" 337 | shift 338 | ;; 339 | --proton-clang) 340 | COMPILER="proton-clang" 341 | shift 342 | ;; 343 | --lto) 344 | LTO="true" 345 | shift 346 | ;; 347 | *) 348 | # unknown option 349 | echo "Unknown option(s)" 350 | exit 351 | ;; 352 | esac 353 | done 354 | 355 | # Start Build (build_clang/build_aosp_clang/build_proton_clang/build_gcc) 356 | if [ "${COMPILER}" == "gnu-gcc" ]; then 357 | build_gcc 358 | elif [ "${COMPILER}" == "clang" ]; then 359 | build_clang 360 | elif [ "${COMPILER}" == "aosp-clang" ]; then 361 | build_aosp_clang 362 | elif [ "${COMPILER}" == "proton-clang" ]; then 363 | build_proton_clang 364 | else 365 | build_gcc 366 | CONFIG="whyred_defconfig" 367 | echo "Compiler not specified" 368 | fi 369 | -------------------------------------------------------------------------------- /kernel/kernel-cl_telegraph.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # Python script to create a telegraph page of kernel changelogs 4 | 5 | import os 6 | from telegraph import Telegraph 7 | 8 | TAG0=os.environ['TAG_LATEST'] 9 | TAG1=os.environ['TAG_SECOND_LATEST'] 10 | Title='Rad Kernel Changelogs for v/x ' + TAG0 11 | 12 | os.system('git log {}^...{} --oneline >> radcl'.format(TAG1, TAG0)) 13 | 14 | # Read text func() from a file 15 | def read(file): 16 | try: 17 | file = open(file, 'r') 18 | data = file.read() 19 | file.close() 20 | 21 | except FileNotFoundError: 22 | data = None 23 | 24 | return data 25 | 26 | 27 | telegraph = Telegraph() 28 | 29 | telegraph.create_account(short_name='rad', author_name='Shashank', author_url='https://github.com/theradcolor') 30 | 31 | content = read("radcl") 32 | content = "

".join(content.split("\n")) 33 | 34 | response = telegraph.create_page( 35 | Title, 36 | html_content='Sources • Kernel GitHub Sources Link

{}

'.format(content), 37 | author_name='Shashank', 38 | author_url='https://github.com/theradcolor' 39 | ) 40 | 41 | print('https://telegra.ph/{}'.format(response['path'])) 42 | -------------------------------------------------------------------------------- /kernel/wg: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (C) 2020 Shashank Baghel 4 | # To fetch latest WireGuard and add them into kernel tree as well as to update to latest 5 | 6 | KERNEL_DIR="/home/theradcolor/whyred/kernel" # Configure kernel directory here 7 | USER_AGENT="WireGuard-AndroidROMBuild/0.3 ($(uname -a))" 8 | WIREGUARD_URL="https://git.zx2c4.com/wireguard-linux-compat/snapshot/wireguard-linux-compat" 9 | 10 | cd "${KERNEL_DIR}" || exit 11 | 12 | while read -r distro package version _; do 13 | if [[ $distro == upstream && $package == linuxcompat ]]; then 14 | VERSION="$version" 15 | break 16 | fi 17 | done < <(curl -A "${USER_AGENT}" -LSs --connect-timeout 30 https://build.wireguard.com/distros.txt) 18 | 19 | if [ ! -f "wireguard-linux-compat-${VERSION}.tar.xz" ]; then 20 | aria2c "${WIREGUARD_URL}"-"${VERSION}".tar.xz 21 | fi 22 | 23 | if [ ! -d "${KERNEL_DIR}"/net/wireguard ]; then 24 | 25 | mkdir "${KERNEL_DIR}/net/wireguard" 26 | tar -C "${KERNEL_DIR}/net/wireguard" -xf wireguard-linux-compat-"${VERSION}".tar.xz --strip-components=2 "wireguard-linux-compat-${VERSION}/src" 27 | git add . 28 | git commit -S -s -m "net: Import WireGuard v${VERSION} from ${WIREGUARD_URL}" 29 | curl https://github.com/theradcolor/android_kernel_xiaomi_whyred/commit/c5ba946f6a2c7ba64989c425db6abf67d83a7797.patch | git am 30 | 31 | elif [ -d "${KERNEL_DIR}"/net/wireguard ]; then 32 | 33 | FILE="${KERNEL_DIR}""/net/wireguard/version.h" 34 | CURRENT_VERSION="$(awk 'NR==2' "${FILE}" | sed 's/[^0-9.]*//g' | sed -r 's/^\s*(.*\S)*\s*$/\1/;/^$/d')" 35 | if [ "${VERSION}" == "${CURRENT_VERSION}" ]; then 36 | echo "WireGuard is up-to-date!" 37 | else 38 | rm -rf "${KERNEL_DIR}""/net/wireguard" 39 | mkdir "${KERNEL_DIR}/net/wireguard" 40 | tar -C "${KERNEL_DIR}/net/wireguard" -xf wireguard-linux-compat-"${VERSION}".tar.xz --strip-components=2 "wireguard-linux-compat-${VERSION}/src" 41 | git add . 42 | git commit -S -s -m "net: Update WireGuard to v${VERSION} from ${WIREGUARD_URL}" 43 | fi 44 | 45 | fi 46 | 47 | rm -rf wireguard-linux-compat-"${VERSION}".tar.xz 48 | -------------------------------------------------------------------------------- /samples/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/radcolor/env/81a4dcf9b323b0255cfa5b27d3fe47c7396174b9/samples/README.md -------------------------------------------------------------------------------- /samples/build-kernel-clang: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################# 4 | # Kernel Build Script # 5 | ############################# 6 | 7 | # Set defaults 8 | wd=$(pwd) 9 | out=$wd/out 10 | BUILD="/home/theradcolor/kernel/source" 11 | ANYKERNEL_DIR=${HOME}/anykernel2 12 | DATE=$(date +"%d-%m-%y") 13 | BUILD_START=$(date +"%s") 14 | 15 | # Define colors 16 | green='\e[0;32m' 17 | white='\033[0m' 18 | 19 | echo -e "*****************************************************" 20 | echo " Compile kernel " 21 | echo -e "*****************************************************" 22 | 23 | # Set kernel source workspace 24 | cd ${BUILD} || exit 25 | 26 | # Use ccache 27 | ccache=$(which ccache) 28 | export USE_CCACHE=1 29 | export CCACHE_DIR="/home/theradcolor/.ccache" 30 | 31 | # Export ARCH 32 | export ARCH=arm64 33 | export SUBARCH=arm64 34 | 35 | # Set kernal configurations 36 | export LOCALVERSION=-v1 37 | export KBUILD_BUILD_USER=theradcolor 38 | export KBUILD_BUILD_HOST=ILLYRIA 39 | 40 | # Compiler String 41 | CLANG_TRIPLE=aarch64-linux-gnu- 42 | GCC64=/home/theradcolor/whyred/compilers/aarch64-linux-android-4.9/bin/aarch64-linux-android- 43 | GCC32=/home/theradcolor/whyred/compilers/arm-linux-androideabi-4.9/bin/arm-linux-androideabi- 44 | CC="${ccache} /home/theradcolor/clang/bin/clang" 45 | KBUILD_COMPILER_STRING="$(${CC} --version | head -n 1 | perl -pe 's/\(http.*?\)//gs' | sed -e 's/ */ /g')" 46 | export KBUILD_COMPILER_STRING 47 | 48 | # Make and Clean 49 | make O="$out" clean 50 | make O="$out" mrproper 51 | 52 | # Make 53 | make O="$out" ARCH=arm64 device_defconfig 54 | 55 | # Build Kernel 56 | make O="$out" CC="${CC}" \ 57 | CROSS_COMPILE="${GCC64}" \ 58 | CROSS_COMPILE_ARM32="${GCC32}" \ 59 | CLANG_TRIPLE="${CLANG_TRIPLE}" \ 60 | -j6 2>&1 | tee "$out"/kernel.log 61 | 62 | BUILD_END=$(date +"%s") 63 | DIFF=$("$BUILD_END" - "$BUILD_START") 64 | echo -e "$green" "Build completed in $($DIFF / 60) minute(s) and $($DIFF % 60) seconds." "$white" 65 | 66 | echo -e "Making Flashable Template using anykernel2" 67 | 68 | # Clean anykernel2 directory 69 | rm -f "$ANYKERNEL_DIR"/Image.gz* 70 | rm -f "$ANYKERNEL_DIR"/zImage* 71 | rm -f "$ANYKERNEL_DIR"/dtb* 72 | 73 | # Change the directory to anykernel2 directory 74 | cd "$ANYKERNEL_DIR" || exit 75 | #remove all zips 76 | rm ./*.zip 77 | 78 | # Copy thhe image.gz-dtb to anykernel2 directory 79 | cp "$out"/arch/arm64/boot/Image.gz-dtb "$ANYKERNEL_DIR"/ 80 | 81 | #Build a flashable zip Device using anykernel2 82 | zip -r9 kernel-"$DATE".zip ./* -x README .git 83 | -------------------------------------------------------------------------------- /samples/build-kernel-gcc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################# 4 | # Kernel Build Script # 5 | ############################# 6 | 7 | # Set defaults 8 | wd=$(pwd) 9 | out=$wd/out 10 | BUILD="/home/theradcolor/kernel/source" 11 | ANYKERNEL_DIR=${HOME}/anykernel2 12 | DATE=$(date +"%d-%m-%y") 13 | BUILD_START=$(date +"%s") 14 | 15 | # Define colors 16 | green='\e[0;32m' 17 | white='\033[0m' 18 | 19 | echo -e "*****************************************************" 20 | echo " Compile kernel " 21 | echo -e "*****************************************************" 22 | 23 | # Set kernel source workspace 24 | cd ${BUILD} || exit 25 | 26 | # Use ccache 27 | export USE_CCACHE=1 28 | export CCACHE_DIR="/home/theradcolor/.ccache" 29 | 30 | # Export ARCH 31 | export ARCH=arm64 32 | export SUBARCH=arm64 33 | 34 | # Set kernal configurations 35 | export LOCALVERSION=-v1 36 | export KBUILD_BUILD_USER=theradcolor 37 | export KBUILD_BUILD_HOST=ILLYRIA 38 | 39 | # Compiler String 40 | GCC64=/home/theradcolor/whyred/compilers/aarch64-linux-android-4.9/bin/aarch64-linux-android- 41 | GCC32=/home/theradcolor/whyred/compilers/arm-linux-androideabi-4.9/bin/arm-linux-androideabi- 42 | 43 | # Make and Clean 44 | make O="$out" clean 45 | make O="$out" mrproper 46 | 47 | # Make 48 | make O="$out" ARCH=arm64 device_defconfig 49 | 50 | # Build Kernel 51 | make O="$out" \ 52 | CROSS_COMPILE="${GCC64}" \ 53 | CROSS_COMPILE_ARM32="${GCC32}" \ 54 | -j6 2>&1 | tee "$out"/kernel.log 55 | 56 | BUILD_END=$(date +"%s") 57 | DIFF=$("$BUILD_END" - "$BUILD_START") 58 | echo -e "$green" "Build completed in $($DIFF / 60) minute(s) and $($DIFF % 60) seconds." "$white" 59 | 60 | echo -e "Making Flashable Template using anykernel2" 61 | 62 | # Clean anykernel2 directory 63 | rm -f "$ANYKERNEL_DIR"/Image.gz* 64 | rm -f "$ANYKERNEL_DIR"/zImage* 65 | rm -f "$ANYKERNEL_DIR"/dtb* 66 | 67 | # Change the directory to anykernel2 directory 68 | cd "$ANYKERNEL_DIR" || exit 69 | #remove all zips 70 | rm ./*.zip 71 | 72 | # Copy thhe image.gz-dtb to anykernel2 directory 73 | cp "$out"/arch/arm64/boot/Image.gz-dtb "$ANYKERNEL_DIR"/ 74 | 75 | #Build a flashable zip Device using anykernel2 76 | zip -r9 kernel-"$DATE".zip ./* -x README .git 77 | -------------------------------------------------------------------------------- /shellfiles: -------------------------------------------------------------------------------- 1 | envsetup/arch 2 | envsetup/git 3 | envsetup/manjaro 4 | kernel/kernel 5 | kernel/wg 6 | samples/build-kernel-clang 7 | samples/build-kernel-gcc 8 | --------------------------------------------------------------------------------