send "export TERM=xterm; $getroot\r"
expect -re $prompt
-# install wanted packages
-send "apt-get install -o Dpkg::Options::=--force-confnew -y sudo less bash-completion vim openssh-server locales git-buildpackage build-essential fakeroot lintian debhelper manpages-dev git dput pristine-tar schroot sbuild </dev/null\r"
+# install wanted packages; openssh postinst does funny things to the terminal, so only give it pipes
+send "DEBIAN_FRONTEND=noninteractive apt-get install -o Dpkg::Options::=--force-confnew -y git-buildpackage libwww-perl less vim lintian debhelper manpages-dev git dput pristine-tar bash-completion libnss-myhostname lptools python-keyrings.alt wget gnupg2 ubuntu-dev-tools python3-debian qemu-kvm qemu-utils schroot sbuild locales openssh-server </dev/null 2>&1 | cat\r"
expect -re $prompt
# set up user
send "deluser --remove-home test; adduser --disabled-password --gecos 'Martin Pitt' martin; echo 'martin:a' | chpasswd; adduser martin sbuild\r"
expect -re $prompt
-send "echo 'martin ALL=(ALL) NOPASSWD:ALL' | tee /etc/sudoers.d/martin; update-locale LANG=C.UTF-8; touch /var/lib/sudo/lectured/martin\r"
+send "echo 'martin ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/martin; update-locale LANG=C.UTF-8; touch /var/lib/sudo/lectured/martin\r"
expect -re $prompt
-send "mkdir /home/martin/.ssh; echo '$sshkey' | tee /home/martin/.ssh/authorized_keys; chown -R martin:martin /home/martin/.ssh\r"
+send "mkdir /home/martin/.ssh; echo '$sshkey' > /home/martin/.ssh/authorized_keys; chown -R martin:martin /home/martin/.ssh\r"
expect -re $prompt
# mount home, /srv, and schroot config from host; TODO: move to NFS?
-send "mkdir /home/martin/h; printf 'home /home/martin/h 9p trans=virtio,access=any,nofail,ro 0 0\nsrv /srv 9p trans=virtio,access=any,nofail,ro 0 0\netcschroot /etc/schroot 9p trans=virtio,access=any,nofail,ro 0 0\n' | tee -a /etc/fstab; mount /home/martin/h; mount /srv; mount /etc/schroot\r"
+send "mkdir /home/martin/h; printf 'home /home/martin/h 9p trans=virtio,access=any,nofail,ro 0 0\nsrv /srv 9p trans=virtio,access=any,nofail,ro 0 0\netcschroot /etc/schroot 9p trans=virtio,access=any,nofail,ro 0 0\n' >> /etc/fstab; mount /home/martin/h; mount /srv; mount /etc/schroot\r"
expect -re $prompt
send "(cd /home/martin; ln -s h/.gbp.conf; ln -s h/.vimrc)\r"
+expect -re $prompt
-# set up lxd if available (on Ubuntu)
-# FIXME: lxd init invocation aborts expect/qemu
-#send "apt-get install -y lxd </dev/null && adduser martin lxd && yes '' | lxd init || true\r"
-send "apt-get install -y lxd </dev/null && adduser martin lxd || true\r"
+#
+## set up lxd if available (on Ubuntu)
+send "(apt-get install -y lxd </dev/null && adduser martin lxd && yes '' | lxd init || true) 2>&1 | cat\r"
expect -re $prompt
interact