diff --git a/bin/xen-create-image b/bin/xen-create-image index 3b16e7f..07051a4 100755 --- a/bin/xen-create-image +++ b/bin/xen-create-image @@ -204,6 +204,10 @@ xen-create-image - Easily create new Xen instances with networking and OpenSSH. to choose a more or less close Debian mirror. See http://wiki.debian.org/DebianGeoMirror for details. + --apt_proxy=url + Specify a proxy to be used by debootstrap, and within + the guest. + --template=tmpl Specify which template file to use when creating the Xen configuration file. @@ -1364,6 +1368,7 @@ sub setupDefaultOptions foreach my $ubuntudist (qw(edgy feisty gutsy intrepid jaunty karmic maverick)) { $CONFIG{ 'mirror_'.$ubuntudist } = 'http://old-releases.ubuntu.com/ubuntu'; } + $CONFIG{ 'apt_proxy' } = ''; $CONFIG{ 'arch' } = ''; $CONFIG{ 'fs' } = 'ext3'; $CONFIG{ 'force' } = 0; @@ -1710,6 +1715,7 @@ sub parseCommandLineArguments "kernel=s", \&checkOption, "initrd=s", \&checkOption, "mirror=s", \&checkOption, + "apt_proxy=s", \&checkOption, "modules=s", \&checkOption, "lvm=s", \$install{ 'lvm' }, "image-dev=s", \$install{ 'image-dev' }, @@ -3576,6 +3582,15 @@ sub installSystem } + # + # Propagate --apt_proxy + # + if ( $CONFIG{ 'apt_proxy' } ) + { + $cmd .= " --apt_proxy=$CONFIG{'apt_proxy'}"; + } + + # # Show the user what they are installing # diff --git a/bin/xt-install-image b/bin/xt-install-image index cdac40a..37eb11e 100755 --- a/bin/xt-install-image +++ b/bin/xt-install-image @@ -27,6 +27,7 @@ xt-install-image - Install a fresh copy of GNU/Linux into a directory --config Read the specified config file in addition to the global configuration file. --mirror The mirror to use when installing with 'debootstrap'. + --apt_proxy The proxy to use when installing with 'debootstrap'. Installation Options: --install-method Specify the installation method to use. @@ -395,6 +396,7 @@ sub parseCommandLineArguments "cachedir=s", \$CONFIG{ 'cachedir' }, "config=s", \$CONFIG{ 'config' }, "mirror=s", \$CONFIG{ 'mirror' }, + "apt_proxy=s", \$CONFIG{ 'apt_proxy' }, # Help. "verbose", \$CONFIG{ 'verbose' }, @@ -757,12 +759,21 @@ sub do_debootstrap $EXTRA .= " --arch $CONFIG{'arch'}"; } + # + # Setup http_proxy so that debootstrap pulls files through the apt-proxy + # + my $PROXY = ''; + if ( $CONFIG{ 'apt_proxy' } ) + { + print("Using apt_proxy: $CONFIG{'apt_proxy'}\n"); + $PROXY = "http_proxy=\"$CONFIG{'apt_proxy'}\""; + } # # This is the command we'll run # my $command = - "$cmd $EXTRA $CONFIG{'dist'} $CONFIG{'location'} $CONFIG{'mirror'}"; + "$PROXY $cmd $EXTRA $CONFIG{'dist'} $CONFIG{'location'} $CONFIG{'mirror'}"; # # Run the command. diff --git a/etc/xen-tools.conf b/etc/xen-tools.conf index 8a0a876..b212f36 100644 --- a/etc/xen-tools.conf +++ b/etc/xen-tools.conf @@ -282,6 +282,10 @@ mirror = `xt-guess-suite-and-mirror --mirror` # mirror_precise = http://archive.ubuntu.com/ubuntu # mirror_quantal = http://archive.ubuntu.com/ubuntu +# If this is defined it will be used by debootstrap, and configured as the +# proxy for the guest +# +# apt_proxy = # # Filesystem options for the different filesystems we support. diff --git a/hooks/dapper/20-setup-apt b/hooks/dapper/20-setup-apt index 4fdd008..f255dfb 100755 --- a/hooks/dapper/20-setup-apt +++ b/hooks/dapper/20-setup-apt @@ -33,9 +33,12 @@ logMessage Script $0 starting # replicate that setup in our new guest via apt-config dump and save # the setting to the proxy guess file. # -logMessage The use of a proxy detected. -apt-config dump | grep -i Acquire::HTTP::Proxy \ - > ${prefix}/etc/apt/apt.conf.d/proxy-guess +if [ ${apt_proxy} ]; then + echo "Acquire::http::Proxy \"${apt_proxy}\";" > ${prefix}/etc/apt/apt.conf.d/01proxy +else + logMessage The use of a proxy detected. + apt-config dump | grep -i Acquire::HTTP::Proxy > ${prefix}/etc/apt/apt.conf.d/01proxy +fi # diff --git a/hooks/debian/20-setup-apt b/hooks/debian/20-setup-apt index 446cd67..b325602 100755 --- a/hooks/debian/20-setup-apt +++ b/hooks/debian/20-setup-apt @@ -32,9 +32,12 @@ logMessage Script $0 starting # replicate that setup in our new guest via apt-config dump and save # the setting to the proxy guess file. # -logMessage The use of a proxy detected. -apt-config dump | grep -i Acquire::HTTP::Proxy \ - > ${prefix}/etc/apt/apt.conf.d/proxy-guess +if [ ${apt_proxy} ]; then + echo "Acquire::http::Proxy \"${apt_proxy}\";" > ${prefix}/etc/apt/apt.conf.d/01proxy +else + logMessage The use of a proxy detected. + apt-config dump | grep -i Acquire::HTTP::Proxy > ${prefix}/etc/apt/apt.conf.d/01proxy +fi # diff --git a/hooks/edgy/20-setup-apt b/hooks/edgy/20-setup-apt index 4463ed5..5833c47 100755 --- a/hooks/edgy/20-setup-apt +++ b/hooks/edgy/20-setup-apt @@ -33,9 +33,12 @@ logMessage Script $0 starting # replicate that setup in our new guest via apt-config dump and save # the setting to the proxy guess file. # -logMessage The use of a proxy detected. -apt-config dump | grep -i Acquire::HTTP::Proxy \ - > ${prefix}/etc/apt/apt.conf.d/proxy-guess +if [ ${apt_proxy} ]; then + echo "Acquire::http::Proxy \"${apt_proxy}\";" > ${prefix}/etc/apt/apt.conf.d/01proxy +else + logMessage The use of a proxy detected. + apt-config dump | grep -i Acquire::HTTP::Proxy > ${prefix}/etc/apt/apt.conf.d/01proxy +fi # diff --git a/hooks/intrepid/20-setup-apt b/hooks/intrepid/20-setup-apt index 4463ed5..5833c47 100755 --- a/hooks/intrepid/20-setup-apt +++ b/hooks/intrepid/20-setup-apt @@ -33,9 +33,12 @@ logMessage Script $0 starting # replicate that setup in our new guest via apt-config dump and save # the setting to the proxy guess file. # -logMessage The use of a proxy detected. -apt-config dump | grep -i Acquire::HTTP::Proxy \ - > ${prefix}/etc/apt/apt.conf.d/proxy-guess +if [ ${apt_proxy} ]; then + echo "Acquire::http::Proxy \"${apt_proxy}\";" > ${prefix}/etc/apt/apt.conf.d/01proxy +else + logMessage The use of a proxy detected. + apt-config dump | grep -i Acquire::HTTP::Proxy > ${prefix}/etc/apt/apt.conf.d/01proxy +fi # diff --git a/hooks/karmic/20-setup-apt b/hooks/karmic/20-setup-apt index 4463ed5..5833c47 100755 --- a/hooks/karmic/20-setup-apt +++ b/hooks/karmic/20-setup-apt @@ -33,9 +33,12 @@ logMessage Script $0 starting # replicate that setup in our new guest via apt-config dump and save # the setting to the proxy guess file. # -logMessage The use of a proxy detected. -apt-config dump | grep -i Acquire::HTTP::Proxy \ - > ${prefix}/etc/apt/apt.conf.d/proxy-guess +if [ ${apt_proxy} ]; then + echo "Acquire::http::Proxy \"${apt_proxy}\";" > ${prefix}/etc/apt/apt.conf.d/01proxy +else + logMessage The use of a proxy detected. + apt-config dump | grep -i Acquire::HTTP::Proxy > ${prefix}/etc/apt/apt.conf.d/01proxy +fi #