god: add?
get from https://cuynutt.ddns.net/ncatt/atherion-pj-main/src/branch/main/heaven.sh history:2856304b00697cee02c9af7401eae23a2306570cb1c822272413ae89c215b276e4e147d2f364967fd86fa5a85e594e1c237c6166d416a5e3729c53d52adb75f9244dac85e61a25e3cac1d97a0c65ea028ef0768e92
This commit is contained in:
parent
da8ccb7564
commit
4a99cd9e20
1 changed files with 264 additions and 0 deletions
264
main/god.sh
Normal file
264
main/god.sh
Normal file
|
|
@ -0,0 +1,264 @@
|
|||
#!/usr/bin/env bash
|
||||
# vim: expandtab tabstop=4 shiftwidth=4
|
||||
|
||||
FILEPATH=$(readlink -f "$0")
|
||||
DIRPATH=$(dirname "$FILEPATH")
|
||||
export DIRPATH
|
||||
|
||||
# Initial startup
|
||||
cd "$DIRPATH"
|
||||
mkdir -p "$DIRPATH"/anykernel3
|
||||
mkdir -p "$DIRPATH"/output
|
||||
clear
|
||||
|
||||
. "$DIRPATH/common.sh"
|
||||
|
||||
# Check if user is running on an actual Linux environment
|
||||
if uname -a | grep -i Linux ; then
|
||||
info "You have Linux environment :)"
|
||||
fi
|
||||
|
||||
# Check if wget exists
|
||||
if ! wget --version ; then
|
||||
err "wget not found !!!"
|
||||
info "Please install wget for your system !"
|
||||
exit 127
|
||||
fi
|
||||
|
||||
COMMIT="$(git rev-parse --short HEAD)"
|
||||
BRANCH="$(git rev-parse --abbrev-ref HEAD)"
|
||||
clear
|
||||
|
||||
|
||||
dependencies() {
|
||||
info "Installing dependencies..."
|
||||
|
||||
if command -v pacman &> /dev/null; then
|
||||
info "Arch/Arch-based system detected, using pacman and yay..."
|
||||
|
||||
sudo pacman -Syu --needed base-devel git lz4 xz zlib gcc python python-setuptools p7zip android-tools erofs-utils \
|
||||
ncurses libx11 readline mesa libgl python-markdown libxml2 libxslt dos2unix kmod openssl elfutils dwarves \
|
||||
libarchive zstd rsync libyaml --noconfirm
|
||||
yay -S android-tools dtc jdk-openjdk dwarves
|
||||
|
||||
elif command -v dnf &> /dev/null; then
|
||||
info "Fedora/RHEL-based system detected, using dnf..."
|
||||
sudo dnf group install "c-development" "development-tools" && \
|
||||
sudo dnf install -y dtc lz4 xz zlib-devel java-latest-openjdk-devel python3 \
|
||||
p7zip p7zip-plugins android-tools erofs-utils \
|
||||
ncurses-devel libX11-devel readline-devel mesa-libGL-devel python3-markdown \
|
||||
libxml2 libxslt dos2unix kmod openssl elfutils-libelf-devel dwarves \
|
||||
openssl-devel libarchive zstd rsync libyaml-devel openssl-devel-engine --skip-unavailable
|
||||
|
||||
elif command -v apt &> /dev/null; then
|
||||
info "Ubuntu/Debian-based system detected, using apt..."
|
||||
sudo apt update && sudo apt install -y git device-tree-compiler lz4 xz-utils zlib1g-dev openjdk-17-jdk gcc g++ python3 python-is-python3 p7zip-full android-sdk-libsparse-utils erofs-utils \
|
||||
default-jdk git gnupg flex bison gperf build-essential zip curl libc6-dev libncurses-dev libx11-dev libreadline-dev libgl1 libgl1-mesa-dev \
|
||||
python3 make sudo gcc g++ bc grep tofrodos python3-markdown libxml2-utils xsltproc zlib1g-dev python-is-python3 libc6-dev libtinfo6 \
|
||||
make repo cpio kmod openssl libelf-dev pahole libssl-dev libarchive-tools zstd libyaml-dev --fix-missing && wget http://security.ubuntu.com/ubuntu/pool/universe/n/ncurses/libtinfo5_6.3-2ubuntu0.1_amd64.deb && sudo dpkg -i libtinfo5_6.3-2ubuntu0.1_amd64.deb
|
||||
|
||||
else
|
||||
err "Neither pacman, dnf, nor apt package manager found. Please install dependencies manually."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
download_clang() {
|
||||
if [ -f "clang/bin/clang" ]; then
|
||||
clang/bin/clang --version
|
||||
else
|
||||
zyc="https://github.com/ZyCromerZ/Clang/releases/download/14.0.6-20250704-release/Clang-14.0.6-20250704.tar.gz"
|
||||
echo "not found clang, please choose option to download clang:"
|
||||
echo "1) zyc clang 14"
|
||||
echo "2) input custom link"
|
||||
echo "3) exit"
|
||||
read -rp "choose: " choice
|
||||
case "$choice" in
|
||||
1)
|
||||
mkdir -p clang && cd clang || return 1
|
||||
wget -q --show-progress "$zyc" || {
|
||||
err "download failed."
|
||||
cd ..
|
||||
return 1
|
||||
}
|
||||
info "extracting..."
|
||||
tar -zxvf Clang-*.tar.gz || err "failed to extract clang file."
|
||||
info "download done, should work"
|
||||
cd ..
|
||||
;;
|
||||
2)
|
||||
read -rp "input custom link: " custom_link
|
||||
if [ -z "$custom_link" ]; then
|
||||
err "link invalid"
|
||||
return 1
|
||||
fi
|
||||
mkdir -p clang && cd clang || return 1
|
||||
wget -q --show-progress -O "clangcustom.tar.gz" "$custom_link" || {
|
||||
err "download failed."
|
||||
cd ..
|
||||
return 1
|
||||
}
|
||||
info "extracting..."
|
||||
tar -zxvf Clang-*.tar.gz || err "failed to extract clang file."
|
||||
cd ..
|
||||
info "download done, should work"
|
||||
;;
|
||||
3)
|
||||
echo "exit."
|
||||
;;
|
||||
*)
|
||||
err "invalid option"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
clone_kernel_sauce() {
|
||||
if [ -d "kernel_source" ] && [ -f "kernel_source/Makefile" ]; then
|
||||
info "kernel source found."
|
||||
cd kernel_source
|
||||
make kernelversion
|
||||
cd ..
|
||||
elif [ -d "kernel_source" ] && [ ! -f "kernel_source/Makefile" ]; then
|
||||
err "kernel source folder found but looks incomplete, deleting and re-cloning..."
|
||||
rm -rf kernel_source
|
||||
read -rp "paste kernel source git link: " kernel_link
|
||||
if [ -z "$kernel_link" ]; then
|
||||
err "no link provided, exiting."
|
||||
return 1
|
||||
fi
|
||||
git clone --depth=1 "$kernel_link" kernel_source || {
|
||||
err "clone failed, check your link and try again."
|
||||
return 1
|
||||
}
|
||||
info "done."
|
||||
else
|
||||
info "no kernel source found."
|
||||
read -rp "paste kernel source git link: " kernel_link
|
||||
if [ -z "$kernel_link" ]; then
|
||||
err "no link provided, exiting."
|
||||
return 1
|
||||
fi
|
||||
git clone --depth=1 "$kernel_link" kernel_source || {
|
||||
err "clone failed, check your link and try again."
|
||||
return 1
|
||||
}
|
||||
info "done."
|
||||
fi
|
||||
}
|
||||
|
||||
build_kernel(){
|
||||
info "exporting environment variables..."
|
||||
export TC="$DIRPATH"/clang
|
||||
export CROSS_COMPILE=$TC/bin/aarch64-linux-gnu-
|
||||
export LD=$TC/bin/ld.lld
|
||||
export OBJCOPY=$TC/bin/llvm-objcopy
|
||||
export AS=$TC/bin/llvm-as
|
||||
export NM=$TC/bin/llvm-nm
|
||||
export STRIP=$TC/bin/llvm-strip
|
||||
export OBJDUMP=$TC/bin/llvm-objdump
|
||||
export READELF=$TC/bin/llvm-readelf
|
||||
export CC=$TC/bin/clang
|
||||
export CROSS_COMPILE_ARM32=$TC/bin/arm-linux-gnueabi-
|
||||
export ARCH=arm64
|
||||
export ANDROID_MAJOR_VERSION=r
|
||||
export KCFLAGS=' -w -pipe -O3'
|
||||
export KCPPFLAGS=' -O3'
|
||||
export CONFIG_SECTION_MISMATCH_WARN_ONLY=y
|
||||
|
||||
info "looking for defconfigs..."
|
||||
mapfile -t defconfigs < <(find kernel_source/arch/arm64/configs -maxdepth 1 -name "*defconfig" | sort)
|
||||
if [ ${#defconfigs[@]} -eq 0 ]; then
|
||||
err "no defconfig found in kernel_source/arch/arm64/configs/, make sure your kernel source is cloned properly."
|
||||
return 1
|
||||
fi
|
||||
echo "available defconfigs:"
|
||||
for i in "${!defconfigs[@]}"; do
|
||||
echo "$((i+1))) $(basename "${defconfigs[$i]}")"
|
||||
done
|
||||
read -rp "choose defconfig (number): " defconfig_choice
|
||||
if ! [[ "$defconfig_choice" =~ ^[0-9]+$ ]] || [ "$defconfig_choice" -lt 1 ] || [ "$defconfig_choice" -gt "${#defconfigs[@]}" ]; then
|
||||
err "invalid choice."
|
||||
return 1
|
||||
fi
|
||||
export config
|
||||
config=$(basename "${defconfigs[$((defconfig_choice-1))]}")
|
||||
info "using defconfig: $config"
|
||||
|
||||
info "start build!"
|
||||
make -C $(pwd)/kernel_source O=$(pwd)/kernel_source/out clean -j$(nproc) && make -C $(pwd)/kernel_source O=$(pwd)/kernel_source/out mrproper -j$(nproc)
|
||||
clear
|
||||
make -C $(pwd)/kernel_source O=$(pwd)/kernel_source/out -j$(nproc) "$config"
|
||||
make -s -C $(pwd)/kernel_source O=$(pwd)/kernel_source/out -j$(nproc)
|
||||
good "build done successfully!"
|
||||
|
||||
if confirm "do you want to copy files to AnyKernel3?"; then
|
||||
if [ -d "AnyKernel3" ]; then
|
||||
info "AnyKernel3 folder already exists, skipping clone."
|
||||
else
|
||||
read -rp "paste AnyKernel3 git link: " ak3_link
|
||||
if [ -z "$ak3_link" ]; then
|
||||
err "no link provided, skipping."
|
||||
return 1
|
||||
fi
|
||||
git clone --depth=1 "$ak3_link" AnyKernel3 || {
|
||||
err "clone failed, check your link and try again."
|
||||
return 1
|
||||
}
|
||||
fi
|
||||
cp out/arch/arm64/boot/Image.gz-dtb AnyKernel3/ || \
|
||||
cp out/arch/arm64/boot/Image.gz AnyKernel3/ || \
|
||||
cp out/arch/arm64/boot/Image AnyKernel3/ || {
|
||||
err "no kernel image found in out/arch/arm64/boot/, check it out!"
|
||||
return 1
|
||||
}
|
||||
good "files copied to AnyKernel3."
|
||||
|
||||
read -rp "enter device codename/model (leave empty to skip): " device_name
|
||||
if confirm "do you want to zip AnyKernel3?"; then
|
||||
local date_str
|
||||
date_str=$(date +"%Y%m%d-%H%M%S")
|
||||
if [ -z "$device_name" ]; then
|
||||
local zip_name="errva-output-$date_str.zip"
|
||||
else
|
||||
local zip_name="errva-output-$device_name-$date_str.zip"
|
||||
fi
|
||||
info "zipping to $zip_name..."
|
||||
cd AnyKernel3
|
||||
zip -r9 "../$zip_name" . || {
|
||||
err "zip failed."
|
||||
cd ..
|
||||
return 1
|
||||
}
|
||||
cd ..
|
||||
good "zipped to $zip_name."
|
||||
else
|
||||
info "skipping zip."
|
||||
fi
|
||||
else
|
||||
info "skipping."
|
||||
fi
|
||||
}
|
||||
|
||||
# Banner
|
||||
echo "Errva`"
|
||||
echo -------------------------------------------------------------
|
||||
echo "Build Android kernel more easy with Errva`"
|
||||
echo "Rename your toolchain to [clang] and put to root folder ($DIRPATH)!"
|
||||
echo -------------------------------------------------------------
|
||||
echo "Current commit : $COMMIT ($BRANCH)"
|
||||
echo "Source code : https://cuynutt.ddns.net/ncatt/errva"
|
||||
echo -------------------------------------------------------------
|
||||
# Main functions
|
||||
PS3='Please select options to continue : '
|
||||
select opt in 'Install dependencies' 'Download clang' 'Clone kernel source' 'Build kernel' 'Exit'
|
||||
do
|
||||
case "$opt" in
|
||||
'Install dependencies') dependencies ;;
|
||||
'Download clang') download_clang ;;
|
||||
'Clone kernel source') clone_kernel_sauce ;;
|
||||
'Build kernel') build_kernel ;;
|
||||
'Exit') exit ;;
|
||||
*) err "invalid option" ;;
|
||||
esac
|
||||
done
|
||||
Loading…
Reference in a new issue