#!/bin/sh -e
# vim:se ts=2 sts=2 et ai sw=2 tw=78:
#
# This updates debhelper compat level to the latest.
#
if [ ! -e Packages ]; then
  wget http://ftp.debian.org/debian/dists/sid/main/binary-amd64/Packages.xz
  unxz Packages.xz
fi
COMPAT=$(grep-dctrl -X -n -F Package -s Version debhelper Packages |\
         sed -e 's/\..*//')

rm -f Packages

FILELIST=$(find . -type f -name control)
for f in $FILELIST; do
#  sed -i -e "s/debhelper *([^,]*)/debhelper-compat (= $COMPAT)/" "$f"
  sed -i -e "s/debhelper-compat *( *= *[1-9][0-9]* *)/debhelper-compat (= $COMPAT)/" "$f"
done


find . -type f -name compat -delete


#FILELIST=$(find . -type f -name copyright)
##set -x
#for f in $FILELIST; do
#  if grep  -e "^Upstream-Contact:" "$f" >/dev/null; then
#    echo "$f +++ found   Upstream-Contact:"
#  else
#    echo "$f ... missing Upstream-Contact:"
#  fi
#done

