wesnoth/data/tools/unit_tree/update-wmlunits
2018-01-08 23:36:10 +01:00

63 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
# script running on the wesnoth server to update units.wesnoth.org
set -e -u
# set them in the environment
# VERSION=1.12
# PORT=1.12.x
# must run from the correct directory
DIR="$(dirname $0)"
EXTRA_ADDON_OPTIONS=${EXTRA_ADDON_OPTIONS:-}
EXTRA_WMLUNITS_OPTIONS=${EXTRA_WMLUNITS_OPTIONS:-}
TIMEOUT=${TIMEOUT:-20}
SOURCES=${SOURCES:-/usr/src/wesnoth}
ADDONS=$DIR/addons
EXE=$DIR/wesnoth
CONFIG=$DIR/config
SRC=$SOURCES/$VERSION
DATA=$SRC
LOG=$DIR/logs
TMPOUT=$DIR/output
OUT=${OUT:-"/srv/www/html/units/$VERSION"}
TRANS=$DIR/translations
BUILD=$DIR/build
# always using the master version
TOOLS=${TOOLS:-$SOURCES/master/data/tools}
export TEMP=$DIR/temp
# in case there's leftovers from a previous run
rm -rf $CONFIG/data/add-ons
rm -rf $TMPOUT
mkdir -p $CONFIG/data/add-ons
mkdir -p $ADDONS
mkdir -p $LOG
mkdir -p $TMPOUT
mkdir -p $TEMP
mkdir -p translations
rm -rf $TEMP/*
# we only need the parser, but have to build the game executable for that
echo BUILDING
cd $DIR # the scons build places the wesnoth executable in the current directory
TRAVIS=1 TRAVIS_OS_NAME=Linux scons -Y "$SRC" --option-cache="$BUILD/.scons-option-cache"
# later can just rebuild updated campaigns, but for now rebuild everything
rm -f $DIR/overview.txt
echo DOWNLOADING
$TOOLS/wesnoth_addon_manager -p $PORT -d '.*' -c $ADDONS $EXTRA_ADDON_OPTIONS > $LOG/wesnoth_addon_manager.txt 2>&1
echo WORKING
python3 -u $TOOLS/wmlunits -t $TRANS -D $DATA -o $TMPOUT -w $EXE \
-C $CONFIG -a $ADDONS -L $DIR/overview.txt -B $DIR/overview.txt \
-T $TIMEOUT $EXTRA_WMLUNITS_OPTIONS > $LOG/wmlunits.txt 2>&1
test -f $TMPOUT/mainline/en_US/mainline.html
test -f $TMPOUT/'pics/core$images$units$woses$wose.png'
rsync -vaz --delete $TMPOUT/ $OUT > $LOG/rsync.txt 2>&1
rm -rf $TEMP/*
rm -rf $TMPOUT