#!/bin/sh

# To add other variable substitutions already predefine $VARSUBST in
# config.

set -e
LOC=`dirname $0`

SED=${SED:="sed"}

VARSUBSTS="$VARSUBST s|%%NAME%%|$NAME|g; \
           s|%%VERSION%%|$VERSION|g; \
           s|%%MAINTAINER%%|$MAINTAINER|g;"

for file in `git ls-files`; do
    if [ ! -x "$file" ]; then                # skip scripts
        $SED "$VARSUBSTS" $file > $file.tmp
        mv -f $file.tmp $file
    fi
done

if [ -f $LOC/hook-pkg-varsubsts ]; then
    . $LOC/hook-pkg-varsubsts
fi
