-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
build-all.sh: improvements #27038
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
build-all.sh: improvements #27038
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -50,6 +52,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 | ||
|
|
@@ -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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also prefer stdout and stderr in a single log as well, however, I remember that Grimler didn't like this:
and this is subjective. For some other people who are not you and me, stdout and stderr in separate logs might be easier to handle and understand, and that might be the reason why they were written to save in separate logs to begin with. @Grimler91 what do you think about it now that it is in a separate PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm personally fine with this change, but it should probably be a separate commit. |
||
| 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" | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using a
casefor this instead of regex.