#! /bin/bash set -ex BASE=$(dirname $(dirname $0)) out=$1 arch=$2 virt_builder_image="$3" if [ -n "$4" ]; then apt_source="$4" fi if [ "$VIRT_BUILDER_NO_CACHE" == "yes" ]; then virt_builder_caching="--no-cache" fi # 18.04 virt-builder image has an invalid apt proxy leftover; delete it virt-builder $virt_builder_image \ $virt_builder_caching \ --output "$out" \ --size 8G \ --format qcow2 \ --arch "$arch" \ --root-password password:foobar \ --ssh-inject root:file:$BASE/../../machine/identity.pub \ --upload $BASE/../../machine/host_key:/etc/ssh/ssh_host_rsa_key \ --chmod 0600:/etc/ssh/ssh_host_rsa_key \ --upload $BASE/../../machine/host_key.pub:/etc/ssh/ssh_host_rsa_key.pub \ ${apt_source:+--write /etc/apt/sources.list:"$apt_source"} \ --write /etc/apt/apt.conf.d/90nolanguages:'Acquire::Languages "none";' \ --run-command "sed -i 's/GRUB_TIMEOUT.*/GRUB_TIMEOUT=0/; /GRUB_CMDLINE_LINUX=/ s/"'"'"$/ console=ttyS0,115200 net.ifnames=0 biosdevname=0"'"'"/' /etc/default/grub" \ --run-command "update-grub" \ --run-command "sed -i 's/ens[^[:space:]:]*/eth0/' /etc/network/interfaces /etc/netplan/*.yaml || true" \ --run-command "rm --verbose -f /etc/apt/apt.conf" \ --run-command "export DEBIAN_FRONTEND=noninteractive; apt-get -y update; apt-get -y install eatmydata; eatmydata apt-get -y dist-upgrade"