#! /bin/bash

set -e

export DEBIAN_FRONTEND="noninteractive"

touch /chroot_scripts/pool_list

for pool_list in /chroot_scripts/pool-lists/*.list
do
	for pkg in $(cat $pool_list)
	do
		if [[ $pkg != "#"* ]]
		then
			echo $pkg >> /chroot_scripts/pool_list
		fi
	done
done

mkdir -p /cdrom/pool/main/
pushd /cdrom/pool/main/
apt-get download --yes $(cat /chroot_scripts/pool_list | tr "\n" " ")
popd