#!/bin/bash
#
# Target dist: Debian Stretch
DIST=stretch

rm -rf ${DIST}
cp -r debian ${DIST}

# No mi_xmlrpc module
sed -i -e '/libxmlrpc-c3-dev/d' -e '/^Package: kamailio-xmlrpc-modules/,/^$/d' \
	${DIST}/control
sed -i -e 's/ mi_xmlrpc[ ,$]*/ /' ${DIST}/rules
sed -i -e '/^EXTRA_EXCLUDED_MODULES=/s/$/ mi_xmlrpc/' ${DIST}/rules

# No dnssec module:
sed -i -e '/libval-dev/d' -e '/^Package: kamailio-dnssec-modules/,/^$/d' \
  ${DIST}/control
sed -i -e 's/ dnssec[ ,$]*/ /' ${DIST}/rules
sed -i -e '/^EXTRA_EXCLUDED_MODULES=/s/$/ dnssec/' ${DIST}/rules

# libbson not in libmongoc
sed -i 's/libmongoc-dev/libbson-dev,\n libmongoc-dev/' \
	${DIST}/control

# No secsipid module
sed -i -e '/libsecsipid-dev/d' -e '/^Package: kamailio-secsipid-modules/,/^$/d' \
	${DIST}/control
sed -i -e 's/ secsipid[ ,$]*/ /' ${DIST}/rules
sed -i -e '/^EXTRA_EXCLUDED_MODULES=/s/$/ secsipid/' ${DIST}/rules

wrap-and-sort -sat -d ${DIST}

# clean backports scripts
rm -rf ${DIST}/backports
exit 0