#! /bin/bash

set -e

export DEBIAN_FRONTEND="noninteractive"

touch /chroot_scripts/rem_list

for rem_list in /chroot_scripts/rem-lists/*.list
do
	for pkg in $(cat $rem_list)
	do
		if [[ $pkg != "#"* ]]
		then
			apt-get purge --yes --option Dpkg::Options::="--force-confnew" --option Dpkg::Options::="--force-overwrite" $pkg || true
		fi
	done
done

apt-get autoremove --yes --option Dpkg::Options::="--force-confnew" --option Dpkg::Options::="--force-overwrite" 