mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-12 23:51:08 +00:00
mk-sbuild: better support apt http proxy (LP: #881654)
This commit is contained in:
commit
2ad6ec42dd
5
debian/changelog
vendored
5
debian/changelog
vendored
@ -8,7 +8,10 @@ ubuntu-dev-tools (0.134) UNRELEASED; urgency=low
|
||||
[ Benjamin Drung ]
|
||||
* syncpackage: Catch user abort.
|
||||
|
||||
-- Benjamin Drung <bdrung@debian.org> Sat, 22 Oct 2011 23:09:56 +0200
|
||||
[ Scott Moser ]
|
||||
* mk-sbuild: better support apt http proxy (LP: #881654)
|
||||
|
||||
-- Scott Moser <smoser@brickies.net> Tue, 25 Oct 2011 16:10:00 -0400
|
||||
|
||||
ubuntu-dev-tools (0.133) unstable; urgency=low
|
||||
|
||||
|
33
mk-sbuild
33
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" <<EOM
|
||||
#!/bin/bash
|
||||
#set -x
|
||||
set -e
|
||||
export http_proxy=${http_proxy}
|
||||
if [ -n "$proxy" ]; then
|
||||
mkdir -p /etc/apt/apt.conf.d/
|
||||
cat > /etc/apt/apt.conf.d/99mk-sbuild-proxy <<EOF
|
||||
## proxy settings copied from mk-sbuild
|
||||
Acquire { HTTP { Proxy "$proxy"; }; };
|
||||
EOF
|
||||
fi
|
||||
# Reload package lists
|
||||
apt-get update || true
|
||||
# Pull down signature requirements
|
||||
@ -646,8 +671,8 @@ if [ ! -r /dev/stdin ]; then ln -s /proc/self/fd/0 /dev/stdin; fi
|
||||
if [ ! -r /dev/stdout ]; then ln -s /proc/self/fd/1 /dev/stdout; fi
|
||||
if [ ! -r /dev/stderr ]; then ln -s /proc/self/fd/2 /dev/stderr; fi
|
||||
# Clean up
|
||||
apt-get clean
|
||||
rm /finish.sh
|
||||
apt-get clean
|
||||
EOM
|
||||
sudo chmod a+x "$MNT"/finish.sh
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user