test-build.sh 3.46 KB
Newer Older
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
#!/bin/bash
#
# Script to test the build of the documentation generated
#
# This program is copyright 2011 by Javier Fernandez-Sanguino <jfs@debian.org>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# For more information please see
#  http://www.gnu.org/licenses/licenses.html#GPL

name=release-notes  # Name of the document
formats="txt html pdf" # Formats the document is build to
26 27 28 29 30
# Directory to look for the published content
publishdir="publish" 
if [ -n "$PUBLISHDIR" ] ; then
    publishdir="$PUBLISHDIR"
fi
31 32 33 34 35 36 37 38 39 40 41 42

# Sanity checks:
if [ ! -e "$name.ent" ] ; then
    echo "ERROR: File $name.ent does not exist, this is required to extract information"
    exit 1
fi
if [ ! -e "Makefile" ] ; then
    echo "ERROR: File Makefile does not exist, this is required to extract information"
    exit 1
fi

# Extract the information
43
arches=`grep '<phrase arch=' $name.ent | sed 's/.* arch=.\([a-z0-9-]*\).*/\1/' | sort -u`
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
langs=`grep "^LANGUAGES " Makefile | sed 's/.*=//'`

# Check if the information we have is OK to proceeded
if [ -z "$arches" ]; then
    echo "ERROR: Cannot find a proper list of the architectures this document is built for."
    exit 1
fi
if [ -z "$langs" ]; then
    echo "ERROR: Cannot find the list of languages this document is built for."
    exit 1
fi

for lang in $langs;  do
    count=0
    okcount=0
    failcount=0
60 61
    pokcount=0
    pfailcount=0
62 63 64 65
    echo "Checking build for language '$lang'"
    for arch in $arches;  do
        for format in $formats;  do
            count=$(($count+1))
66
            # Check the builddir
67 68
            if [ -e "${lang}/${name}.${arch}.${format}" ] ; then
                okcount=$(($okcount+1))
69 70 71 72 73 74 75 76 77 78 79 80 81 82
# Check the publishdir
                if [ -d "$publishdir" ] ; then
                    if  [ "$format" = "html" ] ; then
                        file="${publishdir}/${arch}/${name}/index.${lang}.${format}" 
                    else
                        file="${publishdir}/${arch}/${name}.${lang}.${format}" 
                    fi
                    if [ -e "$file" ] ; then
                        pokcount=$(($pokcount+1))
                    else
                        pfailcount=$(($pfailcount+1))
                        echo -e "\tERROR: Missing $format for $arch in PUBLISHDIR '$publishdir' (language: $lang). Tried looking for '$file'."
                    fi
                fi
83 84
            else
                failcount=$(($failcount+1))
85 86
                echo -e "\tERROR: Missing build document in $format format for $arch (language: $lang)"
            fi
87 88
        done
    done
89 90 91 92
    echo "TOTAL: Build totals for for language '$lang'. BUILD OK: $okcount BUILD FAIL: $failcount of $count documents"
    if [ -d "$publishdir" ] ; then
        echo "TOTAL: Publishing totals for language '$lang'. PUBLISH OK: $pokcount PUBLISH FAIL: $pfailcount of $okcount built"
    fi
93
done
94 95

exit 0