#!/bin/bash
# creates new 0install feeeds

if test -z "$1"; then
  echo "Usage: create stability suffix namesuffix, i.e."
  echo "       create developer armagetronad-alpha 'Armagetron Alpha'"
  exit
fi

set -x

STABILITY=$1
NAME=$2
TITLE=$3
TITLESUFFIX=$(echo ${TITLE} | sed -e "s,Armagetronad ,,")

function transform()
{
 suffix=$3
 arch=$4
 ARCH=${arch}
 test "${arch}" = "Windows" && ARCH="Windows-*"
sed < $1 > $2 \
-e "s,developer,${STABILITY},g" \
-e "s,-os-arch,-${arch},g" -e "s,os-arch,${ARCH},g" -e "s,-arch,-${arch},g" \
-e "s,armagetronad-proto,${NAME}${suffix},g" \
-e "s,Armagetronad Proto,${TITLE},g" \
-e "s,Proto,${TITLESUFFIX},g"
}

cd $(dirname $0)
for suffix in "" "-dedicated"; do
 transform armagetronad-proto.xml ${NAME}${suffix}.xml "${suffix}"
 for arch in Linux-i486 Linux-x86_64 Windows; do
  transform armagetronad-proto-arch.xml ${NAME}${suffix}-${arch}.xml "${suffix}" ${arch}
 done
done

