2015-06-13 01:03:31 +02:00
|
|
|
#!/bin/bash
|
|
|
|
# build-all.sh - script to build all packages with a build order specified by buildorder.py
|
|
|
|
|
|
|
|
set -e -u -o pipefail
|
|
|
|
|
2019-08-06 14:39:42 +02:00
|
|
|
if [ "$(uname -o)" = "Android" ] || [ -e "/system/bin/app_process" ]; then
|
|
|
|
echo "On-device execution of this script is not supported."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-06-04 00:41:30 +02:00
|
|
|
# Read settings from .termuxrc if existing
|
2021-01-18 17:21:17 +01:00
|
|
|
test -f "$HOME"/.termuxrc && . "$HOME"/.termuxrc
|
2016-06-04 00:41:30 +02:00
|
|
|
: ${TERMUX_TOPDIR:="$HOME/.termux-build"}
|
2017-01-19 14:38:16 +01:00
|
|
|
: ${TERMUX_ARCH:="aarch64"}
|
2018-03-04 17:57:38 +01:00
|
|
|
: ${TERMUX_DEBUG:=""}
|
2019-01-01 21:54:05 +01:00
|
|
|
: ${TERMUX_INSTALL_DEPS:="-s"}
|
|
|
|
# Set TERMUX_INSTALL_DEPS to -s unless set to -i
|
2017-01-19 14:38:16 +01:00
|
|
|
|
2019-02-12 09:23:21 +01:00
|
|
|
_show_usage() {
|
2019-01-01 21:11:37 +01:00
|
|
|
echo "Usage: ./build-all.sh [-a ARCH] [-d] [-i] [-o DIR]"
|
2018-03-04 17:57:38 +01:00
|
|
|
echo "Build all packages."
|
2019-02-12 13:23:47 +01:00
|
|
|
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/."
|
2017-01-19 14:38:16 +01:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2019-01-01 21:11:37 +01:00
|
|
|
while getopts :a:hdio: option; do
|
2017-01-19 14:38:16 +01:00
|
|
|
case "$option" in
|
|
|
|
a) TERMUX_ARCH="$OPTARG";;
|
2018-03-04 17:57:38 +01:00
|
|
|
d) TERMUX_DEBUG='-d';;
|
2019-01-01 21:11:37 +01:00
|
|
|
i) TERMUX_INSTALL_DEPS='-i';;
|
2021-01-18 17:21:17 +01:00
|
|
|
o) TERMUX_DEBDIR="$(realpath -m "$OPTARG")";;
|
2017-01-19 14:38:16 +01:00
|
|
|
h) _show_usage;;
|
2021-01-18 17:21:17 +01:00
|
|
|
*) _show_usage >&2 ;;
|
2017-01-19 14:38:16 +01:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift $((OPTIND-1))
|
|
|
|
if [ "$#" -ne 0 ]; then _show_usage; fi
|
|
|
|
|
2018-05-29 11:04:34 +02:00
|
|
|
if [[ ! "$TERMUX_ARCH" =~ ^(all|aarch64|arm|i686|x86_64)$ ]]; then
|
2017-01-19 14:38:16 +01:00
|
|
|
echo "ERROR: Invalid arch '$TERMUX_ARCH'" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
2016-06-04 00:41:30 +02:00
|
|
|
|
2021-01-18 17:21:17 +01:00
|
|
|
BUILDSCRIPT=$(dirname "$0")/build-package.sh
|
2017-01-19 14:38:16 +01:00
|
|
|
BUILDALL_DIR=$TERMUX_TOPDIR/_buildall-$TERMUX_ARCH
|
|
|
|
BUILDORDER_FILE=$BUILDALL_DIR/buildorder.txt
|
|
|
|
BUILDSTATUS_FILE=$BUILDALL_DIR/buildstatus.txt
|
2015-06-13 01:03:31 +02:00
|
|
|
|
2021-01-18 17:21:17 +01:00
|
|
|
if [ -e "$BUILDORDER_FILE" ]; then
|
2015-12-28 12:49:23 +01:00
|
|
|
echo "Using existing buildorder file: $BUILDORDER_FILE"
|
2015-06-13 01:03:31 +02:00
|
|
|
else
|
2021-01-18 17:21:17 +01:00
|
|
|
mkdir -p "$BUILDALL_DIR"
|
|
|
|
./scripts/buildorder.py > "$BUILDORDER_FILE"
|
2015-06-13 01:03:31 +02:00
|
|
|
fi
|
2021-01-18 17:21:17 +01:00
|
|
|
if [ -e "$BUILDSTATUS_FILE" ]; then
|
2015-12-28 12:49:23 +01:00
|
|
|
echo "Continuing build-all from: $BUILDSTATUS_FILE"
|
|
|
|
fi
|
2015-06-13 01:03:31 +02:00
|
|
|
|
2021-01-18 17:21:17 +01:00
|
|
|
exec > >(tee -a "$BUILDALL_DIR"/ALL.out)
|
|
|
|
exec 2> >(tee -a "$BUILDALL_DIR"/ALL.err >&2)
|
2021-02-03 17:30:12 +01:00
|
|
|
trap 'echo ERROR: See $BUILDALL_DIR/${PKG}.err' ERR
|
2015-06-13 01:03:31 +02:00
|
|
|
|
2021-01-18 17:21:17 +01:00
|
|
|
while read -r PKG PKG_DIR; do
|
2015-12-28 12:49:23 +01:00
|
|
|
# Check build status (grepping is a bit crude, but it works)
|
2021-01-18 17:21:17 +01:00
|
|
|
if [ -e "$BUILDSTATUS_FILE" ] && grep "^$PKG\$" "$BUILDSTATUS_FILE" >/dev/null; then
|
2019-03-02 23:34:54 +01:00
|
|
|
echo "Skipping $PKG"
|
2015-12-28 12:49:23 +01:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2019-03-02 23:34:54 +01:00
|
|
|
echo -n "Building $PKG... "
|
2019-02-12 09:41:30 +01:00
|
|
|
BUILD_START=$(date "+%s")
|
2021-01-18 17:21:17 +01:00
|
|
|
bash -x "$BUILDSCRIPT" -a "$TERMUX_ARCH" $TERMUX_DEBUG \
|
|
|
|
${TERMUX_DEBDIR+-o $TERMUX_DEBDIR} $TERMUX_INSTALL_DEPS "$PKG_DIR" \
|
|
|
|
> "$BUILDALL_DIR"/"${PKG}".out 2> "$BUILDALL_DIR"/"${PKG}".err
|
2019-02-12 09:41:30 +01:00
|
|
|
BUILD_END=$(date "+%s")
|
2021-01-18 17:21:17 +01:00
|
|
|
BUILD_SECONDS=$(( BUILD_END - BUILD_START ))
|
2015-06-13 01:03:31 +02:00
|
|
|
echo "done in $BUILD_SECONDS"
|
2015-12-28 12:49:23 +01:00
|
|
|
|
|
|
|
# Update build status
|
2021-01-18 17:21:17 +01:00
|
|
|
echo "$PKG" >> "$BUILDSTATUS_FILE"
|
|
|
|
done<"${BUILDORDER_FILE}"
|
2015-12-28 12:49:23 +01:00
|
|
|
|
|
|
|
# Update build status
|
2021-01-18 17:21:17 +01:00
|
|
|
rm -f "$BUILDSTATUS_FILE"
|
2015-12-28 12:49:23 +01:00
|
|
|
echo "Finished"
|