#!/bin/sh -e

# Finish debootstrap
mount -t proc proc /proc
/debootstrap/debootstrap --second-stage

# Enable the buildlet service.
systemctl enable /etc/systemd/system/buildlet.service

# Disable logind (which fails without dbus).
rm -f /lib/systemd/system/multi-user.target.wants/systemd-logind.service

# Slim the image down a bit.
apt-get clean
rm -rf /var/lib/apt/lists /usr/share/doc
(cd /usr/share/locale/ && ls -1 | grep -v en | xargs rm -rf)
rm -rf /var/cache/debconf/*
rm -rf /usr/share/man

rm /stage2
sync
reboot -f
