From: Serge Hallyn Date: Tue, 23 Apr 2013 13:37:41 +0000 (-0500) Subject: detect APT_PROXY from host apt.conf X-Git-Tag: lxc-1.0.0.alpha1~1^2~273 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cf0f903326cf3cdd10f834c1bbc627fd81e06044;p=thirdparty%2Flxc.git detect APT_PROXY from host apt.conf Introduce a new HTTP_PROXY variable in /etc/default/lxc. If unset or set to none, then behavior continues as before. If set to 'apt', then any http::proxy set in apt.conf will be used as http_proxy for debootstrap, and specified in the container's /etc/apt/apt.conf.d/70proxy. If set to something else, then the value of HTTP_PROXY will be used as http_proxy for debootstrap and specified in the container's 70proxy. Changelog: (apr 23) merge the two apt proxy detection functions. Signed-off-by: Serge Hallyn Acked-by: Stéphane Graber --- diff --git a/templates/lxc-ubuntu.in b/templates/lxc-ubuntu.in index 8a92f955b..83311fdde 100644 --- a/templates/lxc-ubuntu.in +++ b/templates/lxc-ubuntu.in @@ -134,12 +134,48 @@ finalize_user() return 0 } +# +# Choose proxies for container +# http_proxy will be used by debootstrap on the host. +# APT_PROXY will be used to set /etc/apt/apt.conf.d/70proxy in the container. +# +choose_container_proxy() +{ + local rootfs=$1 + local arch=$2 + + if [ -z "$HTTP_PROXY" ]; then + HTTP_PROXY="none" + fi + case "$HTTP_PROXY" in + none) + APT_PROXY= + ;; + apt) + RES=`apt-config shell APT_PROXY Acquire::http::Proxy` + eval $RES + [ -z "$APT_PROXY" ] || export http_proxy=$APT_PROXY + ;; + *) + APT_PROXY=$HTTP_PROXY + export http_proxy=$HTTP_PROXY + ;; + esac +} + write_sourceslist() { # $1 => path to the rootfs # $2 => architecture we want to add # $3 => whether to use the multi-arch syntax or not + if [ -n "$APT_PROXY" ]; then + mkdir -p $rootfs/etc/apt/apt.conf.d + cat > $rootfs/etc/apt/apt.conf.d/70proxy << EOF +Acquire::http::Proxy "$APT_PROXY" ; +EOF + fi + case $2 in amd64|i386) MIRROR=${MIRROR:-http://archive.ubuntu.com/ubuntu} @@ -206,6 +242,7 @@ download_ubuntu() return 1 fi + choose_container_proxy $cache/partial-$arch/ $arch # download a mini ubuntu into a cache echo "Downloading ubuntu $release minimal ..." if [ -n "$(which qemu-debootstrap)" ]; then