wesnoth/data/tools/unit_tree/update-wmlunits
2023-11-27 19:40:04 +01:00

60 lines
1.8 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"
rm -rf "$TEMP"
mkdir -p "$config/data/add-ons"
mkdir -p "$addons"
mkdir -p "$log"
mkdir -p "$tmpout"
mkdir -p "$TEMP"
mkdir -p "$trans"
# we only need the parser, but have to build the game executable for that
echo BUILDING
cd "$dir" || exit # the scons build places the wesnoth executable in the current directory
# continue on failure if there is an executable from a previous build
TRAVIS=1 TRAVIS_OS_NAME=Linux scons -Y "$src" --option-cache="$build/.scons-option-cache" || [ -x wesnoth ]
# 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
rsync -vaz --delete "$tmpout/" "$OUT" > "$log/rsync.txt" 2>&1
rm -rf "$TEMP"
rm -rf "$tmpout"