Skip to content

Commit

Permalink
build-all.sh: improvements
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
Maxython committed Aug 15, 2024
1 parent bcd01a4 commit b2291c8
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -18,25 +17,28 @@ fi
test -f "$HOME"/.termuxrc && . "$HOME"/.termuxrc
: ${TERMUX_TOPDIR:="$HOME/.termux-build"}
: ${TERMUX_ARCH:="aarch64"}
: ${TERMUX_FORMAT:="debian"}
: ${TERMUX_DEBUG_BUILD:=""}
: ${TERMUX_INSTALL_DEPS:=""}

_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. Default: debian."
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
Expand All @@ -49,6 +51,11 @@ if [[ ! "$TERMUX_ARCH" =~ ^(all|aarch64|arm|i686|x86_64)$ ]]; then
exit 1
fi

if [[ ! "$TERMUX_FORMAT" =~ ^(debian|pacman)$ ]]; then
echo "ERROR: Invalid format '$TERMUX_FORMAT'" 1>&2
exit 1
fi

BUILDSCRIPT=$(dirname "$0")/build-package.sh
BUILDALL_DIR=$TERMUX_TOPDIR/_buildall-$TERMUX_ARCH
BUILDORDER_FILE=$BUILDALL_DIR/buildorder.txt
Expand All @@ -64,25 +71,29 @@ 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"
Expand Down

0 comments on commit b2291c8

Please sign in to comment.