#!/data/data/com.termux/files/usr/bin/bash arch=$(uname -m) if [ "$arch" = "aarch64" ]; then arch="aarch64" elif [ "$arch" = "armv7l" ]; then arch="arm" elif [ "$arch" = "armv8l" ]; then arch="arm" else echo -e "\nArchitecture $arch not supported\n" exit 1 fi main_repo=$(grep -E '^deb ' /data/data/com.termux/files/usr/etc/apt/sources.list | awk '{print $2}' | head -n 1) while true; do curl -s $main_repo > /dev/null if [ $? -eq 0 ]; then echo -e "\n\033[32mapt update...\033[0m" apt update > /dev/null 2> >(grep -v "apt does not have a stable CLI interface") && break else echo -e "\nNo internet connection. Please check your connection. \nRetrying in 5s...\n" sleep 5 fi done url="https://raw.githubusercontent.com/nohajc/nohajc.github.io/master/dists/termux/extras/binary-${arch}" get_version() { package_name="$1" local __resultvar=$2 version=$(curl -s "$url/Packages" | awk -v package="$package_name" ' $0 ~ "^Package: " package {found=1} found && /^Version:/ {print $2; exit} ') eval $__resultvar="'$version'" } libprotobuf_version_c="" termux_adb_version_c="" get_version "libprotobuf-tadb-core" libprotobuf_version_c get_version "termux-adb" termux_adb_version_c libprotobuf_version_i=$(pkg show libprotobuf-tadb-core 2>/dev/null | grep Version | cut -d ' ' -f 2) termux_adb_version_i=$(pkg show termux-adb 2>/dev/null | grep Version | cut -d ' ' -f 2) # Function to compare versions compare_versions() { package_name="$1" available_version="$2" installed_version="$3" if [ "$installed_version" == "$available_version" ]; then echo -e "\n$package_name is already the newest version.\n" else curl -O "$url/${package_name}_${available_version}_${arch}.deb" dpkg -i "${package_name}_${available_version}_${arch}.deb" rm -f "${package_name}_${available_version}_${arch}.deb" fi } compare_versions "libprotobuf-tadb-core" "$libprotobuf_version_c" "$libprotobuf_version_i" compare_versions "termux-adb" "$termux_adb_version_c" "$termux_adb_version_i" ln -sf "$PREFIX/bin/termux-fastboot" "$PREFIX/bin/fastboot" && ln -sf "$PREFIX/bin/termux-adb" "$PREFIX/bin/adb" printf "\n\e[1;34mSymbolic links created:\e[0m\n - 'termux-fastboot' -> 'fastboot'\n - 'termux-adb' -> 'adb'\n" packages=( "abseil-cpp" "termux-api" "libusb" "brotli" "libc++" "zlib" "zstd" "liblz4" ) for package in "${packages[@]}"; do installed=$(apt policy "$package" 2>/dev/null | grep 'Installed' | awk '{print $2}') candidate=$(apt policy "$package" 2>/dev/null | grep 'Candidate' | awk '{print $2}') if [ "$installed" == "$candidate" ]; then echo -e "\n$package is already the newest version.\n" else echo -e "\nDownloading $package...\n" apt download "$package" echo -e "\nInstalling $package...\n" dpkg -i "${package}"*.deb rm -f "${package}"*.deb fi done [ ! -f $PREFIX/bin/termux-adb-u ] && echo -e '#!/bin/bash\ncurl -s https://raw.githubusercontent.com/offici5l/termux-adb-fastboot/main/utermuxadb | bash' > $PREFIX/bin/termux-adb-u chmod +x $PREFIX/bin/termux-adb-u echo -e "\n\nany future upgrades will be done with: \n\e[1;32mtermux-adb-u\e[0m\n" printf "\n\e[1;32mdone!\n\nadb\e[0m and \e[1;32mfastboot\e[0m ready to use.\n\n"