#!/bin/bash
#
# Target dist: Ubuntu Jammy
DIST=jammy

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

# No app_java due lack of gcj-jdk
sed -i -e '/gcj-jdk/d' -e '/^Package: kamailio-java-modules/,/^$/d' \
  ${DIST}/control
sed -i -e '/^export JAVA_HOME/d' ${DIST}/rules
sed -i -e 's/ java[ ,$]*/ /' ${DIST}/rules
sed -i -e '/^EXCLUDED_MODULES=/s/$/ java/' ${DIST}/rules

# no dh-systemd
sed -i -e '/dh-systemd/d' ${DIST}/control

# no python2
sed -i -e '/^ python,/d' -e '/python-dev/d' \
  -e '/^Package: kamailio-python-modules/,/^$/d' \
  ${DIST}/control
sed -i -e 's/ python [ ,$]*//' ${DIST}/rules
sed -i -e '/^EXCLUDED_MODULES=/s/$/ python/' ${DIST}/rules

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

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