aboutsummaryrefslogtreecommitdiff
path: root/sbqrun
blob: 6b35189318faf21740cd53ab7242a2e6ee643323 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash

# sbrun wrapper, runs multiple builds.

# usage: sbqrun arg [arg ...]

if [ "$1" = "" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
	cat <<EOF
Usage: $( basename $0 ) [-n] [-t] arg [arg ...]

Run this script from the top level of a SBo repo clone!

If arg is a file, its contents are added to the list of builds. Use -
to read a list of builds from stdin (possibly piped from sbodeps -q).

If arg is a directory, it's added to the list.

If arg is neither, it's assumed to be a bare build name (with no category/
directory) and searched for.

Full sbopkg queue syntax is NOT supported, only a simple list of builds
(no |VAR=value, no @file, no -app). If you need sbopkg, use sbopkg!

Once the list is built, each build is downloaded with sbodl, built with
sbrun -c, and installed with upkg, in the order given. If the -n and/or
-t options are given, they will be passed to sbrun.
EOF
	exit 0
fi

source ~/sbostuff/sbostuff.sh
cdsb

for arg; do
	if [ "$arg" = "-t" -o "$arg" = "-n" ]; then
		SBRUN_OPTS="$SBRUN_OPTS $arg"
	elif [ "$arg" = "-" ]; then
		while read build; do
			BUILDS="$BUILDS $build"
		done
	elif [ -f "$arg" ]; then
		BUILDS="$BUILDS `cat $arg`"
	elif [ -d "$arg" ]; then
		BUILDS="$BUILDS $arg"
	else
		arg=$( echo */$arg )
		if [ -d "$arg" ]; then
			BUILDS="$BUILDS $arg"
		else
			echo "!!! no idea what '$arg' is, skipping"
		fi
	fi
done

FAILED=""
COUNT=0
FAILCOUNT=0

for build in $BUILDS; do
	: $(( COUNT ++ ))
	echo "==== sbqrun: COUNT=$COUNT, FAILCOUNT=$FAILCOUNT, starting $build"
	if ! cdsb "$build"; then
		echo "==== sbqrun: ERROR: no such build: $build"
		FAILED+="$build "
		: $(( FAILCOUNT ++ ))
		continue
	fi

	sbodl || echo "==== sbqrun: WARN: download failed, trying build anyway"

	if ! sbrun -c $SBRUN_OPTS; then
		echo "==== sbqrun: BUILD FAILED: $build, see $(pwd)/build.log"
		FAILED+="$build "
		: $(( FAILCOUNT ++ ))
	else
		if ! upkg; then
			echo "==== sbqrun: $build built, but FAILED to install"
			: $(( FAILCOUNT ++ ))
		fi
	fi
done

echo "==== Processed $COUNT builds"
if [ "$FAILCOUNT" = "0" ]; then
	echo "==== No failures"
	exit 0
else
	echo "==== $FAILCOUNT build failures: $FAILED"
	exit 1
fi