diff --git a/debian/changelog b/debian/changelog index ed2cfe0..7fa641b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,7 +8,10 @@ ubuntu-dev-tools (0.134) UNRELEASED; urgency=low [ Benjamin Drung ] * syncpackage: Catch user abort. - -- Benjamin Drung Sat, 22 Oct 2011 23:09:56 +0200 + [ Scott Moser ] + * mk-sbuild: better support apt http proxy (LP: #881654) + + -- Scott Moser Tue, 25 Oct 2011 16:10:00 -0400 ubuntu-dev-tools (0.133) unstable; urgency=low diff --git a/mk-sbuild b/mk-sbuild index 9f5d506..46f37d5 100755 --- a/mk-sbuild +++ b/mk-sbuild @@ -52,6 +52,7 @@ function usage() echo " --debootstrap-mirror=URL Use URL as the debootstrap source" echo " --debootstrap-include=list Comma separated list of packages to include" echo " --debootstrap-exclude=list Comma separated list of packages to exclude" + echo " --debootstrap-proxy=URL Use PROXY as apt proxy" echo " --distro=DISTRO Install specific distro:" echo " 'ubuntu' or 'debian' " echo " (defaults to determining from release name)" @@ -70,6 +71,7 @@ function usage() echo " DEBOOTSTRAP_MIRROR Mirror location (same as --debootstrap-mirror)" echo " DEBOOTSTRAP_INCLUDE Included packages (same as --debootstrap-include)" echo " DEBOOTSTRAP_EXCLUDE Excluded packages (same as --debootstrap-exclude)" + echo " DEBOOTSTRAP_PROXY Apt proxy (same as --debootstrap-proxy)" echo " TEMPLATE_SOURCES A template for sources.list" echo " TEMPLATE_SCHROOTCONF A template for schroot.conf stanza" if [ -z "$1" ]; then @@ -82,12 +84,14 @@ function usage() if [ -z "$1" ]; then usage fi -OPTS=`getopt -o 'h' --long "help,debug,skip-updates,arch:,name:,source-template:,debootstrap-mirror:,debootstrap-include:,debootstrap-exclude:,personality:,distro:,vg:,type:" -- "$@"` +OPTS=`getopt -o 'h' --long "help,debug,skip-updates,arch:,name:,source-template:,debootstrap-mirror:,debootstrap-include:,debootstrap-exclude:,debootstrap-proxy:,personality:,distro:,vg:,type:" -- "$@"` eval set -- "$OPTS" VG="" DISTRO="" name="" +proxy="_unset_" + while :; do case "$1" in --debug) @@ -134,6 +138,10 @@ while :; do DEBOOTSTRAP_EXCLUDE="$2" shift 2 ;; + --debootstrap-proxy) + proxy="$2" + shift 2 + ;; --distro) DISTRO="$2" shift 2 @@ -450,6 +458,17 @@ if [ -n "$DEBOOTSTRAP_EXCLUDE" ] ; then debootstrap_opts="$debootstrap_opts --exclude=$DEBOOTSTRAP_EXCLUDE" fi +# if http_proxy is set in the environment (even empty) set 'proxy' to it +[ "$proxy" = "_unset_" -a "${DEBOOTSTRAP_PROXY-xx}" = "xx" ] && + proxy=${DEBOOTSTRAP_PROXY} +[ "$proxy" = "_unset_" -a "${http_proxy-xx}" = "xx" ] && proxy=${http_proxy} +if [ "$proxy" = "_unset_" ]; then + _out=$(apt-config shell x Acquire::HTTP::Proxy) && + _out=$(sh -c 'eval $1 && echo $x' -- "$_out") && [ -n "$_out" ] && + proxy="$_out" +fi +[ "$proxy" = "_unset_" ] && proxy="" + DEBOOTSTRAP_COMMAND=debootstrap # Use qemu-kvm-extras-static for foreign chroots if [ "$CHROOT_ARCH" != "$HOST_ARCH" ] ; then @@ -501,7 +520,7 @@ esac sudo mkdir -p -m 0700 "$MNT"/root/.gnupg # debootstrap the chroot -sudo "$DEBOOTSTRAP_COMMAND" --arch="$CHROOT_ARCH" $variant_opt $debootstrap_opts "$RELEASE" "$MNT" "${DEBOOTSTRAP_MIRROR:-http://archive.ubuntu.com/ubuntu}" +sudo ${proxy:+"http_proxy=${proxy}"} "$DEBOOTSTRAP_COMMAND" --arch="$CHROOT_ARCH" $variant_opt $debootstrap_opts "$RELEASE" "$MNT" "${DEBOOTSTRAP_MIRROR:-http://archive.ubuntu.com/ubuntu}" # Update the package sources TEMP_SOURCES=`mktemp -t sources-XXXXXX` @@ -629,7 +648,13 @@ sudo bash -c "cat >> $MNT/finish.sh" < /etc/apt/apt.conf.d/99mk-sbuild-proxy <