#!/bin/sh
# Copyright (C) 2009-2012 Rhonda D'Vine <rhonda@debian.org>
# Licenced under MIT

# Description: rebuild files from .in files
#              This script will (re)generate the branched files from the
#              corresponding .in files.
#              To be called as "sh debian/branchcheck"

set -e

BRANCH=$(dpkg-parsechangelog | sed -n 's/^Source: wesnoth-//p')
BRANODOT=$(echo $BRANCH | tr -d .)

for i in debian/*.in debian/source/*.in debian/patches/*.in debian/tests/*.in; do
	new=$(basename $i .in | sed -e s/BRANCH/$BRANCH/)
	dir=$(dirname $i)
	cp $i $dir/$new
	sed -i -e "s/BRANCH/$BRANCH/g"   $dir/$new
	sed -i -e "s/BRANODOT/$BRANODOT/g" $dir/$new
done

# Requires libtext-csv-xs-perl
debian/csv2dep5.pl
