Refactor build of tty-clock (#685)
[termux-packages] / build-all.sh
CommitLineData
59f0d218
FF
1#!/bin/bash
2# build-all.sh - script to build all packages with a build order specified by buildorder.py
3
4set -e -u -o pipefail
5
a0057943
FF
6# Read settings from .termuxrc if existing
7test -f $HOME/.termuxrc && . $HOME/.termuxrc
8: ${TERMUX_TOPDIR:="$HOME/.termux-build"}
9
59f0d218 10BUILDSCRIPT=`dirname $0`/build-package.sh
a0057943
FF
11BUILDORDER_FILE=$TERMUX_TOPDIR/_buildall/buildorder.txt
12BUILDSTATUS_FILE=$TERMUX_TOPDIR/_buildall/buildstatus.txt
59f0d218
FF
13
14if [ -e $BUILDORDER_FILE ]; then
12622a95 15 echo "Using existing buildorder file: $BUILDORDER_FILE"
59f0d218 16else
a0057943 17 mkdir -p $TERMUX_TOPDIR/_buildall
658bba67 18 ./scripts/buildorder.py > $BUILDORDER_FILE
59f0d218 19fi
12622a95
GS
20if [ -e $BUILDSTATUS_FILE ]; then
21 echo "Continuing build-all from: $BUILDSTATUS_FILE"
22fi
59f0d218 23
a0057943
FF
24exec > >(tee -a $TERMUX_TOPDIR/_buildall/ALL.out)
25exec 2> >(tee -a $TERMUX_TOPDIR/_buildall/ALL.err >&2)
26trap 'echo failure; echo See: $TERMUX_TOPDIR/_buildall/${package}.err' ERR
59f0d218
FF
27
28for package in `cat $BUILDORDER_FILE`; do
12622a95
GS
29 # Check build status (grepping is a bit crude, but it works)
30 if [ -e $BUILDSTATUS_FILE ] && \
31 grep "^$package\$" $BUILDSTATUS_FILE >/dev/null; then
32 echo "Skipping $package"
33 continue
34 fi
35
36 echo -n "Building $package... "
59f0d218 37 BUILD_START=`date "+%s"`
fc89df4d 38 bash -x $BUILDSCRIPT -s $package > $TERMUX_TOPDIR/_buildall/${package}.out 2> $TERMUX_TOPDIR/_buildall/${package}.err
59f0d218
FF
39 BUILD_END=`date "+%s"`
40 BUILD_SECONDS=$(( $BUILD_END - $BUILD_START ))
41 echo "done in $BUILD_SECONDS"
12622a95
GS
42
43 # Update build status
44 echo "$package" >> $BUILDSTATUS_FILE
59f0d218 45done
12622a95
GS
46
47# Update build status
48rm -f $BUILDSTATUS_FILE
49echo "Finished"