aboutsummaryrefslogtreecommitdiff
path: root/sbqrun
blob: 1551a9c547fc256da0c5587466a2e849d2ab140d (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/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] [-p] arg [arg ...]

Options:
  -t  Don't track filesystem writes (passed to sbrun).
  -n  Allow network access (passed to sbrun).
  -p  If a binary package already exists for a given build, install
      it instead of building a new one.

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.

The -p option requires SlackBuild scripts that support the
PRINT_PACKAGE_NAME option (Slackware 15.0 and up). It searches
for built packages in the same place SlackBuild scripts place them
(OUTPUT, TMP, or /tmp).
EOF
	exit 0
fi

olddir="$(pwd)"
source ~/sbostuff/sbostuff.sh
cdsb

for arg; do
	if [ "$arg" = "-p" ]; then
		use_prebuilt=yes
	elif [ "$arg" = "-t" -o "$arg" = "-n" ]; then
		SBRUN_OPTS="$SBRUN_OPTS $arg"
	elif [ "$arg" = "-" ]; then
		while read build; do
			BUILDS="$BUILDS $build"
		done
	elif [ -f "$olddir/$arg" ]; then
		BUILDS="$BUILDS `cat $olddir/$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

	if [ "$use_prebuilt" = "yes" ]; then
		script="$( pwd | sed 's,.*/,,' )".SlackBuild
		if ! grep -q '^[^#]*PRINT_PACKAGE_NAME' "$script"; then
			echo "==== sbqrun: PRINT_PACKAGE_NAME not supported by $script, ignoring -p"
		else
			pkgnam="$( PRINT_PACKAGE_NAME=1 sh $script )"
			OUTPUT="${OUTPUT:-${TMP:-/tmp}}"
			if [ -e "$OUTPUT/$pkgnam" ]; then
				upkg "$OUTPUT/$pkgnam"
				continue
			fi
		fi
	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"
			FAILED+="$build "
			: $(( 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