diff --git a/templates/lxc-ubuntu.in b/templates/lxc-ubuntu.in index 2be868001..ed6131f93 100644 --- a/templates/lxc-ubuntu.in +++ b/templates/lxc-ubuntu.in @@ -105,9 +105,36 @@ download_ubuntu() return 1 fi - mv "$1/partial-$arch" "$1/rootfs-$arch" - echo "Download complete." + echo "Installing updates" + if [ -z "$MIRROR" ]; then + MIRROR="http://archive.ubuntu.com/ubuntu" + fi + cat >> "$1/partial-${arch}/etc/apt/sources.list" << EOF +deb $MIRROR ${release}-updates main universe +deb http://security.ubuntu.com/ubuntu ${release}-security main universe +EOF + chroot "$1/partial-${arch}" apt-get update + if [ $? -ne 0 ]; then + echo "Failed to update the apt cache" + return 1 + fi + cat > "$1/partial-${arch}"/usr/sbin/policy-rc.d << EOF +#!/bin/sh +exit 101 +EOF + chmod +x "$1/partial-${arch}"/usr/sbin/policy-rc.d + chroot "$1/partial-${arch}" apt-get dist-upgrade -y + ret=$? + + rm -f "$1/partial-${arch}"/usr/sbin/policy-rc.d + if [ $ret -ne 0 ]; then + echo "Failed to upgrade the cache" + return 1 + fi + + mv "$1/partial-$arch" "$1/rootfs-$arch" + echo "Download complete" return 0 }