From 552f6333c7d580c13e6a7cb43221441b973f66ed Mon Sep 17 00:00:00 2001 From: Maxython Date: Wed, 29 Oct 2025 01:27:47 +0300 Subject: [PATCH] build-all.sh: improvements - added the ability to change the package format - added library base check by package name - the method of saving processes in the logo has been changed - use `case` to check the `TERMUX_FORMAT` and `TERMUX_ARCH` variables --- build-all.sh | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/build-all.sh b/build-all.sh index 08ce45235399aa..c595376af2a79f 100755 --- a/build-all.sh +++ b/build-all.sh @@ -8,7 +8,6 @@ TERMUX_SCRIPTDIR=$(cd "$(realpath "$(dirname "$0")")"; pwd) # Store pid of current process in a file for docker__run_docker_exec_trap source "$TERMUX_SCRIPTDIR/scripts/utils/docker/docker.sh"; docker__create_docker_exec_pid_file - if [ "$(uname -o)" = "Android" ] || [ -e "/system/bin/app_process" ]; then echo "On-device execution of this script is not supported." exit 1 @@ -18,26 +17,29 @@ fi test -f "$HOME"/.termuxrc && . "$HOME"/.termuxrc : ${TERMUX_TOPDIR:="$HOME/.termux-build"} : ${TERMUX_ARCH:="aarch64"} +: ${TERMUX_FORMAT:="debian"} : ${TERMUX_DEBUG_BUILD:=""} : ${TERMUX_INSTALL_DEPS:="-s"} # Set TERMUX_INSTALL_DEPS to -s unless set to -i _show_usage() { - echo "Usage: ./build-all.sh [-a ARCH] [-d] [-i] [-o DIR]" + echo "Usage: ./build-all.sh [-a ARCH] [-d] [-i] [-o DIR] [-f FORMAT]" echo "Build all packages." echo " -a The architecture to build for: aarch64(default), arm, i686, x86_64 or all." echo " -d Build with debug symbols." echo " -i Build dependencies." echo " -o Specify deb directory. Default: debs/." + echo " -f Specify format pkg: debian(default) or pacman." exit 1 } -while getopts :a:hdio: option; do +while getopts :a:hdio:f: option; do case "$option" in a) TERMUX_ARCH="$OPTARG";; d) TERMUX_DEBUG_BUILD='-d';; i) TERMUX_INSTALL_DEPS='-i';; o) TERMUX_OUTPUT_DIR="$(realpath -m "$OPTARG")";; + f) TERMUX_FORMAT="$OPTARG";; h) _show_usage;; *) _show_usage >&2 ;; esac @@ -45,10 +47,15 @@ done shift $((OPTIND-1)) if [ "$#" -ne 0 ]; then _show_usage; fi -if [[ ! "$TERMUX_ARCH" =~ ^(all|aarch64|arm|i686|x86_64)$ ]]; then - echo "ERROR: Invalid arch '$TERMUX_ARCH'" 1>&2 - exit 1 -fi +case "$TERMUX_ARCH" in + all|aarch64|arm|i686|x86_64);; + *) echo "ERROR: Invalid arch '$TERMUX_ARCH'" 1>&2; exit 1;; +esac + +case "$TERMUX_FORMAT" in + debian|pacman);; + *) echo "ERROR: Invalid format '$TERMUX_FORMAT'" 1>&2; exit 1;; +esac BUILDSCRIPT=$(dirname "$0")/build-package.sh BUILDALL_DIR=$TERMUX_TOPDIR/_buildall-$TERMUX_ARCH @@ -65,25 +72,30 @@ if [ -e "$BUILDSTATUS_FILE" ]; then echo "Continuing build-all from: $BUILDSTATUS_FILE" fi -exec > >(tee -a "$BUILDALL_DIR"/ALL.out) -exec 2> >(tee -a "$BUILDALL_DIR"/ALL.err >&2) -trap 'echo ERROR: See $BUILDALL_DIR/${PKG}.err' ERR +exec &> >(tee -a "$BUILDALL_DIR"/ALL.out) +trap 'echo ERROR: See $BUILDALL_DIR/${PKG}.out' ERR while read -r PKG PKG_DIR; do # Check build status (grepping is a bit crude, but it works) - if [ -e "$BUILDSTATUS_FILE" ] && grep "^$PKG\$" "$BUILDSTATUS_FILE" >/dev/null; then + if [ -e "$BUILDSTATUS_FILE" ] && grep -q "^$PKG\$" "$BUILDSTATUS_FILE"; then echo "Skipping $PKG" continue fi + # Start building + if [ -n "${TERMUX_DEBUG_BUILD}" ]; then + echo "\"$BUILDSCRIPT\" -a \"$TERMUX_ARCH\" $TERMUX_DEBUG_BUILD --format \"$TERMUX_FORMAT\" --library $(test "${PKG_DIR%/*}" = "gpkg" && echo "glibc" || echo "bionic") ${TERMUX_OUTPUT_DIR+-o $TERMUX_OUTPUT_DIR} $TERMUX_INSTALL_DEPS \"$PKG_DIR\"" + fi + echo -n "Building $PKG... " BUILD_START=$(date "+%s") - bash -x "$BUILDSCRIPT" -a "$TERMUX_ARCH" $TERMUX_DEBUG_BUILD \ + "$BUILDSCRIPT" -a "$TERMUX_ARCH" $TERMUX_DEBUG_BUILD --format "$TERMUX_FORMAT" \ + --library $(test "${PKG_DIR%/*}" = "gpkg" && echo "glibc" || echo "bionic") \ ${TERMUX_OUTPUT_DIR+-o $TERMUX_OUTPUT_DIR} $TERMUX_INSTALL_DEPS "$PKG_DIR" \ - > "$BUILDALL_DIR"/"${PKG}".out 2> "$BUILDALL_DIR"/"${PKG}".err + &> "$BUILDALL_DIR"/"${PKG}".out BUILD_END=$(date "+%s") BUILD_SECONDS=$(( BUILD_END - BUILD_START )) - echo "done in $BUILD_SECONDS" + echo "done in $BUILD_SECONDS sec" # Update build status echo "$PKG" >> "$BUILDSTATUS_FILE"