├── LICENSE.txt ├── README.md ├── anykernel.sh ├── build.sh ├── ccache.sh ├── clone.sh ├── env.sh ├── logo.txt ├── setup.sh └── vars.conf /LICENSE.txt: -------------------------------------------------------------------------------- 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 [yyyy] [name of copyright owner] 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Kernel Buildinator 2 | 3 | Ever wanted to compile/build a kernel ? But don't want to learn all the commands ? 4 | Then here comes a tool for you "Kernel Buildinator". Now, no need to learn any commands. 5 | 6 | ## Requirements 7 | Linux 8 | 9 | ## How to use 10 | 11 | ### Download tools 12 | ``` 13 | git clone https://github.com/SiddharthBharadwaj/Kernel_Buildinator.git 14 | cd Kernel_Buildinator 15 | ``` 16 | ### For setting up requirement and starting the build 17 | 18 | ``` 19 | bash setup.sh 20 | ``` 21 | ``` 22 | Notes: 23 | - If you select not to clone kernel source then copy/move your local kernel sources to "Kernel_buildinator/kernel" 24 | - Toolchains & Anykernel will only be cloned if "Kernel_buildinator/kernel" exists 25 | ``` 26 | 27 | ### Things you must know before starting 28 | 29 | - ARCH & SUBARCH 30 | - DEFCONFIG Name 31 | 32 | check setup.sh for more info 33 | 34 | ## TO-DO 35 | 36 | - Simplification & Improvements in code. 37 | - I am Still a Learner so will fix mistakes(if any) too. 38 | 39 | ## Credits 40 | 41 | - @osm0sis for AnyKernel 42 | - @rebenok90x for https://github.com/rebenok90x/kernel-builder 43 | 44 | ## Contact info 45 | Telegram: https://t.me/SiddharthBharadwaj 46 | 47 | ### Help & Pull Requests are always Welcome 48 | -------------------------------------------------------------------------------- /anykernel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Source vars.conf to get all the stored variables 4 | source $sdir/vars.conf 5 | 6 | # Change Current Directory to AnyKernel3 7 | cd "$KERNEL_DIR/AnyKernel3" 8 | 9 | # Make Base Clean to ZIP 10 | git reset --hard 11 | git clean -f -d 12 | 13 | # Change anykernel script values 14 | sed -i "s|^kernel.string=.*|kernel.string=$kstring|g" "$KERNEL_DIR/AnyKernel3/anykernel.sh" 15 | sed -i "s|^device.name1=.*|device.name1=$dname|g" "$KERNEL_DIR/AnyKernel3/anykernel.sh" 16 | sed -i "s|^block.*|block=$block;|g" "$KERNEL_DIR/AnyKernel3/anykernel.sh" 17 | sed -i "s|^supported.versions=.*|supported.versions=|g" "$KERNEL_DIR/AnyKernel3/anykernel.sh" 18 | sed -i "s|^supported.patchlevels=.*|supported.patchlevels=|g" "$KERNEL_DIR/AnyKernel3/anykernel.sh" 19 | sed -i '/# begin ramdisk changes/,/# end ramdisk changes/d' "$KERNEL_DIR/AnyKernel3/anykernel.sh" 20 | sed -i 's/toro//g' "$KERNEL_DIR/AnyKernel3/anykernel.sh" 21 | sed -i 's/plus//g' "$KERNEL_DIR/AnyKernel3/anykernel.sh" 22 | sed -i 's/tuna//g' "$KERNEL_DIR/AnyKernel3/anykernel.sh" 23 | 24 | # Copy zIMAGE/Image.gz-dtb from kernel out 25 | mv $KERNEL_DIR/out/arch/arm64/boot/Image.gz-dtb $KERNEL_DIR/AnyKernel3/Image.gz-dtb 26 | mv $KERNEL_DIR/out/arch/arm/boot/zImage $KERNEL_DIR/AnyKernel3/zImage 27 | 28 | # Create AnyKernel Zip 29 | zip -r9 $ZIPNAME * -x .git README.md 30 | echo -e "\e[1;32mFlashable ZIP Created Succesfully\e[0m" 31 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Clean screen 4 | clear 5 | 6 | # Source vars.conf to get all the stored variables 7 | source $sdir/vars.conf 8 | logo 9 | KERNEL_DIR=`pwd` 10 | cd $KERNEL_DIR 11 | echo -e "\e[1;32m ***Building Kernel..***\e[0m" 12 | 13 | # Start the build with clang 14 | if [ "$use_clang" == y ] 15 | then 16 | export KBUILD_BUILD_USER="$kbuild_u" 17 | export KBUILD_BUILD_HOST="$kbuild_h" 18 | export ARCH="$archf" 19 | export SUBARCH="$sarchf" 20 | export CROSS_COMPILE=$KERNEL_DIR/aarch64-linux-android-4.9/bin/aarch64-linux-android- 21 | export CROSS_COMPILE_ARM32=$KERNEL_DIR/arm-linux-androideabi-4.9/bin/arm-linux-androideabi- 22 | PATH=$KERNEL_DIR/clang-llvm/bin/:$KERNEL_DIR/aarch64-linux-android-4.9/bin/:$PATH 23 | export PATH 24 | #-----------------------------------------# 25 | function check { 26 | if [ -f $KERNEL_DIR/out/arch/arm64/boot/Image.gz-dtb ] || [ -f $KERNEL_DIR/out/arch/arm/boot/zImage ] 27 | then 28 | echo -e "\e[1;32m Build Completed Succesfully\e[0m" 29 | echo -e "\e[1;32m Build took : $((DIFF / 60)) minute(s) and $((DIFF % 60)) second(s)\e[0m" 30 | else 31 | echo -e "\e[0;31m Build failed\e[0m" 32 | fi 33 | } 34 | #-----------------------------------------# 35 | function ak3 { 36 | if [ "$ak" == "y" ] && [ -f $KERNEL_DIR/out/arch/arm64/boot/Image.gz-dtb ] || [ -f $KERNEL_DIR/out/arch/arm/boot/zImage ] 37 | then 38 | check 39 | . $sdir/anykernel.sh 40 | else 41 | check 42 | fi 43 | } 44 | #------------------------------------------# 45 | 46 | make clean && make mrproper O=out 47 | BUILD_START=$(date +"%s") 48 | make O=out $defconfig_name 49 | make -j$(nproc --all) CC=$KERNEL_DIR/clang-llvm/bin/clang CLANG_TRIPLE=aarch64-linux-gnu- O=out 50 | #------# 51 | BUILD_END=$(date +"%s") 52 | DIFF=$((BUILD_END - BUILD_START)) 53 | ak3 54 | return 1 55 | 56 | # Start the build without clang 57 | elif [ "$use_clang" == n ] 58 | then 59 | export KBUILD_BUILD_USER="$kbuild_u" 60 | export KBUILD_BUILD_HOST="kbuild_h" 61 | export ARCH="$archf" 62 | export SUBARCH="$sarchf" 63 | export CROSS_COMPILE=$KERNEL_DIR/aarch64-linux-android-4.9/bin/aarch64-linux-android- 64 | export CROSS_COMPILE_ARM32=$KERNEL_DIR/arm-linux-androideabi-4.9/bin/arm-linux-androideabi- 65 | #-----------------------------------------# 66 | function check { 67 | if [ -f $KERNEL_DIR/out/arch/arm64/boot/Image.gz-dtb ] || [ -f $KERNEL_DIR/out/arch/arm/boot/zImage ] 68 | then 69 | echo -e "\e[1;32m Build Completed Succesfully\e[0m" 70 | echo -e "\e[1;32m Build took : $((DIFF / 60)) minute(s) and $((DIFF % 60)) second(s)\e[0m" 71 | else 72 | echo -e "\e[0;31m Build failed\e[0m" 73 | fi 74 | } 75 | #-----------------------------------------# 76 | function ak3 { 77 | if [ "$ak" == "y" ] && [ -f $KERNEL_DIR/out/arch/arm64/boot/Image.gz-dtb ] || [ -f $KERNEL_DIR/out/arch/arm/boot/zImage ] 78 | then 79 | check 80 | . $sdir/anykernel.sh 81 | else 82 | check 83 | fi 84 | } 85 | #------------------------------------------# 86 | make clean && make mrproper O=out 87 | BUILD_START=$(date +"%s") 88 | make O=out $defconfig_name 89 | make -j$(nproc --all) O=out \ 90 | #------# 91 | BUILD_END=$(date +"%s") 92 | DIFF=$((BUILD_END - BUILD_START)) 93 | ak3 94 | return 1 95 | 96 | else 97 | return 1 98 | fi 99 | -------------------------------------------------------------------------------- /ccache.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Clean screen 4 | clear 5 | 6 | # Source vars.conf to get all the stored variables 7 | source "$sdir"/vars.conf 8 | 9 | logo 10 | 11 | # Setup CCACHE & Execute the next script 12 | if [ "$set_ccache" == "y" ] 13 | then 14 | echo -e "\e[1;32m ***Setting Up CCACHE***\e[0m" 15 | export CCACHE_DIR="$HOME/.ccache" 16 | export CC="ccache gcc" 17 | export CXX="ccache g++" 18 | export PATH="/usr/lib/ccache:$PATH" 19 | ccache -M 5G 20 | echo -e "\e[1;32m Done !!!\e[0m" 21 | echo " " 22 | . "$sdir"/clone.sh 23 | 24 | # Execute next script without setting up CCACHE 25 | elif [ "$set_ccache" == "n" ] 26 | then 27 | echo " " 28 | . "$sdir"/clone.sh 29 | fi 30 | -------------------------------------------------------------------------------- /clone.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Clean screen 4 | clear 5 | 6 | # Source vars.conf to get all the stored variables 7 | source $sdir/vars.conf 8 | cd $sdir 9 | logo 10 | 11 | # Clone kernel source, toolcahins and anykernel3 and execute the next script 12 | if [ "$clone" == "y" ] 13 | then 14 | echo -e "\e[1;32m ***Cloning Kernel***\e[0m" 15 | git clone --progress "$kernelurl" -b "$kernelbranch" kernel 16 | echo -e "\e[1;32m Done !!!\e[0m" 17 | echo " " 18 | if [ ! -d "$sdir/kernel" ] 19 | then 20 | echo "Kernel Source Doesn't Exist. Please Check URL" 21 | return 1; 22 | fi 23 | clear 24 | logo 25 | echo -e "\e[1;32m ***Cloning Toolchains***\e[0m" 26 | cd kernel 27 | KERNEL_DIR=`pwd` 28 | git clone --progress -j$(nproc --all) --depth 5 --no-single-branch https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9.git 29 | git clone --progress -j$(nproc --all) --depth 5 --no-single-branch https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9 30 | git clone -j$(nproc --all) --depth 1 https://github.com/osm0sis/AnyKernel3 31 | if [ "$use_clang" == "y" ] 32 | then 33 | git clone -j$(nproc --all) --depth 1 https://github.com/Panchajanya1999/clang-llvm.git -b 8.0 34 | elif [ "$use_clang" == "n" ] 35 | then 36 | echo "Not cloning clang as it was not selected" 37 | fi 38 | cd aarch64-linux-android-4.9 39 | git reset --hard 22f053ccdfd0d73aafcceff3419a5fe3c01e878b 40 | cd $KERNEL_DIR/arm-linux-androideabi-4.9 41 | git reset --hard 42e5864a7d23921858ca8541d52028ff88acb2b6 42 | cd $KERNEL_DIR 43 | echo -e "\e[1;32m Done !!!\e[0m" 44 | echo " " 45 | . "$sdir"/build.sh 46 | elif [ "$clone" == "n" ] 47 | then 48 | if [ -d "$sdir/kernel" ] 49 | then 50 | echo -e "\e[1;32m ***Cloning Toolchains***\e[0m" 51 | cd kernel 52 | KERNEL_DIR=`pwd` 53 | git clone --progress -j$(nproc --all) --depth 5 --no-single-branch https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9.git 54 | git clone --progress -j$(nproc --all) --depth 5 --no-single-branch https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9 55 | git clone --depth 1 -j$(nproc --all) https://github.com/osm0sis/AnyKernel3 56 | if [ "$use_clang" == "y" ] 57 | then 58 | git clone -j$(nproc --all) --depth 1 https://github.com/Panchajanya1999/clang-llvm.git -b 8.0 59 | elif [ "$use_clang" == "n" ] 60 | then 61 | echo "Not cloning clang as it was not selected" 62 | fi 63 | cd aarch64-linux-android-4.9 64 | git reset --hard 22f053ccdfd0d73aafcceff3419a5fe3c01e878b 65 | cd $KERNEL_DIR/arm-linux-androideabi-4.9 66 | git reset --hard 42e5864a7d23921858ca8541d52028ff88acb2b6 67 | cd $KERNEL_DIR 68 | echo -e "\e[1;32m Done !!!\e[0m" 69 | echo " " 70 | . "$sdir"/build.sh 71 | else 72 | echo "Error: kernel directory does not exist. Aborting ....." 73 | return 1 74 | fi 75 | fi 76 | -------------------------------------------------------------------------------- /env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Clean screen 4 | clear 5 | 6 | # Source vars.conf to get all the stored variables 7 | source $sdir/vars.conf 8 | 9 | logo 10 | 11 | # Download & Install all the required packages and execute the next script 12 | if [ "$buildenv" == "y" ] 13 | then 14 | if [[ "$distro" == "arch" ]]; then 15 | echo -e "\e[1;32m ***Downloading and Installing Packages..***\e[0m" 16 | pacman -Syu 17 | pacman -S base-devel xmlto kmod inetutils bc libelf git ccache lzop gperf zip curl zlib gcc-libs python-networkx libxml2 bzip2 haskell-bzlib squashfs-tools pngcrush schedtool dpkg lz4 optipng openssl 18 | . "$sdir"/ccache.sh 19 | else 20 | echo -e "\e[1;32m ***Downloading and Installing Packages..***\e[0m" 21 | apt-get update 22 | apt-get upgrade -y 23 | apt-get install git bc ccache automake lzop bison gperf build-essential zip curl zlib1g-dev g++-multilib python-networkx libxml2-utils bzip2 libbz2-dev libbz2-1.0 sudo libghc-bzlib-dev squashfs-tools pngcrush schedtool dpkg-dev liblz4-tool make optipng libssl-dev -y 24 | echo -e "\e[1;32m Done !!!\e[0m"; 25 | echo " " 26 | . "$sdir"/ccache.sh 27 | fi 28 | # Execute next script without doing anything 29 | elif [ "$buildenv" == "n" ] 30 | then 31 | echo " " 32 | . "$sdir"/ccache.sh 33 | else 34 | echo "Please enter y or n only." 35 | . "$sdir"/env.sh 36 | fi 37 | -------------------------------------------------------------------------------- /logo.txt: -------------------------------------------------------------------------------- 1 | _ __ _ ____ _ _ _ _ _ 2 | | |/ / | | | _ \ (_)| | | |(_) | | 3 | | ' / ___ _ __ _ __ ___ | | | |_) | _ _ _ | | __| | _ _ __ __ _ | |_ ___ _ __ 4 | | < / _ \| '__|| '_ \ / _ \| | | _ < | | | || || | / _` || || '_ \ / _` || __|/ _ \ | '__| 5 | | . \| __/| | | | | || __/| | | |_) || |_| || || || (_| || || | | || (_| || |_| (_) || | 6 | |_|\_\\___||_| |_| |_| \___||_| |____/ \__,_||_||_| \__,_||_||_| |_| \__,_| \__|\___/ |_| 7 | 8 | By :- Siddharth Bharadwaj 9 | -------------------------------------------------------------------------------- /setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #This file takes all the user input as variables and send them to vars.conf 3 | 4 | # Clean screen 5 | clear 6 | 7 | # Source vars.conf to get LOGO 8 | source $PWD/vars.conf 9 | 10 | # Save and export current working DIR to $sdir 11 | sdir=$(pwd) 12 | export sdir 13 | 14 | # Check OS type & Distro. Then save & export it as a variable 15 | distro=$(awk -F= '$1 == "ID" {print $2}' /etc/os-release) 16 | export distro="$distro" 17 | 18 | logo 19 | echo " " 20 | if [[ "$distro" == "arch" ]]; then 21 | echo "Arch Linux Detected" 22 | fi 23 | 24 | # Ask User For Input 25 | echo -e "\e[1;34mShould I download and install required packages (y/n) ?\e[0m [Default is 'y']" 26 | # Read User Input and Save it into a variable 27 | read -p ">> " buildenv 28 | # Assign Default Value if User Input is Empty 29 | buildenv=${buildenv:-"y"} 30 | # Send the variable to vars.conf 31 | sed -i -e"s/^buildenv=.*/buildenv=$buildenv/g" "$sdir/vars.conf" 32 | clear 33 | logo 34 | echo " " 35 | echo -e "\e[1;34mShould I setup CCACHE (y/n) ?\e[0m [Default is 'n']" 36 | read -p ">> " set_ccache 37 | set_ccache=${set_ccache:-"n"} 38 | sed -i -e"s/^set_ccache=.*/set_ccache=$set_ccache/g" "$sdir/vars.conf" 39 | clear 40 | logo 41 | echo " " 42 | echo -e "\e[1;34mShould I Clone Kernel Source (y/n) ?\e[0m [Default is 'y']" 43 | read -p ">> " clone 44 | clone=${clone:-"y"} 45 | sed -i -e"s/^clone=.*/clone=$clone/g" "$sdir/vars.conf" 46 | clear 47 | logo 48 | echo " " 49 | if [ "$clone" == "y" ] || [ "$clone" == "" ] 50 | then 51 | read -p "Please Enter The Git URL of Kernel Source: " kernelurl 52 | sed -i -e"s|^kernelurl=.*|kernelurl=$kernelurl|g" "$sdir/vars.conf" 53 | read -p "Please Enter The Branch to Clone: " kernelbranch 54 | sed -i -e"s/^kernelbranch=.*/kernelbranch=$kernelbranch/g" "$sdir/vars.conf" 55 | elif [ "$clone" == "n" ] 56 | then 57 | echo " " 58 | else 59 | echo "Please enter y or n only." 60 | return 1 61 | fi 62 | clear 63 | logo 64 | echo -e "\e[1;32mKernel Variables\e[0m" 65 | read -p "Create AnyKernel3 Flashable Kernel Zip (y/n) ? [Default is 'n'] 66 | >> " ak 67 | ak=${ak:-"n"} 68 | sed -i -e"s/^ak=.*/ak=$ak/g" "$sdir/vars.conf" 69 | clear 70 | logo 71 | echo " " 72 | if [ "$ak" == "y" ] 73 | then 74 | echo -e "\e[1;32mAnyKernel Variables\e[0m" 75 | read -p "Enter Kernel ZIP name: " ZIPNAME 76 | sed -i -e"s/^ZIPNAME=.*/ZIPNAME=$ZIPNAME/g" "$sdir/vars.conf" 77 | read -p "Enter kernel.string (example: KernelName by YourName): " kstring 78 | sed -i -e"s|^kstring=.*|kstring=\'$kstring\'|g" "$sdir/vars.conf" 79 | read -p "Enter Device Name (For device check): " dname 80 | sed -i -e"s/^dname=.*/dname=$dname/g" "$sdir/vars.conf" 81 | read -p "Enter Block (Default is /dev/block/platform/omap/omap_hsmmc.0/by-name/boot): 82 | 1. /dev/block/platform/omap/omap_hsmmc.0/by-name/boot 83 | 2. /dev/block/bootdevice/by-name/boot 84 | >> " blocktmp 85 | blocktmp=${blocktmp:-"1"} 86 | if [ "$blocktmp" == 1 ] || [ "$blocktmp" == "" ] 87 | then 88 | sed -i -e"s|^block=.*|block=/dev/block/platform/omap/omap_hsmmc.0/by-name/boot;|g" "$sdir/vars.conf" 89 | elif [ "$blocktmp" == 2 ] 90 | then 91 | sed -i -e"s|^block=.*|block=/dev/block/bootdevice/by-name/boot;|g" "$sdir/vars.conf" 92 | else 93 | echo "Please enter a valid option" 94 | return 1 95 | fi 96 | elif [ "$ak" == "n" ] || [ "$ak" == "" ] 97 | then 98 | echo " " 99 | else 100 | echo "Please enter y or n only." 101 | return 1 102 | fi 103 | clear 104 | logo 105 | echo " " 106 | echo -e "\e[1;32mKernel Variables\e[0m" 107 | read -p "Enter KBUILD_BUILD_USER name: " kbuild_u 108 | sed -i -e"s/^kbuild_u=.*/kbuild_u=$kbuild_u/g" "$sdir/vars.conf" 109 | clear 110 | logo 111 | echo " " 112 | read -p "Enter KBUILD_BUILD_HOST name: " kbuild_h 113 | sed -i -e"s/^kbuild_h=.*/kbuild_h=$kbuild_h/g" "$sdir/vars.conf" 114 | clear 115 | logo 116 | echo " " 117 | echo -e "\e[1;32mKernel Variables\e[0m" 118 | echo "Select ARCH" 119 | echo "1.arm64 2.arm" 120 | read -r arch 121 | if [ "$arch" == 1 ] || [ "$arch" == arm64 ] 122 | then 123 | archf=arm64 124 | sed -i -e"s/^archf=.*/archf=$archf/g" "$sdir/vars.conf" 125 | elif [ "$arch" == 2 ] || [ "$arch" == arm ] 126 | then 127 | archf=arm 128 | sed -i -e"s/^archf=.*/archf=$archf/g" "$sdir/vars.conf" 129 | else 130 | echo "Please enter a valid option" 131 | return 1 132 | fi 133 | echo "Enter SUBARCH" 134 | echo "1.arm64 2.arm" 135 | read -r sarch 136 | if [ "$sarch" == 1 ] || [ "$sarch" == arm64 ] 137 | then 138 | sarchf=arm64 139 | sed -i -e"s/^sarchf=.*/sarchf=$sarchf/g" "$sdir/vars.conf" 140 | elif [ "$sarch" == 2 ] || [ "$sarch" == arm ] 141 | then 142 | sarchf=arm 143 | sed -i -e"s/^sarchf=.*/sarchf=$sarchf/g" "$sdir/vars.conf" 144 | else 145 | echo "Please enter a valid option" 146 | return 1 147 | fi 148 | read -p "Enter DEFCONFIG name: " defconfig_name 149 | sed -i -e"s/^defconfig_name=.*/defconfig_name=$defconfig_name/g" "$sdir/vars.conf" 150 | clear 151 | logo 152 | echo " " 153 | echo -e "\e[1;32mKernel Variables\e[0m" 154 | read -p "Use Clang for Compilation (y/n) ? [Default is 'n'] 155 | >> " use_clang 156 | use_clang=${use_clang:-"n"} 157 | if [ "$use_clang" == "y" ] 158 | then 159 | sed -i -e"s/^use_clang=.*/use_clang=$use_clang/g" "$sdir/vars.conf" 160 | # Execute the next script 161 | . "$sdir"/ccache.sh 162 | 163 | elif [ "$use_clang" == "n" ] 164 | then 165 | sed -i -e"s/^use_clang=.*/use_clang=$use_clang/g" "$sdir/vars.conf" 166 | . "$sdir"/ccache.sh 167 | else 168 | echo "Please enter y or n only." 169 | return 1 170 | fi 171 | -------------------------------------------------------------------------------- /vars.conf: -------------------------------------------------------------------------------- 1 | # This File Contains all variables taken as userinput and also the logo function 2 | # Don't Edit This File 3 | # Logo function 4 | 5 | logo() { 6 | cat "$sdir"/logo.txt 7 | } 8 | 9 | buildenv= 10 | set_ccache= 11 | clone= 12 | kernelurl= 13 | kernelbranch= 14 | kbuild_u= 15 | kbuild_h= 16 | archf= 17 | sarchf= 18 | defconfig_name= 19 | use_clang= 20 | ak= 21 | ZIPNAME= 22 | kstring= 23 | dname= 24 | block= 25 | --------------------------------------------------------------------------------