#!/bin/sh
set -e

. /usr/share/debconf/confmodule

if db_get anna/retriever && [ "$RET" ]; then
	# Install the requested modules immediately
	logger -t anna-install "Installing $@"
	exec anna install "$@"
fi

queue=/var/lib/anna-install/queue

mkdir -p /var/lib/anna-install
touch $queue
for pkg in $@ ; do
	if ! grep -q "^$pkg$" $queue; then
		logger -t anna-install "Queueing udeb $pkg for later installation"
	        echo "$pkg" >> $queue
	fi
done
