aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerge Hallyn <serge.hallyn@canonical.com>2012-01-05 23:34:46 +0100
committerDaniel Lezcano <daniel.lezcano@free.fr>2012-01-05 23:34:46 +0100
commit15da01b3938d7ba45472e6c9d3b183a94dd86ca9 (patch)
treef2feebc9b770c6eaa715eac2fea74e0bf92ea95b
parentFix ia64 clone (diff)
downloadlxc-15da01b3938d7ba45472e6c9d3b183a94dd86ca9.tar.gz
lxc-15da01b3938d7ba45472e6c9d3b183a94dd86ca9.tar.bz2
lxc-15da01b3938d7ba45472e6c9d3b183a94dd86ca9.zip
ubuntu template: use -updates and -security (v3)
Particularly for LTS releases, which many people will want to use in their containers, it is not wise to not use release-security and release-updates. Furthermore the fix allowing ssh to allow the container to shut down is in lucid-updates only. With this patch, after debootstrapping a container, we add -updates and -security to sources.list and do an upgrade under chroot. Unfortunately we need to do this because debootstrap doesn't know how to. Changelog: Nov 14: as Stéphane Graber suggested, make sure no daemons start on the host while doing dist-upgrade from chroot. Nov 15: use security.ubuntu.com, not mirror. (stgraber) Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
-rw-r--r--templates/lxc-ubuntu.in31
1 files changed, 29 insertions, 2 deletions
diff --git a/templates/lxc-ubuntu.in b/templates/lxc-ubuntu.in
index 2be8680..ed6131f 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
}