xonotic/misc/tools/xonotic-map-compiler-autobuild
2010-05-27 16:01:29 +02:00

93 lines
2.2 KiB
Bash
Executable File

#!/bin/sh
set -e
bspdir="$PWD/bspfiles"
url=http://141.2.16.23/~xonotic/bsp-autobuilds/
bspoutdir="$HOME/public_html/bsp-autobuilds/"
allmaps()
{
for F in maps/*.map.options; do
if ! [ -f "$F" ]; then
continue
fi
if ! [ -f "${F%.options}" ]; then
continue
fi
M=${F#maps/}
M=${M%.map.options}
blobhash=`git ls-files -s -- "$F" | cut -d ' ' -f 2`-`git ls-files -s -- "${F%.options}" | cut -d ' ' -f 2`
"$@" "$M" "$blobhash"
done
}
buildthemap()
{
bspdir=$1
M=$2
blobhash=$3
if [ -f "$bspdir/$M-$blobhash.pk3" ]; then
continue
fi
(
cd maps
../../../misc/tools/xonotic-map-compiler "$M" `head -n 1 "$M.map.options"` 2>&1 | tee "$M.log"
)
zip -9r "$bspdir/$M-$blobhash.pk3" "maps/$M.bsp" "maps/$M.log" "maps/$M/" "maps/$M.lin" "gfx/${M}_mini.tga"
ln -snf "../$M-$blobhash.pk3" "$bspdir/latest/$M.pk3" # from ALL branches, so beware!
}
getthemap()
{
url=$1
bspdir_old=$2
bspdir=$3
M=$4
blobhash=$5
if mv "$bspdir_old/$M-$blobhash.pk3" "$bspdir/$M-$blobhash.pk3"; then
continue
fi
if ! wget -O "$bspdir/$M-$blobhash.pk3" "$url$M-$blobhash.pk3"; then
rm -f "$bspdir/$M-$blobhash.pk3"
echo "WARNING: could not download $url$M-$blobhash.pk3, maybe not ready yet"
return 1
fi
if ! unzip -l "$bspdir/$M-$blobhash.pk3"; then
rm -f "$bspdir/$M-$blobhash.pk3"
echo "WARNING: could not download $url$M-$blobhash.pk3, invalid zip file"
return 1
fi
}
case "$1" in
build)
mkdir -p "$bspoutdir"
mkdir -p "$bspoutdir/latest"
cd data/xonotic-maps.pk3dir
git for-each-ref 'refs/remotes' | while read -r HASH TYPE REFNAME; do
git reset --hard
git clean -xfd
git checkout "$HASH"
allmaps buildthemap "$bspoutdir"
done
git checkout master
;;
download)
rm -rf "$bspdir.old"
mv "$bspdir" "$bspdir.old" || true
mkdir -p "$bspdir"
cd data/xonotic-maps.pk3dir
allmaps getthemap "$url" "$bspdir.old" "$bspdir"
echo "List of maps that got deleted (if any) and currently are in $bspdir.old:"
ls -l "$bspdir.old"
;;
download-latest)
mkdir -p "$bspdir"
cd "$bspdir"
rm -f *-????????????????????????????????????????-????????????????????????????????????????.pk3
wget -r -l1 -A "*.pk3" -N --no-parent --no-directories "$url/latest"
;;
esac