publish_release.sh 3.78 KB
#!/bin/sh

if test $# -lt 1 ; then
	echo "Usage: publish_release.sh [fileversion] [version for public]"
	exit
fi

echo "*********** is Steam Generation done? (Y/n)"
read ok
if test "$ok" '=' 'n'; then exit; fi

filever=$1
v=$2
md5def=~/.t-engine/4.0/tome/all.md5
md5steam=~/.t-engine/4.0/tome/steamall.md5

###################################### DEFAULT TOME #####################################
echo "Computing Default MD5s..."
cd tmp/t-engine4-linux64-"$filever"
rm -rf lib64/ t-engine
cp -r ../../../binaries-for-te4-md5/* .
cp -r ../../../t-engine4.steam/game/dlcs/* game/addons/
rm -f $md5def
while true; do
	DISPLAY=:1 ./t-engine -Mtome -n -E'compute_md5_only="all.md5" sleep_on_auth=2' > /dev/null 2>&1
	if test $? -eq 0; then break; fi
done
cd ../..
echo "..done"
echo

###################################### STEAM TOME #####################################
echo "Computing Steam MD5s..."
rm -rf tmp/t-engine4-steam
cp -r tmp/t-engine4-linux64-"$filever" tmp/t-engine4-steam
cd tmp/t-engine4-steam
rm game/engines/te4*.teae
rm game/modules/tome*.team
cp -r ../../../t-engine4.steam/tmp/t-engine4-steam-"$filever"/game/engines/te4*.teae game/engines/
cp -r ../../../t-engine4.steam/tmp/t-engine4-steam-"$filever"/game/modules/tome*.team game/modules
rm -f $md5steam
while true; do
	DISPLAY=:1 ./t-engine -Mtome -n -E'compute_md5_only="steamall.md5" sleep_on_auth=2' > /dev/null 2>&1
	if test $? -eq 0; then break; fi
done
cd ../..
echo "..done"
echo

if test ! -f $md5def; then echo "Missing default md5"; exit; fi
if test ! -f $md5steam; then echo "Missing steam md5"; exit; fi

echo "SQL:"

# New way, pass along a md5 file as generated by the game and it all computes
IFS=$'\n'
steammd5=''
regex="^([^ ]*) : (.*)\[(.*)\]"
for line in `cat $md5steam`; do
	if [[ $line =~ $regex ]]; then
		md5="${BASH_REMATCH[1]}"
		kind="${BASH_REMATCH[2]}"
		if test "$kind" = "module"; then
			steammd5=$md5
		fi
	fi
done
for line in `cat $md5def`; do
	if [[ $line =~ $regex ]]; then
		md5="${BASH_REMATCH[1]}"
		kind="${BASH_REMATCH[2]}"
		name="${BASH_REMATCH[3]}"

		if test "$kind" = "module"; then
			echo "replace into modules_versions set module='$name', md5='$md5', md5_2='$steammd5', shown='false';"
		elif [[ "$name" =~ "tome-ashes-urhrok" ]]; then
			adv=`unzip -p tmp/t-engine4-linux64-$v/game/addons/ashes-urhrok.teaac tome-ashes-urhrok/init.lua|grep addon_version|sed -e 's@.*{\([0-9]\+\),\([0-9]\+\),\([0-9]\+\)}.*@\1.\2.\3@'`
			echo "replace into modules_addons_versions set module='tome', addon='$name' , addon_version='$adv', md5='$md5', download_url='https://te4.org/download-dlc/2/ashes-urhrok.teaac';"
		elif [[ "$name" =~ "tome-orcs" ]]; then
			adv=`unzip -p tmp/t-engine4-linux64-$v/game/addons/orcs.teaac tome-orcs/init.lua|grep addon_version|sed -e 's@.*{\([0-9]\+\),\([0-9]\+\),\([0-9]\+\)}.*@\1.\2.\3@'`
			echo "replace into modules_addons_versions set module='tome', addon='$name' , addon_version='$adv', md5='$md5', download_url='https://te4.org/download-dlc/3/orcs.teaac';"
		elif [[ "$name" =~ "tome-cults" ]]; then
			adv=`unzip -p tmp/t-engine4-linux64-$v/game/addons/cults.teaac tome-cults/init.lua|grep addon_version|sed -e 's@.*{\([0-9]\+\),\([0-9]\+\),\([0-9]\+\)}.*@\1.\2.\3@'`
			echo "replace into modules_addons_versions set module='tome', addon='$name' , addon_version='$adv', md5='$md5', download_url='https://te4.org/download-dlc/5/cults.teaac';"
		else
			echo "replace into modules_addons_versions set module='tome', addon='$name' , md5='$md5', md5_2 ='';"
		fi
	fi
done

ln -fs /foreign/eyal/var/www/te4.org/htdocs/dl/t-engine/t-engine4-windows-$v.zip /foreign/eyal/var/www/te4.org/htdocs/dl/t-engine/full/tome-full-windows-$v.zip
fmd5=`md5sum /foreign/eyal/var/www/te4.org/htdocs/dl/t-engine/full/tome-full-windows-$v.zip | cut -d' ' -f1`

echo "replace into modules_fullzip set file='tome-full-windows-$v.zip', md5='$fmd5';"