#!/bin/sh

set -x
set -e

TARGET="/target"

mount -B /cdrom $TARGET/cdrom
mount -B /sys $TARGET/sys
mount -B /dev/pts $TARGET/dev/pts
chroot $TARGET /usr/share/ubuntu/scripts/pool.sh

for i in `chroot $TARGET ubuntu-drivers list`; do
    if ! chroot $TARGET dpkg-query -W $i >/dev/null 2>&1; then
        chroot $TARGET apt-get install --yes $i
    fi
done

umount $TARGET/dev/pts
umount $TARGET/sys
umount $TARGET/cdrom


while [ -f /pause2 ]; do
	sleep 6
done

