Merge "Always bind-mount pypi mirror if dir exists"

This commit is contained in:
Jenkins 2014-06-28 00:14:13 +00:00 committed by Gerrit Code Review
commit 5151dc0a33
2 changed files with 9 additions and 10 deletions

View File

@ -2,8 +2,9 @@ Inject a PyPI mirror
====================
Use a custom PyPI mirror to build images. The default is to bind mount one from
~/.cache/image-create/pypi/mirror into the build environment. The element
temporarily overwrites /root/.pip.conf and .pydistutils.cfg to use it.
~/.cache/image-create/pypi/mirror into the build environment as mirror URL
file:///tmp/pypi. The element temporarily overwrites /root/.pip.conf
and .pydistutils.cfg to use it.
When online, the official pypi.python.org pypi index is supplied as an
extra-url, so uncached dependencies will still be available. When offline, only
@ -23,6 +24,7 @@ you have more than 9 additional mirrors, some care will be needed.
A typical use of this element is thus:
export PYPI\_MIRROR\_URL=http://site/pypi/Ubuntu-13.10
export PYPI\_MIRROR\_URL\_1=http://site/pypi/
export PYPI\_MIRROR\_URL\_2=file:///tmp/pypi
[pypi-mirror](https://git.openstack.org/cgit/openstack-infra/pypi-mirror) can
be useful in making a partial PyPI mirror suitable for building images. For

View File

@ -3,13 +3,10 @@
set -eu
set -o pipefail
PYPI_MIRROR_URL=${PYPI_MIRROR_URL:-''}
if [ -n "$PYPI_MIRROR_URL" ]; then
# External mirror URL being used - no need to bind mount anything.
exit 0
fi
MIRROR_SOURCE=~/.cache/image-create/pypi/mirror/
if [ -d "$MIRROR_SOURCE" ]; then
MIRROR_TARGET=$TMP_MOUNT_PATH/tmp/pypi
sudo mkdir -p $MIRROR_SOURCE $MIRROR_TARGET
sudo mount --bind $MIRROR_SOURCE $TMP_MOUNT_PATH/tmp/pypi
sudo mount --bind $MIRROR_SOURCE $MIRROR_TARGET
fi