#!/bin/sh

# Updates the debian changelogs when you are on the top of a packaging branch,
# i.e. packaging/debian/jaunty/trunk/
#
# Only argument is the new version desired, plus packages you want to change
# or nothing if you want to change all

version=$1
shift
packs=$@

dist="precise"

if [ -z "$version" ]
then
    echo "Usage: update-changelogs <version>"
    exit 1
fi

if [ -z "$packs" ]
then
    packs=$(echo *)
fi

for dir in $packs
do
    if [ ! -f $dir/debian/$dist/changelog ]
    then
        continue
    fi

    module="zentyal-$dir"

    cat > $dir/debian/$dist/changelog.new <<EOF
$module ($version) $dist; urgency=low

  * New upstream release

 -- $DEBFULLNAME <$DEBEMAIL>  $(date -R)

EOF

cat $dir/debian/$dist/changelog >> $dir/debian/$dist/changelog.new
mv $dir/debian/$dist/changelog.new $dir/debian/$dist/changelog
done
