Unverified Commit cf0f9033 by Serge Hallyn Committed by Stéphane Graber

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: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com> Acked-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
parent 051151de
...@@ -134,12 +134,48 @@ finalize_user() ...@@ -134,12 +134,48 @@ finalize_user()
return 0 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() write_sourceslist()
{ {
# $1 => path to the rootfs # $1 => path to the rootfs
# $2 => architecture we want to add # $2 => architecture we want to add
# $3 => whether to use the multi-arch syntax or not # $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 case $2 in
amd64|i386) amd64|i386)
MIRROR=${MIRROR:-http://archive.ubuntu.com/ubuntu} MIRROR=${MIRROR:-http://archive.ubuntu.com/ubuntu}
...@@ -206,6 +242,7 @@ download_ubuntu() ...@@ -206,6 +242,7 @@ download_ubuntu()
return 1 return 1
fi fi
choose_container_proxy $cache/partial-$arch/ $arch
# download a mini ubuntu into a cache # download a mini ubuntu into a cache
echo "Downloading ubuntu $release minimal ..." echo "Downloading ubuntu $release minimal ..."
if [ -n "$(which qemu-debootstrap)" ]; then if [ -n "$(which qemu-debootstrap)" ]; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment