#!/bin/bash # SPDX-License-Identifier: GPL-2.0-or-later # LOGS=$(pwd)/logs STAMPS=$(pwd)/stamps BUILDS=$(pwd)/builds SOURCES=$(pwd)/src mkdir -p "$LOGS" mkdir -p "$STAMPS" mkdir -p "$BUILDS" mkdir -p "$SOURCES" ID=$(basename $0) libcamera_version() { project="$1" cd "$project" && ./utils/gen-version.sh } libcamera_branch() { project="$1" git -C "$project" rev-parse --abbrev-ref HEAD } log_filename () { echo "$LOGS/$1.log" } buildstamp_filename() { echo "$STAMPS/$1.version" } builddir() { echo "$BUILDS/$1" } srcdir() { echo "$SOURCES/$1" } check_version() { project="$1" ID="$2" VERSION=$(libcamera_version "$project") last_build=$(buildstamp_filename $ID) export VERSION export last_build ## Only rebuild on version change touch "$last_build" PREV_VERSION=$(cat "$last_build") if [[ x"$PREV_VERSION" == x"$VERSION" ]] ; then project=$(realpath --relative-to=. "$project") echo "$ID: $project has no version change, no actions." exit fi } failure_report() { echo "Subject: $0: $1 has failed" echo "" echo "$1 has failed" echo " --- 8< --- " cat $2 echo " --- >8 --- " } SENDMAIL=$(which sendmail) notify_failures() { if [ x"$SENDMAIL" == x"" ]; then echo "No mail client to notify failures..." return fi failure_report "$1" "$2" | sendmail kieran.bingham@ideasonboard.com } pass_fail() { if [ "$1" -ne 0 ]; then echo " $2: *** Failed ***" if [ -e $logfile ]; then tail -n 100 $logfile; fi notify_failures "$2" "$logfile" exit "$1" else echo " $2: Passed" fi return "$1" } completed() { echo "$VERSION" > "$last_build" }