Last active
March 8, 2020 15:31
-
-
Save P1N2O/3d5e46daedb8e1317a24b3270bd65b67 to your computer and use it in GitHub Desktop.
Delta Kernel - Build Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Clone Clang (latest) | |
HOME_DIR=$(pwd) | |
echo "- Cloning Clang" | |
git clone --depth=1 https://github.com/crDroidMod/android_prebuilts_clang_host_linux-x86_clang-6207600 prebuilt/clang | |
# Clone GCC (aarch64) | |
echo "- Cloning GCC (aarch64)" | |
git clone --depth=1 https://github.com/P1N2O/aarch64-linux-android-4.9 prebuilt/aarch64 | |
# Clone GCC (arm) | |
echo "- Cloning GCC (arm)" | |
git clone --depth=1 https://github.com/P1N2O/arm-linux-androideabi-4.9 prebuilt/arm | |
# Clone Kernel source | |
echo "- Cloning Delta Kernel" | |
git clone --depth=1 -b 10.0 [email protected]:P1N2O/delta_kernel_xiaomi_sdm845.git | |
# Fetch current build info | |
BUILD_VERSION=$(awk 'NR==1 {print $2}' delta_kernel_xiaomi_sdm845/release) | |
BUILD_DEVICE=$(awk 'NR==2 {print $2}' delta_kernel_xiaomi_sdm845/release) | |
BUILD_VARIANT=$(awk 'NR==3 {print $2}' delta_kernel_xiaomi_sdm845/release) | |
BUILD_DISPLAY=$(awk 'NR==4 {print $2}' delta_kernel_xiaomi_sdm845/release) | |
# Clone AnyKernel | |
echo "- Cloning AnyKernel" | |
git clone --depth=1 -b ${BUILD_DEVICE} https://github.com/P1N2O/anykernel.git anykernel | |
echo "- Successfully cloned all dependencies!" | |
# Setup Build Env. | |
cd delta_kernel_xiaomi_sdm845 | |
KERNEL_DIR=$(pwd) | |
BUILD_START=$(date +"%s") | |
BUILD_DATE=$(date -u +"%F") | |
WORKING_BRANCH="$(git rev-parse --abbrev-ref HEAD)" | |
KERNEL_DEFCONFIG=delta-${BUILD_DEVICE}_defconfig | |
KERNEL_NAME=Delta-${BUILD_VERSION}-${BUILD_VARIANT}-${BUILD_DISPLAY}Hz | |
KERNEL_IMAGE="${KERNEL_DIR}/out/arch/arm64/boot/Image.gz-dtb" | |
KERNEL_ZIP=${KERNEL_NAME}-${BUILD_DEVICE}.zip | |
PATH="${HOME_DIR}/prebuilt/clang/bin:${HOME_DIR}/prebuilt/aarch64/bin:${HOME_DIR}/prebuilt/arm/bin:${PATH}" | |
export KBUILD_COMPILER_STRING="$(${HOME_DIR}/prebuilt/clang/bin/clang --version | head -n 1 | perl -pe 's/\(http.*?\)//gs' | sed -e 's/ */ /g')" | |
export ARCH=arm64 | |
export KBUILD_BUILD_USER=p1n2o | |
export KBUILD_BUILD_HOST=delta | |
# Write Kernel info to defconfig | |
echo "- Applying Delta Branding to ${KERNEL_DEFCONFIG}" | |
sed -i "/CONFIG_LOCALVERSION=/c\CONFIG_LOCALVERSION=\"-${KERNEL_NAME}\"" arch/arm64/configs/${KERNEL_DEFCONFIG} | |
# Perform Kernel Variant Mod's | |
if [ $BUILD_VARIANT = stock ]; | |
then | |
echo "- Building Stock Variant"; | |
else | |
echo "- Building Delta Varinat"; | |
rm -rf firmware/novatek_nt36672_e10_hw01.fw.ihex | |
rm -rf firmware/novatek_nt36672_e10_hw02.fw.ihex | |
cp -TRv backup/nvt_touch_fw firmware | |
fi | |
# Set Dislpay Refresh Rate | |
echo "- Setting Dislpay Refresh Rate to ${BUILD_DISPLAY}Hz" | |
# Generate dfps-list | |
DFPS_LIST="60 55" | |
if (( $BUILD_DISPLAY >= 61 )) | |
then | |
DFPS_LIST="$BUILD_DISPLAY 60 55" | |
else | |
DFPS_LIST="$BUILD_DISPLAY 55" | |
fi | |
# EBBG | |
sed -i "/qcom,dsi-supported-dfps-list = /c\ qcom,dsi-supported-dfps-list = <${DFPS_LIST}>;" arch/arm64/boot/dts/qcom/dsi-panel-ebbg-fhd-ft8716-video.dtsi | |
sed -i "/qcom,mdss-dsi-panel-framerate = /c\ qcom,mdss-dsi-panel-framerate = <${BUILD_DISPLAY}>;" arch/arm64/boot/dts/qcom/dsi-panel-ebbg-fhd-ft8716-video.dtsi | |
sed -i "/qcom,mdss-dsi-panel-framerate = /c\ qcom,mdss-dsi-panel-framerate = <${BUILD_DISPLAY}>;" arch/arm64/boot/dts/qcom/dsi-panel-ebbg-fhd-ft8719-video.dtsi | |
# JDI | |
sed -i "/qcom,dsi-supported-dfps-list = /c\ qcom,dsi-supported-dfps-list = <${DFPS_LIST}>;" arch/arm64/boot/dts/qcom/dsi-panel-jdi-fhd-nt35596s-video.dtsi | |
sed -i "/qcom,mdss-dsi-panel-framerate = /c\ qcom,mdss-dsi-panel-framerate = <${BUILD_DISPLAY}>;" arch/arm64/boot/dts/qcom/dsi-panel-jdi-fhd-nt35596s-video.dtsi | |
sed -i "/qcom,mdss-dsi-panel-framerate = /c\ qcom,mdss-dsi-panel-framerate = <${BUILD_DISPLAY}>;" arch/arm64/boot/dts/qcom/dsi-panel-jdi-fhd-r63452-cmd.dtsi | |
# TIANMA | |
sed -i "/qcom,mdss-dsi-panel-framerate = /c\ qcom,mdss-dsi-panel-framerate = <${BUILD_DISPLAY}>;" arch/arm64/boot/dts/qcom/dsi-panel-tianma-fhd-nt36672a-video.dtsi | |
sed -i "/qcom,mdss-dsi-panel-framerate = /c\ qcom,mdss-dsi-panel-framerate = <${BUILD_DISPLAY}>;" arch/arm64/boot/dts/qcom/dsi-panel-tianma-fhd-rm69299-cmd.dtsi | |
# TG > Build Start Alert (Insider) | |
function sendBuildStartAlert() { | |
curl -s -X POST "https://api.telegram.org/bot$tg_voithos_token/sendMessage" \ | |
-d chat_id="$tg_delta_insider_id" \ | |
-d "disable_web_page_preview=true" \ | |
-d "parse_mode=html" \ | |
-d text="----------%0AAhem! Build started.%0A----------" | |
} | |
# TG > Build Error Alert (Insider) | |
function sendBuildErrorAlert() { | |
curl -s -X POST "https://api.telegram.org/bot$tg_voithos_token/sendMessage" \ | |
-d chat_id="$tg_delta_insider_id" \ | |
-d "disable_web_page_preview=true" \ | |
-d "parse_mode=html" \ | |
-d text="----------%0AOops! Build throwed an error(s).%0AWasted $(($TOTAL_TIME / 60))min $(($TOTAL_TIME % 60))sec.%0A----------" | |
# Attach Error Log | |
curl -F document=@$(echo kernel.log) "https://api.telegram.org/bot$tg_voithos_token/sendDocument" \ | |
-F chat_id="$tg_delta_insider_id" | |
exit 1 | |
} | |
# TG > Build Success Alert (Insider) | |
function sendBuildSuccessAlert() { | |
curl -s -X POST "https://api.telegram.org/bot$tg_voithos_token/sendMessage" \ | |
-d chat_id="$tg_delta_insider_id" \ | |
-d "disable_web_page_preview=true" \ | |
-d "parse_mode=html" \ | |
-d text="----------%0AYayy! Built Successfully in $(($TOTAL_TIME / 60))min $(($TOTAL_TIME % 60))sec.%0A----------" | |
} | |
# Send Build Details Alert (Insiders) | |
function sendBuildDetails() { | |
curl -s -X POST "https://api.telegram.org/bot$tg_voithos_token/sendMessage" \ | |
-d chat_id="$tg_delta_insider_id" \ | |
-d "disable_web_page_preview=true" \ | |
-d "parse_mode=html" \ | |
-d text="=============================%0A <b>Delta Kernel Update</b>%0A=============================%0A#delta #release #stable%0A%0A<b>Device</b>: <code>Xiaomi Poco F1 (beryllium)</code>%0A<b>Version</b>: <code>${KERNEL_VER}</code>%0A<b>Build Date</b>: <code>${BUILD_DATE}</code>%0A<b>File Size</b>: <code>${ZIP_SIZE}B</code>%0A%0A<b><a href='"https://delta.manuelpinto.in"'>Download Now</a></b>" | |
} | |
# Send Kernel Zip to (Insiders) | |
function sendKernelZip() { | |
cd anykernel || exit 1 | |
ZIP=$(echo *.zip) | |
curl -F document=@$ZIP "https://api.telegram.org/bot$tg_voithos_token/sendDocument" \ | |
-F chat_id="$tg_delta_insider_id" | |
cd .. | |
} | |
# Compile Kernel | |
function compile() { | |
echo "- Build started!" | |
sendBuildStartAlert | |
make -j$(nproc) O=out ARCH=arm64 delta-beryllium_defconfig | |
make -j$(nproc) O=out \ | |
ARCH=arm64 \ | |
CC=clang \ | |
CLANG_TRIPLE=aarch64-linux-gnu- \ | |
CROSS_COMPILE=aarch64-linux-android- \ | |
CROSS_COMPILE_ARM32=arm-linux-androideabi- | tee build.log | |
if ! [ -a "$KERNEL_IMAGE" ]; then | |
BUILD_END=$(date +"%s") | |
TOTAL_TIME=$(($BUILD_END - $BUILD_START)) | |
echo "- Oops! Error(s) in build. Halting CI Instance & Exiting.." | |
echo "- Wasted $(($TOTAL_TIME / 60))min $(($TOTAL_TIME % 60))sec. of precious CI build minutes!" | |
sendBuildErrorAlert | |
exit 1 | |
fi | |
BUILD_END=$(date +"%s") | |
TOTAL_TIME=$(($BUILD_END - $BUILD_START)) | |
sendBuildSuccessAlert | |
echo "" | |
echo "- Build Completed!" | |
} | |
# Zipping | |
function zipIt() { | |
echo "" | |
echo "- Copying Image.gz-dtb to anykernel dir!" | |
cp -f out/arch/arm64/boot/Image.gz-dtb ../anykernel | |
sed -i "1s/.*/${BUILD_VERSION} (${BUILD_VARIANT} ${BUILD_DISPLAY}Hz) | ${BUILD_DATE}/" ${HOME_DIR}/anykernel/version | |
echo "" | |
echo "- Done Copying Image.gz-dtb!" | |
echo "" | |
echo "- Zip it!" | |
cd ../anykernel || exit 1 | |
zip -r9 ${KERNEL_ZIP} * -x .git README.md zip.sh *placeholder | |
echo "- Done Zipping!" | |
SHA1=($(sha1sum ${KERNEL_ZIP})) | |
ZIP_SIZE=($(du -h ${KERNEL_ZIP} | awk '{print $1}')) | |
cd .. | |
} | |
compile | |
zipIt | |
sendBuildDetails | |
sendKernelZip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment