]> git.saurik.com Git - wxWidgets.git/blob - build/buildbot/tools/validate.sh
td162 is down so try td163.
[wxWidgets.git] / build / buildbot / tools / validate.sh
1 #!/bin/sh
2 #############################################################################
3 # Name: validate
4 # Purpose: Reports errors in wxWidgets buildbot configuration files
5 # Author: Mike Wetherell
6 # RCS-ID: $Id$
7 # Copyright: (c) 2007 Mike Wetherell
8 # Licence: wxWidgets licence
9 #############################################################################
10
11 if [ $# -eq 0 -o ! -f "$1" ]; then
12 echo "Usage: $0 FILE..."
13 echo "Reports errors in wxWidgets buildbot configuration files"
14 exit 1
15 fi >&2
16
17 DIR="`dirname $0`"
18 WORKDIR="${TMPDIR:-/tmp}/wx.$$"
19 mkdir "$WORKDIR" || exit
20 trap 'rm -rf "$WORKDIR"' EXIT
21 WORKPAT=`echo "$WORKDIR" | sed 's|[^A-Za-z0-9/]|.|g'`
22
23 # Change the names of the temporary files in an error message to something
24 # to something more informative
25 #
26 error()
27 {
28 if [ -n "$1" ]; then
29 echo "$1" |
30 sed "s|file ${WORKPAT}|${WORKPAT}|g;\
31 s|${WORKPAT}/XSLT|generated XSLT (from $NAME)|g;\
32 s|${WORKPAT}/prep|$NAME (preprocessed)|g"
33 fi
34 }
35
36 # This is pretty ugly, sorry. It tries not to print the same error more than
37 # once, and it tries to send success message to stdout and errors to stderr.
38 # It still doesn't return a meaningful exit code.
39 #
40 while [ $# -gt 0 ]
41 do
42 INPUT="$1"
43 NAME="`echo \"$INPUT\" | sed 's/[|\]/\\\&/g'`"
44 XSLT="$WORKDIR/XSLT"
45 OUTPUT="$WORKDIR/prep"
46
47 if STDERR=`xsltproc --xinclude -o "$XSLT" $DIR/embedded.xsl "$INPUT" 2>&1`
48 then
49 STDERR=`xsltproc --xinclude -o "$OUTPUT" "$XSLT" "$INPUT" 2>&1` \
50 && OK=true || OK=false
51 error "$STDERR" >&2
52
53 if $OK; then
54 STDERR=`xmllint --noout --schema $DIR/bot.xsd "$OUTPUT" 2>&1` \
55 && OUT=1 || OUT=2
56 error "$STDERR" >&$OUT
57 fi
58 else
59 error "$STDERR" >&2
60 fi
61
62 rm -f "$XSLT" "$OUTPUT"
63
64 shift
65 done