#!/bin/bash
#
# Hook for automatic backports at buildserver.net
#
# Target dist: Debian Squeeze

# remove Multi-arch
sed -i -e 's#^DEB_HOST_MULTIARCH.*$##' -e "s#^LIBDIR ?= lib/\$(DEB_HOST_MULTIARCH)#LIBDIR ?= lib#" debian/rules
sed -i -e 's#multiarch_support.patch#no_lib64_on_64_bits.patch#' debian/patches/series
sed -i -e '/^Multi-Arch: .*/d' debian/control

# Downgrade to debhelper 8 compat
sed -i -e  's#debhelper[^,$]*[\ ,$]\+\(.*\)$#debhelper (>= 8), \1#' debian/control
echo 8 > debian/compat

# Hardening flags
sed -i -e '/^ dpkg-dev/d' debian/control
sed -i -e '/^include.*buildflags.mk/d' -e '/.*dpkg-buildflags --export=configure.*/d' debian/rules
sed -i -e '/hardening_flags.patch/d' debian/patches/series

# No libhiredis:
sed -i -e '/libhiredis-dev/d' -e '/^Package: kamailio-redis-modules/,/^$/d' \
	debian/control
sed -i -e 's/ redis[ ,$]*/ /' debian/rules
sed -i -e '/^EXTRA_EXCLUDED_MODULES=/s/$/ redis/' debian/rules
# No mono module
sed -i -e '/libmono-2.0-dev/d' -e '/^Package: kamailio-mono-modules/,/^$/d' \
	debian/control
sed -i -e 's/ mono[ ,$]*/ /' debian/rules
sed -i -e '/^EXTRA_EXCLUDED_MODULES=/s/$/ mono/' debian/rules
sed -i -e 's/db5.1-util/db4.8-util/' debian/control

exit 0
